示例#1
0
文件: console.py 项目: dhn/Ropper
    def __loaddb(self, dbpath):
        if not dbpath.endswith('.db'):
            dbpath = dbpath+'.db'
        if not os.path.exists(dbpath):
            raise RopperError('db does not exist: '+dbpath)

        dao = GadgetDAO(dbpath, self.__cprinter)

        self.binary.gadgets = dao.load(self.binary)
        self.binary.loaded = True

        self.__gadgets[self.binary] = ropper.deleteDuplicates(ropper.filterBadBytes(self.binary.gadgets, self.__options.badbytes))
示例#2
0
    def __loaddb(self, dbpath):
        if not dbpath.endswith('.db'):
            dbpath = dbpath + '.db'
        if not os.path.exists(dbpath):
            raise RopperError('db does not exist: ' + dbpath)

        dao = GadgetDAO(dbpath, self.__cprinter)

        self.binary.gadgets = dao.load(self.binary)
        self.binary.loaded = True

        self.__gadgets[self.binary] = ropper.deleteDuplicates(
            ropper.filterBadBytes(self.binary.gadgets))
示例#3
0
    def __loaddb(self, dbpath):
        if not dbpath.endswith('.db'):
            dbpath = dbpath+'.db'
        if not os.path.exists(dbpath):
            raise RopperError('db does not exist: '+dbpath)

        dao = GadgetDAO(dbpath, self.__cprinter)

        self.binary.gadgets = dao.load(self.binary)
        self.binary.loaded = True
        if not self.__options.all:
            self.__gadgets[self.binary] = ropper.deleteDuplicates(ropper.filterBadBytes(self.binary.gadgets, self.__options.badbytes), self.__printProgress)
        else:
            self.__gadgets[self.binary] = self.binary.gadgets
示例#4
0
    def __savedb(self, dbpath):
        if not dbpath.endswith('.db'):
            dbpath = dbpath+'.db'
        if os.path.exists(dbpath):
            self.__cprinter.printInfo('db exists')
            overwrite = input('Overwrite? [Y/n]: ')
            if not overwrite or overwrite.upper() == 'Y':
                self.__cprinter.printInfo('overwrite db')
                os.remove(dbpath)
            else:
                self.__cprinter.printInfo('choose another db name')
                return
        dao = GadgetDAO(dbpath, self.__cprinter)

        dao.save(self.binary.gadgets)
示例#5
0
    def __savedb(self, dbpath):
        if not dbpath.endswith('.db'):
            dbpath = dbpath+'.db'
        if os.path.exists(dbpath):
            self.__cprinter.printInfo('db exists')
            overwrite = input('Overwrite? [Y/n]: ')
            if not overwrite or overwrite.upper() == 'Y':
                self.__cprinter.printInfo('overwrite db')
                os.remove(dbpath)
            else:
                self.__cprinter.printInfo('choose another db name')
                return
        dao = GadgetDAO(dbpath, self.__cprinter)

        dao.save(self.binary.gadgets)
示例#6
0
    def test_database(self):
        r = Ropper()

        db = './testdb.db'
        if os.path.exists(db):
            os.remove(db)

        dao = GadgetDAO(db)

        gadgets = r.searchGadgets(self.file)

        dao.save(gadgets)
        self.assertTrue(os.path.exists(db))

        loaded_gadgets = dao.load(self.file)
        self.assertEqual(len(gadgets), len(loaded_gadgets))
        self.assertEqual(gadgets[0].lines[0][0], loaded_gadgets[0].lines[0][0])

        os.remove(db)
示例#7
0
    def test_database(self):
        r = Ropper()

        db = "./testdb.db"
        if os.path.exists(db):
            os.remove(db)

        dao = GadgetDAO(db)

        gadgets = r.searchGadgets(self.file)

        dao.save(gadgets)
        self.assertTrue(os.path.exists(db))

        loaded_gadgets = dao.load(self.file)
        self.assertEqual(len(gadgets), len(loaded_gadgets))
        self.assertEqual(gadgets[0].lines[0][0], loaded_gadgets[0].lines[0][0])

        os.remove(db)