Skip to content

Instantly share code, notes, and snippets.

@k3170makan
Last active August 4, 2016 01:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k3170makan/2f0c0330cc2cd0910040 to your computer and use it in GitHub Desktop.
Save k3170makan/2f0c0330cc2cd0910040 to your computer and use it in GitHub Desktop.
Dump Method bytecode from an APK using Androguard
#!/usr/bin/python
from sys import argv
from androguard.core.bytecodes import apk
from androguard.core.bytecodes import dvm
if __name__=="__main__":
a = apk.APK(argv[1])
d = dvm.DalvikVMFormat(a.get_dex())
for current_class in d.get_classes():
for method in current_class.get_methods():
print "[*] ",method.get_name(), method.get_descriptor()
byte_code = method.get_code()
if byte_code != None:
byte_code = byte_code.get_bc()
idx = 0
for i in byte_code.get_instructions():
print "\t, %x " % (idx),i.get_name(),i.get_output()
idx += i.get_length()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment