Beispiel #1
0
    def _init_widgets(self):

        window = QMainWindow()
        window.setWindowFlags(Qt.Widget)

        # pseudo code text box
        self._textedit = QCCodeEdit(self)
        self._textedit.setTextInteractionFlags(Qt.TextSelectableByKeyboard
                                               | Qt.TextSelectableByMouse)
        self._textedit.setLineWrapMode(QCCodeEdit.NoWrap)
        textedit_dock = QDockWidget('Code', self._textedit)
        window.setCentralWidget(textedit_dock)
        textedit_dock.setWidget(self._textedit)

        # decompilation
        self._options = QDecompilationOptions(self,
                                              self.workspace.instance,
                                              options=None)
        options_dock = QDockWidget('Decompilation Options', self._options)
        window.addDockWidget(Qt.RightDockWidgetArea, options_dock)
        options_dock.setWidget(self._options)

        layout = QHBoxLayout()
        layout.addWidget(window)
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)

        self.workspace.plugins.instrument_code_view(self)
Beispiel #2
0
    def __init__(self, workspace, *args, **kwargs):
        super().__init__("interaction console", workspace, *args, **kwargs)

        self.base_caption = "Interaction Console"
        self.workspace = workspace
        self.target = None
        self.conversations = {}
        self.terminal = TerminalWidget(command=None)
        self.analyzer = None
        self.interaction_context = None

        main_layout = QVBoxLayout()
        controls_layout = QHBoxLayout()

        connect_button = QPushButton()
        connect_button.setText("Connect")
        connect_button.clicked.connect(self.connect)
        controls_layout.addWidget(connect_button)

        terminal_window = QMainWindow()
        terminal_window.setWindowFlags(Qt.Widget)
        terminal_window.setCentralWidget(self.terminal)

        main_layout.addLayout(controls_layout)
        main_layout.addWidget(terminal_window)

        self.setLayout(main_layout)
    def _init_widgets(self):

        main = QMainWindow()
        main.setWindowFlags(Qt.Widget)

        # main.setCorner(Qt.TopLeftCorner, Qt.TopDockWidgetArea)
        # main.setCorner(Qt.TopRightCorner, Qt.RightDockWidgetArea)

        pathtree = QPathTree(self.current_simgr, self.current_state, self, self.workspace, parent=main)
        pathtree_dock = QDockWidget('PathTree', pathtree)
        main.setCentralWidget(pathtree_dock)
        # main.addDockWidget(Qt.BottomDockWidgetArea, pathtree_dock)
        pathtree_dock.setWidget(pathtree)

        simgrs = QSimulationManagers(self.workspace.instance, self.current_simgr, self.current_state, parent=main)
        simgrs_dock = QDockWidget('SimulationManagers', simgrs)
        main.addDockWidget(Qt.RightDockWidgetArea, simgrs_dock)
        simgrs_dock.setWidget(simgrs)

        state_viewer = StateInspector(self.workspace, self.current_state, parent=self)
        state_viewer_dock = QDockWidget('Selected State', state_viewer)
        main.addDockWidget(Qt.RightDockWidgetArea, state_viewer_dock)
        state_viewer_dock.setWidget(state_viewer)

        self._pathtree = pathtree
        self._simgrs = simgrs
        self._state_viewer = state_viewer

        main_layout = QHBoxLayout()
        main_layout.addWidget(main)
        main_layout.setContentsMargins(0, 0, 0, 0)

        self.setLayout(main_layout)
Beispiel #4
0
def entry():
    print("Running yorick.py..")

    global qtwindow

    qtwindow = QMainWindow()
    qtwindow.setWindowFlags(Qt.WindowStaysOnTopHint)

    # initialize
    Biped2Bone(qtwindow)
    qtwindow.show()
Beispiel #5
0
def create_window(IMG_PATH):
    #initial window creation
    app = QApplication([])
    qpix = QPixmap(IMG_PATH)
    w, h = get_screen_dim(app.desktop())
    qpix, iw, ih = scale_qpix(qpix, w, h)
    window = QMainWindow()
    window.resize(w, h)
    window.setWindowFlags(Qt.WindowStaysOnBottomHint | Qt.FramelessWindowHint)
    bg = QBackgroundImage(window, w, h)
    bg.setBackground(qpix, iw, ih)
    window.show()

    sys.exit(app.exec_())
