def main(options, arguments): if options.input != None: a = androguard.Androguard(options.input) a.ianalyze() vm1 = a.get_bc()[0][1].get_vm() vmx1 = a.get_bc()[0][1].get_analysis() vm2 = a.get_bc()[1][1].get_vm() vmx2 = a.get_bc()[1][1].get_analysis() dsim = diff.Sim([vm1, vmx1], [vm2, vmx2]) print "DIFF METHODS :", len(dsim.get_diff_methods()) print "NEW METHODS :", len(dsim.get_new_methods()) print "MATCH METHODS :", len(dsim.get_match_methods()) print "DELETE METHODS :", len(dsim.get_delete_methods()) print dsim.get_marks() print dsim.get_final_score() if options.display: print "DIFF METHODS :" diff_methods = dsim.get_diff_methods() for i in diff_methods: i.show2() print "MATCH METHODS :" new_methods = dsim.get_match_methods() for i in new_methods: i.show2() print "NEW METHODS :" new_methods = dsim.get_new_methods() for i in new_methods: i.show2() print "DELETE METHODS :" del_methods = dsim.get_delete_methods() for i in del_methods: i.show2() # Not yet usable elif options.json != None: a = androguard.Androguard([options.json[0]]) a.ianalyze() vm1 = a.get_bc()[0][1].get_vm() vmx1 = a.get_bc()[0][1].get_analysis() diff.SimJson([vm1, vmx1], options.json[1]) elif options.version != None: print "Androsim version %s" % androconf.ANDROGUARD_VERSION
def main(options, arguments) : if options.input != None : a = androguard.Androguard( options.input ) a.ianalyze() vm1 = a.get_bc()[0][1].get_vm() vmx1 = a.get_bc()[0][1].get_analysis() vm2 = a.get_bc()[1][1].get_vm() vmx2 = a.get_bc()[1][1].get_analysis() d = diff.Diff( [ vm1, vmx1 ], [ vm2, vmx2 ] ) details = False if options.display != None : details = True print "DIFF METHODS :", len(d.get_diff_methods()) print "NEW METHODS :", len(d.get_new_methods()) print "MATCH METHODS :", len(d.get_match_methods()) print "DELETE METHODS :", len(d.get_delete_methods()) print "DIFF METHODS :" diff_methods = d.get_diff_methods() for i in diff_methods : exclude = options.exclude if exclude == None : exclude = [] else : exclude = [ int(exclude) ] i.show( details, exclude ) print print "MATCH METHODS :" new_methods = d.get_match_methods() for i in new_methods : i.show2( False ) print "NEW METHODS :" new_methods = d.get_new_methods() for i in new_methods : i.show2( details ) print print "DELETE METHODS :" del_methods = d.get_delete_methods() for i in del_methods : i.show2( details ) print if options.pickle != None : d.sim.raz() fd = open(options.pickle, "w") fd.write( dumps(d, -1) ) fd.close() elif options.version != None : print "Androdiff version %s" % androconf.ANDROGUARD_VERSION
def main(options, arguments) : if options.input != None and options.output != None : a = androguard.Androguard( [ options.input ] ) create_directories( a, options.output ) if options.dot != None or options.format != None : export_apps_to_format( a, options.output, options.dot, options.format ) elif options.version != None : print "Androdd version %s" % misc.ANDRODD_VERSION
def main(options, arguments): if options.input != None: a = androguard.Androguard(options.input) a.ianalyze() vm1 = a.get_bc()[0][1].get_vm() vmx1 = a.get_bc()[0][1].get_analysis() vm2 = a.get_bc()[1][1].get_vm() vmx2 = a.get_bc()[1][1].get_analysis() dsim = diff.Sim([vm1, vmx1], [vm2, vmx2]) print "DIFF METHODS :", len(dsim.get_diff_methods()) print "NEW METHODS :", len(dsim.get_new_methods()) print "MATCH METHODS :", len(dsim.get_match_methods()) print "DELETE METHODS :", len(dsim.get_delete_methods()) print dsim.get_final_score() if options.display: print "DIFF METHODS :" diff_methods = dsim.get_diff_methods() diff_methods.sort(key=lambda v: (v.get_length() + ( (1 - v.sort_h[0][1]) * v.get_length()))) diff_methods.reverse() for i in diff_methods: i.show2() print "MATCH METHODS :" match_methods = dsim.get_match_methods() match_methods.sort(key=lambda v: (v.get_length())) match_methods.reverse() for i in match_methods: i.show2() print "NEW METHODS :" new_methods = dsim.get_new_methods() new_methods.sort(key=lambda v: (v.get_length())) new_methods.reverse() for i in new_methods: i.show2() print "DELETE METHODS :" del_methods = dsim.get_delete_methods() del_methods.sort(key=lambda v: (v.get_length())) del_methods.reverse() for i in del_methods: i.show2() elif options.version != None: print "Androsimforsign version %s" % androconf.ANDROGUARD_VERSION
def __main__() : print sys.argv if len( sys.argv ) > 1 : files = [] for p in sys.argv[1].split(":") : files.extend( get_classes( p ) ) a = androguard.Androguard( files ) try : a.do( sys.argv[2] ) except Exception, e: warning("!!!! Androguard failed !!!!") traceback.print_exc()
def main(options, arguments): if options.input != None: a = androguard.Androguard(options.input) a.ianalyze() vm1 = a.get_bc()[0][1].get_vm() vmx1 = a.get_bc()[0][1].get_analysis() vm2 = a.get_bc()[1][1].get_vm() vmx2 = a.get_bc()[1][1].get_analysis() diff.Sim([vm1, vmx1], [vm2, vmx2]) elif options.json != None: a = androguard.Androguard([options.json[0]]) a.ianalyze() vm1 = a.get_bc()[0][1].get_vm() vmx1 = a.get_bc()[0][1].get_analysis() diff.SimJson([vm1, vmx1], options.json[1]) elif options.version != None: print "Androsim version %s" % misc.ANDROSIM_VERSION
def main(options, arguments): if options.input != None: a = androguard.Androguard(options.input) a.ianalyze() vm1 = a.get_bc()[0][1].get_vm() vmx1 = a.get_bc()[0][1].get_analysis() vm2 = a.get_bc()[1][1].get_vm() vmx2 = a.get_bc()[1][1].get_analysis() d = diff.Diff([vm1, vmx1], [vm2, vmx2], diff.FILTERS_DIFF) details = False if options.display != None: details = True print "DIFF METHODS :" diff_methods = d.get_diff_methods() for i in diff_methods: for elem in diff_methods[i]: elem.show(i, details) print print "NEW METHODS :" new_methods = d.get_new_methods() for i in new_methods: for elem in new_methods[i]: elem.show2(details) print print "DELETE METHODS :" del_methods = d.get_delete_methods() for i in del_methods: for elem in del_methods[i]: elem.show2(details) print elif options.version != None: print "Androdiff version %s" % misc.ANDRODIFF_VERSION
def export_apps_to_xgmml( input, output, fcg, efcg ) : a = androguard.Androguard( [ input ] ) fd = open(output, "w") 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.hmethods[ 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>") fd.close()
''' return _VmB('VmRSS:') - since def stacksize(since=0.0): '''Return stack size in bytes. ''' return _VmB('VmStk:') - since PATH_INSTALL = "./" sys.path.append(PATH_INSTALL + "./") import androguard, analysis # a directory with apks files" TEST = "./apks/" l = [] for i in os.walk(TEST): for j in i[2]: l.append(i[0] + j) print len(l), l _a = androguard.Androguard(l) print "MEMORY : ", memory() / _scale["MB"], "RESIDENT ", resident( ) / _scale["MB"], "STACKSIZE ", stacksize() / _scale["MB"]
("Properties.class", 0), ("Registry.class", 0), ("Util.class", 0), ("WeakKeyException.class", 0), ("Demo1Main.class", 1) ] TEST = [] TEST_OUTPUT = [] for i in FILES : if i[1] == 0 : TEST.append( BASE_TEST + i[0] ) TEST_OUTPUT.append( BASE_TEST_OUTPUT + i[0] ) else : TEST.append( BASE_MAIN_TEST + i[0] ) TEST_OUTPUT.append( BASE_MAIN_TEST_OUTPUT + i[0] ) a = androguard.Androguard( TEST ) a.do( CONF1 ) i = 0 while i < len(TEST) : _a = a.get("file", TEST[i]) fd = open( TEST_OUTPUT[i], "w" ) fd.write( _a.save() ) fd.close() i = i + 1