Ejemplo 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")
Ejemplo n.º 2
0
    def getGexf(self, gexfOut):
        """
        Use Androgexf in androguard to generate graph
        """
        try:
            self.gexfOut = gexfOut
            vm = dvm.DalvikVMFormat(self.apkObj.get_dex())

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

            b = gvmx.export_to_gexf()
            androconf.save_to_disk(b, self.gexfOut)
        except Exception:
            ex = traceback.format_exc()
            self.log.exce(ex)
Ejemplo n.º 3
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(read(options.input))
            except Exception as e:
                print("INVALID DEX", e)

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

        b = gvmx.export_to_gexf()
        androconf.save_to_disk(b, options.output)
Ejemplo n.º 4
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 )

        b = gvmx.export_to_gexf()
        androconf.save_to_disk( b, options.output )
Ejemplo n.º 5
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")
Ejemplo n.º 6
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" )
Ejemplo n.º 7
0
 def saveGexf(self, where, resultsFileName):
     gexfFileName = '%s%s' % (resultsFileName, '.gexf')
     gexfSavePath = os.path.join(where, gexfFileName)
     b = self._stadynaMcg.export_to_gexf()
     androconf.save_to_disk(b, gexfSavePath)
Ejemplo n.º 8
0
 def saveGexf(self, where, resultsFileName):
     gexfFileName = '%s%s' % (resultsFileName, '.gexf')
     gexfSavePath = os.path.join(where, gexfFileName)
     b = self._stadynaMcg.export_to_gexf()
     androconf.save_to_disk(b, gexfSavePath)