Esempio n. 1
0
def register_actions():
    action_desc = ida_kernwin.action_desc_t(
        'fakepdb_pdb_generation',  # The action name. This acts like an ID and must be unique
        'Generate .PDB file',  # The action text.
        __fakepdb_pdbgeneration_actionhandler(False),  # The action handler.
        'Ctrl+Shift+4',  # Optional: the action shortcut
        '',  # Optional: the action tooltip (available in menus/toolbar)
        0)  # Optional: the action icon (shows when in menus/toolbars)

    ida_kernwin.register_action(action_desc)
    ida_kernwin.attach_action_to_menu('Edit/FakePDB/',
                                      'fakepdb_pdb_generation',
                                      ida_kernwin.SETMENU_APP)

    action_desc = ida_kernwin.action_desc_t(
        'fakepdb_pdb_generation_labels',  # The action name. This acts like an ID and must be unique
        'Generate .PDB file (with function labels)',  # The action text.
        __fakepdb_pdbgeneration_actionhandler(True),  # The action handler.
        'Ctrl+Shift+5',  # Optional: the action shortcut
        '',  # Optional: the action tooltip (available in menus/toolbar)
        0)  # Optional: the action icon (shows when in menus/toolbars)

    ida_kernwin.register_action(action_desc)
    ida_kernwin.attach_action_to_menu('Edit/FakePDB/',
                                      'fakepdb_pdb_generation_labels',
                                      ida_kernwin.SETMENU_APP)
Esempio n. 2
0
 def init(self):
     export_action = ida_kernwin.action_desc_t('export-xref:export',
                                               'Export Xref...',
                                               export_handler_t())
     ida_kernwin.register_action(export_action)
     ida_kernwin.attach_action_to_menu('File/Produce file/',
                                       'export-xref:export',
                                       ida_kernwin.SETMENU_APP)
     print("[Export-Xref] Loaded")
     return ida_idaapi.PLUGIN_OK
Esempio n. 3
0
def register_actions():
    action_desc = ida_kernwin.action_desc_t(
        'fakepdb_dumpinfo',                 # The action name. This acts like an ID and must be unique
        'Dump info to .json',               # The action text.
        __fakepdb_dumpinfo_actionhandler(), # The action handler.
        'Ctrl+Shift+1',                     # Optional: the action shortcut
        '',                                 # Optional: the action tooltip (available in menus/toolbar)
        0)                                  # Optional: the action icon (shows when in menus/toolbars)

    ida_kernwin.register_action(action_desc)
    ida_kernwin.attach_action_to_menu('Edit/FakePDB/', 'fakepdb_dumpinfo', ida_kernwin.SETMENU_APP)
Esempio n. 4
0
 def register(self):
     r = ida_kernwin.register_action(self.get_desc())
     if not r:
         log('actions').warning("failed registering %s: %s", self, r)
         return
     ida_kernwin.attach_action_to_menu(self.get_action_path(),
                                       self.get_id(),
                                       ida_kernwin.SETMENU_APP)
     r = ida_kernwin.attach_action_to_toolbar("AnalysisToolBar",
                                              self.get_id())
     if not r:
         log('actions').warn("registration of %s failed: %s", self, r)
