Last active
August 4, 2016 01:01
-
-
Save k3170makan/2f0c0330cc2cd0910040 to your computer and use it in GitHub Desktop.
Dump Method bytecode from an APK using Androguard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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