Exemple #1
0
    def show_menu(self, pos):
        cell = self.itemAt(pos)
        menu = QMenu()

        if isinstance(cell, ByteWidget):
            data = menu.addAction("Show as data\t(D)")
            menu.addAction(data)

            follow = menu.addAction("Follow pointer\t(F)")
            menu.addAction(follow)

            sep1 = utils.get_qmenu_separator()
            menu.addAction(sep1)

            hex_view = menu.addAction("HEX\t(H)")
            if self.view == VIEW_HEX:
                hex_view.setEnabled(False)
            menu.addAction(hex_view)

            asm_view = menu.addAction("ASM\t(A)")
            if self.view == VIEW_ASM:
                asm_view.setEnabled(False)
            menu.addAction(asm_view)

            sep2 = utils.get_qmenu_separator()
            menu.addAction(sep2)

        mode = None
        if self.app.get_arch() == 'arm' and self.view == VIEW_ASM:
            if self.cs_mode == CS_MODE_ARM:
                mode = menu.addAction("THUMB mode\t(O)")
                menu.addAction(mode)
            elif self.cs_mode == CS_MODE_THUMB:
                mode = menu.addAction("ARM mode\t(O)")
                menu.addAction(mode)

            sep3 = utils.get_qmenu_separator()
            menu.addAction(sep3)

        jump_to = menu.addAction("Jump to\t(G)")

        action = menu.exec_(self.mapToGlobal(pos))
        if action == jump_to:
            self.trigger_jump_to()
        elif isinstance(cell, ByteWidget):
            if action == follow:
                self.trigger_follow_pointer()
            elif action == hex_view:
                self.set_view_type(VIEW_HEX)
            elif action == asm_view:
                self.set_view_type(VIEW_ASM)

        if self.app.get_arch() == 'arm':
            if mode is not None and action == mode:
                self.swap_arm_mode()
Exemple #2
0
    def show_menu(self, pos):
        menu = QMenu()
        add_action = menu.addAction("Hook address\t(A)")
        on_load_action = menu.addAction("Hook module load\t(O)")

        item = self.itemAt(pos)
        if item is not None:
            item = self.item(self.itemAt(pos).row(), 0)
        is_hook_item = item is not None and isinstance(
            item, HookWidget) and item.get_hook_data().get_ptr() > 0
        if is_hook_item:
            sep = utils.get_qmenu_separator()
            menu.addAction(sep)

            cond_action = menu.addAction("Condition\t(C)")
            logic_action = menu.addAction("Logic\t(L)")

        action = menu.exec_(self.mapToGlobal(pos))
        if action == add_action:
            self.add_hook()
        elif action == on_load_action:
            self.hook_on_load()
        if is_hook_item:
            if action == cond_action:
                self.set_condition()
            elif action == logic_action:
                self.set_logic()
Exemple #3
0
    def show_menu(self, pos):
        menu = QMenu()
        add_action = menu.addAction("Native\t(N)")

        if self.app.get_dwarf().java_available:
            hook_java_action = menu.addAction("Java\t(J)")
            on_load_action = menu.addAction("Module load\t(O)")

        item = self.itemAt(pos)
        if item is not None:
            item = self.item(self.itemAt(pos).row(), 0)
        is_hook_item = item is not None and isinstance(item, HookWidget)
        if is_hook_item:
            sep = utils.get_qmenu_separator()
            menu.addAction(sep)

            if item.get_hook_data().ptr > 0:
                # is either a native or java hook
                cond_action = menu.addAction("Condition")
                logic_action = menu.addAction("Logic")

                sep2 = utils.get_qmenu_separator()
                menu.addAction(sep2)

            delete_action = menu.addAction("Delete")

        action = menu.exec_(self.mapToGlobal(pos))
        if action == add_action:
            self.hook_native()

        if self.app.get_dwarf().java_available:
            if action == on_load_action:
                self.hook_onload()
            elif action == hook_java_action:
                self.hook_java()
        if is_hook_item:
            if action == delete_action:
                self.delete_hook(item,
                                 self.item(item.row(), 0).get_hook_data())
            elif action == cond_action:
                self.set_condition(item)
            elif action == logic_action:
                self.set_logic(item)