Esempio n. 5
0
    def _install_load_trace(self):

        # TODO: create a custom IDA icon
        #icon_path = plugin_resource(os.path.join("icons", "load.png"))
        #icon_data = open(icon_path, "rb").read()
        #self._icon_id_file = ida_kernwin.load_custom_icon(data=icon_data)

        # describe a custom IDA UI action
        action_desc = ida_kernwin.action_desc_t(
            self.ACTION_LOAD_TRACE,  # The action name
            "~T~enet trace file...",  # The action text
            IDACtxEntry(self._interactive_load_trace),  # The action handler
            None,  # Optional: action shortcut
            "Load a Tenet trace file",  # Optional: tooltip
            -1  # Optional: the action icon
        )

        # register the action with IDA
        result = ida_kernwin.register_action(action_desc)
        assert result, f"Failed to register '{action_desc.name}' action with IDA"

        # attach the action to the File-> dropdown menu
        result = ida_kernwin.attach_action_to_menu(
            "File/Load file/",  # Relative path of where to add the action
            self.ACTION_LOAD_TRACE,  # The action ID (see above)
            ida_kernwin.SETMENU_APP  # We want to append the action after ^
        )
        assert result, f"Failed action attach {action_desc.name}"

        logger.info(f"Installed the '{action_desc.name}' menu entry")
    def install(self):
        """
        Install the action into the IDA UI.

        :return: did the install succeed
        """
        # Read and load the icon file
        iconData = str(open(self._icon, 'rb').read())
        self._iconId = ida_kernwin.load_custom_icon(data=iconData)

        # Create the action description
        actionDesc = ida_kernwin.action_desc_t(self._ACTION_ID, self._text,
                                               self._handler, None,
                                               self._tooltip, self._iconId)

        # Register the action using its description
        result = ida_kernwin.register_action(actionDesc)
        if not result:
            raise RuntimeError("Failed to register action")

        # Attach the action to the chosen menu
        result = ida_kernwin.attach_action_to_menu(self._menu, self._ACTION_ID,
                                                   ida_kernwin.SETMENU_APP)
        if not result:
            raise RuntimeError("Failed to attach action")

        logger.debug("Installed the action")
        return True
Esempio n. 7
0
def add_action(action):
    """
    Add an ida-action
    :param action: action given as the `Action` namedtuple
    :return: None
    """
    class Handler(ida_kernwin.action_handler_t):
        def __init__(self):
            ida_kernwin.action_handler_t.__init__(self)

        def activate(self, ctx):
            action.handler()
            return 1

        def update(self, ctx):
            return ida_kernwin.AST_ENABLE_FOR_WIDGET

    act_icon = -1
    if action.icon_filename:
        icon_full_filename = \
            pkg_resources.resource_filename('fa',
                                            os.path.join(
                                                'res',
                                                'icons',
                                                action.icon_filename))
        with open(icon_full_filename, 'rb') as f:
            icon_data = f.read()
        act_icon = ida_kernwin.load_custom_icon(data=icon_data, format="png")

    act_name = action.name

    ida_kernwin.unregister_action(act_name)
    if ida_kernwin.register_action(ida_kernwin.action_desc_t(
            act_name,  # Name. Acts as an ID. Must be unique.
            action.label,  # Label. That's what users see.
            Handler(),  # Handler. Called when activated, and for updating
            action.hotkey,  # Shortcut (optional)
            None,  # Tooltip (optional)
            act_icon)):  # Icon ID (optional)

        # Insert the action in the menu
        if not ida_kernwin.attach_action_to_menu(
                "FA/", act_name, ida_kernwin.SETMENU_APP):
            print("Failed attaching to menu.")

        # Insert the action in a toolbar
        if not ida_kernwin.attach_action_to_toolbar("fa", act_name):
            print("Failed attaching to toolbar.")

        class Hooks(ida_kernwin.UI_Hooks):
            def finish_populating_widget_popup(self, widget, popup):
                if ida_kernwin.get_widget_type(widget) == \
                        ida_kernwin.BWN_DISASM:
                    ida_kernwin.attach_action_to_popup(widget,
                                                       popup,
                                                       act_name,
                                                       None)

        hooks = Hooks()
        hooks.hook()
Esempio n. 8
0
    def install(self):
        action_name = self.__class__.__name__

        # Read and load the icon file
        icon_data = str(open(self._icon, "rb").read())
        self._icon_id = ida_kernwin.load_custom_icon(data=icon_data)

        # Create the action descriptor
        action_desc = ida_kernwin.action_desc_t(
            self._ACTION_ID,
            self._text,
            self._handler,
            None,
            self._tooltip,
            self._icon_id,
        )

        # Register the action using its descriptor
        result = ida_kernwin.register_action(action_desc)
        if not result:
            raise RuntimeError("Failed to register action %s" % action_name)

        # Attach the action to the chosen menu
        result = ida_kernwin.attach_action_to_menu(
            self._menu, self._ACTION_ID, ida_kernwin.SETMENU_APP
        )
        if not result:
            action_name = self.__class__.__name__
            raise RuntimeError("Failed to install action %s" % action_name)

        self._plugin.logger.debug("Installed action %s" % action_name)
        return True
