Пример #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)
Пример #2
0
    def init(self):
        self.xray_hooks = None
        if not is_compatible():
            kw.msg("%s: decompiler not available, skipping." % PLUGIN_NAME)
            return ida_idaapi.PLUGIN_SKIP

        load_cfg()

        kw.register_action(
            kw.action_desc_t(
                XRAY_LOADCFG_ACTION_ID,
                "%s: reload config" % PLUGIN_NAME,
                loadcfg_action_handler_t(),
                "Ctrl-R"))

        kw.register_action(
            kw.action_desc_t(
                XRAY_FILTER_ACTION_ID,
                "%s: toggle" % PLUGIN_NAME,
                xray_action_handler_t(),
                "F3"))

        kw.register_action(
            kw.action_desc_t(
                XRAY_QUERY_ACTION_ID,
                "%s: search" % PLUGIN_NAME,
                regexfilter_action_handler_t(),
                "Ctrl-F"))

        self.xray_hooks = xray_hooks_t()
        self.xray_hooks.hook()
        return ida_idaapi.PLUGIN_KEEP
Пример #3
0
 def init(self):
     # Register actions
     ida_kernwin.register_action(
         ida_kernwin.action_desc_t(
             ACTNAME_REFRESH, "Refresh", refresh_ah_t(self)))
     ida_kernwin.register_action(
         ida_kernwin.action_desc_t(
             ACTNAME_CLOSE, "Close", close_ah_t(self)))
     return ida_idaapi.PLUGIN_KEEP
Пример #4
0
    def OnPopup(self, form, popup_handle):
        # graph closer
        actname = "graph_closer:%s" % self.title
        desc = ida_kernwin.action_desc_t(actname, "Close: %s" % self.title, GraphCloser(self))
        ida_kernwin.attach_dynamic_action_to_popup(form, popup_handle, desc)

        # color changer
        actname = "color_changer:%s" % self.title
        desc = ida_kernwin.action_desc_t(actname, "Change colors: %s" % self.title, ColorChanger(self))
        ida_kernwin.attach_dynamic_action_to_popup(form, popup_handle, desc)

        # selection printer
        actname = "selection_printer:%s" % self.title
        desc = ida_kernwin.action_desc_t(actname, "Print selection: %s" % self.title, SelectionPrinter(self))
        ida_kernwin.attach_dynamic_action_to_popup(form, popup_handle, desc)
Пример #5
0
    def handler(f):
        # 1) Create the handler class
        class MyHandler(ida_kernwin.action_handler_t):
            def __init__(self):
                ida_kernwin.action_handler_t.__init__(self)

            # Say hello when invoked.
            def activate(self, ctx):
                t = threading.Thread(target=f)
                t.start()
                return 1

            # This action is always available.
            def update(self, ctx):
                return ida_kernwin.AST_ENABLE_ALWAYS

        # 2) Describe the action
        action_desc = ida_kernwin.action_desc_t(
            name,  # The action name. This acts like an ID and must be unique
            name,  # The action text.
            MyHandler(),  # The action handler.
            shortcut,  # Optional: the action shortcut
            name,  # Optional: the action tooltip (available in menus/toolbar)
            0)  # Optional: the action icon (shows when in menus/toolbars)

        # 3) Register the action
        ida_kernwin.register_action(action_desc)
        return f
Пример #6
0
 def OnPopup(self, form, popup_handle):
     for c in ["A", "B"]:
         actname = "choose:act%s" % c
         desc = ida_kernwin.action_desc_t(actname, "command %s" % c,
                                          chooser_handler_t(c))
         ida_kernwin.attach_dynamic_action_to_popup(form, popup_handle,
                                                    desc)
Пример #7
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
Пример #8
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()
Пример #9
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
Пример #11
0
    def finish_populating_widget_popup(self, widget, popup_handle):
        if kw.get_widget_type(widget) == kw.BWN_PSEUDOCODE:

            class FilterHandler(kw.action_handler_t):
                def __init__(self, name):
                    self.name = name
                    kw.action_handler_t.__init__(self)

                def activate(self, ctx):
                    obj = FILTERS[self.name]
                    obj.set_activated(not obj.is_activated())
                    vu = hr.get_widget_vdui(ctx.widget)
                    if vu:
                        vu.refresh_view(not obj.is_activated())
                    return 1

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

            for name, obj in FILTERS.items():
                action_desc = kw.action_desc_t(
                    '%s%s' % (ACTION_NAME, name), name, FilterHandler(name),
                    None, None, 34 if obj.is_activated() else -1)
                kw.attach_dynamic_action_to_popup(widget, popup_handle,
                                                  action_desc, POPUP_ENTRY)
Пример #12
0
def main(): # type: () -> None
    if hr.init_hexrays_plugin():
        existing = ida_kernwin.unregister_action(ACTION_NAME)
        ida_kernwin.register_action(
            ida_kernwin.action_desc_t(ACTION_NAME, "sead::SafeString", sead_string_ah_t(), "F12"))
        if not existing:
            hr.install_hexrays_callback(cb)
Пример #13
0
    def finish_populating_widget_popup(self, widget, popup_handle):
        if ida_kernwin.get_widget_type(widget) == ida_kernwin.BWN_PSEUDOCODE:

            class menu_handler_t(ida_kernwin.action_handler_t):
                def __init__(self, name):
                    ida_kernwin.action_handler_t.__init__(self)
                    self.name = name

                def activate(self, ctx):
                    if self.name == HRDevHelper.get_action_name(
                            HRDevHelper.act_show_ctree):
                        show_ctree_graph()
                    elif self.name == HRDevHelper.get_action_name(
                            HRDevHelper.act_show_sub_tree):
                        show_ctree_graph(create_subgraph=True)
                    elif self.name == HRDevHelper.get_action_name(
                            HRDevHelper.act_show_context):
                        context_viewer_t.open()
                    else:
                        ida_kernwin.warning("Not implemented")
                    return 1

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

            for actname, data in self.actions.items():
                desc, hotkey = data
                action_desc = ida_kernwin.action_desc_t(
                    actname, desc, menu_handler_t(actname), hotkey, None, -1)
                ida_kernwin.attach_dynamic_action_to_popup(
                    widget, popup_handle, action_desc, "%s/" % PLUGIN_NAME)
Пример #14
0
 def get_desc(self):
   return ida_kernwin.action_desc_t(
     self.get_id(),
     self.get_text(),
     self,
     self.get_shortcut(),
     self.get_tooltip(),
     self.get_icon())
Пример #15
0
def register(action, *args):
    ida_kernwin.register_action(
        ida_kernwin.action_desc_t(
            action.name,
            action.description,
            action(*args),
            action.hotkey
        )
    )
Пример #16
0
 def _register_action(self, hotkey, desc):
     actname = HRDevHelper.get_action_name(desc)
     print(actname)
     if ida_kernwin.register_action(
             ida_kernwin.action_desc_t(actname, desc, hotkey_handler_t(),
                                       hotkey, None, -1)):
         self._registered_actions[actname] = (desc, hotkey)
     else:
         ida_kernwin.warning("%s: failed registering action" % PLUGIN_NAME)
Пример #17
0
Файл: vds3.py Проект: clayne/src
 def init(self):
     if ida_hexrays.init_hexrays_plugin():
         i = hexrays_callback_info()
         ida_kernwin.register_action(
             ida_kernwin.action_desc_t(inverter_actname, "Invert then/else",
                                       invert_action_handler_t(i), "I"))
         self.vds3_hooks = vds3_hooks_t(i)
         self.vds3_hooks.hook()
         return ida_idaapi.PLUGIN_KEEP  # keep us in the memory
Пример #18
0
    def OnPopup(self, form, popup_handle):
        # graph closer
        actname = 'graph_closer:{}'.format(self.title)
        desc = ida_kernwin.action_desc_t(
            actname, 'Close: {}'.format(self.title), GraphCloser(self))
        ida_kernwin.attach_dynamic_action_to_popup(form, popup_handle, desc)

        # color changer
        actname = 'color_changer:{}'.format(self.title)
        desc = ida_kernwin.action_desc_t(
            actname, 'Change colors: {}'.format(self.title), ColorChanger(self))
        ida_kernwin.attach_dynamic_action_to_popup(form, popup_handle, desc)

        # selection printer
        actname = 'selection_printer:{}'.format(self.title)
        desc = ida_kernwin.action_desc_t(
            actname, 'Print selection: {}'.format(self.title), SelectionPrinter(self))
        ida_kernwin.attach_dynamic_action_to_popup(form, popup_handle, desc)
Пример #19
0
    def init(self):
        self.xray_hooks = None
        if is_compatible():
            load_cfg()

            kw.register_action(
                kw.action_desc_t(XRAY_LOADCFG_AID,
                                 "%s: reload config" % PLUGIN_NAME,
                                 loadcfg_action_handler_t(), "Ctrl-r"))

            kw.register_action(
                kw.action_desc_t(XRAY_FILTER_AID, "%s: toggle" % PLUGIN_NAME,
                                 xray_action_handler_t(), "F3"))

            self.xray_hooks = xray_hooks_t()
            self.xray_hooks.hook()
            return ida_idaapi.PLUGIN_KEEP

        return ida_idaapi.PLUGIN_SKIP
Пример #20
0
def ApiPtrTypeSetInstall():
    if ida_hexrays.init_hexrays_plugin():
        ra = ida_kernwin.register_action(
            ida_kernwin.action_desc_t(API_TYPE_ACTION_NAME,
                                      API_TYPE_ACTION_DESC,
                                      api_ptr_type_setter(),
                                      API_TYPE_ACTION_SHORTCUT))

    else:
        print("API * type setter: hexrays is not available.")
Пример #21
0
 def init(self):
     if ida_hexrays.init_hexrays_plugin():
         print(
             "Hex-rays version %s has been detected, Structure offsets ready to use"
             % ida_hexrays.get_hexrays_version())
         ida_kernwin.register_action(
             ida_kernwin.action_desc_t("vds17:strchoose",
                                       "Structure offsets",
                                       func_stroff_ah_t(), "Shift+T"))
         return ida_idaapi.PLUGIN_KEEP  # keep us in the memory
Пример #22
0
Файл: vds5.py Проект: ylkcy/src
 def init(self):
     if ida_hexrays.init_hexrays_plugin():
         ida_kernwin.register_action(
             ida_kernwin.action_desc_t(ACTION_NAME,
                                       "Hex-Rays show C graph (IDAPython)",
                                       display_graph_ah_t(),
                                       ACTION_SHORTCUT))
         self.vds5_hooks = vds5_hooks_t()
         self.vds5_hooks.hook()
         return ida_idaapi.PLUGIN_KEEP  # keep us in the memory
Пример #23
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
Пример #24
0
    def OnPopup(self, form, popup_handle):
        controller = self.controller

        #
        # so, i'm pretty picky about my UI / interactions. IDA puts items in
        # the right click context menus of custom (code) viewers.
        #
        # these items aren't really relevant (imo) to the microcode viewer,
        # so I do some dirty stuff here to filter them out and ensure only
        # my items will appear in the context menu.
        #
        # there's only one right click context item right now, but in the
        # future i'm sure there will be more.
        #

        class FilterMenu(QtCore.QObject):
            def __init__(self, qmenu):
                super(QtCore.QObject, self).__init__()
                self.qmenu = qmenu

            def eventFilter(self, obj, event):
                if event.type() != QtCore.QEvent.Polish:
                    return False
                for action in self.qmenu.actions():
                    if action.text() in ["&Font...",
                                         "&Synchronize with"]:  # lol..
                        qmenu.removeAction(action)
                self.qmenu.removeEventFilter(self)
                self.qmenu = None
                return True

        p_qmenu = ctypes.cast(int(popup_handle),
                              ctypes.POINTER(ctypes.c_void_p))[0]
        qmenu = sip.wrapinstance(int(p_qmenu), QtWidgets.QMenu)
        self.filter = FilterMenu(qmenu)
        qmenu.installEventFilter(self.filter)

        # only handle right clicks on lines containing micro instructions
        ins_token = self.model.mtext.get_ins_for_line(self.model.current_line)
        if not ins_token:
            return False

        class MyHandler(ida_kernwin.action_handler_t):
            def activate(self, ctx):
                controller.show_subtree(ins_token)

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

        # inject the 'View subtree' action into the right click context menu
        desc = ida_kernwin.action_desc_t(None, 'View subtree', MyHandler())
        ida_kernwin.attach_dynamic_action_to_popup(form, popup_handle, desc,
                                                   None)

        return True
