Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc **untested** changes #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 31 additions & 35 deletions ipapiescan.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
import zipfile
import biplist
import glob
import os
import sys
import subprocess
import re
import subprocess
import zipfile

from os.path import expanduser


def doit(basedir):

ipas = glob.glob(basedir + "/*.ipa")

for fn in ipas:

x = zipfile.ZipFile(fn)

y = x.namelist()
infoplist = ""
execFile = ""

for n in y:
if n[-11:] == "/Info.plist":
infoplist = n
infoplist = filter(lambda _: _.endswith('/Info.plist'), y)

if infoplist == "":
if not infoplist:
return
else:
infoplist = infoplist[0]

plistData = x.read(infoplist)
plist = biplist.readPlistFromString(plistData)
Expand All @@ -34,26 +31,25 @@ def doit(basedir):
appname = plist["CFBundleName"]
else:
appname = plist["CFBundleIdentifier"]
appname += (32-len(appname)) * " "
appname = appname.ljust(32, ' ')

if "CFBundleExecutable" not in plist:
continue
l = len(plist["CFBundleExecutable"])
continue

for n in y:
if n[-l:] == plist["CFBundleExecutable"]:
execFile = n
execFile = filter(lambda _: _.endswith(plist['CFBundleExecutable']), y)

if execFile == "":
if not execFile:
print "Cannot find execFile"
continue

else:
execFile = execFile[0]

data = x.read(execFile)
tname = "ipapiescan_XABCDEF"
f = open(tname, "w+b")
f.write(data)
f.close()

output = subprocess.check_output(["otool", "-vh", tname])
archstr = ""
if output.find("ARM V6") != -1:
Expand All @@ -67,29 +63,29 @@ def doit(basedir):
bestarch = "armv7"
if bestarch == "armv6":
archstr += " "

if archstr == "":
print "%s - illegal architecture" % (appname)
print output
else:
output = subprocess.check_output(["otool", "-arch", bestarch ,"-vh", tname])
if output.find("PIE") == -1:
pie = "NO_PIE"
#print output
else:
pie = "PIE "

output = subprocess.check_output(["otool", "-arch", bestarch ,"-lv", tname])
output = subprocess.check_output(["otool", "-arch", bestarch,
"-vh", tname])
pie = "PIE " if "PIE" in output else "NO_PIE"

output = subprocess.check_output(["otool", "-arch", bestarch,
"-lv", tname])
if output.find("LC_VERSION_MIN_IPHONEOS") == -1:
minversion = "N/A"
else:
#print output
p = re.compile('LC_VERSION_MIN_IPHONEOS[^v]*version[^0-9]+([0-9]+\.[0-9]+)', re.MULTILINE|re.DOTALL)
p = re.compile('LC_VERSION_MIN_IPHONEOS[^v]*version[^0-9]+([0-9]+\.[0-9]+)', re.MULTILINE | re.DOTALL)
x = p.search(output)
minversion = x.groups(0)[0]

print "%s - %s - %s - %s" % (appname, archstr, pie, minversion)

os.unlink(tname)

doit(os.getenv("HOME") + "/Music/iTunes/iTunes Media/Mobile Applications/")

if __name__ == '__main__':
doit(expanduser("~/Music/iTunes/iTunes Media/Mobile Applications/"))