Exemple #1
0
    def __init__(self, parent, source, title):
        super(binWidget, self).__init__()
        Observable.__init__(self)
        self.parent = parent
        
        self.title = title
        self.active = False
        # offset for text window
        #self.data = mapped
        self.dataOffset = 0
        
        self.dataModel = source
        self.cursor = Cursor(0, 0)

        self.themes = {
            'font': QtGui.QFont('Monaco', 9, QtGui.QFont.Light),
            'background': QtGui.QColor(0x00, 0x2b, 0x36),
            'background_cursor': QtGui.QColor(255, 255, 0),
            'selection': QtGui.QColor(125, 255, 0),
            'pen': QtGui.QColor(0xb5, 0x89, 0x00)
            }

        self.multipleViewModes = []
        for view_mode in self.dataModel.GetViews():
            v = view_mode(self.themes, self.size().width(), self.size().height(), self.dataModel, self.cursor, self)
            textDecorator = HighlightASCII(TextDecorator(v))

            v.setTransformationEngine(textDecorator)

            self.multipleViewModes.append(v)

        self.viewMode = self.multipleViewModes[0]



        self.Banners = Banners()

        self.Banners.add(FileAddrBanner(self.themes, self.dataModel, self.viewMode)) 
        self.Banners.add(TopBanner(self.themes, self.dataModel, self.viewMode))
        self.Banners.add(BottomBanner(self.themes, self.dataModel, self.viewMode))

        self.offsetWindow_h = 0
        self.offsetWindow_v = 0
        self.searchable = Searchable(self.dataModel, self.viewMode)


        self.initUI()

        self.searchWindow = SearchWindow(self, None, self.searchable)

        self.addHandler(self.searchable)
        self.addHandler(self.Banners)

        self.notify(self.viewMode)  
Exemple #2
0
    def __init__(self, parent, source):
        super(binWidget, self).__init__()
        Observable.__init__(self)
        self.parent = parent

        # offset for text window
        #self.data = mapped
        self.dataOffset = 0

        self.dataModel = source
        self.cursor = Cursor(0, 0)

        #        self.multipleViewModes = [BinViewMode(self.size().width(), self.size().height(), self.dataModel, self.cursor, self),
        #                                  HexViewMode(self.size().width(), self.size().height(), self.dataModel, self.cursor, self)]

        logging.basicConfig(level=logging.ERROR)
        self.manager = PluginManager(
            categories_filter={"FileFormat": FileFormat})

        root = os.path.dirname(sys.argv[0])
        self.manager.setPluginPlaces([os.path.join(root, 'plugins', 'format')])
        #self.manager.setPluginPlaces(["plugins"])

        # Load plugins
        self.manager.locatePlugins()
        self.manager.loadPlugins()

        Formats = []
        for plugin in self.manager.getPluginsOfCategory("FileFormat"):
            # plugin.plugin_object is an instance of the plugin
            po = plugin.plugin_object
            if po.recognize(self.dataModel):
                print('[+] ' + po.name)
                Formats.append(po)

        # sort plugins by priority
        Formats = sorted(Formats, key=lambda x: x.priority, reverse=True)
        po = Formats[0]
        print('Choosed plugin: ' + po.name)

        #print QtGui.QFontDatabase.addApplicationFont(os.path.join('terminus-ttf-4.39', 'TerminusTTF-4.39.ttf'))

        self.multipleViewModes = [
            BinViewMode(self.size().width(),
                        self.size().height(),
                        self.dataModel,
                        self.cursor,
                        self,
                        plugin=po),
            HexViewMode(self.size().width(),
                        self.size().height(),
                        self.dataModel,
                        self.cursor,
                        self,
                        plugin=po),
            DisasmViewMode(self.size().width(),
                           self.size().height(),
                           self.dataModel,
                           self.cursor,
                           self,
                           plugin=po)
        ]

        self.viewMode = self.multipleViewModes[0]

        self.textDecorator = TextDecorator(self.viewMode)

        self.viewMode.setTransformationEngine(self.textDecorator)

        self.multipleViewModes[1].setTransformationEngine(self.textDecorator)

        self.Banners = Banners()

        #self.Banners.add(BottomBanner(self.dataModel, self.viewMode))
        #        self.Banners.add(TopBanner(self.dataModel, self.viewMode))

        #self.Banners.add(self.banner)
        #        self.filebanner = FileAddrBanner(self.dataModel, self.viewMode)
        #self.filebanner = PEBanner(self.dataModel, self.viewMode)
        #self.Banners.add(PEBanner(self.dataModel, self.viewMode))
        #self.Banners.add(FileAddrBanner(self.dataModel, self.viewMode))
        #self.Banners.add(FileAddrBanner(self.dataModel, self.viewMode))

        # self.offsetWindow_h = self.filebanner.getDesiredGeometry()[0] + 25
        self.offsetWindow_h = 0
        self.offsetWindow_v = 0
        self.searchable = Searchable(self.dataModel, self.viewMode)

        self.initUI()

        [po.init(viewMode, parent=self) for viewMode in self.multipleViewModes]

        for banner in po.getBanners():
            self.Banners.add(banner)

        po.registerShortcuts(self)
        self.po = po

        #self.scrolled = QtCore.pyqtSignal(int, name='scroll')
        #self.scrolled.connect(self.scroll_from_outside)
        self.searchWindow = SearchWindow(self, None, self.searchable)

        self.addHandler(self.po)
        self.addHandler(self.searchable)
        self.addHandler(self.Banners)

        self.notify(self.viewMode)