Beispiel #1
0
 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)
Beispiel #2
0
    def populating_popup(self, widget, popup, vu):
        print '[*] DEBUG: vu.item.citype = %d' % vu.item.citype
        if vu.item.citype != ida_hexrays.VDI_EXPR:
            return 0

        lvar = vu.item.get_lvar()

        ida_kernwin.attach_action_to_popup(widget, popup, MakeItConst.name, None)
        return self._log("populating_popup: widget=%s, popup=%s, vu=%s" % (widget, popup, vu))
Beispiel #3
0
 def Show(self, *args):
     ok = ida_kernwin.simplecustviewer_t.Show(self, *args)
     if ok:
         # permanently attach actions to this viewer's popup menu
         for av in actions_variants:
             actname = say_something_handler_t.compose_action_name(av)
             ida_kernwin.attach_action_to_popup(self.GetWidget(), None,
                                                actname)
     return ok
Beispiel #4
0
 def show(self):
     ok = self.Show(self.modal) >= 0
     if ok:
         # permanently attach actions to this chooser's popup menu
         for av in actions_variants:
             actname = chooser_handler_t.compose_action_name(av)
             ida_kernwin.attach_action_to_popup(self.GetWidget(), None,
                                                actname)
     return ok
Beispiel #5
0
 def finish_populating_widget_popup(self, widget, popup):
     # We'll add our action to all "IDA View-*"s.
     # If we wanted to add it only to "IDA View-A", we could
     # also discriminate on the widget's title:
     #
     #  if ida_kernwin.get_widget_title(widget) == "IDA View-A":
     #      ...
     #
     if ida_kernwin.get_widget_type(widget) == ida_kernwin.BWN_DISASM:
         ida_kernwin.attach_action_to_popup(widget, popup, act_name, None)
Beispiel #6
0
    def _hxe_popuplating_popup(self, widget, popup, vdui):
        """
        Handle a Hex-Rays popup menu event.

        When the user right clicks within a decompiler window, we use this
        callback to insert the 'View microcode' menu entry into the ctx menu.
        """
        ida_kernwin.attach_action_to_popup(widget, popup,
                                           self.ACTION_VIEW_MICROCODE, None,
                                           ida_kernwin.SETMENU_APP)
Beispiel #7
0
    def run(self, arg):
        if self.view:
            self.Close()
        fn = ida_kernwin.ask_file(0, "*.asm", "Select ASM file to view")
        if not fn:
            return
        self.view = asmview_t()
        if not self.view.Create(fn):
            return
        self.view.Show()
        widget = self.view.GetWidget()

        # Attach actions to this widget's popup menu
        ida_kernwin.attach_action_to_popup(widget, None, ACTNAME_REFRESH)
        ida_kernwin.attach_action_to_popup(widget, None, ACTNAME_CLOSE)
Beispiel #8
0
 def populating_popup(self, widget, phandle, vu):
     kw.attach_action_to_popup(vu.ct, None, XRAY_FILTER_ACTION_ID,
                               PLUGIN_NAME + "/")
     kw.attach_action_to_popup(vu.ct, None, XRAY_LOADCFG_ACTION_ID,
                               PLUGIN_NAME + "/")
     kw.attach_action_to_popup(vu.ct, None, XRAY_QUERY_ACTION_ID,
                               PLUGIN_NAME + "/")
     kw.attach_action_to_popup(vu.ct, None, XRAY_COLOR_ACTION_ID,
                               PLUGIN_NAME + "/")
     return 0
Beispiel #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)
Beispiel #10
0
def show_win():
    x = dbgcmd_t()
    if not x.Create():
        print "Failed to create debugger command line!"
        return None
    x.Show()

    # Attach actions to this widget's popup menu
    widget = x.GetWidget()
    ida_kernwin.attach_action_to_popup(widget, None, ACTNAME_CLEAR)
    ida_kernwin.attach_action_to_popup(widget, None, ACTNAME_NEWCMD)
    ida_kernwin.attach_action_to_popup(widget, None, ACTNAME_CLOSE)
    return x
Beispiel #11
0
def show_win():
    x = dbgcmd_t()
    if not x.Create():
        print("Failed to create debugger command line!")
        return None
    x.Show()

    # Attach actions to this widget's popup menu
    widget = x.GetWidget()
    ida_kernwin.attach_action_to_popup(widget, None, ACTNAME_CLEAR)
    ida_kernwin.attach_action_to_popup(widget, None, ACTNAME_NEWCMD)
    ida_kernwin.attach_action_to_popup(widget, None, ACTNAME_CLOSE)
    return x
Beispiel #12
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)
Beispiel #13
0
Datei: vds5.py Projekt: ylkcy/src
 def populating_popup(self, widget, handle, vu):
     ida_kernwin.attach_action_to_popup(vu.ct, None, ACTION_NAME)
     return 0
Beispiel #14
0
    @staticmethod
    def compose_action_name(v):
        return "dump_extra_comments:%s" % v


# -----------------------------------------------------------------------
# create actions (and attach them to IDA View-A's context menu if possible)
widget_title = "IDA View-A"
ida_view = ida_kernwin.find_widget(widget_title)

actions_variants = [
    ("previous", ida_lines.E_PREV, "Ctrl+Shift+Y"),
    ("next", ida_lines.E_NEXT, "Ctrl+Shift+Z"),
]
for label, anchor, shortcut in actions_variants:
    actname = dump_at_point_handler_t.compose_action_name(label)
    if ida_kernwin.unregister_action(actname):
        print("Unregistered previously-registered action \"%s\"" % actname)

    desc = ida_kernwin.action_desc_t(
        actname,
        "Dump %s extra comments" % label,
        dump_at_point_handler_t(anchor),
        shortcut)
    if ida_kernwin.register_action(desc):
        print("Registered action \"%s\"" % actname)

    if ida_view and ida_kernwin.attach_action_to_popup(ida_view, None, actname):
        print("Permanently attached action \"%s\" to \"%s\"" % (actname, widget_title))
