def export_apps_to_xgmml( input, output, fcg, efcg ): a = Androguard( [ input ] ) with open(output, "w") as fd: fd.write("<?xml version='1.0'?>\n") fd.write("<graph label=\"Androguard XGMML %s\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ns1=\"http://www.w3.org/1999/xlink\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns=\"http://www.cs.rpi.edu/XGMML\" directed=\"1\">\n" % (os.path.basename(input))) for vm in a.get_vms(): x = analysis.VMAnalysis( vm ) # CFG for method in vm.get_methods(): g = x.get_method( method ) export_xgmml_cfg(g, fd) if fcg: export_xgmml_fcg(vm, x, fd) if efcg: export_xgmml_efcg(vm, x, fd) fd.write("</graph>")
def export_apps_to_xgmml(input, output, fcg, efcg): a = Androguard([input]) with open(output, "w") as fd: fd.write("<?xml version='1.0'?>\n") fd.write( "<graph label=\"Androguard XGMML %s\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ns1=\"http://www.w3.org/1999/xlink\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns=\"http://www.cs.rpi.edu/XGMML\" directed=\"1\">\n" % (os.path.basename(input))) for vm in a.get_vms(): x = analysis.VMAnalysis(vm) # CFG for method in vm.get_methods(): g = x.get_method(method) export_xgmml_cfg(g, fd) if fcg: export_xgmml_fcg(vm, x, fd) if efcg: export_xgmml_efcg(vm, x, fd) fd.write("</graph>")
def decompile(apkname, output): print "Dump information %s in %s" % (apkname, output) apk_vm_serial = [] a = Androguard([apkname]) decompiler_type = None if not os.path.exists(output): print "Create directory %s" % output os.makedirs(output) else: print "Clean directory %s" % output androconf.rrmdir(output) os.makedirs(output) output_dir = output if output_dir[-1] != "/": output_name = output_dir + "/" print "Output dir: %s" % output_dir for vm in a.get_vms(): vm_list = [] #vm_list = [vm, vmx] print "Analysis ...", sys.stdout.flush() vmx = analysis.VMAnalysis(vm) vm_list.append(vm) vm_list.append(vmx) print "End" print "Decompilation ...", sys.stdout.flush() if not decompiler_type: vm.set_decompiler(decompiler.DecompilerDAD(vm, vmx)) elif decompiler_type == "dex2jad": vm.set_decompiler( decompiler.DecompilerDex2Jad(vm, androconf.CONF["PATH_DEX2JAR"], androconf.CONF["BIN_DEX2JAR"], androconf.CONF["PATH_JAD"], androconf.CONF["BIN_JAD"], androconf.CONF["TMP_DIRECTORY"])) elif decompiler_type == "dex2winejad": vm.set_decompiler( decompiler.DecompilerDex2WineJad( vm, androconf.CONF["PATH_DEX2JAR"], androconf.CONF["BIN_DEX2JAR"], androconf.CONF["PATH_JAD"], androconf.CONF["BIN_WINEJAD"], androconf.CONF["TMP_DIRECTORY"])) elif decompiler_type == "ded": vm.set_decompiler( decompiler.DecompilerDed(vm, androconf.CONF["PATH_DED"], androconf.CONF["BIN_DED"], androconf.CONF["TMP_DIRECTORY"])) elif decompiler_type == "dex2fernflower": vm.set_decompiler( decompiler.DecompilerDex2Fernflower( vm, androconf.CONF["PATH_DEX2JAR"], androconf.CONF["BIN_DEX2JAR"], androconf.CONF["PATH_FERNFLOWER"], androconf.CONF["BIN_FERNFLOWER"], androconf.CONF["OPTIONS_FERNFLOWER"], androconf.CONF["TMP_DIRECTORY"])) else: raise ("invalid decompiler !") apk_vm_serial.append(vm_list) print "End" return apk_vm_serial