def _main(sdb_path, patch_name): from sdb import SDB with open(sdb_path, "rb") as f: buf = f.read() g_logger.debug("loading database") s = SDB() s.vsParse(bytearray(buf)) g_logger.debug("done loading database") index = SdbIndex() g_logger.debug("indexing strings") index.index_sdb(s) g_logger.debug("done indexing strings") library = item_get_child(s.database_root, SDB_TAGS.TAG_LIBRARY) for shim_ref in item_get_children(library, SDB_TAGS.TAG_SHIM_REF): patch = item_get_child(shim_ref, SDB_TAGS.TAG_PATCH) name_ref = item_get_child(patch, SDB_TAGS.TAG_NAME) name = index.get_string(name_ref.value.reference) bits = item_get_child(patch, SDB_TAGS.TAG_PATCH_BITS) if name == patch_name: ps = GreedyVArray(sdb.PATCHBITS) ps.vsParse(bits.value.value) for i, _ in ps: p = ps[int(i)] print(p.tree()) print(" disassembly:") for l in disassemble(str(p.pattern), p.rva): print(" " + l) print("")
def main(sdb_path): from sdb import SDB with open(sdb_path, "rb") as f: buf = f.read() s = SDB() s.vsParse(buf) for l in dump(s): sys.stdout.write(l.encode("utf-8")) sys.stdout.write("\n")
def _main(sdb_path): from sdb import SDB with open(sdb_path, "rb") as f: buf = f.read() s = SDB() s.vsParse(bytearray(buf)) for l in dump(s): sys.stdout.write(l.encode("utf-8")) sys.stdout.write("\n")
def main(sdb_path): from sdb import SDB with open(sdb_path, "rb") as f: buf = f.read() s = SDB() s.vsParse(bytearray(buf)) for l in dump(s): sys.stdout.write(l) sys.stdout.write("\n")
def _main(sdb_path): from sdb import SDB with open(sdb_path, "rb") as f: buf = f.read() s = SDB() s.vsParse(bytearray(buf)) d = SdbDatabaseDumper(s) for l in d.dump(): sys.stdout.write(l.encode("utf-8")) sys.stdout.write("\n")
def _main(sdb_path): from sdb import SDB with open(sdb_path, "rb") as f: buf = f.read() g_logger.debug("loading database") s = SDB() s.vsParse(bytearray(buf)) g_logger.debug("done loading database") d = SdbInfoDumper(s) for l in d.dump_info(): sys.stdout.write(l.encode("utf-8")) sys.stdout.write("\n")
def _main(sdb_path): from sdb import SDB with open(sdb_path, "rb") as f: buf = f.read() s = SDB() try: s.vsParse(bytearray(buf)) except sdb.InvalidSDBFileError: g_logger.error("not an SDB file: %s" % (sdb_path)) return -1 d = SdbShimDumper(s) for l in d.dump_database(): sys.stdout.write(l.encode("utf-8")) sys.stdout.write("\n")
def _main(sdb_path, patch_name): from sdb import SDB with open(sdb_path, "rb") as f: buf = f.read() g_logger.debug("loading database") s = SDB() s.vsParse(bytearray(buf)) g_logger.debug("done loading database") index = SdbIndex() g_logger.debug("indexing strings") index.index_sdb(s) g_logger.debug("done indexing strings") try: library = item_get_child(s.database_root, SDB_TAGS.TAG_LIBRARY) except KeyError: pass else: for shim_ref in item_get_children(library, SDB_TAGS.TAG_SHIM_REF): patch = item_get_child(shim_ref, SDB_TAGS.TAG_PATCH) name_ref = item_get_child(patch, SDB_TAGS.TAG_NAME) name = index.get_string(name_ref.value.reference) if name != patch_name: continue bits = item_get_child(patch, SDB_TAGS.TAG_PATCH_BITS) dump_patch(bits, arch=ARCH_32) try: patch = item_get_child(s.database_root, SDB_TAGS.TAG_PATCH) except KeyError: pass else: name_ref = item_get_child(patch, SDB_TAGS.TAG_NAME) name = index.get_string(name_ref.value.reference) if name == patch_name: bits = item_get_child(patch, SDB_TAGS.TAG_PATCH_BITS) dump_patch(bits, arch=ARCH_32)