def SearchCodePathDialog(ret_only=False, extended=False): f1 = idaapi.choose_func("Select starting function", 0) if not f1: return sea = f1.startEA f2 = idaapi.choose_func("Select target function", idc.ScreenEA()) if not f2: return tea = f2.startEA nodes = SearchCodePath(sea, tea, extended) if len(nodes) > 0: if ret_only: return nodes else: g = PathsBrowser( "Code paths from %s to %s" % (idc.GetFunctionName(sea), idc.GetFunctionName(tea)), nodes, sea, tea) g.Show() else: idaapi.info("No codepath found between %s and %s" % (idc.GetFunctionName(sea), idc.GetFunctionName(tea))) return nodes
def btn_clicked(self, checked): del checked f = idaapi.choose_func("Choose function to match with database", self.func.startEA if self.func else 0) if f: self.set_func(f) self.changed.emit()
def btn_pick_clicked(self): ida_f = idaapi.choose_func("Pick a function to hook", idaapi.BADADDR) func_addr = ida_f.startEA func_name = idaapi.get_func_name(func_addr) self.picked_function = func_addr self.edit_picked_fun.setText("0x{:X} ({})".format(func_addr, func_name))
def _activate(self, ctx): func = idaapi.choose_func("Add LCA Target", 0) if not func: return lca_viewer.add_target(func.startEA) lca_viewer.rebuild_graph() lca_viewer.Refresh() lca_viewer.Show()
def activate(ctx): file_id = netnode.bound_file_id function = idaapi.choose_func("Choose function to match with database", idc.ScreenEA()) if function is None: return data = instances.FunctionInstance(file_id, function.startEA) network.query("POST", "collab/instances/", params=data.serialize(), json=True)
def SearchCodePathDialog(ret_only=False, extended=False): f1 = idaapi.choose_func("Select starting function", 0) if not f1: return sea = f1.startEA f2 = idaapi.choose_func("Select target function", idc.ScreenEA()) if not f2: return tea = f2.startEA nodes = SearchCodePath(sea, tea, extended) if len(nodes) > 0: if ret_only: return nodes else: g = PathsBrowser( "Code paths from %s to %s" % (idc.GetFunctionName(sea), idc.GetFunctionName(tea)), nodes, sea, tea ) g.Show() else: idaapi.info("No codepath found between %s and %s" % (idc.GetFunctionName(sea), idc.GetFunctionName(tea))) return nodes
def make_func_sigs(config): logger = logging.getLogger("idb2pat:make_func_sigs") sigs = [] if config.mode == USER_SELECT_FUNCTION: f = idaapi.choose_func("Choose Function:", idc.BADADDR) if f is None: logger.error("No function selected") return [] idc.jumpto(f.start_ea) if not idaapi.has_any_name(idc.get_full_flags(f.start_ea)): logger.error("Function doesn't have a name") return [] try: sigs.append(make_func_sig(config, f)) except Exception as e: logger.exception(e) logger.error("Failed to create signature for function at %s (%s)", hex(f.start_ea), idc.get_func_name(f.start_ea) or "") elif config.mode == NON_AUTO_FUNCTIONS: for f in get_functions(): # HTC - remove check FUNC_LIB flag to include library functions if idaapi.has_name(idc.get_full_flags(f.start_ea)): # and f.flags & idc.FUNC_LIB == 0: try: sigs.append(make_func_sig(config, f)) except FuncTooShortException: pass except Exception as e: logger.exception(e) logger.error( "Failed to create signature for function at %s (%s)", hex(f.start_ea), idc.get_name(f.start_ea) or "") elif config.mode == LIBRARY_FUNCTIONS: for f in get_functions(): if idaapi.has_name(idc.get_full_flags( f.start_ea)) and f.flags & idc.FUNC_LIB != 0: try: sigs.append(make_func_sig(config, f)) except FuncTooShortException: pass except Exception as e: logger.exception(e) logger.error( "Failed to create signature for function at %s (%s)", hex(f.start_ea), idc.get_name(f.start_ea) or "") elif config.mode == PUBLIC_FUNCTIONS: for f in get_functions(): if idaapi.is_public_name(f.start_ea): try: sigs.append(make_func_sig(config, f)) except FuncTooShortException: pass except Exception as e: logger.exception(e) logger.error( "Failed to create signature for function at %s (%s)", hex(f.start_ea), idc.get_name(f.start_ea) or "") elif config.mode == ENTRY_POINT_FUNCTIONS: for i in zrange(idaapi.get_func_qty()): f = idaapi.get_func(idaapi.get_entry(idaapi.get_entry_ordinal(i))) if f is not None: try: sigs.append(make_func_sig(config, f)) except FuncTooShortException: pass except Exception as e: logger.exception(e) logger.error( "Failed to create signature for function at %s (%s)", hex(f.start_ea), idc.get_name(f.start_ea) or "") elif config.mode == ALL_FUNCTIONS: n = idaapi.get_func_qty() for i, f in enumerate(get_functions()): try: logger.info("[ %d / %d ] %s %s", i + 1, n, idc.get_name(f.start_ea), hex(f.start_ea)) sigs.append(make_func_sig(config, f)) except FuncTooShortException: pass except Exception as e: logger.exception(e) logger.error( "Failed to create signature for function at %s (%s)", hex(f.start_ea), idc.get_name(f.start_ea) or "") return sigs