Skip to content

Instantly share code, notes, and snippets.

@guysmoilov
Last active August 29, 2015 14:24
Show Gist options
  • Save guysmoilov/d8013650213c662f4e70 to your computer and use it in GitHub Desktop.
Save guysmoilov/d8013650213c662f4e70 to your computer and use it in GitHub Desktop.
Get number of methods in a dex file contained in an apk.
import zipfile
import sys
def methods_in_dex(dex_bytes):
return int.from_bytes(dex_bytes[88:92], byteorder='little', signed=False)
def methods_in_apk(apkfile, dexfile='classes.dex'):
with zipfile.ZipFile(apkfile, 'r') as apkzip:
dex_bytes = apkzip.read(dexfile)
return methods_in_dex(dex_bytes)
if __name__ == "__main__":
print(methods_in_apk(sys.argv[1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment