Exemple #1
0
    def build_central_content(self):
        main_panel = QSplitter(self)
        main_panel.setHandleWidth(1)
        main_panel.setOrientation(Qt.Vertical)
        main_panel.setContentsMargins(0, 0, 0, 0)

        from ui.panel_context import ContextPanel
        self.context_panel = ContextPanel(self.app, 0, 0)
        main_panel.addWidget(self.context_panel)

        box = QVBoxLayout()
        box.setContentsMargins(0, 0, 0, 0)
        from ui.panel_memory import MemoryPanel
        self.memory_panel = MemoryPanel(self.app)
        box.addWidget(self.memory_panel)

        from ui.panel_java_explorer import JavaExplorerPanel
        self.java_explorer_panel = JavaExplorerPanel(self.app)
        self.java_explorer_panel.hide()
        box.addWidget(self.java_explorer_panel)

        q = QWidget()
        q.setLayout(box)
        main_panel.addWidget(q)

        from ui.panel_console import ConsolePanel
        self.console_panel = ConsolePanel(self.app)
        main_panel.addWidget(self.console_panel)

        main_panel.setStretchFactor(0, 1)
        main_panel.setStretchFactor(1, 3)
        main_panel.setStretchFactor(2, 1)
        return main_panel
Exemple #2
0
    def _create_ui_elem(self, elem):
        if not isinstance(elem, str):
            return

        if elem not in self._ui_elems:
            self._ui_elems.append(elem)

        if elem == 'watchers':
            from ui.panel_watchers import WatchersPanel
            self.watchers_dwidget = QDockWidget('Watchers', self)
            self.watchers_panel = WatchersPanel(self)
            # dont respond to dblclick mem cant be shown
            # self.watchers_panel.onItemDoubleClicked.connect(
            #    self._on_watcher_clicked)
            self.watchers_panel.onItemRemoved.connect(
                self._on_watcher_removeditem)
            self.watchers_panel.onItemAdded.connect(self._on_watcher_added)
            self.watchers_dwidget.setWidget(self.watchers_panel)
            self.watchers_dwidget.setObjectName('WatchersPanel')
            self.addDockWidget(Qt.LeftDockWidgetArea, self.watchers_dwidget)
            self.view_menu.addAction(self.watchers_dwidget.toggleViewAction())
        elif elem == 'hooks':
            from ui.panel_hooks import HooksPanel
            self.hooks_dwiget = QDockWidget('Breakpoints', self)
            self.hooks_panel = HooksPanel(self)
            self.hooks_panel.onShowMemoryRequest.connect(
                self._on_watcher_clicked)
            self.hooks_panel.onHookRemoved.connect(self._on_hook_removed)
            self.hooks_dwiget.setWidget(self.hooks_panel)
            self.hooks_dwiget.setObjectName('HooksPanel')
            self.addDockWidget(Qt.LeftDockWidgetArea, self.hooks_dwiget)
            self.view_menu.addAction(self.hooks_dwiget.toggleViewAction())
        elif elem == 'bookmarks':
            from ui.panel_bookmarks import BookmarksPanel
            self.bookmarks_dwiget = QDockWidget('Boomarks', self)
            self.bookmarks_panel = BookmarksPanel(self)
            self.bookmarks_panel.onShowMemoryRequest.connect(
                self._on_watcher_clicked)
            self.bookmarks_dwiget.setWidget(self.bookmarks_panel)
            self.bookmarks_dwiget.setObjectName('BookmarksPanel')
            self.addDockWidget(Qt.LeftDockWidgetArea, self.bookmarks_dwiget)
            self.view_menu.addAction(self.bookmarks_dwiget.toggleViewAction())
        elif elem == 'registers':
            from ui.panel_context import ContextPanel
            self.registers_dock = QDockWidget('Context', self)
            self.context_panel = ContextPanel(self)
            self.registers_dock.setWidget(self.context_panel)
            self.registers_dock.setObjectName('ContextsPanel')
            self.addDockWidget(Qt.RightDockWidgetArea, self.registers_dock)
            self.view_menu.addAction(self.registers_dock.toggleViewAction())
        elif elem == 'memory':
            from ui.panel_memory import MemoryPanel
            self.memory_panel = MemoryPanel(self)
            self.memory_panel.onShowDisassembly.connect(
                self._disassemble_range)
            self.memory_panel.dataChanged.connect(self._on_memory_modified)
            self.memory_panel.statusChanged.connect(self.set_status_text)
            self.main_tabs.addTab(self.memory_panel, 'Memory')
        elif elem == 'jvm-debugger':
            from ui.panel_java_explorer import JavaExplorerPanel
            self.java_explorer_panel = JavaExplorerPanel(self)
            self.main_tabs.addTab(self.java_explorer_panel, 'JVM debugger')
            self.main_tabs.tabBar().moveTab(
                self.main_tabs.indexOf(self.java_explorer_panel), 1)
        elif elem == 'jvm-inspector':
            from ui.panel_java_inspector import JavaInspector
            self.java_inspector_panel = JavaInspector(self)
            self.main_tabs.addTab(self.java_inspector_panel, 'JVM inspector')
        elif elem == 'console':
            from ui.panel_console import ConsolePanel
            self.console_dock = QDockWidget('Console', self)
            self.console_panel = ConsolePanel(self)
            self.dwarf.onLogToConsole.connect(self._log_js_output)
            self.console_dock.setWidget(self.console_panel)
            self.console_dock.setObjectName('ConsolePanel')
            self.addDockWidget(Qt.BottomDockWidgetArea, self.console_dock)
            self.view_menu.addAction(self.console_dock.toggleViewAction())
        elif elem == 'backtrace':
            from ui.panel_backtrace import BacktracePanel
            self.backtrace_dock = QDockWidget('Backtrace', self)
            self.backtrace_panel = BacktracePanel(self)
            self.backtrace_dock.setWidget(self.backtrace_panel)
            self.backtrace_dock.setObjectName('BacktracePanel')
            self.backtrace_panel.onShowMemoryRequest.connect(
                self._on_watcher_clicked)
            self.addDockWidget(Qt.RightDockWidgetArea, self.backtrace_dock)
            self.view_menu.addAction(self.backtrace_dock.toggleViewAction())
        elif elem == 'threads':
            from ui.panel_contexts_list import ContextsListPanel
            self.threads_dock = QDockWidget('Threads', self)
            self.contexts_list_panel = ContextsListPanel(self)
            self.dwarf.onThreadResumed.connect(
                self.contexts_list_panel.resume_tid)
            self.contexts_list_panel.onItemDoubleClicked.connect(
                self._manually_apply_context)
            self.threads_dock.setWidget(self.contexts_list_panel)
            self.threads_dock.setObjectName('ThreadPanel')
            self.addDockWidget(Qt.RightDockWidgetArea, self.threads_dock)
            self.view_menu.addAction(self.threads_dock.toggleViewAction())
        elif elem == 'modules':
            from ui.panel_modules import ModulesPanel
            self.modules_panel = ModulesPanel(self)
            self.modules_panel.onModuleSelected.connect(
                self._on_module_dblclicked)
            self.modules_panel.onModuleFuncSelected.connect(
                self._on_modulefunc_dblclicked)
            self.modules_panel.onAddHook.connect(self._on_addmodule_hook)
            self.modules_panel.onDumpBinary.connect(self._on_dumpmodule)
            self.main_tabs.addTab(self.modules_panel, 'Modules')
        elif elem == 'ranges':
            from ui.panel_ranges import RangesPanel
            self.ranges_panel = RangesPanel(self)
            self.ranges_panel.onItemDoubleClicked.connect(
                self._range_dblclicked)
            self.ranges_panel.onDumpBinary.connect(self._on_dumpmodule)
            # connect to watcherpanel func
            self.ranges_panel.onAddWatcher.connect(
                self.watchers_panel.do_addwatcher_dlg)
            self.main_tabs.addTab(self.ranges_panel, 'Ranges')
        elif elem == 'search':
            from ui.panel_search import SearchPanel
            self.search_panel = SearchPanel(self)
            self.search_panel.onShowMemoryRequest.connect(
                self._on_watcher_clicked)
            self.main_tabs.addTab(self.search_panel, 'Search')
        elif elem == 'data':
            from ui.panel_data import DataPanel
            self.data_panel = DataPanel(self)
            self.main_tabs.addTab(self.data_panel, 'Data')
        elif elem == 'trace':
            from ui.panel_trace import TracePanel
            self.trace_panel = TracePanel(self)
            self.main_tabs.addTab(self.trace_panel, 'Trace')
        elif elem == 'disassembly':
            from ui.widgets.disasm_view import DisassemblyView
            self.asm_panel = DisassemblyView(self)
            self.asm_panel.onShowMemoryRequest.connect(self._on_disasm_showmem)
            self.main_tabs.addTab(self.asm_panel, 'Disassembly')
        elif elem == 'emulator':
            from ui.panel_emulator import EmulatorPanel
            self.emulator_panel = EmulatorPanel(self)
            self.main_tabs.addTab(self.emulator_panel, 'Emulator')
        elif elem == 'java-trace':
            from ui.panel_java_trace import JavaTracePanel
            self.java_trace_panel = JavaTracePanel(self)
            self.main_tabs.addTab(self.java_trace_panel, 'JVM tracer')
        elif elem == 'smali':
            from ui.panel_smali import SmaliPanel
            self.smali_panel = SmaliPanel()
            self.main_tabs.addTab(self.smali_panel, 'Smali')
        else:
            print('no handler for elem: ' + elem)

        # make tabs unclosable and sort
        self._handle_tab_change()

        # TODO: remove add @2x
        for item in self.findChildren(QDockWidget):
            if item:
                if 'darwin' in sys.platform:
                    item.setStyleSheet(
                        'QDockWidget::title { padding-left:-30px; } QDockWidget::close-button, QDockWidget::float-button  { width: 10px; height:10px }'
                    )
