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))
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))
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
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)
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)
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)