def activate(self, ctx): ida_auto.set_ida_state(ida_auto.st_Work) if self.with_labels: print('FakePDB/generate pdb (with function labels):') else: print('FakePDB/generate pdb:') dumper = DumpInfo() native = Native() #calculate locations idb_dir = os.path.dirname(ida_loader.get_path( ida_loader.PATH_TYPE_IDB)) pe_filename_ext = ida_nalt.get_root_filename() pe_filename, _ = os.path.splitext(ida_nalt.get_root_filename()) filepath_exe = ida_nalt.get_input_file_path() filepath_json = os.path.join(idb_dir, pe_filename_ext + ".json") filepath_pdb = os.path.join(idb_dir, pe_filename + ".pdb") #generate json print(' * generating JSON: %s' % filepath_json) dumper.dump_info(filepath_json) print(' * generating PDB: %s' % filepath_pdb) native.pdb_generate(filepath_exe, filepath_json, filepath_pdb, self.with_labels) print(' * symserv EXE id: %s' % native.pe_timestamp(filepath_exe)) print(' * symserv PDB id: %s' % native.pe_guidage(filepath_exe)) print(' * done') ida_auto.set_ida_state(ida_auto.st_Ready) return 1
def run(self, arg): """ run function for XML Exporter plugin. Args: arg: Integer, non-zero value enables auto-run feature for IDA batch (no gui) processing mode. Default is 0. """ st = idc.set_ida_state(idc.IDA_STATUS_WORK) xml = idaxml.XmlExporter(arg) try: try: xml.export_xml() except idaxml.Cancelled: ida_kernwin.hide_wait_box() msg = "XML Export cancelled!" print "\n" + msg idc.warning(msg) except: ida_kernwin.hide_wait_box() msg = "***** Exception occurred: XML Exporter failed! *****" print "\n" + msg + "\n", sys.exc_type, sys.exc_value idc.warning(msg) finally: xml.cleanup() ida_auto.set_ida_state(st)
def activate(self, ctx): # get active filename pe_filename_ext = ida_nalt.get_root_filename() if not pe_filename_ext: print('FakePDB/generate lib: file not loaded') return 1 ida_auto.set_ida_state(ida_auto.st_Work) print('FakePDB/generate lib:') dumper = DumpInfo() native = Native() #calculate locations idb_dir = os.path.dirname(ida_loader.get_path( ida_loader.PATH_TYPE_IDB)) pe_filename, _ = os.path.splitext(ida_nalt.get_root_filename()) filepath_exe = ida_nalt.get_input_file_path() filepath_json = os.path.join(idb_dir, pe_filename_ext + ".json") filepath_lib = os.path.join(idb_dir, pe_filename + ".lib") #generate json print(' * generating JSON: %s' % filepath_json) dumper.dump_info(filepath_json) print(' * generating LIB: %s' % filepath_lib) native.coff_createlib(filepath_json, filepath_lib) print(' * done') ida_auto.set_ida_state(ida_auto.st_Ready) return 1
def activate(self, ctx): ida_auto.set_ida_state(ida_auto.st_Work) if self.with_labels: print('FakePDB/generate pdb (with function labels):') else: print('FakePDB/generate pdb:') dumper = InformationDumper() generator = PdbGenerator() #get exe location filepath_ida = ida_loader.get_path(ida_loader.PATH_TYPE_IDB) pre, _ = os.path.splitext(filepath_ida) pre, _ = os.path.splitext(pre) filepath_exe = pre + ".exe" filepath_json = pre + ".exe.json" filepath_pdb = pre + ".pdb" #generate json print(' * generating JSON: %s' % filepath_json) dumper.dump_info(filepath_json) print(' * generating PDB: %s' % filepath_pdb) generator.generate(filepath_exe, filepath_json, filepath_pdb, self.with_labels) print(' * symserv EXE id: %s' % generator.get_symserv_exe(filepath_exe)) print(' * symserv PDB id: %s' % generator.get_symserv_pdb(filepath_exe)) print(' * done') ida_auto.set_ida_state(ida_auto.st_Ready) return 1
def activate(self, ctx): filepath = ida_loader.get_path(ida_loader.PATH_TYPE_IDB) pre, _ = os.path.splitext(filepath) filepath = pre + ".json" dumper = InformationDumper() print('FakePDB/dumpinfo:') ida_auto.set_ida_state(ida_auto.st_Work) dumper.dump_info(filepath) ida_auto.set_ida_state(ida_auto.st_Ready) print(' * done') return 1
def export_ida_project_to_xml(): """ Export the current project into XML format """ global EXPORT_XML_FILE xml_file_path, bin_file_path = get_ida_exported_files() print("GhIDA:: [DEBUG] EXPORT_XML_FILE: %s" % EXPORT_XML_FILE) # Check if files are alredy available if os.path.isfile(xml_file_path) and \ os.path.isfile(bin_file_path) and \ not EXPORT_XML_FILE: return xml_file_path, bin_file_path EXPORT_XML_FILE = False # Otherwise call the XML exporter IDA plugin print("GhIDA:: [DEBUG] Exporting IDA project into XML format") st = idc.set_ida_state(idc.IDA_STATUS_WORK) xml = XmlExporter(1) try: xml.export_xml(xml_file_path) print("GhIDA:: [INFO] XML exporting completed") except Cancelled: ida_kernwin.hide_wait_box() msg = "GhIDA:: [!] XML Export cancelled!" print("\n" + msg) idc.warning(msg) except Exception: ida_kernwin.hide_wait_box() msg = "GhIDA:: [!] Exception occurred: XML Exporter failed!" excinfo = sys.exc_info() tb = excinfo[2] print("\n" + msg + "\n", excinfo[:2], tb) traceback.print_tb(tb) idc.warning(msg) finally: xml.cleanup() ida_auto.set_ida_state(st) # check if both xml and binary format exist if not os.path.isfile(xml_file_path) or \ not os.path.isfile(bin_file_path): raise Exception("GhIDA:: [!] XML or bytes file non existing.") return xml_file_path, bin_file_path
def do_export(): st = ida_auto.set_ida_state(idc.IDA_STATUS_WORK) xml = XmlExporter(1) try: try: xml.export_xml() FELogger.info("已导出IDA数据到XML") except Cancelled: ida_kernwin.hide_wait_box() FELogger.warn("已取消XML导出") except Exception as e: ida_kernwin.hide_wait_box() FELogger.warn("导出XML失败 %s" % e) finally: xml.cleanup() ida_auto.set_ida_state(st)
def activate(self, ctx): # get active filename pe_filename_ext = ida_nalt.get_root_filename() if not pe_filename_ext: print('FakePDB/dumpinfo: file not loaded') return 1 #calculate locations idb_dir = os.path.dirname(ida_loader.get_path( ida_loader.PATH_TYPE_IDB)) filepath_json = os.path.join(idb_dir, pe_filename_ext + ".json") dumper = DumpInfo() print('FakePDB/dumpinfo:') ida_auto.set_ida_state(ida_auto.st_Work) dumper.dump_info(filepath_json) ida_auto.set_ida_state(ida_auto.st_Ready) print(' * done') return 1
name = { 'ea': ea, 'name': ida_name.get_nlist_name(i), 'is_public': ida_name.is_public_name(ea), 'is_func': ida_funcs.get_func(ea) is not None } names.append(name) return names def main(): filepath = ida_loader.get_path(ida_loader.PATH_TYPE_IDB) pre, ext = os.path.splitext(filepath) filepath = pre + ".exe.json" output = { 'segments': processSegments(), 'functions': processFunctions(), 'names': processNames() } with open(filepath, "w") as f: json.dump(output, f, indent=4) ida_auto.set_ida_state(IDA_STATUS_WORK) main() ida_auto.set_ida_state(IDA_STATUS_READY)