Example #1
0
    def _on_modules_contextmenu(self, pos):
        """ Modules ContextMenu
        """
        index = self.modules_list.indexAt(pos).row()
        glbl_pt = self.modules_list.mapToGlobal(pos)
        context_menu = QMenu(self)
        if index != -1:
            context_menu.addAction(
                'Dump Binary', lambda: self._on_dumpmodule(
                    self.modules_model.item(index, 1).text(),
                    self.modules_model.item(index, 2).text()))
            context_menu.addAction(
                'Copy address', lambda: utils.copy_hex_to_clipboard(
                    self.modules_model.item(index, 1).text()))
            context_menu.addSeparator()
            context_menu.addAction(
                'Copy Name', lambda: utils.copy_str_to_clipboard(
                    self.modules_model.item(index, 0).text()))
            context_menu.addAction(
                'Copy Path', lambda: utils.copy_str_to_clipboard(
                    self.modules_model.item(index, 3).text()))
            context_menu.addSeparator()

        context_menu.addAction('Refresh', self.update_modules)
        context_menu.exec_(glbl_pt)
Example #2
0
    def _on_context_menu(self, pos):
        context_menu = QMenu(self)
        context_menu.addMenu(self.new_menu)

        context_menu.addSeparator()
        index = self._hooks_list.indexAt(pos).row()
        if index != -1:
            context_menu.addAction(
                'Copy address', lambda: utils.copy_hex_to_clipboard(
                    self._hooks_model.item(index, 0).text()))
            context_menu.addAction(
                'Jump to address', lambda: self._app_window.jump_to_address(
                    self._hooks_model.item(index, 0).text()))
            context_menu.addSeparator()
            context_menu.addAction('Edit Logic',
                                   lambda: self._on_modify_logic(index))
            context_menu.addAction('Edit Condition',
                                   lambda: self._on_modify_condition(index))
            context_menu.addSeparator()
            context_menu.addAction('Delete Hook',
                                   lambda: self._on_delete_hook(index))

            if self._hooks_list.search_enabled:
                context_menu.addSeparator()
                context_menu.addAction('Search',
                                       self._hooks_list._on_cm_search)

        # show context menu
        global_pt = self._hooks_list.mapToGlobal(pos)
        context_menu.exec(global_pt)
Example #3
0
    def _on_contextmenu(self, pos):
        context_menu = QMenu(self)
        index = self._bookmarks_list.indexAt(pos).row()
        if index != -1:
            context_menu.addAction(
                'Copy address', lambda: utils.copy_hex_to_clipboard(
                    self._bookmarks_model.item(index, 0).text()))
            context_menu.addAction(
                'Jump to address', lambda: self._app_window.jump_to_address(
                    self._bookmarks_model.item(index, 0).text()))

            # todo: add hook address menu

            context_menu.addSeparator()
            context_menu.addAction('Edit',
                                   lambda: self._create_bookmark(index=index))
            context_menu.addAction('Delete',
                                   lambda: self._on_delete_bookmark(index))
            context_menu.addSeparator()
            if self._bookmarks_list.search_enabled:
                context_menu.addSeparator()
                context_menu.addAction('Search',
                                       self._bookmarks_list._on_cm_search)
                context_menu.addSeparator()
        context_menu.addAction('New', self._create_bookmark)
        global_pt = self._bookmarks_list.mapToGlobal(pos)
        context_menu.exec(global_pt)
Example #4
0
    def _on_imports_contextmenu(self, pos):
        """ ImportList ContextMenu
        """
        index = self.imports_list.indexAt(pos).row()
        if index != -1:
            context_menu = QMenu(self)
            func_name = self.imports_model.item(index, 0).text()
            addr = self.imports_model.item(index, 1).text()
            context_menu.addAction(
                'Add Hook', lambda: self._add_hook(addr, func_name))
            context_menu.addSeparator()
            context_menu.addAction(
                'Copy address', lambda: utils.copy_hex_to_clipboard(
                    self.imports_model.item(index, 1).text()))
            context_menu.addSeparator()
            context_menu.addAction(
                'Copy FunctionName', lambda: utils.copy_str_to_clipboard(
                    func_name))
            context_menu.addAction(
                'Copy ModuleName', lambda: utils.copy_str_to_clipboard(
                    self.imports_model.item(index, 2).text()))

            # show context menu
            glbl_pt = self.imports_list.mapToGlobal(pos)
            context_menu.exec_(glbl_pt)
