My favorites | Sign in
Project Home Downloads Wiki Issues Source
Repository:
Checkout   Browse   Changes   Clones  
Changes to /demos/disassembler_analysis.py
a7887d5d8446 vs. a954a482ac43 Compare: vs.  Format:
Revision a954a482ac43
Go to: 
Project members, sign in to write a code review
/demos/disassembler_analysis.py   a7887d5d8446 /demos/disassembler_analysis.py   a954a482ac43
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 import sys, hashlib 3 import sys, hashlib
4 4
5 PATH_INSTALL = "./" 5 PATH_INSTALL = "./"
6 sys.path.append(PATH_INSTALL + "./") 6 sys.path.append(PATH_INSTALL + "./")
7 7
8 import androguard, analysis 8 import androguard, analysis
9 9
10 #TEST = 'examples/java/test/orig/Test1.class' 10 #TEST = 'examples/java/test/orig/Test1.class'
11 #TEST = 'examples/java/Demo1/orig/DES.class' 11 #TEST = 'examples/java/Demo1/orig/DES.class'
12 #TEST = 'examples/java/Demo1/orig/Util.class' 12 #TEST = 'examples/java/Demo1/orig/Util.class'
13 #TEST = 'examples/android/Test/bin/classes.dex' 13 #TEST = 'examples/android/Test/bin/classes.dex'
14 TEST = 'examples/android/TestsAndroguard/bin/classes.dex' 14 TEST = 'examples/android/TestsAndroguard/bin/classes.dex'
15 #TEST = 'examples/android/TC/bin/classes.dex' 15 #TEST = 'examples/android/TC/bin/classes.dex'
16 #TEST = 'examples/android/Hello_Kitty/classes.dex' 16 #TEST = 'examples/android/Hello_Kitty/classes.dex'
17 17
18 a = androguard.AndroguardS( TEST ) 18 a = androguard.AndroguardS( TEST )
19 x = analysis.VM_BCA( a.get_vm() ) 19 x = analysis.VMAnalysis( a.get_vm() )
20 20
21 21
22 # CFG 22 # CFG
23 for method in a.get_methods() : 23 for method in a.get_methods() :
24 g = x.hmethods[ method ] 24 g = x.hmethods[ method ]
25 25
26 print method.get_class_name(), method.get_name(), method.get_descriptor(), method.get_code().get_length(), method.get_code().registers_size.get_value() 26 print method.get_class_name(), method.get_name(), method.get_descriptor(), method.get_code().get_length(), method.get_code().registers_size.get_value()
27 27
28 idx = 0 28 idx = 0
29 for i in g.basic_blocks.get() : 29 for i in g.basic_blocks.get() :
30 print "\t %s %x %x" % (i.name, i.start, i.end), i.ins[-1].get_name(), '[ CHILDS = ', ', '.join( "%x-%x-%s" % (j[0], j[1], j[2].get_name()) for j in i.childs ), ']', '[ FATHERS = ', ', '.join( j[2].get_name() for j in i.fathers ), ']', i.free_blocks_offsets 30 print "\t %s %x %x" % (i.name, i.start, i.end), i.ins[-1].get_name(), '[ CHILDS = ', ', '.join( "%x-%x-%s" % (j[0], j[1], j[2].get_name()) for j in i.childs ), ']', '[ FATHERS = ', ', '.join( j[2].get_name() for j in i.fathers ), ']', i.free_blocks_offsets
31 31
32 for ins in i.get_ins() : 32 for ins in i.get_ins() :
33 print "\t\t %x" % idx, ins.get_name(), ins.get_operands() 33 print "\t\t %x" % idx, ins.get_name(), ins.get_operands()
34 idx += ins.get_length() 34 idx += ins.get_length()
35 35
36 print "" 36 print ""
Powered by Google Project Hosting