Esempio n. 9
0
    def editor_menuaction(self):
        action_desc = ida_kernwin.action_desc_t(
            'my:editoraction',  # The action name. This acts like an ID and must be unique
            'Python Editor!',  # The action text.
            MyEditorHandler(),  # The action handler.
            'Ctrl+H',  # Optional: the action shortcut DO IT  HERE!
            'Script editor',  # Optional: the action tooltip (available in menus/toolbar)
            ida_kernwin.load_custom_icon(":/ico/python.png")  # hackish load action icon , if no custom icon use number from 1-150 from internal ida
        )

        # 3) Register the action
        ida_kernwin.register_action(action_desc)

        ida_kernwin.attach_action_to_menu(
            'Edit/Editor...',  # The relative path of where to add the action
            'my:editoraction',  # The action ID (see above)
            ida_kernwin.SETMENU_APP)  # We want to append the action after the 'Manual instruction...

        ida_kernwin.get_current_widget()
        ida_kernwin.attach_action_to_popup(form, None, "my:editoraction", None)
Esempio n. 10
0
def register_open_action():
    """
    Provide the action that will create the widget
    when the user asks for it.
    """
    class create_widget_t(ida_kernwin.action_handler_t):
        def activate(self, ctx):
            if ida_kernwin.find_widget(title) is None:
                global auto_inst
                auto_inst = auto_inst_t()
                assert (auto_inst.Create())
                assert (auto_inst.Show())

        def update(self, ctx):
            return ida_kernwin.AST_ENABLE_ALWAYS

    action_name = "autoinst:create"
    ida_kernwin.register_action(
        ida_kernwin.action_desc_t(action_name, title, create_widget_t()))
    ida_kernwin.attach_action_to_menu("View/Open subviews/Strings",
                                      action_name, ida_kernwin.SETMENU_APP)
Esempio n. 11
0
def init_hooks(idausr):
    _setter = IdausrTemporarySetter(idausr)

    class ActionHandler(ida_kernwin.action_handler_t):
        def __init__(self, handler):
            ida_kernwin.action_handler_t.__init__(self)
            self.handler = handler

        def activate(self, ctx):
            with _setter:
                self.handler()

        def update(self, ctx):
            return ida_kernwin.AST_ENABLE_ALWAYS

    for name, label, handler, before in _HOOKS:
        if ida_kernwin.unregister_action(name):
            action = ida_kernwin.action_desc_t(name, label,
                                               ActionHandler(handler))
            ida_kernwin.register_action(action)
            ida_kernwin.attach_action_to_menu(before, name,
                                              ida_kernwin.SETMENU_INS)
Esempio n. 12
0
    def _init_actions(self):
        action = ida_kernwin.action_desc_t(self.act_static,
                                           'static analyzer: main menu',
                                           FEStaticAnalyzer(), 'Ctrl+Shift+s',
                                           '静态分析器主菜单', 0)
        ida_kernwin.register_action(action)
        ida_kernwin.attach_action_to_menu(MENU_PATH, self.act_static,
                                          ida_kernwin.SETMENU_APP)

        action = ida_kernwin.action_desc_t(
            self.act_dbg_hook, 'dynamic analyzer: enable/disable debug hook',
            FEDynamicAnalyzer(), 'Ctrl+Shift+d', '启用/解除DEBUG Hook', 0)
        ida_kernwin.register_action(action)
        ida_kernwin.attach_action_to_menu(MENU_PATH, self.act_dbg_hook,
                                          ida_kernwin.SETMENU_APP)

        action = ida_kernwin.action_desc_t(self.act_pattern,
                                           'code pattern: find code pattern',
                                           FECodePattern(), 'Ctrl+Shift+c',
                                           '代码模式扫描', 0)
        ida_kernwin.register_action(action)
        ida_kernwin.attach_action_to_menu(MENU_PATH, self.act_pattern,
                                          ida_kernwin.SETMENU_APP)

        action = ida_kernwin.action_desc_t(self.act_test,
                                           'reverse assist tools',
                                           FEReAssist(), 'Ctrl+Shift+x',
                                           '逆向辅助工具', 0)
        ida_kernwin.register_action(action)
        ida_kernwin.attach_action_to_menu(MENU_PATH, self.act_assist,
                                          ida_kernwin.SETMENU_APP)

        action = ida_kernwin.action_desc_t(self.act_test, 'functional test',
                                           FEFuncTest(), 'Ctrl+Shift+q',
                                           '功能性测试', 0)
        ida_kernwin.register_action(action)
        ida_kernwin.attach_action_to_menu(MENU_PATH, self.act_test,
                                          ida_kernwin.SETMENU_APP)