Пример #25
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)
Пример #26
0
    def finish_populating_widget_popup(self, widget, popup):
        widget_type = idaapi.get_widget_type(widget)
        if ((idaapi.BWN_FUNCS == widget_type) and self.taintinfo.showing_taint()):
            # about to show context menu for "Functions window" - as taint is
            # shown, add item to show window of tainted functions
            ida_kernwin.unregister_action(ShowTaintedFuncs.ACTION_NAME)

            # could also provide a shortcut and icon in the action_desc_t, if helpful
            if ida_kernwin.register_action(
                ida_kernwin.action_desc_t(
                    ShowTaintedFuncs.ACTION_NAME,
                    ShowTaintedFuncs.ACTION_LABEL,
                    ShowTaintedFuncs(self.taintinfo),
                    None,
                    ShowTaintedFuncs.ACTION_TOOLTIP)):
                    # if middle arg is None, this item is added permanently to the popup menu
                    # if it lists a TPopupMenu* handle, then this action is added just for this invocation
                    ida_kernwin.attach_action_to_popup(widget, popup, ShowTaintedFuncs.ACTION_NAME)
        elif ((idaapi.BWN_DISASM == widget_type) and self.taintinfo.have_taint_info()):
            # about to show context menu for a disassembly window - as taint
            # information is available, add either a Show or Hide item
            ida_kernwin.unregister_action(ShowHideTaint.ACTION_NAME)
            if (self.taintinfo.showing_taint()):
                if ida_kernwin.register_action(
                    ida_kernwin.action_desc_t(
                        ShowHideTaint.ACTION_NAME,
                        ShowHideTaint.HIDE_ACTION_LABEL,
                        ShowHideTaint(self.taintinfo),
                        None,
                        ShowHideTaint.HIDE_ACTION_TOOLTIP)):
                        ida_kernwin.attach_action_to_popup(widget, popup, ShowHideTaint.ACTION_NAME)
            else:
                if ida_kernwin.register_action(
                    ida_kernwin.action_desc_t(
                        ShowHideTaint.ACTION_NAME,
                        ShowHideTaint.SHOW_ACTION_LABEL,
                        ShowHideTaint(self.taintinfo),
                        None,
                        ShowHideTaint.SHOW_ACTION_TOOLTIP)):
                        ida_kernwin.attach_action_to_popup(widget, popup, ShowHideTaint.ACTION_NAME)
Пример #27
0
    def init(self):
        self.vds5_hooks = None
        if not ida_hexrays.init_hexrays_plugin():
            idaapi.msg("hexrays-graph: hexrays is not available.")
            return idaapi.PLUGIN_SKIP

        ida_kernwin.register_action(
            ida_kernwin.action_desc_t(ACTION_NAME,
                                      "Hex-Rays show C graph (IDAPython)",
                                      display_graph_ah_t(), ACTION_SHORTCUT))
        self.vds5_hooks = vds5_hooks_t()
        self.vds5_hooks.hook()
        return idaapi.PLUGIN_KEEP
Пример #28
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)
Пример #29
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
Пример #30
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
Пример #31
0
    args = convert_args_to_long(xref_args)
    if args:
        try:
            key = idaapi.get_many_bytes(args[2], args[3] if idc.Dword(args[3]) == 0xffffffff else idc.Dword(args[3]))
            data = idaapi.get_many_bytes(args[0], args[1] if idc.Dword(args[1]) == 0xffffffff else idc.Dword(args[1]))
        except TypeError:
            print("Couldn't retrieve the cipher or the key.")
            print(xref_args)
        else:
            key = null_pad(key, 0x20)
            if args[4] == 1:
                data = custom_b64decode(data)
            plain = PKCS7_unpad(AES.new(key, AES.MODE_CBC, "\x00"*16).decrypt(data))
            #add_comment(cfunc, plain, xref)
            print(plain)
    else:
        print("Not all args are numbers")
        print(xref_args)

CUSTOM_B64_ALPHA = "IJKLMNOPABCDEFGHQRSTUVWXghijklmnYZabcdefopqrstuv456789+/wxyz0123"
ACTION_NAME = "extract-decrypt-arguments-var-prop"
ida_kernwin.unregister_action(ACTION_NAME)
if idaapi.init_hexrays_plugin():
    ida_kernwin.register_action(ida_kernwin.action_desc_t(ACTION_NAME, "Extract and decrypt arguments", extract_args_t(decrypt_data, True), None))