Beispiel #6
0
    def __init__(self, window: QMainWindow, vscreen: VScreen):
        self.window = window
        self.vscreen = vscreen

        window.setWindowFlags(Qt.Window
                              | Qt.MSWindowsFixedSizeDialogHint
                              | Qt.WindowMinimizeButtonHint
                              | Qt.WindowCloseButtonHint
                              | Qt.CustomizeWindowHint)

        self.centralWidget = QWidget()
        self.centralWidget.setLayout(QVBoxLayout())
        self.centralWidget.layout().setContentsMargins(0, 0, 0, 0)
        window.setCentralWidget(self.centralWidget)

        self.monitor_overview_widget = VScreenOverview(vscreen, window)
        self.centralWidget.layout().addWidget(self.monitor_overview_widget)

        self.sub_widget = QWidget()
        self.sub_layout = QVBoxLayout()
        self.sub_widget.setLayout(self.sub_layout)
        self.centralWidget.layout().addWidget(self.sub_widget)

        self.monitor_info_group = QGroupBox()
        self.monitor_info_group.setLayout(QHBoxLayout())

        for monitor in self.vscreen.monitor_order:
            info_box = QGroupBox("Monitor Information")
            info_box.ui = UiMonitorInfoBox(info_box, monitor)
            self.monitor_info_group.layout().addWidget(info_box)
        self.sub_layout.addWidget(self.monitor_info_group)

        self.button_group = QDialogButtonBox(Qt.Horizontal)
        self.button_group.setStyleSheet('* { button-layout: 2 }')
        self.close_button = self.button_group.addButton("Close", QDialogButtonBox.RejectRole)
        self.adjust_button = self.button_group.addButton("Adjust", QDialogButtonBox.ActionRole)
        self.about_button = self.button_group.addButton("About", QDialogButtonBox.HelpRole)
        self.sub_layout.addWidget(self.button_group)

        self.translate_ui()
    def _init_widgets(self):
        self._linear_viewer = QLinearDisassembly(self.workspace, self, parent=self)
        self._flow_graph = QDisassemblyGraph(self.workspace, self, parent=self)
        self._feature_map = QFeatureMap(self, parent=self)
        self._statusbar = QDisasmStatusBar(self, parent=self)

        vlayout = QVBoxLayout()
        vlayout.addWidget(self._feature_map)
        vlayout.addWidget(self._flow_graph)
        vlayout.addWidget(self._linear_viewer)
        vlayout.addWidget(self._statusbar)
        vlayout.setContentsMargins(0, 0, 0, 0)

        self._feature_map.setMaximumHeight(25)
        vlayout.setStretchFactor(self._feature_map, 0)
        vlayout.setStretchFactor(self._flow_graph, 1)
        vlayout.setStretchFactor(self._linear_viewer, 1)
        vlayout.setStretchFactor(self._statusbar, 0)

        hlayout = QHBoxLayout()
        hlayout.addLayout(vlayout)

        base = QWidget()
        base.setLayout(hlayout)

        main_window = QMainWindow()
        main_window.setWindowFlags(Qt.Widget)
        main_window.setCentralWidget(base)
        self.main_window = main_window

        main_layout = QHBoxLayout()
        main_layout.addWidget(main_window)

        self.setLayout(main_layout)

        self.display_disasm_graph()
        # self.display_linear_viewer()

        self.workspace.plugins.instrument_disassembly_view(self)
