[英]How to list contents of a .app file in Python
我正在尝试列出.ipa文件中的文件。我正在尝试提取ipa以测试ipa中数据库的安全性。 解压缩后,我得到了Myappname.app文件。 我想在python.i中列出此文件的内容,我尝试了以下代码,但未列出内容
import os
for file in os.listdir("/mydir"):
if file.endswith(".txt"):
print(file)
但是我可以使用以下Java代码访问Myappname.app文件的内容。
void listf(String directoryName, ArrayList<File> files) {
File directory = new File(directoryName);
// get all the files from a directory
File[] fList = directory.listFiles();
for (File file : fList) {
if (file.isFile()) {
files.add(file);
} else if (file.isDirectory()) {
listf(file.getAbsolutePath(), files);
}
}
}
您的file
只是文件名,因此您必须打开它并阅读内容
print( open("/mydir/" + file, 'r').read() )
我通过使用glob.glob和os.path.isfile解决了它。 提取的文件夹包含一些文件和文件夹。 如果我传递文件而不是文件夹,则listdir会引发错误,因此我使用os.path.isfile && os.path.isdir过滤的文件将false返回此文件夹。
if os.path.exists(ipaExtractedPath):
for file in os.listdir(ipaExtractedPath):
if not os.path.isfile(ipaExtractedPath+"/"+file):
for f in glob.glob(ipaExtractedPath +"/"+file+"/*.db"):
try:
// some code here
break
conn.close()
except sqlite3.Error:
print "Error open db.\n"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.