DecompileMethods¶
This is an autogenerated documentation file for the script: DecompileMethods
Run it¶
$ ./androanalyze scripts_builtin/DecompileMethods.py --package-names com.spotify.music
View the results¶
Non-Binary¶
$ ./androquery result -sn DecompileMethods -pn com.spotify.music
Empty
Binary¶
For the case that the result may exceed 16MB, it is stored in MongoDB’s gridFS. Therefore we need to use a different query syntax:
View the meta data:
$ ./androquery result -sn DecompileMethods -pn com.spotify.music -nd
Empty
View the raw data:
$ ./androquery result -sn DecompileMethods -pn com.spotify.music -nd -r
Empty
Source¶
# encoding: utf-8
__author__ = "Nils Tobias Schmidt"
__email__ = "schmidt89 at informatik.uni-marburg.de"
from androguard.decompiler.dad import decompile
from androlyze.model.script.AndroScript import AndroScript
CAT_DECOMPILE = "decompiled_methods"
class DecompileMethods(AndroScript):
''' Get the source code from the apk for each method. '''
VERSION = "0.1"
def _analyze(self, apk, dalvik_vm_format, vm_analysis, gvm_analysis, *args, **kwargs):
''' This sample code is taken from `androguard` and has been modified!
See Also
--------
http://code.google.com/p/androguard/wiki/RE#Source_Code
'''
res = self.res
res.register_keys([CAT_DECOMPILE])
# CFG
for method in dalvik_vm_format.get_methods():
mx = vm_analysis.get_method(method)
if method.get_code() == None:
continue
try:
classname, methodname, method_descriptor = method.get_class_name(), method.get_name(), method.get_descriptor()
# skip android classes
if classname.find("Landroid") != -1:
continue
CAT = (CAT_DECOMPILE, classname, methodname)
res.register_keys([method_descriptor], *CAT)
ms = decompile.DvMethod(mx)
# process to the decompilation
ms.process()
# get the source !
res.log(method_descriptor, ms.get_source().split("\n"), *CAT)
except:
pass
############################################################
#---Options
############################################################
def needs_dalvik_vm_format(self):
return True
def needs_vmanalysis(self):
return True