コード例 #1
0
    def PopulateForm(self):
        ### init widgets
        # model
        self.sim = QtGui.QStandardItemModel()
        self.sim.setHorizontalHeaderLabels(
            ['ThreadId', 'Address', 'Disasm', 'Stack Comment', 'CPU Context'])

        # toolbar
        self.ftb = QtWidgets.QToolBar()
        self.stb = QtWidgets.QToolBar()

        # tree view
        self.treeView = QtWidgets.QTreeView()
        self.treeView.setToolTip('Double click a grade to filter')
        self.treeView.setExpandsOnDoubleClick(True)
        self.treeView.setSortingEnabled(False)
        self.treeView.setSelectionBehavior(
            QtWidgets.QAbstractItemView.SelectRows)
        # Context menus
        self.treeView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.treeView.customContextMenuRequested.connect(
            self.OnCustomContextMenu)

        self.treeView.doubleClicked.connect(self.ItemDoubleClickSlot)
        self.treeView.setModel(self.sim)

        ### populate widgets
        # fill model with data
        self.PopulateModel(0)
        # finalize layout
        layout = QtWidgets.QGridLayout()
        layout.addWidget(self.treeView)

        self.parent.setLayout(layout)
コード例 #2
0
    def PopulateForm(self):
        ### init widgets
        # model
        self.sim = QtGui.QStandardItemModel()
        self.sim.setHorizontalHeaderLabels(
            ['ThreadId', 'Address', 'Disasm', 'Stack Comment', 'CPU Context'])

        # toolbar
        self.utb = QtWidgets.QToolBar()
        self.ltb = QtWidgets.QToolBar()
        # tree view
        self.treeView = QtWidgets.QTreeView()
        self.treeView.setExpandsOnDoubleClick(True)
        self.treeView.setSortingEnabled(False)
        self.treeView.setSelectionBehavior(
            QtWidgets.QAbstractItemView.SelectRows)
        self.treeView.setToolTip(
            'Highlights:\n Rust red - Input\n Violet - Output\n Olive - Both')

        ### populate widgets
        # fill model with data
        self.PopulateModel()
        # fill toolbar with data
        self.PopulateUpperToolbar()
        self.PopulateLowerToolbar()
        self.treeView.setModel(self.sim)
        # finalize layout
        layout = QtWidgets.QGridLayout()
        layout.addWidget(self.utb)
        layout.addWidget(self.treeView)
        layout.addWidget(self.ltb)

        self.parent.setLayout(layout)
コード例 #3
0
    def PopulateForm(self):
        ### init widgets
        # model
        self.sim = QtGui.QStandardItemModel()

        # tree view
        self.treeView = QtWidgets.QTreeView()
        self.treeView.setExpandsOnDoubleClick(True)
        self.treeView.setSortingEnabled(False)
        self.treeView.setSelectionBehavior(
            QtWidgets.QAbstractItemView.SelectRows)
        self.treeView.setToolTip(
            'Filter instructions/clusters/basic blocks from trace by double clicking on them.'
        )
        # Context menus
        self.treeView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.treeView.customContextMenuRequested.connect(
            self.OnCustomContextMenu)

        self.treeView.doubleClicked.connect(self.ItemDoubleClickSlot)
        self.treeView.setModel(self.sim)

        ### populate widgets
        # fill model with data
        self.PopulateModel()

        # self.treeView.setFirstColumnSpanned(0, self.treeView.rootIndex(), True)
        # finalize layout
        layout = QtWidgets.QGridLayout()
        layout.addWidget(self.treeView)

        self.parent.setLayout(layout)
コード例 #4
0
    def PopulateForm(self):
        ### init widgets
        # model
        self.sim = QtGui.QStandardItemModel()
        self.sim.setHorizontalHeaderLabels([
            'Stack Address', 'Address Mapped to CPU Reg',
            'Value Changes during Execution'
        ])

        # tree view
        self.treeView = QtWidgets.QTreeView()
        self.treeView.setExpandsOnDoubleClick(True)
        self.treeView.setSortingEnabled(False)
        self.treeView.setSelectionBehavior(
            QtWidgets.QAbstractItemView.SelectRows)

        ### populate widgets
        # fill model with data
        self.PopulateModel()

        self.treeView.setModel(self.sim)
        # finalize layout
        layout = QtWidgets.QGridLayout()
        layout.addWidget(self.treeView)

        self.parent.setLayout(layout)
コード例 #5
0
 def PopulateUpperToolbar(self):
     assert isinstance(self.input, set)
     self.utb.addWidget(
         QtWidgets.QLabel(
             'Input values found (check to highlight in trace): '))
     for value in self.input:
         self.ucb_map.append(QtWidgets.QCheckBox(value))
         self.ucb_map[-1].stateChanged.connect(self.OnValueChecked)
         self.utb.addWidget(self.ucb_map[-1])
         self.utb.addSeparator()
コード例 #6
0
 def PopulateSelectiveRegsToolbar(self):
     self.stb.addWidget(QtWidgets.QLabel('Selective Register Folding: '))
     assert isinstance(self.trace, Trace)
     if self.trace.ctx_reg_size == 32:
         for i in range(8):
             self.foldable_regs.append(
                 QtWidgets.QCheckBox(
                     get_reg_by_size(i, self.trace.ctx_reg_size)))
             self.foldable_regs[-1].stateChanged.connect(
                 lambda: self.FoldRegs())
             self.stb.addWidget(self.foldable_regs[-1])
             self.stb.addSeparator()
     elif self.trace.ctx_reg_size == 64:
         for i in range(16):
             self.foldable_regs.append(
                 QtWidgets.QCheckBox(
                     get_reg_by_size(i, self.trace.ctx_reg_size)))
             self.foldable_regs[-1].stateChanged.connect(
                 lambda: self.FoldRegs())
             self.stb.addWidget(self.foldable_regs[-1])
             self.stb.addSeparator()