Beispiel #15
0
 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)
Beispiel #16
0
 def populating_popup(self, widget, phandle, vu):
     ida_kernwin.attach_action_to_popup(widget, phandle, "vdsxrefs:show",
                                        None)
     return 0
Beispiel #17
0
    def _popup_hook(self, widget, popup):
        """
        (Event) IDA is about to show a popup for the given TWidget.
        """

        # TODO: return if plugin/trace is not active
        pass

        # fetch the (IDA) window type (eg, disas, graph, hex ...)
        view_type = ida_kernwin.get_widget_type(widget)

        # only attach these context items to popups in disas views
        if view_type == ida_kernwin.BWN_DISASMS:

            # prep for some shady hacks
            p_qmenu = ctypes.cast(int(popup),
                                  ctypes.POINTER(ctypes.c_void_p))[0]
            qmenu = sip.wrapinstance(int(p_qmenu), QtWidgets.QMenu)

            #
            # inject and organize the Tenet plugin actions
            #

            ida_kernwin.attach_action_to_popup(
                widget,
                popup,
                self.ACTION_NEXT_EXECUTION,  # The action ID (see above)
                "Rename",  # Relative path of where to add the action
                ida_kernwin.SETMENU_APP  # We want to append the action after ^
            )

            #
            # this is part of our bodge to inject a plugin action submenu
            # at a specific location in the QMenu, cuz I don't think it's
            # actually possible with the native IDA API's (for groups...)
            #

            for action in qmenu.actions():
                if action.text() == "Go to next execution":

                    # inject a group for the exta 'go to' actions
                    goto_submenu = QtWidgets.QMenu("Go to...")
                    qmenu.insertMenu(action, goto_submenu)

                    # hold a Qt ref of the submenu so it doesn't GC
                    self.__goto_submenu = goto_submenu
                    break

            ida_kernwin.attach_action_to_popup(
                widget,
                popup,
                self.ACTION_FIRST_EXECUTION,  # The action ID (see above)
                "Go to.../",  # Relative path of where to add the action
                ida_kernwin.SETMENU_APP  # We want to append the action after ^
            )

            ida_kernwin.attach_action_to_popup(
                widget,
                popup,
                self.ACTION_FINAL_EXECUTION,  # The action ID (see above)
                "Go to.../",  # Relative path of where to add the action
                ida_kernwin.SETMENU_APP  # We want to append the action after ^
            )

            ida_kernwin.attach_action_to_popup(
                widget,
                popup,
                self.ACTION_PREV_EXECUTION,  # The action ID (see above)
                "Rename",  # Relative path of where to add the action
                ida_kernwin.SETMENU_APP  # We want to append the action after ^
            )

            #
            # inject a seperator to help insulate our plugin action group
            #

            for action in qmenu.actions():
                if action.text() == "Go to previous execution":
                    qmenu.insertSeparator(action)
                    break
Beispiel #18
0
 def populating_popup(self, widget, phandle, vu):
     kw.attach_action_to_popup(vu.ct, None, XRAY_FILTER_AID)
     return 0
 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)
Beispiel #20
0
 def populating_popup(self, widget, phandle, vu):
     ida_kernwin.attach_action_to_popup(vu.ct, None, inverter_actname)
     return 0
Beispiel #21
0
 def populating_popup(self, widget, popup_handle, vu):
     if IsPtrSizedLvar(vu):
         ida_kernwin.attach_action_to_popup(widget, popup_handle,
                                            API_TYPE_ACTION_NAME)
     return 0
Beispiel #22
0
 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)
 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)
Beispiel #24
0
 def finish_populating_widget_popup(self, form, popup):
     if ida_kernwin.get_widget_type(form) == ida_kernwin.BWN_CPUREGS:
         ida_kernwin.attach_action_to_popup(form, popup, ACTION_NAME)
 def update(self, ctx):
     if ctx.widget_type == BWN_DISASM:
         attach_action_to_popup(ctx.widget, None, self.name)
         return AST_ENABLE_FOR_WIDGET
     return AST_DISABLE_FOR_WIDGET
Beispiel #26
0
        ida_kernwin.action_handler_t.__init__(self)

    def activate(self, ctx):
        for idx in ctx.chooser_selection:
            addr, _, _, s = ida_kernwin.get_chooser_data(ctx.widget_title, idx)
            print("%s: '%s'" % (addr, s))
        return 0

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


klasses = [copy_only_string, print_string]

sw = ida_kernwin.find_widget("Strings window")
if not sw:
    sw = ida_kernwin.open_strings_window(ida_idaapi.BADADDR)

for klass in klasses:
    ida_kernwin.unregister_action(klass.ACTION_NAME)

    if ida_kernwin.register_action(
            ida_kernwin.action_desc_t(klass.ACTION_NAME, klass.ACTION_LABEL,
                                      klass(), klass.ACTION_SHORTCUT)):
        if sw:
            ida_kernwin.attach_action_to_popup(sw, None, klass.ACTION_NAME)
            print("Permanently added '%s' action to 'String window's popup" %
                  klass.ACTION_LABEL)
Beispiel #27
0
 def finish_populating_widget_popup(self, widget, popup):
     ida_kernwin.attach_action_to_popup(widget, popup, "Hyara:select_start_address", None)
     ida_kernwin.attach_action_to_popup(widget, popup, "Hyara:select_end_address", None)