def __init__(self, parent, action):
        super(FuncSignProbDockWidget, self).__init__(parent, action)
        
        self.setObjectName("func_sign_probDockWidget")
        self.setWindowTitle("func_sign_prob DockWidget")

        self._multiWidget = QWidget()
        self._layout = QVBoxLayout()
        
        self._funcSignLabel = QLabel(self)
        self._progressBar = QProgressBar(self)
        self._disasTextEdit = QPlainTextEdit(self)
        
        self._layout.addWidget(self._funcSignLabel)
        self._layout.addWidget(self._progressBar)
        self._layout.addWidget(self._disasTextEdit)
        
        self._multiWidget.setLayout(self._layout);
        self.setWidget(self._multiWidget);
        
        self._userHomePath = os.path.expanduser('~')
        #print(f'user-home-path >{self._userHomePath}<')

        cutter.core().seekChanged.connect(self.update_contents)

        self.inferenceClass = InferenceClass(parent)
        self.inferenceClass.resultReady.connect(self.showInferenceResult)
        self.inferenceClass.summaryReady.connect(self.showInferenceResultSummary)
        self.inferenceClass.updateProgressBar.connect(self.updateProgressBar)
Ejemplo n.º 2
0
    def __init__(self, parent, action):
        super(FortuneWidget, self).__init__(parent, action)
        self.setObjectName("FancyDockWidgetFromCoolPlugin")
        self.setWindowTitle("Sample Python Plugin")

        content = QWidget()
        self.setWidget(content)

        # Create layout and label
        layout = QVBoxLayout(content)
        content.setLayout(layout)
        self.text = QLabel(content)
        self.text.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        self.text.setFont(cutter.Configuration.instance().getFont())
        layout.addWidget(self.text)

        button = QPushButton(content)
        button.setText("Want a fortune?")
        button.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        button.setMaximumHeight(50)
        button.setMaximumWidth(200)
        layout.addWidget(button)
        layout.setAlignment(button, Qt.AlignHCenter)

        button.clicked.connect(self.generate_fortune)
        cutter.core().seekChanged.connect(self.generate_fortune)

        self.show()
Ejemplo n.º 3
0
    def __init__(self, parent, action):
        try:
            super(AngrWidget, self).__init__(parent, action)
            register_debugger(cutterDebugger())
            self.stateMgr = None
            self.main = parent

            self.findAddrs = []
            self.avoidAddrs = []
            self.symAddrs = {}

            self.setObjectName("angr_cutter")
            self.setWindowTitle("AngrCutter")

            self.setupLayout()
            self.show()

            self.setupActions()

            self.startButton.clicked.connect(self.startExplore)
            self.applySimButton.clicked.connect(self.applySim)

            cutter.core().toggleDebugView.connect(self.debugStateChanged)
            cutter.core().refreshAll.connect(self.refreshAll)

        except Exception as e:
            printMessage(traceback.format_exc(), LogLevel.ERROR)
Ejemplo n.º 4
0
    def __init__(self, parent, action):
        """Initializes the widget gui."""
        super(YaraDockWidget, self).__init__(parent, action)
        self.setObjectName('Yara')
        self.setWindowTitle('Yara')

        self.table = QTableWidget(self)
        self.table.setShowGrid(False)
        self.table.verticalHeader().hide()

        self.table.setColumnCount(4)

        self.table.setHorizontalHeaderLabels(
            ['File Offset', 'String Content', 'Rule', 'Filename'])
        self.table.resizeColumnsToContents()
        self.table.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.table.setSelectionBehavior(QAbstractItemView.SelectRows)

        self.table.horizontalHeader().setSectionResizeMode(
            2, QHeaderView.Stretch)

        self.setWidget(self.table)

        cutter.core().seekChanged.connect(self.update_contents)
        self.update_contents()
