예제 #1
0
    def __init__(self, parent, binaryView):
        QScrollArea.__init__(self, parent)

        View.__init__(self)
        View.setBinaryDataNavigable(self, True)
        self.setupView(self)

        # BinaryViewType
        self.binaryView = binaryView

        self.rootSelectionStart = 0
        self.rootSelectionEnd = 1

        self.ioRoot = None
        self.ioCurrent = None

        # top half = treeWidget + structPath
        self.treeWidget = MyQTreeWidget()
        self.treeWidget.setColumnCount(4)
        self.treeWidget.setHeaderLabels(['label', 'value', 'start', 'end'])
        self.treeWidget.itemSelectionChanged.connect(self.onTreeSelect)

        self.structPath = QLineEdit("root")
        self.structPath.setReadOnly(True)

        topHalf = QWidget(self)
        layout = QVBoxLayout()
        layout.addWidget(self.treeWidget)
        layout.addWidget(self.structPath)
        topHalf.setLayout(layout)

        # bottom half = hexWidget
        self.hexWidget = HexEditor(binaryView,
                                   ViewFrame.viewFrameForWidget(self), 0)

        # splitter = top half, bottom half
        self.splitter = QSplitter(self)
        self.splitter.setOrientation(Qt.Vertical)
        self.splitter.addWidget(topHalf)
        self.splitter.addWidget(self.hexWidget)

        self.setWidgetResizable(True)
        self.setWidget(self.splitter)

        self.kaitaiParse()
예제 #2
0
    def __init__(self, parent, binaryView):
        QScrollArea.__init__(self, parent)

        View.__init__(self)
        View.setBinaryDataNavigable(self, True)
        self.setupView(self)

        # input and output, Y = ROT13(X)
        X = binaryView.read(0, len(binaryView))
        Y = codecs.encode(X.decode('utf-8'), 'rot_13').encode('utf-8')

        # store original binary view (X) and our translated binary view (Y)
        self.binaryViewX = binaryView
        self.binaryViewY = binaryview.BinaryView.new(Y)

        self.setWidgetResizable(True)
        self.hexWidget = HexEditor(self.binaryViewY,
                                   ViewFrame.viewFrameForWidget(self), 0)
        self.setWidget(self.hexWidget)

        # capture writes to translated binary view
        notification = Rot13Notification(self.binaryViewX)
        self.binaryViewY.register_notification(notification)
예제 #3
0
    def __init__(self, parent, data):
        QScrollArea.__init__(self, parent)
        View.__init__(self)
        View.setBinaryDataNavigable(self, True)
        self.setupView(self)
        self.data = data
        self.currentOffset = 0
        self.byteView = None
        self.fullAnalysisButton = None
        self.importsWidget = None

        container = QWidget(self)
        layout = QVBoxLayout()

        entropyGroup = QGroupBox("Entropy", container)
        entropyLayout = QVBoxLayout()
        entropyLayout.addWidget(
            entropy.EntropyWidget(entropyGroup, self, self.data))
        entropyGroup.setLayout(entropyLayout)
        layout.addWidget(entropyGroup)

        hdr = None
        try:
            if self.data.view_type == "PE":
                hdr = headers.PEHeaders(self.data)
            elif self.data.view_type != "Raw":
                hdr = headers.GenericHeaders(self.data)
        except:
            log.log_error(traceback.format_exc())

        if hdr is not None:
            headerGroup = QGroupBox("Headers", container)
            headerLayout = QVBoxLayout()
            headerWidget = headers.HeaderWidget(headerGroup, hdr)
            headerLayout.addWidget(headerWidget)
            headerGroup.setLayout(headerLayout)
            layout.addWidget(headerGroup)

        if self.data.executable:
            importExportSplitter = QSplitter(Qt.Horizontal)

            importGroup = QGroupBox("Imports", container)
            importLayout = QVBoxLayout()
            self.importsWidget = imports.ImportsWidget(importGroup, self,
                                                       self.data)
            importLayout.addWidget(self.importsWidget)
            importGroup.setLayout(importLayout)
            importExportSplitter.addWidget(importGroup)

            exportGroup = QGroupBox("Exports", container)
            exportLayout = QVBoxLayout()
            exportLayout.addWidget(
                exports.ExportsWidget(exportGroup, self, self.data))
            exportGroup.setLayout(exportLayout)
            importExportSplitter.addWidget(exportGroup)

            layout.addWidget(importExportSplitter)

            if self.data.view_type != "PE":
                segmentsGroup = QGroupBox("Segments", container)
                segmentsLayout = QVBoxLayout()
                segmentsWidget = sections.SegmentsWidget(
                    segmentsGroup, self.data)
                segmentsLayout.addWidget(segmentsWidget)
                segmentsGroup.setLayout(segmentsLayout)
                layout.addWidget(segmentsGroup)
                if len(segmentsWidget.segments) == 0:
                    segmentsGroup.hide()

            sectionsGroup = QGroupBox("Sections", container)
            sectionsLayout = QVBoxLayout()
            sectionsWidget = sections.SectionsWidget(sectionsGroup, self.data)
            sectionsLayout.addWidget(sectionsWidget)
            sectionsGroup.setLayout(sectionsLayout)
            layout.addWidget(sectionsGroup)
            if len(sectionsWidget.sections) == 0:
                sectionsGroup.hide()

            buttonLayout = QHBoxLayout()
            buttonLayout.addStretch(1)
            self.loadDynamicButton = QPushButton("Load Dynamic Imports")
            self.loadDynamicButton.clicked.connect(
                self.importsWidget.scanDynamic)
            buttonLayout.addWidget(self.loadDynamicButton)
            self.fullAnalysisButton = QPushButton("Start Full Analysis")
            self.fullAnalysisButton.clicked.connect(self.startFullAnalysis)
            buttonLayout.addWidget(self.fullAnalysisButton)
            layout.addLayout(buttonLayout)
            layout.addStretch(1)
        else:
            self.byteView = byte.ByteView(self, self.data)
            layout.addWidget(self.byteView, 1)

        container.setLayout(layout)
        self.setWidgetResizable(True)
        self.setWidget(container)

        if self.fullAnalysisButton is not None and Settings().get_string(
                "analysis.mode", data) == "full":
            self.fullAnalysisButton.hide()
