def load_file(ctx): if not os.path.exists(ctx.filename): error("file {ctx.filename} doesn't exist".format(ctx=ctx)) if ctx.interactive: return False die() if not os.path.isfile(ctx.filename): error("this is not a file".format(ctx=ctx)) if ctx.interactive: return False die() dirname = os.path.dirname(ctx.filename) db_path = dirname + "/" if dirname != "" else "" db_path += "." + os.path.basename(ctx.filename) + ".db" db_exists = os.path.exists(db_path) ctx.db_path = db_path try: dis = Disassembler(ctx.filename, ctx.raw_type, ctx.raw_base, ctx.raw_big_endian, load_symbols=not db_exists) except ExcArch as e: error("arch %s is not supported" % e.arch) if ctx.interactive: return False die() except ExcFileFormat: error("the file is not PE or ELF binary") if ctx.interactive: return False die() except ExcPEFail as e: error(str(e.e)) error("It seems that pefile.parse_data_directories is bugged.") error("Maybe you should Retry") if ctx.interactive: return False die() # Load symbols in the database if db_exists: info("open database %s" % db_path) fd = open(db_path, "r") db = json.loads(fd.read()) ctx.db = db sym = dis.binary.symbols rev_sym = dis.binary.reverse_symbols for name, addr in db["symbols"].items(): sym[name] = addr rev_sym[addr] = name fd.close() ctx.dis = dis ctx.libarch = dis.load_arch_module() return True
def load_file(self, filename=None): if filename is None: filename = self.filename if not os.path.exists(filename): error("file {self.filename} doesn't exist".format(self=self)) if self.interactive_mode: return False die() if not os.path.isfile(filename): error("this is not a file".format(self=self)) if self.interactive_mode: return False die() self.db = Database() self.db.load(filename) try: dis = Disassembler(filename, self.raw_type, self.raw_base, self.raw_big_endian, self.db) except ExcArch as e: error("arch %s is not supported" % e.arch) if self.interactive_mode: return False die() except ExcFileFormat: error("the file is not PE or ELF binary") if self.interactive_mode: return False die() except ExcPEFail as e: error(str(e.e)) error("it seems that there is a random bug in pefile, you shoul retry.") error("please report here https://github.com/joelpx/reverse/issues/16") if self.interactive_mode: return False die() self.dis = dis self.libarch = dis.load_arch_module() return True
def load_file(ctx): if not os.path.exists(ctx.filename): error("file {ctx.filename} doesn't exists".format(ctx=ctx)) if ctx.interactive: return False die() if not os.path.isfile(ctx.filename): error("this is not a file".format(ctx=ctx)) if ctx.interactive: return False die() try: dis = Disassembler(ctx.filename, ctx.raw_type, ctx.raw_base, ctx.raw_big_endian) except ExcArch as e: error("arch %s is not supported" % e.arch) if ctx.interactive: return False die() except ExcFileFormat: error("the file is not PE or ELF binary") if ctx.interactive: return False die() except ExcPEFail as e: error(str(e.e)) error("It seems that pefile.parse_data_directories is bugged.") error("Maybe you should Retry") if ctx.interactive: return False die() ctx.dis = dis ctx.libarch = dis.load_arch_module() if ctx.symfile: dis.load_user_sym_file(ctx.symfile) return True
def __init__(self, session=None, parent=None, device=None): super(Dwarf, self).__init__(parent=parent) self._app_window = parent self.database = Database(self) self.keystone_installed = False try: import keystone.keystone_const self.keystone_installed = True except: pass self.java_available = False # frida device self._device = device # process self._pid = 0 self._package = None self._process = None self._script = None self._spawned = False self._resumed = False # kernel self._kernel = Kernel(self) # hooks self.hooks = {} self.native_on_loads = {} self.java_on_loads = {} self.java_hooks = {} self.watchers = {} self.temporary_input = '' self.native_pending_args = None self.java_pending_args = None # context self._arch = '' self._pointer_size = 0 self.contexts = {} self.context_tid = 0 self._platform = '' # disassembler self.disassembler = Disassembler(self) # connect to self self.onApplyContext.connect(self._on_apply_context) self.onRequestJsThreadResume.connect(self._on_request_resume_from_js)
def load_file(ctx): if not os.path.exists(ctx.filename): error("file {ctx.filename} doesn't exist".format(ctx=ctx)) if ctx.interactive: return False die() if not os.path.isfile(ctx.filename): error("this is not a file".format(ctx=ctx)) if ctx.interactive: return False die() dirname = os.path.dirname(ctx.filename) db_path = dirname + "/" if dirname != "" else "" db_path += "." + os.path.basename(ctx.filename) + ".db" db_exists = os.path.exists(db_path) ctx.db_path = db_path jmptables = {} inline_comments = {} previous_comments = {} sym = {} rev_sym = {} mips_gp = -1 # Open the database if db_exists: info("open database %s" % db_path) fd = open(db_path, "r") db = json.loads(fd.read()) ctx.db = db # Saved symbols sym = db["symbols"] for name, addr in db["symbols"].items(): rev_sym[addr] = name try: # Saved comments for ad, comm in db["inline_comments"].items(): inline_comments[int(ad)] = comm for ad, comm in db["previous_comments"].items(): previous_comments[int(ad)] = comm # Saved jmptables for j in db["jmptables"]: jmptables[j["inst_addr"]] = \ Jmptable(j["inst_addr"], j["table_addr"], j["table"], j["name"]) except: # Not available in previous versions, this try will be # removed in the future pass try: mips_gp = db["mips_gp"] except: # Not available in previous versions, this try will be # removed in the future pass fd.close() try: dis = Disassembler(ctx.filename, ctx.raw_type, ctx.raw_base, ctx.raw_big_endian, sym, rev_sym, jmptables, inline_comments, previous_comments, load_symbols=not db_exists, mips_gp=mips_gp) except ExcArch as e: error("arch %s is not supported" % e.arch) if ctx.interactive: return False die() except ExcFileFormat: error("the file is not PE or ELF binary") if ctx.interactive: return False die() except ExcPEFail as e: error(str(e.e)) error("it seems that there is a random bug in pefile, you shoul retry.") error("please report here https://github.com/joelpx/reverse/issues/16") if ctx.interactive: return False die() ctx.dis = dis ctx.libarch = dis.load_arch_module() return True
def load_file(ctx): if not os.path.exists(ctx.filename): error("file {ctx.filename} doesn't exist".format(ctx=ctx)) if ctx.interactive: return False die() if not os.path.isfile(ctx.filename): error("this is not a file".format(ctx=ctx)) if ctx.interactive: return False die() dirname = os.path.dirname(ctx.filename) db_path = dirname + "/" if dirname != "" else "" db_path += "." + os.path.basename(ctx.filename) + ".db" db_exists = os.path.exists(db_path) ctx.db_path = db_path jmptables = {} inline_comments = {} previous_comments = {} sym = {} rev_sym = {} mips_gp = -1 # Open the database if db_exists: info("open database %s" % db_path) fd = open(db_path, "r") db = json.loads(fd.read()) ctx.db = db # Saved symbols sym = db["symbols"] for name, addr in db["symbols"].items(): rev_sym[addr] = name try: # Saved comments for ad, comm in db["inline_comments"].items(): inline_comments[int(ad)] = comm for ad, comm in db["previous_comments"].items(): previous_comments[int(ad)] = comm # Saved jmptables for j in db["jmptables"]: jmptables[j["inst_addr"]] = \ Jmptable(j["inst_addr"], j["table_addr"], j["table"], j["name"]) except: # Not available in previous versions, this try will be # removed in the future pass try: mips_gp = db["mips_gp"] except: # Not available in previous versions, this try will be # removed in the future pass fd.close() try: dis = Disassembler(ctx.filename, ctx.raw_type, ctx.raw_base, ctx.raw_big_endian, sym, rev_sym, jmptables, inline_comments, previous_comments, load_symbols=not db_exists, mips_gp=mips_gp) except ExcArch as e: error("arch %s is not supported" % e.arch) if ctx.interactive: return False die() except ExcFileFormat: error("the file is not PE or ELF binary") if ctx.interactive: return False die() except ExcPEFail as e: error(str(e.e)) error( "it seems that there is a random bug in pefile, you shoul retry.") error("please report here https://github.com/joelpx/reverse/issues/16") if ctx.interactive: return False die() ctx.dis = dis ctx.libarch = dis.load_arch_module() return True