コード例 #7
0
    def PopulateOptimizationsToolbar(self):
        self.ftb.addWidget(
            QtWidgets.QLabel(
                'Available Optimizations (check to run on trace): '))
        self.cpcb = QtWidgets.QCheckBox(optimization_names[0])
        self.cpcb.stateChanged.connect(lambda: self.OptimizeTrace(self.cpcb))
        self.ftb.addWidget(self.cpcb)
        self.ftb.addSeparator()

        self.sacb = QtWidgets.QCheckBox(optimization_names[1])
        self.sacb.stateChanged.connect(lambda: self.OptimizeTrace(self.sacb))
        self.ftb.addWidget(self.sacb)
        self.ftb.addSeparator()

        self.oscb = QtWidgets.QCheckBox(optimization_names[2])
        self.oscb.stateChanged.connect(lambda: self.OptimizeTrace(self.oscb))
        self.ftb.addWidget(self.oscb)
        self.ftb.addSeparator()

        self.uocb = QtWidgets.QCheckBox(optimization_names[3])
        self.uocb.stateChanged.connect(lambda: self.OptimizeTrace(self.uocb))
        self.ftb.addWidget(self.uocb)
        self.ftb.addSeparator()

        self.pcb = QtWidgets.QCheckBox(optimization_names[4])
        self.pcb.stateChanged.connect(lambda: self.OptimizeTrace(self.pcb))
        self.ftb.addWidget(self.pcb)
        self.ftb.addSeparator()
コード例 #8
0
    def OnCustomContextMenu(self, point):
        menu = QtWidgets.QMenu()
        # Actions
        action_undo = QtWidgets.QAction('Undo', self.treeView)
        action_undo.triggered.connect(self.Undo)
        action_restore = QtWidgets.QAction('Restore original trace',
                                           self.treeView)
        action_restore.triggered.connect(self.Restore)
        action_forward_to_clustering = QtWidgets.QAction(
            "Open in Clustering Analysis", self.treeView)
        action_forward_to_clustering.triggered.connect(self.ClusterForward)
        action_export_trace = QtWidgets.QAction('Export this trace...',
                                                self.treeView)
        action_export_trace.triggered.connect(self.SaveTrace)
        action_close_viewer = QtWidgets.QAction('Close Viewer', self.treeView)
        action_close_viewer.triggered.connect(lambda: self.Close(4))
        # add actions to menu
        menu.addAction(action_undo)
        menu.addAction(action_restore)
        menu.addAction(action_forward_to_clustering)
        menu.addAction(action_export_trace)
        menu.addSeparator()
        menu.addAction(action_close_viewer)

        menu.exec_(self.treeView.viewport().mapToGlobal(point))
コード例 #9
0
    def OnCustomContextMenu(self, point):
        menu = QtWidgets.QMenu()

        # Actions
        action_set_t = QtWidgets.QAction('Set grade threshold...',
                                         self.treeView)
        action_set_t.triggered.connect(self.SetThreshold)
        action_restore = QtWidgets.QAction('Show All', self.treeView)
        action_restore.triggered.connect(self.Restore)
        action_export_trace = QtWidgets.QAction('Export this trace...',
                                                self.treeView)
        action_export_trace.triggered.connect(self.SaveTrace)
        action_close_viewer = QtWidgets.QAction('Close Viewer', self.treeView)
        action_close_viewer.triggered.connect(lambda: self.Close(4))
        # add actions to menu
        menu.addAction(action_set_t)
        menu.addAction(action_restore)
        menu.addAction(action_export_trace)
        menu.addSeparator()
        menu.addAction(action_close_viewer)

        menu.exec_(self.treeView.viewport().mapToGlobal(point))
コード例 #10
0
    def OnCustomContextMenu(self, point):
        menu = QtWidgets.QMenu()
        init_index = self.treeView.indexAt(point)
        index = self.treeView.indexAt(point)
        level = 0
        while index.parent().isValid():
            index = index.parent()
            level += 1

        text = 'Remove Line'

        if level == 0:
            text = "Remove Cluster / Line"
        elif level == 1 and get_vmr().bb:
            text = "Remove Basic Block"
        elif level == 2:
            text = "Remove Line"
        try:
            action_remove = QtWidgets.QAction(text, self.treeView)
            action_remove.triggered.connect(
                lambda: self.ItemDoubleClickSlot(init_index))
            menu.addAction(action_remove)
            menu.addSeparator()
        except:
            print '[*] An Exception occured, remove action could not be added to the menu!'
        # Actions
        action_remove_threshold = QtWidgets.QAction(
            'Remove several clusters...', self.treeView)
        action_remove_threshold.triggered.connect(self.ClusterRemoval)
        action_undo = QtWidgets.QAction('Undo', self.treeView)
        action_undo.triggered.connect(self.Undo)
        action_restore = QtWidgets.QAction('Restore original trace',
                                           self.treeView)
        action_restore.triggered.connect(self.Restore)
        action_export_trace = QtWidgets.QAction('Export this trace ...',
                                                self.treeView)
        action_export_trace.triggered.connect(self.SaveTrace)
        action_close_viewer = QtWidgets.QAction('Close Viewer', self.treeView)
        action_close_viewer.triggered.connect(lambda: self.Close(4))

        # add actions to menu
        menu.addAction(action_remove_threshold)
        menu.addAction(action_undo)
        menu.addAction(action_restore)
        menu.addAction(action_export_trace)
        menu.addSeparator()
        menu.addAction(action_close_viewer)

        menu.exec_(self.treeView.viewport().mapToGlobal(point))