Example #5
0
    def _on_contextmenu(self, pos):
        """ ContextMenu
        """
        index = self.indexAt(pos).row()
        glbl_pt = self.mapToGlobal(pos)
        context_menu = QMenu(self)
        if index != -1:
            mem_prot = self._ranges_model.item(index, 2).text()
            # is readable
            if 'r' in mem_prot:
                context_menu.addAction(
                    'Dump Binary', lambda: self._on_dumprange(
                        self._ranges_model.item(index, 0).text(),
                        self._ranges_model.item(index, 1).text()))
                context_menu.addSeparator()

            context_menu.addAction(
                'Add Watcher', lambda: self._on_addwatcher(
                    self._ranges_model.item(index, 0).text()))

            context_menu.addAction(
                'Copy address', lambda: utils.copy_hex_to_clipboard(
                    self._ranges_model.item(index, 0).text()))
            context_menu.addSeparator()

        context_menu.addAction('Refresh', self.update_ranges)
        context_menu.exec_(glbl_pt)
Example #6
0
    def _on_modules_contextmenu(self, pos):
        """ Modules ContextMenu
        """
        index = self.modules_list.indexAt(pos).row()
        glbl_pt = self.modules_list.mapToGlobal(pos)
        context_menu = QMenu(self)
        if index != -1:
            context_menu.addAction(
                'Dump Binary', lambda: self._on_dumpmodule(
                    self.modules_model.item(index, 1).text(),
                    self.modules_model.item(index, 2).text()))
            context_menu.addAction(
                'Copy address', lambda: utils.copy_hex_to_clipboard(
                    self.modules_model.item(index, 1).text()))
            context_menu.addSeparator()
            context_menu.addAction(
                'Copy Name', lambda: utils.copy_str_to_clipboard(
                    self.modules_model.item(index, 0).text()))
            context_menu.addAction(
                'Copy Path', lambda: utils.copy_str_to_clipboard(
                    self.modules_model.item(index, 3).text()))
            context_menu.addSeparator()
            file_path = self.modules_model.item(index, 3).text()
            if self._app_window.dwarf._platform == 'linux':
                context_menu.addAction(
                    'Show ELF Info', lambda: self._on_parse_elf(file_path))
                context_menu.addSeparator()
            #elif file_path and (file_path.endswith('.dll') or file_path.endswith('.exe')):
            #   context_menu.addAction('Show PE Info', lambda: self._on_parse_pe(file_path))
            #   context_menu.addSeparator()

        context_menu.addAction('Refresh', self.update_modules)
        context_menu.exec_(glbl_pt)
Example #7
0
 def _on_context_menu(self, pos):
     model_index = self.elf_info.indexAt(pos)
     if model_index.column() == 0 and model_index.data():
         if model_index.data().startswith('0x'):
             context_menu = QMenu()
             context_menu.addAction('Add to Bookmarks', lambda: self.parent().bookmarks_panel.insert_bookmark(model_index.data(), 'init_array'))
             context_menu.addAction('Copy Address', lambda: utils.copy_hex_to_clipboard(model_index.data()))
             # show contextmenu
             glbl_pt = self.elf_info.mapToGlobal(pos)
             context_menu.exec_(glbl_pt)
Example #8
0
 def _on_native_contextmenu(self, pos):
     index = self._nativectx_list.indexAt(pos).row()
     glbl_pt = self._nativectx_list.mapToGlobal(pos)
     context_menu = QMenu(self)
     if index != -1:
         context_menu.addAction(
             'Copy address', lambda: utils.copy_hex_to_clipboard(
                 self._nativectx_model.item(index, 1).text()))
         context_menu.addAction(
             'Jump to address', lambda: self._app_window.jump_to_address(
                 self._nativectx_model.item(index, 1).text()))
     context_menu.exec_(glbl_pt)
Example #9
0
 def _on_contextmenu(self, pos):
     index = self.list_view.indexAt(pos).row()
     glbl_pt = self.list_view.mapToGlobal(pos)
     context_menu = QMenu(self)
     context_menu.addAction('Add watcher', self._on_additem_clicked)
     if index != -1:
         context_menu.addSeparator()
         context_menu.addAction(
             'Copy address', lambda: utils.copy_hex_to_clipboard(
                 self._watchers_model.item(index, 0).text()))
         context_menu.addAction(
             'Delete address', lambda: self.remove_address(
                 self._watchers_model.item(index, 0).text()))
     context_menu.exec_(glbl_pt)
