Skip to content

Instantly share code, notes, and snippets.

@guysmoilov

guysmoilov/dex.py

Last active Aug 29, 2015
Embed
What would you like to do?
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