def main(): idaapi.auto_wait() base = idaapi.get_imagebase() tif = idaapi.tinfo_t() f = open(os.environ.get("DESTPATH", "functype_"), 'w') for ea in Segments(): # only code segment if idaapi.segtype(ea) != idaapi.SEG_CODE: continue for fva in Functions(get_segm_start(ea), get_segm_end(ea)): func_name = get_func_name(fva) has_type = idaapi.get_tinfo(tif, fva) or idaapi.guess_tinfo( tif, fva) if not has_type: continue info = serialize(tif) if info is None: continue print( hex(fva - base)[:-1], "|", func_name, "|", tif, "|", len(info['args'])) f.write("0x%x|%s|%s\n" % (fva - base, func_name, json.dumps(info))) f.close() idaapi.qexit(0)
def main(): sys.path.append(os.getcwd()) sys.path.append(os.path.dirname(__file__)) # TODO: use idc.ARGV with some option parsing package worker = IdaWorker(idc.ARGV[1]) worker.run() idaapi.qexit(0)
def main(): # check for correct usage if len(idc.ARGV) < 2: print('No script provided') idaapi.qexit(3) run_script(idc.ARGV[1]) # all went fine, exit cleanly idaapi.qexit(0)
def run_script(script_path): """ Runs the given (IDA) python script in the current context. """ try: # remove wrapper from argv idc.ARGV = idc.ARGV[1:] # add the script's path to the import paths so relative imports will work script_dir = os.path.dirname(os.path.realpath(script_path)) sys.path.insert(0, script_dir) # run the script by loading it imp.load_source('__main__', script_path) except KeyboardInterrupt: # likely ctrl+c, so exit cleanly idaapi.qexit(0) except Exception as e: # there went something wrong, print error and exit cleanly with error code print('Error running script:') traceback.print_exc(e) idaapi.qexit(2)
except Exception as e: print(str(e)) continue if targets and func_id and \ targets[0]['score'] >= bai_config['threshold']: bai_mark.apply_bai_high_score(ea, targets[0]['function']['name'], targets[0]['score']) cur_json = { 'id': func_id, 'score': targets[0]['score'], 'target': { 'id': targets[0]['function']['id'], 'name': targets[0]['function']['name'] } } output_json[str(ea)] = cur_json path = os.path.join(get_user_idadir(), "output.json") with open(path, "w") as f: f.write(str(json.dumps(output_json, sort_keys=True, indent=2))) f.close() if __name__ == "__main__": ida_auto.auto_wait() if idc.ARGV[1] == '1': cmd_upload(*idc.ARGV[2:]) elif idc.ARGV[1] == '2': cmd_match() idaapi.qexit(0)
def exitIda(self): goToOrigin() simicsString = gdbProt.Evalx('SendGDBMonitor("@cgc.idaDone()");') print("Telling gdb server we are exiting") time.sleep(2) idaapi.qexit(0)
if targets and func_id and \ targets[0]['score'] >= bai_config['threshold']: bai_mark.apply_bai_high_score(ea, targets[0]['function']['name'], targets[0]['score']) cur_json = { 'id': func_id, 'score': targets[0]['score'], 'target': { 'id': targets[0]['function']['id'], 'name': targets[0]['function']['name'] } } output_json[str(ea)] = cur_json path = os.path.join(get_user_idadir(), "output.json") with open(path, "w") as f: f.write(str(json.dumps(output_json, sort_keys=True, indent=2))) f.close() if __name__ == "__main__": ida_auto.auto_wait() retcode = 0 if check_ida(): if idc.ARGV[1] == '1': cmd_upload(*idc.ARGV[2:]) elif idc.ARGV[1] == '2': cmd_match() else: retcode = 1 idaapi.qexit(retcode)
name=name, return_type=return_type, arguments=arguments, local_vars=local_vars, raw_code=raw_code, ) self.functions.append( CollectedFunction( ea=ea, debug=self.debug_functions[ea], decompiler=decompiler, )) self.write_info() return 1 ida.auto_wait() if not ida.init_hexrays_plugin(): ida.load_plugin("hexrays") ida.load_plugin("hexx64") if not ida.init_hexrays_plugin(): print("Unable to load Hex-rays") ida.qexit(1) else: print(f"Hex-rays version {ida.get_hexrays_version()}") decompiler = CollectDecompiler() decompiler.activate(None) print("Done with activate") ida.qexit(0)
def main(): # TODO: use idc.ARGV with some option parsing package worker = idaworker.IdaWorker(idc.ARGV[1]) should_quit = worker.run() if should_quit: idaapi.qexit(0)