Example #10
0
    def _on_context_menu(self, event):
        """ build and show contextmenu
        """
        loc_x = event.pos().x()
        loc_y = event.pos().y()

        context_menu = QMenu()

        context_menu.addAction('Jump to address', lambda: self._on_cm_jump_to_address())

        # allow modeswitch arm/thumb
        if self.capstone_arch == CS_ARCH_ARM:
            mode_str = 'ARM'
            if self.capstone_mode == CS_MODE_ARM:
                mode_str = 'THUMB'

            entry_str = '&Switch to {0} Mode'.format(mode_str)
            context_menu.addAction(entry_str, self._on_switch_mode)
            context_menu.addSeparator()

        index = self.pixel_to_line(loc_x, loc_y)
        if 0 <= index < self.visible_lines():
            if index + self.pos < len(self._lines):
                if isinstance(self._lines[index + self.pos], Instruction):
                    context_menu.addAction('Copy address', lambda: utils.copy_hex_to_clipboard(self._lines[index + self.pos].address))

                    context_menu.addSeparator()

                    if self._uppercase_hex:
                        str_fmt = '0x{0:X}'
                    else:
                        str_fmt = '0x{0:x}'
                    addr_str = str_fmt.format(self._lines[index + self.pos].address)
                    if self._app_window.watchers_panel:
                        if self._app_window.dwarf.is_address_watched(self._lines[index + self.pos].address):
                            context_menu.addAction('Remove watcher', lambda: self._app_window.watchers_panel.remove_address(addr_str))
                        else:
                            context_menu.addAction('Watch address', lambda: self._app_window.watchers_panel.do_addwatcher_dlg(addr_str))
                    if self._app_window.hooks_panel:
                        if self._lines[index + self.pos].address in self._app_window.dwarf.hooks:
                            context_menu.addAction('Remove hook', lambda: self._app_window.dwarf.dwarf_api('deleteHook', addr_str))
                        else:
                            context_menu.addAction('Hook address', lambda: self._app_window.dwarf.hook_native(addr_str))

        glbl_pt = self.mapToGlobal(event.pos())
        context_menu.exec_(glbl_pt)
Example #11
0
 def _on_contextmenu(self, pos):
     context_menu = QMenu(self)
     context_menu.addMenu(self.new_menu)
     context_menu.addSeparator()
     index = self._hooks_list.indexAt(pos).row()
     if index != -1:
         context_menu.addAction(
             'Copy address', lambda: utils.copy_hex_to_clipboard(
                 self._hooks_model.item(index, 0).text()))
         context_menu.addSeparator()
         context_menu.addAction('Modify Logic',
                                lambda: self._on_modify_logic(index))
         context_menu.addAction('Modify Condition',
                                lambda: self._on_modify_condition(index))
         context_menu.addSeparator()
         context_menu.addAction('Delete Hook',
                                lambda: self._on_deletehook(index))
     global_pt = self._hooks_list.mapToGlobal(pos)
     context_menu.exec(global_pt)
Example #12
0
    def _on_context_menu(self, pos):
        index = self.indexAt(pos).row()
        glbl_pt = self.mapToGlobal(pos)
        context_menu = QMenu(self)
        if index != -1:
            if self._mode == 'native':
                addr_item = self.model().item(index, 0).text()
                symbol_item = self.model().item(index, 1).text()
                # show contextmenu
                context_menu.addAction(
                    'Jump to {0}'.format(addr_item),
                    lambda: self.onShowMemoryRequest.emit(['bt', addr_item]))
                context_menu.addSeparator()
                context_menu.addAction(
                    'Copy Address',
                    lambda: utils.copy_hex_to_clipboard(addr_item))
                if symbol_item and symbol_item != '-':
                    context_menu.addAction(
                        'Copy Symbol',
                        lambda: utils.copy_str_to_clipboard(symbol_item))
            elif self._mode == 'java':
                method_item = self.model().item(index, 0).text()
                if method_item.startswith('at '):
                    method_item = method_item.replace('at ', '')

                source_item = self.model().item(index, 1).text()
                if ':' in source_item:
                    source_item = source_item.split(':')[0]
                # show contextmenu
                # context_menu.addAction('Jump to', lambda: self._app_window.jump_to_address(addr_item.text()))
                # context_menu.addSeparator()
                # TODO: add jumpto java
                context_menu.addAction(
                    'Copy Method',
                    lambda: utils.copy_str_to_clipboard(method_item))
                context_menu.addAction(
                    'Copy Source',
                    lambda: utils.copy_str_to_clipboard(source_item))

            context_menu.exec_(glbl_pt)