class popup_hooks_t(ida_kernwin.UI_Hooks):
    def finish_populating_widget_popup(self, w, popup):
        if ida_kernwin.get_widget_type(w) == ida_kernwin.BWN_FUNCS:
            ida_kernwin.attach_action_to_popup(w, popup, ACTION_NAME, None)
hooks = popup_hooks_t()
hooks.hook()
Пример #32
0
class newcmd_dbgcmd_ah_t(base_dbgcmd_ah_t):
    def activate(self, ctx):
        dbgcmd.IssueCommand()

# -----------------------------------------------------------------------
class close_dbgcmd_ah_t(base_dbgcmd_ah_t):
    def activate(self, ctx):
        dbgcmd.Close()

# -----------------------------------------------------------------------
# Register actions (if needed)
ACTNAME_CLEAR = "dbgcmd:clear"
ACTNAME_NEWCMD = "dbgcmd:newcmd"
ACTNAME_CLOSE = "dbgcmd:close"
ida_kernwin.register_action(
    ida_kernwin.action_desc_t(
        ACTNAME_CLEAR, "Clear", clear_dbgcmd_ah_t(), "x"))
ida_kernwin.register_action(
    ida_kernwin.action_desc_t(
        ACTNAME_NEWCMD, "New command", newcmd_dbgcmd_ah_t(), "Insert"))
ida_kernwin.register_action(
    ida_kernwin.action_desc_t(
        ACTNAME_CLOSE, "Close", close_dbgcmd_ah_t(), "Escape"))

# -----------------------------------------------------------------------
class dbgcmd_t(ida_kernwin.simplecustviewer_t):
    def Create(self):
        # Form the title
        title = "Debugger command window"
        # Create the customview
        if not ida_kernwin.simplecustviewer_t.Create(self, title):
            return False
Пример #33
0
# --------------------------------------------------------------------------
class my_hooks_t(ida_kernwin.UI_Hooks):
    def __init__(self):
        ida_kernwin.UI_Hooks.__init__(self)

    def populating_widget_popup(self, widget, popup):
        if ida_kernwin.get_widget_type(widget) == ida_kernwin.BWN_PSEUDOCODE:
            ida_kernwin.attach_action_to_popup(widget, popup, ACTION_NAME)
my_hooks = my_hooks_t()
my_hooks.hook()


# --------------------------------------------------------------------------
SVC_EXIT       = 0x900001
SVC_EXIT_GROUP = 0x9000f8

if ida_hexrays.init_hexrays_plugin():
    udc_exit = udc_exit_t(SVC_EXIT, "svc_exit")
    udc_exit.toggle_install()

    udc_exit_group = udc_exit_t(SVC_EXIT_GROUP, "svc_exit_group")
    udc_exit_group.toggle_install()

    ida_kernwin.register_action(
        ida_kernwin.action_desc_t(
            ACTION_NAME,
            "vds8.py:Toggle UDC",
            toggle_udc_ah_t(),
            ACTION_SHORTCUT))

Пример #34
0
        import tempfile
        fname = tempfile.mktemp(suffix=".gdl")
        cg.gen_gdl(fname)
        ida_gdl.display_gdl(fname)
        return 1

    def update(self, ctx):
        return ida_kernwin.AST_ENABLE_FOR_WIDGET if \
            ctx.widget_type == ida_kernwin.BWN_PSEUDOCODE else \
            ida_kernwin.AST_DISABLE_FOR_WIDGET


class vds5_hooks_t(ida_hexrays.Hexrays_Hooks):
    def populating_popup(self, widget, handle, vu):
        idaapi.attach_action_to_popup(vu.ct, None, ACTION_NAME)
        return 0

if ida_hexrays.init_hexrays_plugin():
    ida_kernwin.register_action(
        ida_kernwin.action_desc_t(
            ACTION_NAME,
            "Hex-Rays show C graph (IDAPython)",
            display_graph_ah_t(),
            ACTION_SHORTCUT))
    vds5_hooks = vds5_hooks_t()
    vds5_hooks.hook()
else:
    print('hexrays-graph: hexrays is not available.')