Python idaapi.msg() Examples

The following are 30 code examples of idaapi.msg(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module idaapi , or try the search function .
Example #1
Source File: plugin_loader_bap.py    From bap-ida-python with MIT License 6 votes vote down vote up
def init(self):
        """Read directory and load as many plugins as possible."""
        self.plugins = []

        idaapi.msg("BAP Loader activated\n")

        bap.utils.run.check_and_configure_bap()

        plugin_path = os.path.dirname(bap.plugins.__file__)
        idaapi.msg("BAP> Loading plugins from {}\n".format(plugin_path))

        for plugin in sorted(os.listdir(plugin_path)):
            path = os.path.join(plugin_path, plugin)
            if not plugin.endswith('.py') or plugin.startswith('__'):
                continue  # Skip non-plugins
            idaapi.msg('BAP> Loading {}\n'.format(plugin))
            self.plugins.append(idaapi.load_plugin(path))
        return idaapi.PLUGIN_KEEP 
Example #2
Source File: FunctionViewEx.py    From DIE with MIT License 6 votes vote down vote up
def on_show_callgraph(self, function_context):

        if not isinstance(function_context, DIE.Lib.DIEDb.dbFunction_Context):
            if function_context is not None:
                raise ValueError("Wrong value sent to 'on_show_callgraph': %s. excpected dbFunction_Context" % function_context.__class__)
            else:
                raise ValueError("Wrong value sent to 'on_show_callgraph'")

        graph = nx.DiGraph()

        call_graph = self.die_db.get_call_graph_to(function_context)
        if not call_graph:
            idaapi.msg("No Execution Graph")
            return

        for ctxt_node in call_graph:
            (from_address, to_address) = ctxt_node
            graph.add_edge(from_address, to_address)

        function_name = self.die_db.get_function_name(function_context.function)
        viewer = sark.ui.NXGraph(graph, "Callgraph for {}".format(function_name), handler=sark.ui.AddressNodeHandler())
        viewer.Show()

        return 
Example #3
Source File: FunctionViewEx.py    From DIE with MIT License 6 votes vote down vote up
def clear_highlights(self):
        """
        Clear all highlighted items
        @return:
        """
        try:
            self.functionTreeView.collapseAll()

            for persistent_index in self.highligthed_items:
                if persistent_index.isValid():
                    item = self.functionModel.itemFromIndex(persistent_index)
                    item.setBackground(QtCore.Qt.white)
                    cur_font = item.font()
                    cur_font.setBold(False)
                    item.setFont(cur_font)

            self.highligthed_items = []

        except Exception as ex:
            idaapi.msg("Error while clearing highlights: %s\n" % ex)


###############################################################################################
#  Find Items. 
Example #4
Source File: DIE.py    From DIE with MIT License 6 votes vote down vote up
def load_db(self):
        try:
            db_file = idc.AskFile(0, "*.ddb", "Load DIE Db File")
            if db_file is not None:
                self.die_db.load_db(db_file)

            if self.die_db is not None:
                self.show_db_details()

        except DbFileMismatch as mismatch:
            idaapi.msg("Error while loading DIE DB: %s\n" % mismatch)

        except Exception as ex:
            logging.exception("Error while loading DB: %s", ex)
            return False


    ###########################################################################
    # Function View 
Example #5
Source File: DIE.py    From DIE with MIT License 6 votes vote down vote up
def show_db_details(self):
        """
        Print DB details
        """
        (start_time,
         end_time,
         filename,
         num_of_functions,
         num_of_threads,
         numof_parsed_val) = self.die_db.get_run_info()

        idaapi.msg("Die DB Loaded.\n")
        idaapi.msg("Start Time: %s, End Time %s\n" % (ctime(start_time), ctime(end_time)))
        idaapi.msg("Functions: %d, Threads: %d\n" % (num_of_functions, num_of_threads))
        idaapi.msg("Parsed Values: %d\n" % numof_parsed_val)

    ###########################################################################
    # Mark\Unmark Execution Flow 
Example #6
Source File: ValueViewEx.py    From DIE with MIT License 6 votes vote down vote up
def itemDoubleClickSlot(self, index):
        """
        TreeView DoubleClicked Slot.
        @param index: QModelIndex object of the clicked tree index item.
        @return:
        """

        func_context_list = index.data(role=DIE.UI.ContextList_Role)
        try:
            if self.function_view is None:
                self.function_view = DIE.UI.FunctionViewEx.get_view()

            if func_context_list is not None and len(func_context_list) > 0:
                if not self.function_view.isVisible():
                    self.function_view.Show()

                self.function_view.find_context_list(func_context_list)

        except Exception as ex:
            idaapi.msg("Error while loading function view: %s\n" % ex) 
Example #7
Source File: DIE.py    From DIE with MIT License 6 votes vote down vote up
def show_cfg(self):
        """
        Show execution Call flow graph
        """
        cfg = self.die_db.get_call_graph_complete()
        graph = nx.DiGraph()

        if not cfg:
            idaapi.msg("No CFG to display")
            return

        for ctxt_node in cfg:
            (from_address, to_address) = ctxt_node
            graph.add_edge(from_address, to_address)

        viewer = sark.ui.NXGraph(graph, "Callgraph for {}".format("Exection CFG"), handler=sark.ui.AddressNodeHandler())
        viewer.Show() 
Example #8
Source File: ValueViewEx.py    From DIE with MIT License 6 votes vote down vote up
def clear_highlights(self):
        """
        Clear all highlighted items
        @return:
        """
        try:
            self.valueTreeView.collapseAll()

            for persistent_index in self.highligthed_items:
                if persistent_index.isValid():
                    item = self.valueModel.itemFromIndex(persistent_index)
                    item.setBackground(QtCore.Qt.white)
                    cur_font = item.font()
                    cur_font.setBold(False)
                    item.setFont(cur_font)

            self.highligthed_items = []

        except Exception as ex:
            idaapi.msg("Error while clearing highlights: %s\n" % ex)

###############################################################################################
#  Find Items
#
############################################################################################### 
Example #9
Source File: DebugAPI.py    From DIE with MIT License 6 votes vote down vote up
def profile_stop(self):
        """
        Stop profiling the application and display results.
        @return:
        """
        # If profiling is activated:
        if self.pr is None:
            return False

        self.pr.disable()
        s = StringIO.StringIO()
        sortby = 'tottime'
        ps = pstats.Stats(self.pr, stream=s).sort_stats(sortby)
        ps.print_stats()

        idaapi.msg("%s\n" % (s.getvalue(), )) 
Example #10
Source File: ida_prefix.py    From prefix with MIT License 6 votes vote down vote up
def term(self):
        """
        This is called by IDA when it is unloading the plugin.
        """

        # unhook our plugin hooks
        self._hooks.unhook()

        # unregister our actions & free their resources
        self._del_action_bulk()
        self._del_action_clear()
        self._del_action_recursive()

        # done
        idaapi.msg("%s terminated...\n" % self.wanted_name)

    #--------------------------------------------------------------------------
    # Plugin Hooks
    #-------------------------------------------------------------------------- 
Example #11
Source File: ida_prefix.py    From prefix with MIT License 6 votes vote down vote up
def init(self):
        """
        This is called by IDA when it is loading the plugin.
        """

        # initialize the menu actions our plugin will inject
        self._init_action_bulk()
        self._init_action_clear()
        self._init_action_recursive()

        # initialize plugin hooks
        self._init_hooks()

        # done
        idaapi.msg("%s %s initialized...\n" % (self.wanted_name, VERSION))
        return idaapi.PLUGIN_KEEP 
Example #12
Source File: meaningful.py    From Sark with MIT License 6 votes vote down vote up
def show_highlighted_function_meaningful():
    line = sark.Line()
    meaningful_displayed = False
    for xref in line.xrefs_from:
        try:
            if xref.type.is_flow:
                continue

            function = sark.Function(xref.to)
            show_meaningful_in_function(function)
            meaningful_displayed = True

        except sark.exceptions.SarkNoFunction:
            pass

    if not meaningful_displayed:
        idaapi.msg("[FunctionStrings] No function referenced by current line: 0x{:08X}.\n".format(idc.here())) 
Example #13
Source File: find_functions.py    From Malware_Scripts with MIT License 6 votes vote down vote up
def activate(self, ctx):
		ea = ScreenEA()
		str_id = idaapi.get_highlighted_identifier()
		if str_id[-1] == 'h':
			addr = int(str_id[:-1], 16)
		elif str_id[-1] == 'o':
			addr = int(str_id[:-1], 8)
		elif str_id[-1] == 'b':
			addr = int(str_id[:-1], 2)
		else:
			addr = int(str_id)
		temp = self.find_nearest_function(addr)
		if temp != None:
			n = GetFunctionName(ea)
			n_addr = int(n[4:],16)
			idaapi.msg(temp)
			idc.MakeName(n_addr, temp) 
Example #14
Source File: ida2pwntools.py    From ida2pwntools with Apache License 2.0 6 votes vote down vote up
def prepare_debug_ui(self):
		if idaapi.is_debugger_on():
			idaapi.warning("[%s] the debugger is currently running" % PLUGNAME)
			return

		wd = WaitDialog()
		idaapi.msg("[%s] waiting...\n" % (PLUGNAME))
		wd.thread.start()
		wd.exec_()

		target_pid = wd.get_target_pid()
		if target_pid != -1:
			ida_dbg.attach_process(target_pid,-1)
			ida_dbg.wait_for_next_event(ida_dbg.WFNE_SUSP, -1)
			ida_dbg.continue_process()
		else:
			idaapi.msg("[%s] exit waiting\n" % (PLUGNAME)) 
Example #15
Source File: apply_callee_type_plugin.py    From flare-ida with Apache License 2.0 5 votes vote down vote up
def run(self, arg):
        #idaapi.msg('apply_callee_type_plugin:run\n')
        flare.apply_callee_type.main() 
Example #16
Source File: struct_typer_plugin.py    From flare-ida with Apache License 2.0 5 votes vote down vote up
def term(self):
        #idaapi.msg("StructTyper term() called!\n")
        pass 
Example #17
Source File: apply_callee_type_plugin.py    From flare-ida with Apache License 2.0 5 votes vote down vote up
def PLUGIN_ENTRY():
    try:
        return apply_callee_type_plugin_t()
    except Exception as err:
        import traceback
        msg("Error: %s\n%s" % (str(err), traceback.format_exc()))
        raise 
Example #18
Source File: apply_callee_type_plugin.py    From flare-ida with Apache License 2.0 5 votes vote down vote up
def init(self):
        idaapi.msg('apply_callee_type_plugin:init\n')

        installMenu()
        return idaapi.PLUGIN_OK 
Example #19
Source File: apply_callee_type_plugin.py    From flare-ida with Apache License 2.0 5 votes vote down vote up
def doApplyCallee(*args):
    #idaapi.msg('doApplyCallee:Calling now\n')
    flare.apply_callee_type.main() 
Example #20
Source File: stackstrings_plugin.py    From flare-ida with Apache License 2.0 5 votes vote down vote up
def run(self, arg):
        try:
            idaapi.msg("StackStrings run() called with %d!\n" % arg)
            if is_py2:
                flare.stackstrings.main()
                idaapi.msg("StackStrings run() done")
            else:
                idaapi.msg("WARNING: stackstrings only works under python2 due to vivisect dependency\n")
        except Exception as err:
            idaapi.msg("Exception during run: %s\n" % str(err))
            raise
            
        idaapi.msg("StackStrings run() complete!\n") 
Example #21
Source File: stackstrings_plugin.py    From flare-ida with Apache License 2.0 5 votes vote down vote up
def term(self):
        idaapi.msg("StackStrings term() called!\n") 
Example #22
Source File: Python_editor.py    From Python_editor with The Unlicense 5 votes vote down vote up
def term(self):
        idaapi.msg("") 
Example #23
Source File: Python_editor.py    From Python_editor with The Unlicense 5 votes vote down vote up
def term(self):
        idaapi.msg("") 
Example #24
Source File: Python_editor.py    From Python_editor with The Unlicense 5 votes vote down vote up
def run(self, arg):
        idaapi.msg("run() called with %d!\n" % arg) 
Example #25
Source File: Python_editor.py    From Python_editor with The Unlicense 5 votes vote down vote up
def init(self):
        idaapi.msg("Python Editor Is Found Use Alt+E to load to menu \n")
        return idaapi.PLUGIN_OK 
Example #26
Source File: ida_prefix.py    From prefix with MIT License 5 votes vote down vote up
def recursive_prefix(addr):
    """
    Recursively prefix a function tree with a user defined string.
    """
    func_addr = idaapi.get_name_ea(idaapi.BADADDR, idaapi.get_func_name(addr))
    if func_addr == idaapi.BADADDR:
        idaapi.msg("Prefix: 0x%08X does not belong to a defined function\n" % addr)
        return

    # prompt the user for a prefix to apply to the selected functions
    tag = idaapi.ask_str(PREFIX_DEFAULT, 0, "Function Tag")

    # the user closed the window... ignore
    if tag == None:
        return

    # the user put a blank string and hit 'okay'... notify & ignore
    elif tag == '':
        idaapi.warning("[ERROR] Tag cannot be empty [ERROR]")
        return

    # recursively collect all the functions called by this function
    nodes_xref_down = graph_down(func_addr, path=set([]))

    # graph_down returns the int address needs to be converted
    tmp  = []
    tmp1 = ''
    for func_addr in nodes_xref_down:
        tmp1 = idaapi.get_func_name(func_addr)
        if tmp1:
            tmp.append(tmp1)
    nodes_xref_down = tmp

    # prefix the tree of functions
    for rename in nodes_xref_down:
        func_addr = idaapi.get_name_ea(idaapi.BADADDR, rename)
        if tag not in rename:
            idaapi.set_name(func_addr,'%s%s%s' % (str(tag), PREFIX_SEPARATOR, rename), idaapi.SN_NOWARN)

    # refresh the IDA views
    refresh_views() 
Example #27
Source File: ida_prefix.py    From prefix with MIT License 5 votes vote down vote up
def run(self, arg):
        """
        This is called by IDA when this file is loaded as a script.
        """
        idaapi.msg("%s cannot be run as a script.\n" % self.wanted_name) 
Example #28
Source File: plugin_loader.py    From Sark with MIT License 5 votes vote down vote up
def message(*messages):
    for msg in messages:
        for line in msg.splitlines():
            idaapi.msg("[PluginLoader] {}\n".format(line)) 
Example #29
Source File: quick_copy.py    From Sark with MIT License 5 votes vote down vote up
def message(*messages):
    for msg in messages:
        for line in msg.splitlines():
            idaapi.msg("[QuickCopy] {}\n".format(line)) 
Example #30
Source File: function_flow.py    From Sark with MIT License 5 votes vote down vote up
def _activate(self, ctx):
        clear_func(ctx.cur_ea)
        mark_exit_nodes(ctx.cur_ea)

        idaapi.msg("\n" * 2)

        for block in iter_exit_nodes(ctx.cur_ea):
            idaapi.msg("Exit at 0x{:08X}\n".format(block.start_ea))