Ejemplo n.º 5
0
    def connect_signals(self):

        QObject.connect(cutter.core(), SIGNAL("functionRenamed(RVA, QString)"),
                        self.model_data.refresh_function_names)
        QObject.connect(cutter.core(), SIGNAL("functionsChanged()"),
                        self.model_data.refresh_function_names)
        QObject.connect(cutter.core(), SIGNAL("seekChanged(RVA)"),
                        self.signal_shim_slot_checkbox_limit_by_changed)
    def __init__(self, parent, action):
        super(CheckOptionsDockWidget, self).__init__(parent, action)
        self.setObjectName("check_optionsDockWidget")
        self.setWindowTitle("Check options DockWidget")

        #self._label = QLabel(self)
        self._disasTextEdit = QPlainTextEdit(self)
        #self.setWidget(self._label)
        self.setWidget(self._disasTextEdit)

        #QObject.connect(cutter.core(), SIGNAL("seekChanged(RVA)"), self.update_contents)
        cutter.core().seekChanged.connect(self.update_contents)
        self.update_contents()
Ejemplo n.º 7
0
 def highlight(self):
     """
     This function highlights all drcov-ed basic blocks
     """
     core = cutter.core()
     highlighter = core.getBBHighlighter()
     for bblock in self.config['bb_hits']:
         highlighter.highlight(bblock, self.config['color'])
Ejemplo n.º 8
0
 def clear_highlight(self):
     """
     This function removes highlights from all drcov-ed basic blocks
     """
     core = cutter.core()
     highlighter = core.getBBHighlighter()
     for bblock in self.config['bb_hits']:
         highlighter.clear(bblock)
Ejemplo n.º 9
0
 def paint(self):
     core = cutter.core()
     highlighter = core.getBBHighlighter()
     if self.config['colorize']:
         for bb in self.config['bb_hits']:
             highlighter.highlight(bb, self.config['color'])
     else:
         for bb in self.config['bb_hits']:
             highlighter.clear(bb)
Ejemplo n.º 10
0
    def __init__(self, parent=None):
        QTableWidget.__init__(self, parent)
        self.parent = parent
        self.symRegs = {}

        self.setShowGrid(False)
        self.verticalHeader().hide()
        self.setColumnCount(2)

        self.setHorizontalHeaderLabels(['Register', 'Value'])
        self.resizeColumnsToContents()
        self.setEditTriggers(QAbstractItemView.NoEditTriggers)

        self.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)

        cutter.core().registersChanged.connect(self.updateContents)

        self.updateContents()
Ejemplo n.º 11
0
    def startExplore(self):
        if len(self.findAddrs) == 0:
            printMessage(
                "You have to set a find address to explore to", LogLevel.WARNING)
            return

        self.stateMgr = StateManager()
        self.simMgr = self.stateMgr.simulation_manager()

        # Configure symbolic memory addresses and registers
        for addr in self.symAddrs:
            self.stateMgr.sim(addr, self.symAddrs[addr])
        for reg in self.viewRegisters.symRegs:
            self.stateMgr.sim(
                self.stateMgr[reg], self.viewRegisters.symRegs[reg])

        # Start exploration
        printMessage("Starting exploration with find (%s) and avoid (%s)" %
                     (self.findAddrs, self.avoidAddrs,), LogLevel.INFO)
        printMessage("Symbolics are: " +
                     str(self.stateMgr.symbolics), LogLevel.INFO)
        self.simMgr.explore(find=self.findAddrs, avoid=self.avoidAddrs)

        # Attempt to print the results
        if len(self.simMgr.found):
            printMessage("Found: " + str(self.simMgr.found[0]), LogLevel.INFO)

            conc = self.stateMgr.concretize(self.simMgr.found[0])
            for addr in conc:
                printMessage("0x%x ==> %s" %
                             (addr, repr(conc[addr])), LogLevel.INFO)

            self.applySimButton.setDisabled(False)
        else:
            printMessage("Failed to find a state", LogLevel.ERROR)
            self.applySimButton.setDisabled(True)

        # Synchronize displays
        cutter.core().refreshAll.emit()
        # Return to the previous seek
        cutter.cmd("s %d" % cutter.core().getProgramCounterValue())
