コード例 #1
0
ファイル: ApkOpearate.py プロジェクト: smilinrobin/LAND
	def get_methods2(self) :
		## parse the apk file
		a = AndroguardS(self.__folder +"\\"+ self.__filename + '.apk')
		for method in a.get_methods() :
			class_name = method.get_class_name()
			method_name = method.get_name()
			## filter useless file
			if class_name.find('Landroid')==-1 and class_name.find('BuildConfig',0)==-1 and class_name.find('R$',0)==-1 and class_name.find('R;',0)==-1 and method_name.find('<clinit>',0)==-1:
				if self.getfolder().replace('\\','/') in class_name:
					method = '%s--->%s%s\n' %(class_name, method.get_name(), method.get_descriptor())
					self.__methods.append(method.replace(' ',''))	
				## record all methods
				
		with open(Constant.info_path+self.__filename+"\\"+Constant.method_file, 'w') as methods_write :
			for m in self.__methods:
				methods_write.write(m)
コード例 #2
0
 def get_methods(self):
     ## initial self.package
     self.get_package()
     ## parse the apk file
     a = AndroguardS(self.__path + self.__filename + '.apk')
     for method in a.get_methods():
         class_name = method.get_class_name()
         method_name = method.get_name()
         ## filter useless file
         if class_name.find('Landroid') == -1 and class_name.find(
                 'BuildConfig', 0) == -1 and class_name.find(
                     'R$', 0) == -1 and class_name.find(
                         'R;', 0) == -1 and method_name.find('<clinit>',
                                                             0) == -1:
             if self.getPackagePath() in class_name:
                 method = '%s--->%s%s' % (class_name, method.get_name(),
                                          method.get_descriptor())
                 self.__methods.append(method)
コード例 #3
0
PATH_INSTALL = "./"
sys.path.append(PATH_INSTALL)

from androguard.core.androgen import AndroguardS
from androguard.core.analysis import analysis
from androguard.core.bytecodes import dvm

TEST = 'examples/android/TestsAndroguard/bin/classes.dex'

a = AndroguardS( TEST )
x = analysis.VMAnalysis( a.get_vm() )


# CFG
for method in a.get_methods():
    g = x.get_method( method )

    # Display only methods with exceptions
    if method.get_code() == None:
      continue

    if method.get_code().tries_size <= 0:
      continue

    print method.get_class_name(), method.get_name(), method.get_descriptor(), method.get_code().get_length(), method.get_code().registers_size

    idx = 0
    for i in g.basic_blocks.get():
        print "\t %s %x %x" % (i.name, i.start, i.end), '[ NEXT = ', ', '.join( "%x-%x-%s" % (j[0], j[1], j[2].get_name()) for j in i.childs ), ']', '[ PREV = ', ', '.join( j[2].get_name() for j in i.fathers ), ']'
コード例 #4
0
#!/usr/bin/env python

import sys, hashlib

PATH_INSTALL = "./"
sys.path.append(PATH_INSTALL)

from androguard.core.androgen import AndroguardS
from androguard.core.analysis import analysis

TEST = 'examples/android/TestsAndroguard/bin/classes.dex'

a = AndroguardS(TEST)
x = analysis.VMAnalysis(a.get_vm())

for method in a.get_methods():
    g = x.get_method(method)

    if method.get_code() == None:
        continue

    idx = 0
    for i in g.basic_blocks.get():
        for ins in i.get_instructions():
            op_value = ins.get_op_value()

            # packed/sparse
            if op_value == 0x2b or op_value == 0x2c:
                special_ins = i.get_special_ins(idx)
                if special_ins != None:
                    print "\t %x" % idx, ins, special_ins, ins.get_name(