Exemple #4
0
    def show_menu(self, pos):
        cell = self.itemAt(pos)
        menu = QMenu()

        if cell:
            if isinstance(cell, ByteWidget):
                address = QAction(hex(cell.get_ptr()))
                address.triggered.connect(self.trigger_copy_address)
                menu.addAction(address)

                address_sep = utils.get_qmenu_separator()
                menu.addAction(address_sep)

            asm_view = menu.addAction("ASM\t(A)")
            asm_view.triggered.connect(self.show_asm_view)
            menu.addAction(asm_view)

            menu.addSeparator()

        if isinstance(cell, ByteWidget):
            # todo
            # data = menu.addAction("Show as data\t(D)")
            # menu.addAction(data)

            hook_address = QAction("Hook address")
            hook_address.triggered.connect(self.trigger_hook_address)
            menu.addAction(hook_address)

            follow = QAction("Follow pointer\t(F)")
            follow.triggered.connect(self.trigger_follow_pointer)
            menu.addAction(follow)

            menu.addSeparator()

        if cell:
            wb = QAction("Write bytes")
            wb.triggered.connect(self.trigger_write_bytes)
            menu.addAction(wb)

            ws = menu.addAction("Write string")
            ws.triggered.connect(self.trigger_write_string)

            menu.addSeparator()

        jump_to = QAction("Jump to\t(G)")
        jump_to.triggered.connect(self.trigger_jump_to)
        menu.addAction(jump_to)

        menu.exec_(self.mapToGlobal(pos))
Exemple #5
0
    def show_menu(self, pos):
        cell = self.itemAt(pos)
        menu = QMenu()

        if cell:
            if isinstance(cell, ByteWidget):
                address = QAction(hex(cell.get_ptr()))
                address.triggered.connect(self.trigger_copy_address)
                menu.addAction(address)

                address_sep = utils.get_qmenu_separator()
                menu.addAction(address_sep)

            hex_view = QAction("HEX\t(H)")
            if self.view == VIEW_HEX:
                hex_view.setEnabled(False)
            hex_view.triggered.connect(self.set_view_type_hex)
            menu.addAction(hex_view)

            asm_view = menu.addAction("ASM\t(A)")
            if self.view == VIEW_ASM:
                asm_view.setEnabled(False)
            asm_view.triggered.connect(self.set_view_type_asm)
            menu.addAction(asm_view)

            sep1 = utils.get_qmenu_separator()
            menu.addAction(sep1)

        if isinstance(cell, ByteWidget):
            # todo
            # data = menu.addAction("Show as data\t(D)")
            # menu.addAction(data)

            hook_address = QAction("Hook address")
            hook_address.triggered.connect(self.trigger_hook_address)
            menu.addAction(hook_address)

            follow = QAction("Follow pointer\t(F)")
            follow.triggered.connect(self.trigger_follow_pointer)
            menu.addAction(follow)

            sep2 = utils.get_qmenu_separator()
            menu.addAction(sep2)

        if self.app.get_arch() == 'arm' and self.view == VIEW_ASM:
            if self.cs_mode == CS_MODE_ARM:
                mode = QAction("THUMB mode\t(O)")
            else:
                mode = QAction("ARM mode\t(O)")

            mode.triggered.connect(self.swap_arm_mode)
            menu.addAction(mode)

            sep3 = utils.get_qmenu_separator()
            menu.addAction(sep3)

        if cell:
            if self.view == VIEW_ASM:
                # todo
                # patch = menu.addAction("Patch instruction")
                # menu.addAction(patch)
                pass
            elif self.view == VIEW_HEX:
                wb = QAction("Write bytes")
                wb.triggered.connect(self.trigger_write_bytes)
                menu.addAction(wb)

                ws = menu.addAction("Write string")
                ws.triggered.connect(self.trigger_write_string)
                menu.addAction(ws)

                sep4 = utils.get_qmenu_separator()
                menu.addAction(sep4)

        jump_to = QAction("Jump to\t(G)")
        jump_to.triggered.connect(self.trigger_jump_to)
        menu.addAction(jump_to)

        menu.exec_(self.mapToGlobal(pos))