Esempio n. 1
0
def create_graph(input, output):
    if input != None and output != None:

        ret_type = androconf.is_android(input)
        vm = None
        a = None
        if ret_type == "APK":
            a = apk.APK(input)
            if a.is_valid_APK():
                vm = dvm.DalvikVMFormat(a.get_dex())
            else:
                print "INVALID APK"
        elif ret_type == "DEX":
            try:
                vm = dvm.DalvikVMFormat(open(input, "rb").read())
            except Exception, e:
                print "INVALID DEX", e

        vmx = analysis.VMAnalysis(vm)
        gvmx = ganalysis.GVMAnalysis(vmx, a)

        create_directories(vm, output)

        dd = data.Data(vm, vmx, gvmx, a)

        buff = dd.export_methodcalls_to_gml()
        androconf.save_to_disk(buff, output + "/" + "methodcalls.graphml")
Esempio n. 2
0
def main(options, arguments):
    if options.input != None and options.output != None:

        ret_type = androconf.is_android(options.input)
        vm = None
        a = None
        if ret_type == "APK":
            a = apk.APK(options.input)
            if a.is_valid_APK():
                vm = dvm.DalvikVMFormat(a.get_dex())
            else:
                print "INVALID APK"
        elif ret_type == "DEX":
            try:
                vm = dvm.DalvikVMFormat(open(options.input, "rb").read())
            except Exception, e:
                print "INVALID DEX", e

        vmx = analysis.VMAnalysis(vm)
        gvmx = ganalysis.GVMAnalysis(vmx, a)

        create_directories(vm, options.output)

        #        dv.export_to_gml( options.output )

        dd = data.Data(vm, vmx, gvmx, a)

        buff = dd.export_apk_to_gml()
        androconf.save_to_disk(buff, options.output + "/" + "apk.graphml")

        buff = dd.export_methodcalls_to_gml()
        androconf.save_to_disk(buff,
                               options.output + "/" + "methodcalls.graphml")

        buff = dd.export_dex_to_gml()
        for i in buff:
            androconf.save_to_disk(buff[i],
                                   options.output + "/" + i + ".graphml")