diff options
| -rw-r--r-- | example/disasm/full.py | 4 | ||||
| -rwxr-xr-x | example/jitter/msp430.py | 2 | ||||
| -rw-r--r-- | example/jitter/sandbox_call.py | 2 | ||||
| -rw-r--r-- | example/symbol_exec/depgraph.py | 2 | ||||
| -rw-r--r-- | example/symbol_exec/dse_crackme.py | 2 | ||||
| -rw-r--r-- | miasm2/analysis/sandbox.py | 6 | ||||
| -rw-r--r-- | miasm2/jitter/jitcore_tcc.py | 2 | ||||
| -rw-r--r-- | miasm2/jitter/llvmconvert.py | 4 | ||||
| -rw-r--r-- | miasm2/jitter/loader/pe.py | 6 |
9 files changed, 15 insertions, 15 deletions
diff --git a/example/disasm/full.py b/example/disasm/full.py index ad85f7dc..84c856e1 100644 --- a/example/disasm/full.py +++ b/example/disasm/full.py @@ -61,10 +61,10 @@ if args.verbose: log.info('Load binary') if args.rawbinary: shift = args.shiftoffset if args.shiftoffset is not None else 0 - cont = Container.fallback_container(open(args.filename).read(), + cont = Container.fallback_container(open(args.filename, "rb").read(), None, addr=shift) else: - with open(args.filename) as fdesc: + with open(args.filename, "rb") as fdesc: cont = Container.from_stream(fdesc, addr=args.shiftoffset) default_addr = cont.entry_point diff --git a/example/jitter/msp430.py b/example/jitter/msp430.py index b69f91c6..6dd67542 100755 --- a/example/jitter/msp430.py +++ b/example/jitter/msp430.py @@ -40,7 +40,7 @@ def jit_msp430_binary(args): myjit.jit.log_mn = args.log_mn myjit.jit.log_newbloc = args.log_newbloc - myjit.vm.add_memory_page(0, PAGE_READ | PAGE_WRITE, open(filepath).read()) + myjit.vm.add_memory_page(0, PAGE_READ | PAGE_WRITE, open(filepath, "rb").read()) myjit.add_breakpoint(0x1337, lambda _: exit(0)) diff --git a/example/jitter/sandbox_call.py b/example/jitter/sandbox_call.py index 49365004..dc64af15 100644 --- a/example/jitter/sandbox_call.py +++ b/example/jitter/sandbox_call.py @@ -13,7 +13,7 @@ options = parser.parse_args() sb = Sandbox_Linux_arml(options.filename, options, globals()) -with open(options.filename) as fdesc: +with open(options.filename, "rb") as fdesc: cont = Container.from_stream(fdesc) addr_to_call = cont.symbol_pool.getby_name("md5_starts").offset diff --git a/example/symbol_exec/depgraph.py b/example/symbol_exec/depgraph.py index 4d518cb3..c1d6174d 100644 --- a/example/symbol_exec/depgraph.py +++ b/example/symbol_exec/depgraph.py @@ -31,7 +31,7 @@ parser.add_argument("--json", args = parser.parse_args() # Get architecture -with open(args.filename) as fstream: +with open(args.filename, "rb") as fstream: cont = Container.from_stream(fstream) arch = args.architecture if args.architecture else cont.arch diff --git a/example/symbol_exec/dse_crackme.py b/example/symbol_exec/dse_crackme.py index 9ac4d6d1..303447a4 100644 --- a/example/symbol_exec/dse_crackme.py +++ b/example/symbol_exec/dse_crackme.py @@ -31,7 +31,7 @@ def xxx_fopen(jitter): global my_FILE_ptr ret_addr, args = jitter.func_args_systemv(['path', 'mode']) fname = jitter.get_str_ansi(args.path) - FILE_to_info[my_FILE_ptr] = FInfo(fname, open(fname)) + FILE_to_info[my_FILE_ptr] = FInfo(fname, open(fname, "rb")) my_FILE_ptr += 1 return jitter.func_ret_stdcall(ret_addr, my_FILE_ptr - 1) diff --git a/miasm2/analysis/sandbox.py b/miasm2/analysis/sandbox.py index a1736bea..07297094 100644 --- a/miasm2/analysis/sandbox.py +++ b/miasm2/analysis/sandbox.py @@ -199,7 +199,7 @@ class OS_Win(OS): fname_basename = os.path.basename(self.fname).lower() # Load main pe - with open(self.fname) as fstream: + with open(self.fname, "rb") as fstream: self.pe = vm_load_pe(self.jitter.vm, fstream.read(), load_hdr=self.options.load_hdr, name=self.fname, @@ -275,7 +275,7 @@ class OS_Linux(OS): # Import manager self.libs = libimp_elf() - with open(self.fname) as fstream: + with open(self.fname, "rb") as fstream: self.elf = vm_load_elf(self.jitter.vm, fstream.read(), name=self.fname, **kwargs) preload_elf(self.jitter.vm, self.elf, self.libs) @@ -321,7 +321,7 @@ class OS_Linux_str(OS): libs = libimp_elf() self.libs = libs - data = open(self.fname).read() + data = open(self.fname, "rb").read() self.options.load_base_addr = int(self.options.load_base_addr, 0) self.jitter.vm.add_memory_page( self.options.load_base_addr, PAGE_READ | PAGE_WRITE, data, diff --git a/miasm2/jitter/jitcore_tcc.py b/miasm2/jitter/jitcore_tcc.py index 5b47bf6d..28288400 100644 --- a/miasm2/jitter/jitcore_tcc.py +++ b/miasm2/jitter/jitcore_tcc.py @@ -69,7 +69,7 @@ class JitCore_Tcc(JitCore_Cc_Base): fname_out = os.path.join(self.tempdir, "%s.c" % block_hash) if os.access(fname_out, os.R_OK): - func_code = open(fname_out).read() + func_code = open(fname_out, "rb").read() else: func_code = self.gen_c_code(block.label, block) diff --git a/miasm2/jitter/llvmconvert.py b/miasm2/jitter/llvmconvert.py index 0f88d842..83349781 100644 --- a/miasm2/jitter/llvmconvert.py +++ b/miasm2/jitter/llvmconvert.py @@ -313,7 +313,7 @@ class LLVMContext_JIT(LLVMContext): # No need to overwrite return - open(fname_out, "w").write(buffer) + open(fname_out, "wb").write(buffer) @staticmethod def cache_getbuffer(module): @@ -323,7 +323,7 @@ class LLVMContext_JIT(LLVMContext): fname_out = module.fname_out if os.access(fname_out, os.R_OK): - return open(fname_out).read() + return open(fname_out, "rb").read() return None def enable_cache(self): diff --git a/miasm2/jitter/loader/pe.py b/miasm2/jitter/loader/pe.py index 87d5ae25..65bf284b 100644 --- a/miasm2/jitter/loader/pe.py +++ b/miasm2/jitter/loader/pe.py @@ -234,7 +234,7 @@ def vm_load_pe_lib(vm, fname_in, libs, lib_path_base, **kargs): log.info('Loading module %r', fname_in) fname = os.path.join(lib_path_base, fname_in) - with open(fname) as fstream: + with open(fname, "rb") as fstream: pe = vm_load_pe(vm, fstream.read(), name=fname_in, **kargs) libs.add_export_lib(pe, fname_in) return pe @@ -335,7 +335,7 @@ def vm2pe(myjit, fname, libs=None, e_orig=None, mye.DirRes.set_rva(s_res.addr) log.debug('%r', mye.DirRes) # generation - open(fname, 'w').write(str(mye)) + open(fname, 'wb').write(str(mye)) return mye @@ -501,7 +501,7 @@ def vm_load_pe_and_dependencies(vm, fname, name2module, runtime_lib, pe_obj = name2module[name] else: try: - with open(fname) as fstream: + with open(fname, "rb") as fstream: log.info('Loading module name %r', fname) pe_obj = vm_load_pe( vm, fstream.read(), name=fname, **kwargs) |