Esempio n. 13
0
 def registerAction(self):
     action_desc = ida_kernwin.action_desc_t(
         self.id,
         self.name,
         self,
         self.shortcut,
         self.tooltip,
         0
     )
     if not ida_kernwin.register_action(action_desc):
         return False
     if not ida_kernwin.attach_action_to_menu(self.menuPath, self.id, 0):
         return False
     return True
Esempio n. 14
0
	def init(self):
		import_action = ida_kernwin.action_desc_t(
			'idasync:import',
			'IDA-Sync JSON file...',
			ImportHandler())
		export_action = ida_kernwin.action_desc_t(
			'idasync:export',
			'Create IDA-Sync JSON file...',
			ExportHandler())
		ida_kernwin.register_action(import_action)
		ida_kernwin.register_action(export_action)
		ida_kernwin.attach_action_to_menu(
			'File/Load file/Parse C header file...',
			'idasync:import',
			ida_kernwin.SETMENU_APP
		)
		ida_kernwin.attach_action_to_menu(
			'File/Produce file/Create C header file...',
			'idasync:export',
			ida_kernwin.SETMENU_APP
		)
		print("[IDA-Sync] Loaded")
		return ida_idaapi.PLUGIN_OK
    def init(self):
        self.logger = init_logger('bit_tester_plugin_t')
        # Create the plugin action
        if hasattr(sys.modules['idaapi'], '_ks_bit_tester_installed'):
            return
        action_desc = idaapi.action_desc_t(ACTION_NAME, PLUGIN_DISPLAY_NAME,
                                           ENUM_HANDLER, PLUGIN_SHORTCUT,
                                           PLUGIN_COMMENT)

        if not idaapi.register_action(action_desc):
            raise Exception(f"Failed to register action.")

        # Register in the context menu
        if not ida_kernwin.attach_action_to_menu(PLUGIN_MENU_PATH, ACTION_NAME,
                                                 idaapi.SETMENU_APP):
            raise Exception(f"Failed to attach action to menu.")
        setattr(sys.modules['idaapi'], '_ks_bit_tester_installed', True)
        return idaapi.PLUGIN_OK
Esempio n. 16
0
    def install(self):
        action_descriptor = ida_kernwin.action_desc_t(
            self._action_name,
            self._text,
            self._handler,
            None,
            self._tooltip,
            -1,  # This is for icon, maybe later we'll have one
        )

        # Register the action in the ida kernel
        if not ida_kernwin.register_action(action_descriptor):
            raise RuntimeError('Failed to register the save to server action')

        # Attach the action to the wanted menu
        if not ida_kernwin.attach_action_to_menu(self._menu, self._action_name, ida_kernwin.SETMENU_APP):
            raise RuntimeError('Failed to intall the save to menu action')

        return True