Ejemplo n.º 12
0
    def startExplore(self):
        if len(self.findAddrs) == 0:
            print(
                "[angr-cutter]: You have to set a find address to explore to")
            return

        self.stateMgr = StateManager()
        self.simMgr = self.stateMgr.simulation_manager()

        # Configure symbolic memory addresses and registers
        for addr in self.symAddrs:
            self.stateMgr.sim(addr, self.symAddrs[addr])
        for reg in self.viewRegisters.symRegs:
            self.stateMgr.sim(self.stateMgr[reg],
                              self.viewRegisters.symRegs[reg])

        # Start exploration
        print(
            "[angr-cutter]: Starting exploration with find (%s) and avoid (%s)"
            % (
                self.findAddrs,
                self.avoidAddrs,
            ))
        print("[angr-cutter]: Symbolics are: " + str(self.stateMgr.symbolics))
        self.simMgr.explore(find=self.findAddrs, avoid=self.avoidAddrs)

        # Attempt to print the results
        if len(self.simMgr.found):
            print("[angr-cutter]: Found: " + str(self.simMgr.found[0]))

            conc = self.stateMgr.concretize(self.simMgr.found[0])
            for addr in conc:
                print("[angr-cutter] 0x%x ==> %s" % (addr, repr(conc[addr])))

            self.applySimButton.setDisabled(False)
        else:
            print("[angr-cutter]: Failed to find a state")
            self.applySimButton.setDisabled(True)

        # Synchronize displays
        cutter.core().refreshAll.emit()
Ejemplo n.º 13
0
    def __init__(self, parent, action):
        super(MyDockWidget, self).__init__(parent, action)
        self.setObjectName("MyDockWidget")
        self.setWindowTitle("My cool DockWidget")

        self._label = QLabel(self)
        self.setWidget(self._label)

        cutter.core().seekChanged.connect(self.update_contents)

        ##this will freeze cutter gui
        #         self.threadClass = threadClass()
        #         self.runSomethingInThreadThread = QThread()
        #         self.runSomethingInThreadThread.start()
        #         self.threadClass.moveToThread(self.runSomethingInThreadThread)
        #
        #         self.threadClass.resultReady.connect(self.showResultFromThread)
        #         self.startRunSomethingInThreadSignal.connect(self.threadClass.runSomethingInThread)

        self.threadClass = threadClass()
        self.threadClass.resultReady.connect(self.showResultFromThread)
Ejemplo n.º 14
0
    def __init__(self, parent, action):
        super(CutterRefWidget, self).__init__(parent, action)
        self.setObjectName("ins_ref")
        self.setWindowTitle("Instruction Reference")

        self.view = QTextEdit(self)
        self.view.setReadOnly(True)
        self.setWidget(self.view)

        self.cutterref = None
        self.previous_inst = ""

        QObject.connect(cutter.core(), SIGNAL("seekChanged(RVA)"),
                        self.update_content)
Ejemplo n.º 15
0
    def debugStateChanged(self):
        # Calculate the diff based on the previous baddr
        baddr = int(cutter.cmd("e bin.baddr").strip('\n'), 16)
        diff = baddr - self.baddr
        self.baddr = baddr

        if cutter.core().currentlyDebugging:
            disableUi = False
        else:
            del self.stateMgr
            self.stateMgr = None
            disableUi = True
            # applySim can be enabled only after startExplore
            self.applySimButton.setDisabled(True)

        # Enable exploration action when in debug mode
        self.startButton.setDisabled(disableUi)
        self.stopButton.setDisabled(disableUi)

        # Rebase addresses
        tmp = []
        for addr in self.findAddrs:
            tmp.append(addr + diff)
        self.findAddrs = tmp

        tmp = []
        for addr in self.avoidAddrs:
            tmp.append(addr + diff)
        self.avoidAddrs = tmp

        tmp = {}
        for addr in self.symAddrs:
            tmp[addr + diff] = self.symAddrs[addr]
        self.symAddrs = tmp

        self.update()
