def main(): logging.basicConfig(level=logging.DEBUG) # cleanup any existing data netnode.Netnode(TEST_NAMESPACE).kill() pytest.main(['--capture=sys', os.path.dirname(__file__)])
def get_meta_netnode(): """ Get the netnode used to store settings metadata in the current IDB. Note that this implicitly uses the open IDB via the idc iterface. """ node_name = "$ {org:s}.{application:s}".format( org=IDA_SETTINGS_ORGANIZATION, application=IDA_SETTINGS_APPLICATION) return netnode.Netnode(node_name)
def main(): is_selected, sel_start, sel_end = ida_kernwin.read_selection() if not is_selected: logger.error('range must be selected') return -1 sel_end = ida_bytes.next_head(sel_end) buf = ida_bytes.get_bytes(sel_start, sel_end - sel_start) if buf is None: logger.error('failed to fetch instruction bytes') return -1 f = ida_funcs.get_func(sel_start) if f != ida_funcs.get_func(sel_end): logger.error('range must be within a single function') return -1 # find mappings from "$localN" to "custom_name" regvars = {} for i in range(0x1000): regvar = ida_frame.find_regvar(f, sel_start, '$local%d' % i) if regvar is None: continue regvars[regvar.canon] = regvar.user if len(regvars) >= f.regvarqty: break globals_ = {} for i, offset in netnode.Netnode('$ wasm.offsets').get('globals', {}).items(): globals_['$global' + i] = ida_name.get_name(offset) frame = {} if f.frame != ida_idaapi.BADADDR: names = set([]) for i in range(ida_struct.get_struc_size(f.frame)): s = ida_struct.get_struc(f.frame) if not s: continue m = ida_struct.get_member(s, i) if not m: continue name = ida_struct.get_member_name(m.id) if name in names: continue frame[i] = name names.add(name) emu = Emulator(buf) emu.run() print( emu.render(ctx={ 'regvars': regvars, 'frame': frame, 'globals': globals_, }))
def killing_netnode(namespace): ''' wraps a netnode in a contextmanager that will eventually destroy its contents. probably only useful for testing when a clean state is req'd. ''' n = netnode.Netnode(namespace) try: yield n finally: n.kill()
def __init__(self): # Initialize ROP gadget search engine self.engine = IdaRopEngine() self.engine.rop = IdaRopSearch(self.engine) self.ropView = IdaRopView(self.engine) # Defered csv loading for a faster startup self.defered_loading = False # List of menu item added by the plugin self.addmenu_item_ctxs = list() # blob manager for saving internal db into idb file self.blob_manager = None if netnode_package: self.blob_manager = netnode.Netnode("$ idarop.rop_blob") else: print( "[IdaRop] IdaRop rely on the Netnode package to save the rop database in the idb file." ) print( " Since it's not present, the results will be discarded when closing IDA." )
def _netnode(self): node_name = "$ {org:s}.{application:s}.{plugin_name:s}".format( org=IDA_SETTINGS_ORGANIZATION, application=IDA_SETTINGS_APPLICATION, plugin_name=self._plugin_name) return netnode.Netnode(node_name)