def init_stub(self): """Initialize stubbing capabilities""" if not isinstance(self.engine, MiasmEngine): # Unsupported capability return # Get stubs' implementation context = {} for fpath in config.stubs: execfile(fpath, context) if not context: return libs = None if isinstance(self.ctr, ContainerPE): from miasm2.jitter.loader.pe import preload_pe, libimp_pe libs = libimp_pe() preload_pe(self.jitter.vm, self.ctr.executable, libs) elif isinstance(self.ctr, ContainerELF): from miasm2.jitter.loader.elf import preload_elf, libimp_elf libs = libimp_elf() preload_elf(self.jitter.vm, self.ctr.executable, libs) else: return # Add associated breakpoints self.jitter.add_lib_handler(libs, context)
def __init__(self, custom_methods, *args, **kwargs): from miasm2.jitter.loader.elf import vm_load_elf, preload_elf, libimp_elf from miasm2.os_dep import linux_stdlib methods = linux_stdlib.__dict__ methods.update(custom_methods) super(OS_Linux, self).__init__(methods, *args, **kwargs) # Import manager self.libs = libimp_elf() 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) self.entry_point = self.elf.Ehdr.entry # Library calls handler self.jitter.add_lib_handler(self.libs, methods) linux_stdlib.ABORT_ADDR = self.CALL_FINISH_ADDR # Arguments self.argv = [self.PROGRAM_PATH] if self.options.command_line: self.argv += self.options.command_line self.envp = self.options.environment_vars
def __init__(self, custom_methods, *args, **kwargs): from miasm2.jitter.loader.elf import vm_load_elf, preload_elf, libimp_elf from miasm2.os_dep import linux_stdlib methods = linux_stdlib.__dict__ methods.update(custom_methods) super(OS_Linux, self).__init__(methods, *args, **kwargs) # Import manager self.libs = libimp_elf() with open(self.fname) 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) self.entry_point = self.elf.Ehdr.entry # Library calls handler self.jitter.add_lib_handler(self.libs, methods) # Arguments self.argv = [self.PROGRAM_PATH] if self.options.command_line: self.argv += self.options.command_line self.envp = self.options.environment_vars
def __init__(self, custom_methods, *args, **kwargs): from miasm2.jitter.loader.elf import vm_load_elf, preload_elf super(OS_Linux, self).__init__(custom_methods, *args, **kwargs) # Import manager libs = libimp() self.libs = libs elf = vm_load_elf(self.jitter.vm, self.fname) self.elf = elf preload_elf(self.jitter.vm, elf, libs) # Library calls handler self.jitter.add_lib_handler(libs, custom_methods)
def __init__(self, custom_methods, *args, **kwargs): from miasm2.jitter.loader.elf import vm_load_elf, preload_elf, libimp_elf from miasm2.os_dep import linux_stdlib methods = linux_stdlib.__dict__ methods.update(custom_methods) super(OS_Linux, self).__init__(methods, *args, **kwargs) # Import manager self.libs = libimp_elf() with open(self.fname) as fstream: self.elf = vm_load_elf(self.jitter.vm, fstream.read(), **kwargs) preload_elf(self.jitter.vm, self.elf, self.libs) self.entry_point = self.elf.Ehdr.entry # Library calls handler self.jitter.add_lib_handler(self.libs, methods)