def destroy(self): self.destroying = True self.is_loaded = False self.hooks.unhook() window = idaapi.find_tform(self.title) if (window): idaapi.close_tform(window, 0)
def destroy(self): self.destroying = True self.is_loaded = False self.hooks.unhook() window = idaapi.find_tform(self.title) if(window): idaapi.close_tform(window, 0)
def __init__(self, funcname, affected, edges, ui_obj): #Lets make sure we dont open the same graph twice. (it can crash IDA ... ) AlreadyOpenGraph = idaapi.find_tform("call graph of 0x%08x" % funcname) if (AlreadyOpenGraph != None): idaapi.close_tform(AlreadyOpenGraph, 0) idaapi.GraphViewer.__init__(self, "call graph of 0x%08x" % funcname) self.funcname = funcname self.affected = affected self.edges = edges self.f_to_id = {} self.id_to_f = {} self.ui_obj = ui_obj
def __init__(self, funcname, blocks, edges, blockInfo, options): #Lets make sure we dont open the same graph twice. (it can crash IDA ... ) self.options = options AlreadyOpenGraph = idaapi.find_tform("basic block graph to " + funcname) if(AlreadyOpenGraph != None): idaapi.close_tform(AlreadyOpenGraph, 0) idaapi.GraphViewer.__init__(self, "basic block graph to " + funcname) self.funcname = funcname self.blocks = blocks self.blockInfo = blockInfo self.edges = edges self.block_to_id = {} self.id_to_block = {}
def __init__(self, funcname, blocks, edges, blockInfo, options): #Lets make sure we dont open the same graph twice. (it can crash IDA ... ) self.options = options AlreadyOpenGraph = idaapi.find_tform("basic block graph to " + funcname) if (AlreadyOpenGraph != None): idaapi.close_tform(AlreadyOpenGraph, 0) idaapi.GraphViewer.__init__(self, "basic block graph to " + funcname) self.funcname = funcname self.blocks = blocks self.blockInfo = blockInfo self.edges = edges self.block_to_id = {} self.id_to_block = {}
def __init__(self, funcname, affected, edges, ui_obj): #Lets make sure we dont open the same graph twice. (it can crash IDA ... ) AlreadyOpenGraph = idaapi.find_tform("call graph of 0x%08x" % funcname) if(AlreadyOpenGraph != None): idaapi.close_tform(AlreadyOpenGraph, 0) idaapi.GraphViewer.__init__(self, "call graph of 0x%08x" % funcname) self.funcname = funcname self.affected = affected self.edges = edges self.f_to_id = {} self.id_to_f = {} self.ui_obj = ui_obj
def close_hx_views(self): # NOTE: `self.close_pseudocode()` got called in this loop # `dict.values()` returns a temp list for ct in self.hx_views.values(): idaapi.close_tform(ct, 0)
def run_bap_with(argument_string, no_extras=False): """ Run bap with the given argument_string. Uses the currently open file, dumps latest symbols from IDA and runs BAP with the argument_string Also updates the 'BAP View' Note: If no_extras is set to True, then none of the extra work mentioned above is done, and instead, bap is just run purely using bap <executable> <argument_string> """ from bap.plugins.bap_view import BAP_View from bap.utils import config import ida import idc import tempfile check_and_configure_bap() bap_executable_path = config.get('bap_executable_path') if bap_executable_path is None: return # The user REALLY doesn't want us to run it args = { 'bap_executable_path': bap_executable_path, 'bap_output_file': tempfile.mkstemp(suffix='.out', prefix='ida-bap-')[1], 'input_file_path': idc.GetInputFilePath(), 'symbol_file_location': tempfile.mkstemp(suffix='.sym', prefix='ida-bap-')[1], 'header_path': tempfile.mkstemp(suffix='.h', prefix='ida-bap-')[1], 'remaining_args': argument_string } if no_extras: command = ( "\ \"{bap_executable_path}\" \"{input_file_path}\" \ {remaining_args} \ > \"{bap_output_file}\" 2>&1 \ ".format(**args) ) else: bap_api_enabled = (config.get('enabled', default='0', section='bap_api').lower() in ('1', 'true', 'yes')) ida.dump_symbol_info(args['symbol_file_location']) if bap_api_enabled: ida.dump_c_header(args['header_path']) idc.Exec( "\ \"{bap_executable_path}\" \ --api-add=c:\"{header_path}\" \ ".format(**args) ) command = ( "\ \"{bap_executable_path}\" \"{input_file_path}\" \ --read-symbols-from=\"{symbol_file_location}\" \ --symbolizer=file \ --rooter=file \ {remaining_args} \ -d > \"{bap_output_file}\" 2>&1 \ ".format(**args) ) idc.Exec(command) with open(args['bap_output_file'], 'r') as f: BAP_View.update( "BAP execution string\n" + "--------------------\n" + "\n" + '\n --'.join(command.strip().split('--')) + "\n" + "\n" + "Output\n" + "------\n" + "\n" + f.read() ) # Force close BAP View # This forces the user to re-open the new view if needed # This "hack" is needed since IDA decides to give a different BAP_View # class here, than the cls parameter it sends to BAP_View # TODO: Fix this import idaapi tf = idaapi.find_tform("BAP View") if tf: idaapi.close_tform(tf, 0) # Do a cleanup of all the temporary files generated/added if not no_extras: if bap_api_enabled: idc.Exec( "\ \"{bap_executable_path}\" \ --api-remove=c:`basename \"{header_path}\"` \ ".format(**args) ) idc.Exec( "\ rm -f \ \"{symbol_file_location}\" \ \"{header_path}\" \ \"{bap_output_file}\" \ ".format(**args) )
def run_bap_with(argument_string): """ Run bap with the given argument_string. Uses the currently open file, dumps latest symbols from IDA and runs BAP with the argument_string Also updates the 'BAP View' """ from bap.plugins.bap_view import BAP_View from bap.utils import config import ida import idc import tempfile check_and_configure_bap() bap_executable_path = config.get('bap_executable_path') if bap_executable_path is None: return # The user REALLY doesn't want us to run it args = { 'bap_executable_path': bap_executable_path, 'bap_output_file': tempfile.mkstemp(suffix='.out', prefix='ida-bap-')[1], 'input_file_path': idc.GetInputFilePath(), 'symbol_file_location': tempfile.mkstemp(suffix='.sym', prefix='ida-bap-')[1], 'header_path': tempfile.mkstemp(suffix='.h', prefix='ida-bap-')[1], 'remaining_args': argument_string } bap_api_enabled = (config.get('enabled', default='0', section='bap_api').lower() in ('1', 'true', 'yes')) ida.dump_symbol_info(args['symbol_file_location']) if bap_api_enabled: ida.dump_c_header(args['header_path']) idc.Exec("\ \"{bap_executable_path}\" \ --api-add=c:\"{header_path}\" \ ".format(**args)) command = ("\ \"{bap_executable_path}\" \"{input_file_path}\" \ --read-symbols-from=\"{symbol_file_location}\" --symbolizer=file \ {remaining_args} \ -d > \"{bap_output_file}\" 2>&1 \ ".format(**args)) idc.Exec(command) with open(args['bap_output_file'], 'r') as f: BAP_View.update("BAP execution string\n" + "--------------------\n" + "\n" + '\n --'.join(('bap' + argument_string).split('--')) + "\n" + "\n" + "Output\n" + "------\n" + "\n" + f.read()) # Force close BAP View # This forces the user to re-open the new view if needed # This "hack" is needed since IDA decides to give a different BAP_View # class here, than the cls parameter it sends to BAP_View # TODO: Fix this import idaapi tf = idaapi.find_tform("BAP View") if tf: idaapi.close_tform(tf, 0) # Do a cleanup of all the temporary files generated/added if bap_api_enabled: idc.Exec("\ \"{bap_executable_path}\" \ --api-remove=c:`basename \"{header_path}\"` \ ".format(**args)) idc.Exec("\ rm -f \ \"{symbol_file_location}\" \ \"{header_path}\" \ \"{bap_output_file}\" \ ".format(**args))