import os, sys
def countTargetFile(targetDir):
resultStr =
''
targetTypes = [
'.nib',
'.m',
'.js']
for targetType
in targetTypes:
targetCount =
0
for root, dirs, files
in os.walk(targetDir):
for file
in files:
if file.endswith(targetType):
print os.path.join(root, file)
targetCount +=
1
oneResult =
'type = ' + targetType +
', target count = ' + str(targetCount)
print oneResult
resultStr += oneResult +
'\n'
return resultStr
def deal(baseDir, filename):
print 'process file:' + baseDir + filename
tmpDir = os.getcwd() +
'/unzip_folders/' + filename.replace(
' ',
'_')
print tmpDir
try:
os.mkdir(tmpDir)
zipFile = tmpDir +
'/' +
'tmp.zip'
command =
'cp ' + baseDir + filename.replace(
' ',
'\ ') +
' ' + zipFile
os.system(command)
command =
'unzip ' + zipFile +
' -d ' + tmpDir
print command
os.system(command)
except OSError:
print 'file exist, ignore'
resultStr = countTargetFile(tmpDir +
'/Payload')
file = open(tmpDir.replace(
'.ipa',
'') +
'_result.txt',
'w')
file.write(filename +
':\n')
file.write(resultStr)
file.write(
'\n')
file.close()
def process():
baseDir = os.getcwd()
targetFiles = os.listdir(
'./ipa_folders')
print targetFiles
for oneFile
in targetFiles:
if oneFile.endswith(
'.ipa'):
deal(baseDir +
'/ipa_folders/', oneFile)
if __name__ ==
'__main__':
process()
print 'over'
转载地址:脚本
转载请注明原文地址: https://ju.6miu.com/read-1297040.html