diff options
Diffstat (limited to 'example')
| -rwxr-xr-x | example/asm/shellcode.py | 15 | ||||
| -rw-r--r-- | example/asm/simple.py | 2 | ||||
| -rw-r--r-- | example/disasm/callback.py | 2 | ||||
| -rw-r--r-- | example/disasm/full.py | 6 | ||||
| -rw-r--r-- | example/expression/access_c.py | 2 | ||||
| -rw-r--r-- | example/expression/asm_to_ir.py | 2 | ||||
| -rw-r--r-- | example/expression/graph_dataflow.py | 2 | ||||
| -rw-r--r-- | example/expression/solve_condition_stp.py | 8 | ||||
| -rw-r--r-- | example/ida/ctype_propagation.py | 4 | ||||
| -rw-r--r-- | example/ida/depgraph.py | 6 | ||||
| -rw-r--r-- | example/ida/graph_ir.py | 6 | ||||
| -rw-r--r-- | example/ida/utils.py | 2 | ||||
| -rw-r--r-- | example/jitter/sandbox_call.py | 4 | ||||
| -rw-r--r-- | example/jitter/unpack_upx.py | 2 |
14 files changed, 32 insertions, 31 deletions
diff --git a/example/asm/shellcode.py b/example/asm/shellcode.py index 331e4d69..9be5b517 100755 --- a/example/asm/shellcode.py +++ b/example/asm/shellcode.py @@ -71,11 +71,12 @@ loc_db = LocationDB() asmcfg, loc_db = parse_asm.parse_txt(machine.mn, attrib, source, loc_db) # Fix shellcode addrs -loc_db.set_offset(loc_db.getby_name("main"), addr_main) +loc_db.set_location_offset(loc_db.get_name_location("main"), addr_main) if args.PE: - loc_db.set_offset(loc_db.getby_name_create("MessageBoxA"), - pe.DirImport.get_funcvirt('USER32.dll', 'MessageBoxA')) + loc_db.set_location_offset(loc_db.get_or_create_name_location("MessageBoxA"), + pe.DirImport.get_funcvirt('USER32.dll', + 'MessageBoxA')) # Print and graph firsts blocks before patching it for block in asmcfg.blocks: @@ -89,10 +90,10 @@ patches = asmblock.asm_resolve_final(machine.mn, dst_interval) if args.encrypt: # Encrypt code - loc_start = loc_db.getby_name_create(args.encrypt[0]) - loc_stop = loc_db.getby_name_create(args.encrypt[1]) - ad_start = loc_db.loc_key_to_offset(loc_start) - ad_stop = loc_db.loc_key_to_offset(loc_stop) + loc_start = loc_db.get_or_create_name_location(args.encrypt[0]) + loc_stop = loc_db.get_or_create_name_location(args.encrypt[1]) + ad_start = loc_db.get_location_offset(loc_start) + ad_stop = loc_db.get_location_offset(loc_stop) new_patches = dict(patches) for ad, val in patches.items(): diff --git a/example/asm/simple.py b/example/asm/simple.py index 068d3627..5480e2f5 100644 --- a/example/asm/simple.py +++ b/example/asm/simple.py @@ -22,7 +22,7 @@ loop: ''') # Set 'main' loc_key's offset -loc_db.set_offset(loc_db.getby_name("main"), 0x0) +loc_db.set_location_offset(loc_db.get_name_location("main"), 0x0) # Spread information and resolve instructions offset patches = asmblock.asm_resolve_final(mn_x86, asmcfg, loc_db) diff --git a/example/disasm/callback.py b/example/disasm/callback.py index 85090070..b9a09c09 100644 --- a/example/disasm/callback.py +++ b/example/disasm/callback.py @@ -27,7 +27,7 @@ def cb_x86_callpop(cur_bloc, loc_db, *args, **kwargs): return loc_key = dst.loc_key - offset = loc_db.loc_key_to_offset(loc_key) + offset = loc_db.get_location_offset(loc_key) ## The destination must be the next instruction if offset != last_instr.offset + last_instr.l: return diff --git a/example/disasm/full.py b/example/disasm/full.py index 1e5d2334..ddf91e29 100644 --- a/example/disasm/full.py +++ b/example/disasm/full.py @@ -99,8 +99,8 @@ for addr in args.address: addrs.append(int(addr, 0)) except ValueError: # Second chance, try with symbol - loc_key = mdis.loc_db.getby_name(addr) - offset = mdis.loc_db.loc_key_to_offset(loc_key) + loc_key = mdis.loc_db.get_name_location(addr) + offset = mdis.loc_db.get_location_offset(loc_key) addrs.append(offset) if len(addrs) == 0 and default_addr is not None: @@ -143,7 +143,7 @@ while not finish and todo: for dest in instr.getdstflow(mdis.loc_db): if not dest.is_loc(): continue - offset = mdis.loc_db.loc_key_to_offset(dest.loc_key) + offset = mdis.loc_db.get_location_offset(dest.loc_key) todo.append((mdis, instr, offset)) if args.funcswatchdog is not None and args.funcswatchdog <= 0: diff --git a/example/expression/access_c.py b/example/expression/access_c.py index 9b92d201..8e440cc1 100644 --- a/example/expression/access_c.py +++ b/example/expression/access_c.py @@ -144,7 +144,7 @@ dis_engine, ira = machine.dis_engine, machine.ira mdis = dis_engine(cont.bin_stream, loc_db=cont.loc_db) addr_head = 0 asmcfg = mdis.dis_multiblock(addr_head) -lbl_head = mdis.loc_db.getby_offset(addr_head) +lbl_head = mdis.loc_db.get_offset_location(addr_head) ir_arch_a = ira(mdis.loc_db) for block in asmcfg.blocks: diff --git a/example/expression/asm_to_ir.py b/example/expression/asm_to_ir.py index 421d0884..6db07e9b 100644 --- a/example/expression/asm_to_ir.py +++ b/example/expression/asm_to_ir.py @@ -24,7 +24,7 @@ loop: ''') -loc_db.set_offset(loc_db.getby_name("main"), 0x0) +loc_db.set_location_offset(loc_db.get_name_location("main"), 0x0) for block in asmcfg.blocks: print block diff --git a/example/expression/graph_dataflow.py b/example/expression/graph_dataflow.py index d0d5564a..dd9d3e9b 100644 --- a/example/expression/graph_dataflow.py +++ b/example/expression/graph_dataflow.py @@ -97,7 +97,7 @@ def gen_block_data_flow_graph(ir_arch, ad, block_flow_cb): irblock_0 = None for irblock in ir_arch.blocks.values(): loc_key = irblock.loc_key - offset = ir_arch.loc_db.loc_key_to_offset(loc_key) + offset = ir_arch.loc_db.get_location_offset(loc_key) if offset == ad: irblock_0 = irblock break diff --git a/example/expression/solve_condition_stp.py b/example/expression/solve_condition_stp.py index b941f092..41b812cd 100644 --- a/example/expression/solve_condition_stp.py +++ b/example/expression/solve_condition_stp.py @@ -101,10 +101,10 @@ if __name__ == '__main__': loc_db=mdis.loc_db) - argc_lbl = loc_db.getby_name('argc') - argv_lbl = loc_db.getby_name('argv') - ret_addr_lbl = loc_db.getby_name('ret_addr') - init_lbl = loc_db.getby_name('init') + argc_lbl = loc_db.get_name_location('argc') + argv_lbl = loc_db.get_name_location('argv') + ret_addr_lbl = loc_db.get_name_location('ret_addr') + init_lbl = loc_db.get_name_location('init') argc = ExprLoc(argc_lbl, 32) argv = ExprLoc(argv_lbl, 32) diff --git a/example/ida/ctype_propagation.py b/example/ida/ctype_propagation.py index 9a81baef..f236cf26 100644 --- a/example/ida/ctype_propagation.py +++ b/example/ida/ctype_propagation.py @@ -304,8 +304,8 @@ def analyse_function(): infos_types[expr] = set([objc]) # Add fake head - lbl_real_start = ir_arch.loc_db.getby_offset(addr) - lbl_head = ir_arch.loc_db.getby_name_create("start") + lbl_real_start = ir_arch.loc_db.get_offset_location(addr) + lbl_head = ir_arch.loc_db.get_or_create_name_location("start") first_block = asmcfg.label2block(lbl_real_start) diff --git a/example/ida/depgraph.py b/example/ida/depgraph.py index 8e635203..1ba7bee7 100644 --- a/example/ida/depgraph.py +++ b/example/ida/depgraph.py @@ -28,7 +28,7 @@ class depGraphSettingsForm(ida_kernwin.Form): self.address = idc.ScreenEA() cur_block = None for block in ira.getby_offset(self.address): - offset = self.ira.loc_db.loc_key_to_offset(block.loc_key) + offset = self.ira.loc_db.get_location_offset(block.loc_key) if offset is not None: # Only one block non-generated assert cur_block is None @@ -230,7 +230,7 @@ def launch_depgraph(): # Simplify affectations for irb in ir_arch.blocks.values(): irs = [] - offset = ir_arch.loc_db.loc_key_to_offset(irb.loc_key) + offset = ir_arch.loc_db.get_location_offset(irb.loc_key) fix_stack = offset is not None and settings.unalias_stack for assignblk in irb: if fix_stack: @@ -251,7 +251,7 @@ def launch_depgraph(): # Get dependency graphs dg = settings.depgraph graphs = dg.get(loc_key, elements, line_nb, - set([ir_arch.loc_db.getby_offset(func.startEA)])) + set([ir_arch.loc_db.get_offset_location(func.startEA)])) # Display the result comments = {} diff --git a/example/ida/graph_ir.py b/example/ida/graph_ir.py index 955dee62..50895b88 100644 --- a/example/ida/graph_ir.py +++ b/example/ida/graph_ir.py @@ -36,7 +36,7 @@ def label_str(self): def color_irblock(irblock, ir_arch): out = [] - lbl = idaapi.COLSTR(ir_arch.loc_db.str_loc_key(irblock.loc_key), idaapi.SCOLOR_INSN) + lbl = idaapi.COLSTR(ir_arch.loc_db.pretty_str(irblock.loc_key), idaapi.SCOLOR_INSN) out.append(lbl) for assignblk in irblock: for dst, src in sorted(assignblk.iteritems()): @@ -118,8 +118,8 @@ def build_graph(verbose=False, simplify=False): for addr, name in idautils.Names(): if name is None: continue - if (mdis.loc_db.getby_offset(addr) or - mdis.loc_db.getby_name(name)): + if (mdis.loc_db.get_offset_location(addr) or + mdis.loc_db.get_name_location(name)): # Symbol alias continue mdis.loc_db.add_location(name, addr) diff --git a/example/ida/utils.py b/example/ida/utils.py index 254617ba..c66475f2 100644 --- a/example/ida/utils.py +++ b/example/ida/utils.py @@ -98,7 +98,7 @@ class TranslatorIDA(Translator): def from_ExprLoc(self, expr): if self.loc_db is not None: - out = self.loc_db.str_loc_key(expr.loc_key) + out = self.loc_db.pretty_str(expr.loc_key) else: out = str(expr) out = idaapi.COLSTR(out, idaapi.SCOLOR_REG) diff --git a/example/jitter/sandbox_call.py b/example/jitter/sandbox_call.py index 5fc50a9c..3eb0b86e 100644 --- a/example/jitter/sandbox_call.py +++ b/example/jitter/sandbox_call.py @@ -15,8 +15,8 @@ sb = Sandbox_Linux_arml(options.filename, options, globals()) with open(options.filename, "rb") as fdesc: cont = Container.from_stream(fdesc) - loc_key = cont.loc_db.getby_name("md5_starts") - addr_to_call = cont.loc_db.loc_key_to_offset(loc_key) + loc_key = cont.loc_db.get_name_location("md5_starts") + addr_to_call = cont.loc_db.get_location_offset(loc_key) # Calling md5_starts(malloc(0x64)) addr = linobjs.heap.alloc(sb.jitter, 0x64) diff --git a/example/jitter/unpack_upx.py b/example/jitter/unpack_upx.py index 6b7b4f50..665fa15a 100644 --- a/example/jitter/unpack_upx.py +++ b/example/jitter/unpack_upx.py @@ -60,7 +60,7 @@ assert(len(leaves) == 1) l = leaves.pop() logging.info(l) -end_offset = mdis.loc_db.loc_key_to_offset(l) +end_offset = mdis.loc_db.get_location_offset(l) logging.info('final offset') logging.info(hex(end_offset)) |