예제 #4
0
    def __init__(self, parent, data):
        QAbstractScrollArea.__init__(self, parent)
        View.__init__(self)
        View.setBinaryDataNavigable(self, True)
        self.setupView(self)
        self.data = data
        self.byte_mapping = [
            u' ', u'☺', u'☻', u'♥', u'♦', u'♣', u'♠', u'•', u'◘', u'○', u'◙',
            u'♂', u'♀', u'♪', u'♫', u'☼', u'▸', u'◂', u'↕', u'‼', u'¶', u'§',
            u'▬', u'↨', u'↑', u'↓', u'→', u'←', u'∟', u'↔', u'▴', u'▾', u' ',
            u'!', u'"', u'#', u'$', u'%', u'&', u'\'', u'(', u')', u'*', u'+',
            u',', u'-', u'.', u'/', u'0', u'1', u'2', u'3', u'4', u'5', u'6',
            u'7', u'8', u'9', u':', u';', u'<', u'=', u'>', u'?', u'@', u'A',
            u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', u'L',
            u'M', u'N', u'O', u'P', u'Q', u'R', u'S', u'T', u'U', u'V', u'W',
            u'X', u'Y', u'Z', u'[', u'\\', u']', u'^', u'_', u'`', u'a', u'b',
            u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', u'l', u'm',
            u'n', u'o', u'p', u'q', u'r', u's', u't', u'u', u'v', u'w', u'x',
            u'y', u'z', u'{', u'|', u'}', u'~', u'⌂', u'Ç', u'ü', u'é', u'â',
            u'ä', u'à', u'å', u'ç', u'ê', u'ë', u'è', u'ï', u'î', u'ì', u'Ä',
            u'Å', u'É', u'æ', u'Æ', u'ô', u'ö', u'ò', u'û', u'ù', u'ÿ', u'Ö',
            u'Ü', u'¢', u'£', u'¥', u'₧', u'ƒ', u'á', u'í', u'ó', u'ú', u'ñ',
            u'Ñ', u'ª', u'º', u'¿', u'⌐', u'¬', u'½', u'¼', u'¡', u'«', u'»',
            u'░', u'▒', u'▓', u'│', u'┤', u'╡', u'╢', u'╖', u'╕', u'╣', u'║',
            u'╗', u'╝', u'╜', u'╛', u'┐', u'└', u'┴', u'┬', u'├', u'─', u'┼',
            u'╞', u'╟', u'╚', u'╔', u'╩', u'╦', u'╠', u'═', u'╬', u'╧', u'╨',
            u'╤', u'╥', u'╙', u'╘', u'╒', u'╓', u'╫', u'╪', u'┘', u'┌', u'█',
            u'▄', u'▌', u'▐', u'▀', u'α', u'ß', u'Γ', u'π', u'Σ', u'σ', u'µ',
            u'τ', u'Φ', u'Θ', u'Ω', u'δ', u'∞', u'φ', u'ε', u'∩', u'≡', u'±',
            u'≥', u'≤', u'⌠', u'⌡', u'÷', u'≈', u'°', u'∙', u'·', u'√', u'ⁿ',
            u'²', u'■', u' '
        ]

        if sys.version_info.major == 2:
            mapping = {}
            for i in range(0, 256):
                mapping[chr(i)] = self.byte_mapping[i]
            self.byte_mapping = mapping

        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.setFocusPolicy(Qt.StrongFocus)

        self.cursorAddr = self.data.start
        self.prevCursorAddr = self.cursorAddr
        self.selectionStartAddr = self.cursorAddr
        self.topAddr = self.cursorAddr
        self.topLine = 0
        self.selectionVisible = False
        self.caretVisible = False
        self.caretBlink = True
        self.leftButtonDown = False
        self.cols = 128
        self.updatesRequired = False
        self.visibleRows = 1
        self.lines = []

        self.updateRanges()

        areaSize = self.viewport().size()
        self.adjustSize(areaSize.width(), areaSize.height())

        if self.allocatedLength > 0x7fffffff:
            self.scrollBarMultiplier = (self.allocatedLength // 0x7fffffff) + 1
        else:
            self.scrollBarMultiplier = 1
        self.wheelDelta = 0
        self.updatingScrollBar = False
        self.verticalScrollBar().setRange(0, (self.allocatedLength - 1) //
                                          self.scrollBarMultiplier)
        self.verticalScrollBar().sliderMoved.connect(self.scrollBarMoved)
        self.verticalScrollBar().actionTriggered.connect(self.scrollBarAction)

        self.cursorTimer = QTimer(self)
        self.cursorTimer.setInterval(500)
        self.cursorTimer.setSingleShot(False)
        self.cursorTimer.timeout.connect(self.cursorTimerEvent)
        self.cursorTimer.start()

        self.updateTimer = QTimer(self)
        self.updateTimer.setInterval(200)
        self.updateTimer.setSingleShot(False)
        #self.updateTimer.timeout.connect(self.updateTimerEvent)

        self.actionHandler().bindAction("Move Cursor Up",
                                        UIAction(lambda ctxt: self.up(False)))
        self.actionHandler().bindAction(
            "Move Cursor Down", UIAction(lambda ctxt: self.down(False)))
        self.actionHandler().bindAction(
            "Move Cursor Left", UIAction(lambda ctxt: self.left(1, False)))
        self.actionHandler().bindAction(
            "Move Cursor Right", UIAction(lambda ctxt: self.right(1, False)))
        self.actionHandler().bindAction(
            "Move Cursor Word Left",
            UIAction(lambda ctxt: self.left(8, False)))
        self.actionHandler().bindAction(
            "Move Cursor Word Right",
            UIAction(lambda ctxt: self.right(8, False)))
        self.actionHandler().bindAction("Extend Selection Up",
                                        UIAction(lambda ctxt: self.up(True)))
        self.actionHandler().bindAction("Extend Selection Down",
                                        UIAction(lambda ctxt: self.down(True)))
        self.actionHandler().bindAction(
            "Extend Selection Left", UIAction(lambda ctxt: self.left(1, True)))
        self.actionHandler().bindAction(
            "Extend Selection Right",
            UIAction(lambda ctxt: self.right(1, True)))
        self.actionHandler().bindAction(
            "Extend Selection Word Left",
            UIAction(lambda ctxt: self.left(8, True)))
        self.actionHandler().bindAction(
            "Extend Selection Word Right",
            UIAction(lambda ctxt: self.right(8, True)))
        self.actionHandler().bindAction(
            "Page Up", UIAction(lambda ctxt: self.pageUp(False)))
        self.actionHandler().bindAction(
            "Page Down", UIAction(lambda ctxt: self.pageDown(False)))
        self.actionHandler().bindAction(
            "Extend Selection Page Up",
            UIAction(lambda ctxt: self.pageUp(True)))
        self.actionHandler().bindAction(
            "Extend Selection Page Down",
            UIAction(lambda ctxt: self.pageDown(True)))
        self.actionHandler().bindAction(
            "Move Cursor to Start of Line",
            UIAction(lambda ctxt: self.moveToStartOfLine(False)))
        self.actionHandler().bindAction(
            "Move Cursor to End of Line",
            UIAction(lambda ctxt: self.moveToEndOfLine(False)))
        self.actionHandler().bindAction(
            "Move Cursor to Start of View",
            UIAction(lambda ctxt: self.moveToStartOfView(False)))
        self.actionHandler().bindAction(
            "Move Cursor to End of View",
            UIAction(lambda ctxt: self.moveToEndOfView(False)))
        self.actionHandler().bindAction(
            "Extend Selection to Start of Line",
            UIAction(lambda ctxt: self.moveToStartOfLine(True)))
        self.actionHandler().bindAction(
            "Extend Selection to End of Line",
            UIAction(lambda ctxt: self.moveToEndOfLine(True)))
        self.actionHandler().bindAction(
            "Extend Selection to Start of View",
            UIAction(lambda ctxt: self.moveToStartOfView(True)))
        self.actionHandler().bindAction(
            "Extend Selection to End of View",
            UIAction(lambda ctxt: self.moveToEndOfView(True)))