我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用idaapi.get_input_file_path()。
def save_results(lists_of_instr, list_of_func_names): one_file = "userdlls_instr_to_instrument.txt" analyzed_file = idc.GetInputFile() analyzed_file = analyzed_file.replace(".","_") current_time = strftime("%Y-%m-%d_%H-%M-%S") file_name = WINHE_RESULTS_DIR + "\\" + one_file file_log = WINHE_RESULTS_DIR + "\\" + analyzed_file + "_" + current_time + ".txt" file = open(file_name, 'a') log = open(file_log, 'w') analyzed_file = analyzed_file.lower() list_of_instr = get_unique(lists_of_instr) list_of_func_names = get_unique_names(list_of_func_names) for instr in list_of_instr: file.write(idaapi.get_input_file_path().lower() + "!" + str(instr) + "\n") log.write(str(len(list_of_func_names)) + "\n") for name in list_of_func_names: log.write(name + "\n") print name file.close() log.close()
def save_results(lists_of_instr, list_of_func_names): ''' The function saves results in a file @list_of_instr - a list of instructions to save_results @list_of_func_name - a list of functions names to save ''' one_file = "sysdlls_instr_to_instrument.txt" analyzed_file = idc.GetInputFile() analyzed_file = analyzed_file.replace(".","_") current_time = strftime("%Y-%m-%d_%H-%M-%S") file_name = WINHE_RESULTS_DIR + "\\" + one_file file_log = WINHE_RESULTS_DIR + "\\" + analyzed_file + "_" + current_time + ".txt" file = open(file_name, 'a') log = open(file_log, 'w') analyzed_file = analyzed_file.lower() list_of_instr = get_unique(lists_of_instr) for instr in list_of_instr: file.write(idaapi.get_input_file_path().lower() + "!" + str(instr) + "\n") log.write(str(len(list_of_func_names)) + "\n") for name in list_of_func_names: log.write(name + "\n") file.close() log.close()
def dump_data(): """Extracts and dumps useful data from the file being processed. The output is written using pickle and it consists of a set with all the code heads followed by func.Function objects (ended with a None).""" def __dump(out, type, lb=0, ub=0): if type == 'code_head': cPickle.dump(get_code_heads(), out, cPickle.HIGHEST_PROTOCOL) for f in functions_iter(): cPickle.dump(f, out, cPickle.HIGHEST_PROTOCOL) if type == 'code_blk': for bc in _get_blocks_codes_per_func_iter(): cPickle.dump(bc, out, cPickle.HIGHEST_PROTOCOL) cPickle.dump(None, out) out.close() __dump(util.open_dump(idaapi.get_input_file_path(), 'wb', 'dmp'), 'code_head') __dump(util.open_dump(idaapi.get_input_file_path(), 'wb', 'code_blk'), 'code_blk')
def __init__(self): self.broker = Broker() self.trace_id = 0 self.traces = {} self.configuration = configuration() self.solvers = [] self.analyses = [] self.nb_cpus = 1 self.binsec_connected = False self.pinsec_connected = False self.seg_mapping = None self.fun_mapping = None self.update_mapping() self.nb_instr = self.compute_nb_instr() self.ftype = "ELF" if open(idaapi.get_input_file_path()).read(2) == ELF else "PE" self.imports = self.compute_imports()
def save_symbols(): """ Gather symbols and write to .map using expected naming convention. """ input_file_path = idaapi.get_input_file_path() if not os.path.exists(input_file_path): print "ClemSym: warning: {} does not exist.".format(input_file_path) output_path = input_file_path + '.map' new_data = get_symbol_map() if os.path.exists(output_path): with open(output_path, 'rb') as orig_fd: orig_data = orig_fd.read() if orig_data == new_data: print "ClemSym: symbol map on disk is already up to date" return # Always backup as we *really* don't want to kill someone's # hand-made symbol map! bak_ctr = 0 while os.path.exists(output_path + '.bak' + str(bak_ctr)): bak_ctr += 1 os.rename(output_path, output_path + '.bak' + str(bak_ctr)) print "ClemSym: writing symbols to", output_path with open(output_path, 'wb') as output_fd: output_fd.write(new_data)
def get_input_file_path(): """Return the name of the currently processed file.""" return idaapi.get_input_file_path()
def GetInputFilePath(): """ Get input file path This function returns the full path of the file being disassembled """ return idaapi.get_input_file_path()