Example #13
0
    def _on_contextmenu(self, pos):
        """ ContextMenu
        """
        index = self.indexAt(pos).row()
        glbl_pt = self.mapToGlobal(pos)
        context_menu = QMenu(self)
        if index != -1:
            mem_prot = self._ranges_model.item(index, 2).text()
            # is readable
            if 'r' in mem_prot:
                context_menu.addAction(
                    'Dump Binary', lambda: self._on_dumprange(
                        self._ranges_model.item(index, 0).text(),
                        self._ranges_model.item(index, 1).text()))
                context_menu.addSeparator()

            context_menu.addAction(
                'Add Watcher', lambda: self._on_addwatcher(
                    self._ranges_model.item(index, 0).text()))

            context_menu.addAction(
                'Copy address', lambda: utils.copy_hex_to_clipboard(
                    self._ranges_model.item(index, 0).text()))
            context_menu.addSeparator()

            if self._ranges_model.item(index, 5):
                file_path = self._ranges_model.item(index, 5).text()
                if file_path:
                    context_menu.addAction(
                        'Copy Path',
                        lambda: utils.copy_str_to_clipboard(file_path))
                    context_menu.addSeparator()
                    if self._app_window.dwarf._platform == 'linux':
                        context_menu.addAction(
                            'Show ELF Info',
                            lambda: self._on_parse_elf(file_path))
                        context_menu.addSeparator()

        context_menu.addAction('Refresh', self.update_ranges)
        context_menu.exec_(glbl_pt)
Example #14
0
    def _on_context_menu(self, event):
        """ build and show contextmenu
        """
        loc_x = event.pos().x()
        loc_y = event.pos().y()

        context_menu = QMenu()

        def add_default_actions():
            context_menu.addAction(
                'Jump to address',
                lambda: self.debug_panel.on_cm_jump_to_address(view=1))

            # allow mode switch arm/thumb
            if self._app_window.dwarf.disassembler.capstone_arch == CS_ARCH_ARM:
                if self._app_window.dwarf.disassembler.capstone_mode == CS_MODE_THUMB:
                    mode_str = 'ARM'
                else:
                    mode_str = 'THUMB'
                entry_str = '&Switch to {0} mode'.format(mode_str)
                context_menu.addAction(entry_str, self._on_switch_mode)

        if not self._lines:
            add_default_actions()

            # allow jumpto in empty panel
            glbl_pt = self.mapToGlobal(event.pos())
            context_menu.exec_(glbl_pt)
            return

        index = self.pixel_to_line(loc_x, loc_y)
        address = -1
        if 0 <= index < self.visible_lines():
            if index + self.pos < len(self._lines):
                if isinstance(self._lines[index + self.pos], Instruction):
                    address = self._lines[index + self.pos].address
                    addr_str = hex(address)

                    context_menu.addAction(addr_str)
                    context_menu.addSeparator()

                    if self._app_window.watchers_panel:
                        if self._app_window.dwarf.is_address_watched(address):
                            context_menu.addAction(
                                'Remove watcher', lambda: self._app_window.
                                watchers_panel.remove_address(addr_str))
                        else:
                            context_menu.addAction(
                                'Watch address', lambda: self._app_window.
                                watchers_panel.do_addwatcher_dlg(addr_str))
                    if self._app_window.hooks_panel:
                        if address in self._app_window.dwarf.hooks:
                            context_menu.addAction(
                                'Remove hook',
                                lambda: self._app_window.dwarf.dwarf_api(
                                    'deleteHook', addr_str))
                        else:
                            context_menu.addAction(
                                'Hook address', lambda: self._app_window.dwarf.
                                hook_native(addr_str))

                    context_menu.addSeparator()

                    context_menu.addAction(
                        'Copy address',
                        lambda: utils.copy_hex_to_clipboard(address))

        context_menu.addAction("&Jump to address",
                               self.debug_panel.on_cm_jump_to_address)

        glbl_pt = self.mapToGlobal(event.pos())
        context_menu.exec_(glbl_pt)