My favorites | Sign in
Project Home Downloads Wiki Issues Source
Repository:
Checkout   Browse   Changes   Clones  
Changes to /demos/disassembler_exceptions.py
a7887d5d8446 vs. a954a482ac43 Compare: vs.  Format:
Revision a954a482ac43
Go to: 
Project members, sign in to write a code review
/demos/disassembler_exceptions.py   a7887d5d8446 /demos/disassembler_exceptions.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/TestsAndroguard/bin/classes.dex' 13 TEST = 'examples/android/TestsAndroguard/bin/classes.dex'
14 #TEST = 'examples/android/Hello_Kitty/classes.dex' 14 #TEST = 'examples/android/Hello_Kitty/classes.dex'
15 15
16 a = androguard.AndroguardS( TEST ) 16 a = androguard.AndroguardS( TEST )
17 x = analysis.VM_BCA( a.get_vm() ) 17 x = analysis.VMAnalysis( a.get_vm() )
18 18
19 19
20 # CFG 20 # CFG
21 for method in a.get_methods() : 21 for method in a.get_methods() :
22 g = x.hmethods[ method ] 22 g = x.hmethods[ method ]
23 23
24 # Display only methods with exceptions 24 # Display only methods with exceptions
25 if method.get_code().tries_size.get_value() <= 0 : 25 if method.get_code().tries_size.get_value() <= 0 :
26 continue 26 continue
27 27
28 print method.get_class_name(), method.get_name(), method.get_descriptor(), method.get_code().get_length(), method.get_code().registers_size.get_value() 28 print method.get_class_name(), method.get_name(), method.get_descriptor(), method.get_code().get_length(), method.get_code().registers_size.get_value()
29 29
30 idx = 0 30 idx = 0
31 for i in g.basic_blocks.get() : 31 for i in g.basic_blocks.get() :
32 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 32 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
33 33
34 for ins in i.get_ins() : 34 for ins in i.get_ins() :
35 print "\t\t %x" % idx, ins.get_name(), ins.get_operands() 35 print "\t\t %x" % idx, ins.get_name(), ins.get_operands()
36 idx += ins.get_length() 36 idx += ins.get_length()
37 37
38 print "" 38 print ""
39 39
40 handlers = method.get_code().handlers 40 handlers = method.get_code().handlers
41 for try_item in method.get_code().tries : 41 for try_item in method.get_code().tries :
42 print try_item 42 print try_item
43 43
44 44
45 for handler_catch_list in method.get_code().handlers : 45 for handler_catch_list in method.get_code().handlers :
46 print "\t HANDLER_CATCH_LIST SIZE", handler_catch_list.size 46 print "\t HANDLER_CATCH_LIST SIZE", handler_catch_list.size
47 for handler_catch in handler_catch_list.list : 47 for handler_catch in handler_catch_list.list :
48 print "\t\t HANDLER_CATCH SIZE ", handler_catch.size 48 print "\t\t HANDLER_CATCH SIZE ", handler_catch.size
49 for handler in handler_catch.handlers : 49 for handler in handler_catch.handlers :
50 print "\t\t\t HANDLER", handler.type_idx, a.get_vm().get_class_manager().get_type( handler.type_idx ), handler.addr 50 print "\t\t\t HANDLER", handler.type_idx, a.get_vm().get_class_manager().get_type( handler.type_idx ), handler.addr
Powered by Google Project Hosting