Esempio n. 17
0
    def attach_to_menu(self, path, flags=idaapi.SETMENU_APP):
        """
            Attach this :class:`BipAction` as an element in the menu. The
            name of the action will be the one defined as the ``label`` of the
            constructor.

            This will be called automatically when the :class:`BipAction`
            is :meth:`~BipAction.register` if the path is provided in argument
            of the constructor as ``path_menu``. If the ``path_menu`` is not
            provided in the constructor this can be done by calling this
            function but the :meth:`~BipAction.register` must first be called.

            Attaching into the ``Edit/Plugins/`` menu when IDA is loading may
            create problem as this menu seems to be remade later and the entry
            may be overwritten (this seems to depend of IDA version and how
            early this method is called).

            :return: ``True`` if the action succeded, ``False`` otherwise.
        """
        # by default, add menu item after the specified path (can also be SETMENU_INS)
        return ida_kernwin.attach_action_to_menu(path, self._name, flags)
Esempio n. 18
0
    def OnClose(self, parent_form):
        return

    def Show(self):
        return ida_kernwin.PluginForm.Show(self, "Tag Manager")


class open_tag_manager_action_t(ida_kernwin.action_handler_t):
    def __init__(self):
        self._tag_manager_interface = TagManagerInterface()

    def activate(self, ctx):
        self._tag_manager_interface.Show()

    def update(self, ctx):
        return ida_kernwin.AST_ENABLE_FOR_WIDGET


ida_kernwin.register_action(
    ida_kernwin.action_desc_t(
        ACTION_NAME,
        "Open the tag manager",
        open_tag_manager_action_t(),
        "Ctrl+Y"))

if not ida_kernwin.attach_action_to_menu("View", ACTION_NAME, ida_kernwin.SETMENU_APP):
    print("IDA Function Tagger: Failed to update the menus")

print("IDA Function Tagger has been loaded; to open it, either use the 'View' menu or press CTRL+Y")
Esempio n. 19
0
hooks = None
act_name = "example:add_action"

if ida_kernwin.register_action(
        ida_kernwin.action_desc_t(
            act_name,  # Name. Acts as an ID. Must be unique.
            "Say hi!",  # Label. That's what users see.
            SayHi("developer"
                  ),  # Handler. Called when activated, and for updating
            "Ctrl+F12",  # Shortcut (optional)
            "Greets the user",  # Tooltip (optional)
            act_icon)):  # Icon ID (optional)
    print("Action registered. Attaching to menu.")

    # Insert the action in the menu
    if ida_kernwin.attach_action_to_menu("Edit/Export data", act_name,
                                         ida_kernwin.SETMENU_APP):
        print("Attached to menu.")
    else:
        print("Failed attaching to menu.")

    # Insert the action in a toolbar
    if ida_kernwin.attach_action_to_toolbar("AnalysisToolBar", act_name):
        print("Attached to toolbar.")
    else:
        print("Failed attaching to toolbar.")

    # We will also want our action to be available in the context menu
    # for the "IDA View-A" widget.
    #
    # To do that, we could in theory retrieve a reference to "IDA View-A", and
    # then request to "permanently" attach the action to it, using something
Esempio n. 20
0
        print(self.greetings)

    def update(self, ctx):
        return ida_kernwin.AST_ENABLE_ALWAYS


ACTION_NAME_0 = "my_action_0"
ACTION_NAME_1 = "my_action_1"
for action_name, greetings in [
    (ACTION_NAME_0, "Hello, world"),
    (ACTION_NAME_1, "Hi there"),
]:
    desc = ida_kernwin.action_desc_t(action_name, "Say \"%s\"" % greetings,
                                     greeter_t(greetings))
    if ida_kernwin.register_action(desc):
        print("Registered action \"%s\"" % action_name)

# Then, let's attach some actions to them - both core actions
# and custom ones is allowed (also, any action can be attached
# to multiple menus.)
for action_name, path in [
    (ACTION_NAME_0, "Custom menu"),
    (ACTION_NAME_0, "View/Custom submenu/"),
    (ACTION_NAME_1, "Custom menu"),
    (ACTION_NAME_1, "View/Custom submenu/"),
    ("About", "Custom menu"),
    ("About", "View/Custom submenu/"),
]:
    ida_kernwin.attach_action_to_menu(path, action_name,
                                      ida_kernwin.SETMENU_INS)