Exemple #3
0
 def _create_ui_elem(self, elem):
     if elem == 'watchers':
         from ui.panel_watchers import WatchersPanel
         self.watchers_dwidget = QDockWidget('Watchers', self)
         self.watchers_panel = WatchersPanel(self)
         # dont respond to dblclick mem cant be shown
         # self.watchers_panel.onItemDoubleClicked.connect(
         #    self._on_watcher_clicked)
         self.watchers_panel.onItemRemoved.connect(
             self._on_watcher_removeditem)
         self.watchers_panel.onItemAdded.connect(self._on_watcher_added)
         self.watchers_dwidget.setWidget(self.watchers_panel)
         self.watchers_dwidget.setObjectName('WatchersPanel')
         self.addDockWidget(Qt.LeftDockWidgetArea, self.watchers_dwidget)
         self.view_menu.addAction(self.watchers_dwidget.toggleViewAction())
     elif elem == 'hooks':
         from ui.panel_hooks import HooksPanel
         self.hooks_dwiget = QDockWidget('Hooks', self)
         self.hooks_panel = HooksPanel(self)
         self.hooks_panel.onShowMemoryRequest.connect(
             self._on_watcher_clicked)
         self.hooks_panel.onHookRemoved.connect(self._on_hook_removed)
         self.hooks_dwiget.setWidget(self.hooks_panel)
         self.hooks_dwiget.setObjectName('HooksPanel')
         self.addDockWidget(Qt.LeftDockWidgetArea, self.hooks_dwiget)
         self.view_menu.addAction(self.hooks_dwiget.toggleViewAction())
     elif elem == 'registers':
         from ui.panel_context import ContextPanel
         self.registers_dock = QDockWidget('Context', self)
         self.context_panel = ContextPanel(self)
         self.registers_dock.setWidget(self.context_panel)
         self.registers_dock.setObjectName('ContextsPanel')
         self.addDockWidget(Qt.RightDockWidgetArea, self.registers_dock)
         self.view_menu.addAction(self.registers_dock.toggleViewAction())
     elif elem == 'memory':
         from ui.panel_memory import MemoryPanel
         self.memory_panel = MemoryPanel(self)
         self.memory_panel.onShowDisassembly.connect(
             self._disassemble_range)
         self.memory_panel.dataChanged.connect(self._on_memory_modified)
         self.memory_panel.statusChanged.connect(self.set_status_text)
         self.main_tabs.addTab(self.memory_panel, 'Memory')
     elif elem == 'javaexplorer':
         from ui.panel_java_explorer import JavaExplorerPanel
         self.java_explorer_panel = JavaExplorerPanel(self)
         self.main_tabs.addTab(self.java_explorer_panel, 'JavaExplorer')
     elif elem == 'java-inspector':
         from ui.panel_java_inspector import JavaInspector
         self.java_inspector_panel = JavaInspector(self)
         self.main_tabs.addTab(self.java_inspector_panel, 'Java Inspector')
     elif elem == 'console':
         from ui.panel_console import ConsolePanel
         self.console_dock = QDockWidget('Console', self)
         self.console_panel = ConsolePanel(self)
         self.dwarf.onLogToConsole.connect(self._log_js_output)
         self.console_dock.setWidget(self.console_panel)
         self.console_dock.setObjectName('ConsolePanel')
         self.addDockWidget(Qt.BottomDockWidgetArea, self.console_dock)
         self.view_menu.addAction(self.console_dock.toggleViewAction())
     elif elem == 'backtrace':
         from ui.panel_backtrace import BacktracePanel
         self.backtrace_panel = BacktracePanel(self)
         # splitter.addWidget(self.backtrace_panel)
     elif elem == 'threads':
         from ui.panel_contexts_list import ContextsListPanel
         self.threads_dock = QDockWidget('Threads', self)
         self.contexts_list_panel = ContextsListPanel(self)
         self.dwarf.onThreadResumed.connect(
             self.contexts_list_panel.resume_tid)
         self.contexts_list_panel.onItemDoubleClicked.connect(
             self._apply_context)
         self.threads_dock.setWidget(self.contexts_list_panel)
         self.threads_dock.setObjectName('ThreadPanel')
         self.addDockWidget(Qt.RightDockWidgetArea, self.threads_dock)
         self.view_menu.addAction(self.threads_dock.toggleViewAction())
     elif elem == 'modules':
         from ui.panel_modules import ModulesPanel
         self.modules_panel = ModulesPanel(self)
         self.modules_panel.onModuleSelected.connect(
             self._on_module_dblclicked)
         self.modules_panel.onModuleFuncSelected.connect(
             self._on_modulefunc_dblclicked)
         self.modules_panel.onAddHook.connect(self._on_addmodule_hook)
         self.modules_panel.onDumpBinary.connect(self._on_dumpmodule)
         self.main_tabs.addTab(self.modules_panel, 'Modules')
     elif elem == 'ranges':
         from ui.panel_ranges import RangesPanel
         self.ranges_panel = RangesPanel(self)
         self.ranges_panel.onItemDoubleClicked.connect(
             self._range_dblclicked)
         self.ranges_panel.onDumpBinary.connect(self._on_dumpmodule)
         # connect to watcherpanel func
         self.ranges_panel.onAddWatcher.connect(
             self.watchers_panel.do_addwatcher_dlg)
         self.main_tabs.addTab(self.ranges_panel, 'Ranges')
     elif elem == 'data':
         from ui.panel_data import DataPanel
         self.data_panel = DataPanel(self)
         self.main_tabs.addTab(self.data_panel, 'Data')
     elif elem == 'trace':
         from ui.panel_trace import TracePanel
         self.trace_panel = TracePanel(self)
         self.main_tabs.addTab(self.trace_panel, 'Trace')
     elif elem == 'disassembly':
         from ui.disasm_view import DisassemblyView
         self.asm_panel = DisassemblyView(self)
         self.asm_panel.onShowMemoryRequest.connect(self._on_disasm_showmem)
         self.main_tabs.addTab(self.asm_panel, 'Disassembly')
     elif elem == 'emulator':
         from ui.panel_emulator import EmulatorPanel
         self.emulator_panel = EmulatorPanel(self)
         self.main_tabs.addTab(self.emulator_panel, 'Emulator')
     elif elem == 'java-trace':
         from ui.panel_java_trace import JavaTracePanel
         self.java_trace_panel = JavaTracePanel(self)
         self.main_tabs.addTab(self.java_trace_panel, 'Java-Trace')
     elif elem == 'smali':
         from ui.panel_smali import SmaliPanel
         self.smali_panel = SmaliPanel()
         self.main_tabs.addTab(self.smali_panel, 'Smali')
     else:
         print('no handler for elem: ' + elem)
