예제 #1
0
    def __init__(self, custom_methods, *args, **kwargs):
        from miasm.jitter.loader.elf import vm_load_elf, preload_elf, libimp_elf
        from miasm.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
예제 #2
0
파일: sandbox.py 프로젝트: cea-sec/miasm
    def __init__(self, custom_methods, *args, **kwargs):
        from miasm.jitter.loader.elf import vm_load_elf, preload_elf, libimp_elf
        from miasm.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