Ejemplo n.º 16
0
 def applySim(self):
     self.stateMgr.to_dbg(self.simMgr.found[0])
     # Synchronize all widgets with the applied memory/register values
     cutter.core().refreshAll.emit()
     # Return to the previous seek
     cutter.cmd("s %d" % cutter.core().getProgramCounterValue())
Ejemplo n.º 17
0
def rename_function(location, new_name):
    try:
        cutter.core().renameFunction(location, new_name)
    except Exception as e:
        log(str(e))
Ejemplo n.º 18
0
 def input_file(self):
     path = cutter.core().currentlyOpenFile.rstrip()
     return open(path, "rb")
Ejemplo n.º 19
0
 def generate_fortune(self):
     fortune = cutter.cmd("fo").replace("\n", "")
     res = cutter.core().cmdRaw(f"?E {fortune}")
     self.text.setText(res)
Ejemplo n.º 20
0
 def seek(self, idx):
     row = idx.row()
     addr = int(self.covTable.item(row, 2).text(), 16)
     cutter.core().seek(addr)
Ejemplo n.º 21
0
    def setupActions(self):
        self.findAddrAction = QAction("Angr - find address", self)
        self.avoidAddrAction = QAction("Angr - avoid address", self)
        self.symAddrAction = QAction("Angr - symbolize address", self)
        self.unsetAddrAction = QAction("Angr - unset address", self)

        cutter.core().addContextMenuExtensionAction(
            cutter.CutterCore.ContextMenuType.Disassembly, self.findAddrAction)
        cutter.core().addContextMenuExtensionAction(
            cutter.CutterCore.ContextMenuType.Disassembly,
            self.avoidAddrAction)
        cutter.core().addContextMenuExtensionAction(
            cutter.CutterCore.ContextMenuType.Disassembly, self.symAddrAction)
        cutter.core().addContextMenuExtensionAction(
            cutter.CutterCore.ContextMenuType.Disassembly,
            self.unsetAddrAction)
        cutter.core().addContextMenuExtensionSeparator(
            cutter.CutterCore.ContextMenuType.Disassembly)

        cutter.core().addContextMenuExtensionAction(
            cutter.CutterCore.ContextMenuType.Addressable, self.symAddrAction)
        cutter.core().addContextMenuExtensionAction(
            cutter.CutterCore.ContextMenuType.Addressable,
            self.unsetAddrAction)
        cutter.core().addContextMenuExtensionSeparator(
            cutter.CutterCore.ContextMenuType.Addressable)

        self.findAddrAction.triggered.connect(self.setFindAddr)
        self.avoidAddrAction.triggered.connect(self.setAvoidAddr)
        self.unsetAddrAction.triggered.connect(self.unsetAddr)
        self.symAddrAction.triggered.connect(self.setSymAddr)
Ejemplo n.º 22
0
 def is_active(self):
     return cutter.core().currentlyDebugging
Ejemplo n.º 23
0
 def _get_sections(self):
     sections = cutter.core().getAllSections()
Ejemplo n.º 24
0
def seek(location):
    cutter.core().seek(location)
Ejemplo n.º 25
0
 def applySim(self):
     self.stateMgr.to_dbg(self.simMgr.found[0])
     # Synchronize all widgets with the applied memory/register values
     cutter.core().refreshAll.emit()
Ejemplo n.º 26
0
def define_function(location, name):
    try:
        cutter.core().createFunctionAt(location, name)
    except Exception as e:
        log(str(e))
Ejemplo n.º 27
0
def trigger_function_renamed(rva, new_name):
    cutter.core().triggerFunctionRenamed(rva, new_name)
Ejemplo n.º 28
0
def trigger_flags_changed():
    cutter.core().triggerFlagsChanged()