Exemple #4
0
    def __init__(self, app, *__args):
        super().__init__(*__args)

        self.app = app
        self.emulator = self.app.get_dwarf().get_emulator()
        self.until_address = 0

        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)

        buttons = QHBoxLayout()
        self.btn_start = QPushButton('start')
        self.btn_start.clicked.connect(self.handle_start)
        self.btn_step = QPushButton('step')
        self.btn_step.clicked.connect(self.handle_step)
        self.btn_stop = QPushButton('stop')
        self.btn_stop.clicked.connect(self.handle_stop)
        self.btn_stop.setEnabled(False)
        self.btn_clean = QPushButton('clean')
        self.btn_clean.clicked.connect(self.handle_clean)
        self.btn_clean.setEnabled(False)
        self.btn_options = QPushButton('options')
        self.btn_options.clicked.connect(self.handle_options)
        buttons.addWidget(self.btn_start)
        buttons.addWidget(self.btn_step)
        buttons.addWidget(self.btn_stop)
        buttons.addWidget(self.btn_clean)
        buttons.addWidget(self.btn_options)
        layout.addLayout(buttons)

        splitter = QSplitter()
        splitter.setHandleWidth(1)
        splitter.setOrientation(Qt.Vertical)

        self.panel = QSplitter()
        self.panel.setHandleWidth(1)
        self.panel.setOrientation(Qt.Horizontal)

        self.central_panel = QSplitter()
        self.central_panel.setHandleWidth(1)
        self.central_panel.setOrientation(Qt.Vertical)

        self.asm_table = AsmTableWidget(self.app)
        self.memory_table = MemoryTableWidget(self.app)

        self.ranges_list = QListWidget(self.app)
        self.ranges_list.itemDoubleClicked.connect(
            self.ranges_item_double_clicked)

        from ui.panel_context import ContextPanel
        self.context_panel = ContextPanel(self.app)

        self.tabs = QTabWidget()
        self.tabs.addTab(self.asm_table, 'asm')
        self.tabs.addTab(self.memory_table, 'hex')

        self.central_panel.addWidget(self.context_panel)
        self.central_panel.addWidget(self.tabs)

        self.central_panel.setStretchFactor(0, 1)
        self.central_panel.setStretchFactor(1, 3)

        self.panel.addWidget(self.ranges_list)
        self.panel.addWidget(self.central_panel)

        self.panel.setStretchFactor(0, 1)
        self.panel.setStretchFactor(1, 4)
        splitter.addWidget(self.panel)

        self.console = QConsoleWidget(self.app)
        splitter.addWidget(self.console)

        splitter.setStretchFactor(0, 3)
        splitter.setStretchFactor(1, 1)
        layout.addWidget(splitter)
        self.setLayout(layout)

        self.app.get_dwarf().get_bus().add_event(self.on_emulator_start,
                                                 'emulator_start')
        self.app.get_dwarf().get_bus().add_event(self.on_emulator_stop,
                                                 'emulator_stop')
        self.app.get_dwarf().get_bus().add_event(self.on_emulator_hook,
                                                 'emulator_hook')
        self.app.get_dwarf().get_bus().add_event(self.on_emulator_memory_hook,
                                                 'emulator_memory_hook')
        self.app.get_dwarf().get_bus().add_event(
            self.on_emulator_memory_range_mapped,
            'emulator_memory_range_mapped')
        self.app.get_dwarf().get_bus().add_event(self.on_emulator_log,
                                                 'emulator_log')