class SeedTableView(BaseView):
    def __init__(self, workspace: Workspace, *args, **kwargs):
        super().__init__("SeedTableView", workspace, *args, **kwargs)
        self.base_caption = "Seed Table"
        self.workspace = workspace
        self.instance = workspace.instance
        workspace.instance.project.am_subscribe(self.on_project_load)
        self._init_widgets()

    def page_changed(self, i):
        self.table_data.set_page(self.page_dropdown.currentIndex() + 1)

    def _init_widgets(self):
        self.main = QMainWindow()
        self.main.setWindowFlags(Qt.Widget)

        self.container = QWidget()  # create containing widget to keep things nice
        self.container.setLayout(QVBoxLayout())

        # count label
        self.seed_count_label = QLabel("Count:")

        # create table
        self.page_dropdown = QComboBox()
        self.table = SeedTableWidget(self, self.workspace)
        self.table_data = SeedTableModel(self.workspace, self.table, self.page_dropdown, self.seed_count_label)
        self.table.setModel(self.table_data)
        self.table.init_parameters()  # need to set table model before messing with column resizing
        self.container.layout().addWidget(self.table)

        # create bottom section
        self.bottom_widget = QWidget()
        self.bottom_widget.setLayout(QHBoxLayout())
        # page buttons
        self.next_page_btn = QPushButton(">")
        self.next_page_btn.setMaximumWidth(40)
        self.next_page_btn.clicked.connect(self.table_data.go_next_page)
        self.prev_page_btn = QPushButton("<")
        self.prev_page_btn.setMaximumWidth(40)
        self.prev_page_btn.clicked.connect(self.table_data.go_prev_page)
        # page label
        self.page_label = QLabel("Page:")
        # page dropdown
        self.page_dropdown.addItems(list(map(str, range(1, 1))))  # test
        self.page_dropdown.setCurrentIndex(0)
        self.page_dropdown.activated.connect(self.page_changed)
        # filter box
        self.filter_box = SeedTableFilterBox(self)
        self.filter_box.returnPressed.connect(self._on_filter_change)
        # filter checkboxes
        # "NC", "C", "NT", "L", "E"
        self.nc_checkbox = QCheckBox("NC")
        self.nc_checkbox.stateChanged.connect(self._on_filter_change)
        self.c_checkbox = QCheckBox("C")
        self.c_checkbox.stateChanged.connect(self._on_filter_change)
        self.nt_checkbox = QCheckBox("NT")
        self.nt_checkbox.stateChanged.connect(self._on_filter_change)
        self.l_checkbox = QCheckBox("L")
        self.l_checkbox.stateChanged.connect(self._on_filter_change)
        self.e_checkbox = QCheckBox("E")
        self.e_checkbox.stateChanged.connect(self._on_filter_change)


        self.bottom_widget.layout().addWidget(self.seed_count_label)
        self.bottom_widget.layout().addWidget(self.filter_box)
        self.bottom_widget.layout().addWidget(self.nc_checkbox)
        self.bottom_widget.layout().addWidget(self.c_checkbox)
        self.bottom_widget.layout().addWidget(self.nt_checkbox)
        self.bottom_widget.layout().addWidget(self.l_checkbox)
        self.bottom_widget.layout().addWidget(self.e_checkbox)
        # self.bottom_widget.layout().addStretch()
        self.bottom_widget.layout().addWidget(self.prev_page_btn)
        self.bottom_widget.layout().addWidget(self.page_label)
        self.bottom_widget.layout().addWidget(self.page_dropdown)
        self.bottom_widget.layout().addWidget(self.next_page_btn)

        self.container.layout().addWidget(self.bottom_widget)

        self.main.setCentralWidget(self.container)
        main_layout = QVBoxLayout()
        main_layout.addWidget(self.main)
        self.setLayout(main_layout)

    def on_project_load(self, **kwargs):
        if self.instance.project.am_none:
            return
        pass

    def _on_filter_change(self):
        raw_filter = self.filter_box.text()
        inp = None
        if len(raw_filter) > 0:
            inp, _ = codecs.escape_decode(raw_filter, 'hex')
        flags = []
        if self.nc_checkbox.isChecked():
            flags.append("non-crashing")
        if self.c_checkbox.isChecked():
            flags.append("crashing")
        if self.l_checkbox.isChecked():
            flags.append("leaking")
        if self.nt_checkbox.isChecked():
            flags.append("non-terminating")
        if self.e_checkbox.isChecked():
            flags.append("exploit")

        self.table_data.clear_seeds()
        if len(flags) == 0 and inp is None:
            data = self.table_data.seed_db.get_all_seeds()
        else:
            if inp:
                data = self.table_data.seed_db.filter_seeds_by_value(inp)
                data = list(filter(lambda s: all([x in s.tags for x in flags]), data))
            else:
                data = self.table_data.seed_db.filter_seeds_by_tag(tags=flags)
        self.table_data.add_seed(data)
    def _init_widgets(self):
        main = QMainWindow()
        main.setWindowFlags(Qt.Widget)

        carttree = QProgramTree(self.workspace)
        self._carttree = carttree
        carttree_dock = QDockWidget("Cartprograph Tree", carttree)
        main.setCentralWidget(carttree_dock)
        carttree_dock.setWidget(carttree)

        # TODO: THIS NEEDS A REFACTOR.. BAD
        # BEGIN CONSOLE VIEW ASSEMBLY
        console_view = self.workspace.view_manager.first_view_in_category(
            "console")
        self.console_tabs = console_view.tab_widget = QTabWidget()
        console_view.tab_widget.setTabPosition(QTabWidget.South)
        console_view.ipython_tab = QWidget()
        console_view.ipython_tab.setLayout(
            QHBoxLayout(console_view.ipython_tab))
        console_view.tab_layout = QHBoxLayout()
        console_view.ipython_tab.layout().addWidget(
            console_view._ipython_widget)
        console_view.tab_widget.addTab(console_view.ipython_tab, "Console")
        console_view.tab_layout.addWidget(console_view.tab_widget)
        console_view.layout().setContentsMargins(0, 0, 0, 0)
        console_view.layout().addLayout(console_view.tab_layout)
        console_view.min_size = QSize(0, 125)
        console_view._ipython_widget.push_namespace(
            {"cartprograph": self.workspace.cartprograph})
        console_group = QtWidgets.QGroupBox()
        console_group.setLayout(QtWidgets.QVBoxLayout(console_group))

        self.console_output = QPlainTextEdit()
        self.console_output.setReadOnly(True)
        console_group.layout().addWidget(self.console_output)

        self.console_input = QLineEdit()
        console_group.layout().addWidget(self.console_input)
        self.console_input.returnPressed.connect(
            lambda: self.workspace.cartprograph.client.send_input(
                self.selected_item_id,
                self.console_input.text() + "\n"))
        self.workspace.view_manager.first_view_in_category(
            "console").tab_widget.addTab(console_group, "Cartprograph Console")
        # END CONSOLE VIEW ASSEMBLY

        # BEGIN TAB VIEW ASSEMBLY
        func_view = self.workspace.view_manager.first_view_in_category(
            "functions")
        self.func_tabs = func_view.tab_widget = QTabWidget()
        funcview_container = QWidget()
        funcview_container.setLayout(QVBoxLayout(funcview_container))
        func_tabs_layout = QHBoxLayout()
        funcview_container.layout().addWidget(func_view._function_table)
        funcview_container.layout().addWidget(func_view._status_label)
        func_view.tab_widget.addTab(funcview_container, "Functions")
        func_tabs_layout.addWidget(func_view.tab_widget)
        func_view.layout().setContentsMargins(0, 0, 0, 0)
        func_view.layout().addLayout(func_tabs_layout)

        table_tabs = QTabWidget()
        table_functab = QWidget()
        table_functab.setLayout(QVBoxLayout(table_functab))
        table_blocktab = QWidget()
        table_blocktab.setLayout(QVBoxLayout(table_blocktab))
        table_datapoint_tab = QWidget()
        table_datapoint_tab.setLayout(QVBoxLayout(table_datapoint_tab))
        table_watchertab = QWidget()
        table_watchertab.setLayout(QVBoxLayout(table_watchertab))

        self.functable = QTableWidget()
        self.functable.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.functable.setSizeAdjustPolicy(
            QtWidgets.QAbstractScrollArea.AdjustToContents)
        table_tabs.addTab(table_functab, "Syscalls")
        table_functab.layout().addWidget(self.functable)

        self.blocktable = QTableWidget()
        self.blocktable.setEditTriggers(QAbstractItemView.NoEditTriggers)
        table_tabs.addTab(table_blocktab, "Basic Blocks")
        table_blocktab.layout().addWidget(self.blocktable)
        self.blocktable.cellDoubleClicked.connect(self._handle_table_click)

        self.datapoint_table = QTableWidget()
        self.datapoint_table.setEditTriggers(QAbstractItemView.NoEditTriggers)
        table_tabs.addTab(table_datapoint_tab, "Datapoints")
        table_datapoint_tab.layout().addWidget(self.datapoint_table)

        self.watcherlist = QListWidget()

        table_tabs.addTab(table_watchertab, "Watchers")
        table_watchertab.layout().addWidget(self.watcherlist)
        self.watcherRefreshButton = QPushButton("Refresh")
        table_watchertab.layout().addWidget(self.watcherRefreshButton)

        self.watcherlist.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.watcherlist.customContextMenuRequested.connect(
            self._watcher_context_menu)
        self.watcherlist.itemDoubleClicked.connect(self._handle_watcher_click)
        self.watcherlist.itemChanged.connect(self._handle_watcher_change)

        self.watcherRefreshButton.clicked.connect(self._fire_watcher_update)

        func_view.tab_widget.addTab(table_tabs, "Cartprograph")

        # END TAB VIEW ASSEMBLY

        main_layout = QVBoxLayout()

        main_layout.addWidget(main)
        self.setLayout(main_layout)