Exemple #1
0
    def __init__(self, custom_methods, *args, **kwargs):
        super(OS_Linux_str, self).__init__(custom_methods, *args, **kwargs)

        # Import manager
        libs = libimp()
        self.libs = libs

        data = open(self.fname).read()
        self.options.load_base_addr = int(self.options.load_base_addr, 16)
        self.jitter.vm.add_memory_page(self.options.load_base_addr, PAGE_READ | PAGE_WRITE, data)

        # Library calls handler
        self.jitter.add_lib_handler(libs, custom_methods)
Exemple #2
0
    def __init__(self, custom_methods, *args, **kwargs):
        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)
Exemple #3
0
    def __init__(self, custom_methods, *args, **kwargs):
        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)
Exemple #4
0
    def __init__(self, custom_methods, *args, **kwargs):
        super(OS_Linux_str, self).__init__(custom_methods, *args, **kwargs)

        # Import manager
        libs = libimp()
        self.libs = libs

        data = open(self.fname).read()
        self.options.load_base_addr = int(self.options.load_base_addr, 16)
        self.jitter.vm.add_memory_page(self.options.load_base_addr,
                                       PAGE_READ | PAGE_WRITE, data)

        # Library calls handler
        self.jitter.add_lib_handler(libs, custom_methods)
Exemple #5
0
    def __init__(self, custom_methods, *args, **kwargs):
        super(OS_Win, self).__init__(custom_methods, *args, **kwargs)

        # Import manager
        libs = libimp()
        self.libs = libs
        win_api_x86_32.winobjs.runtime_dll = libs

        # Load library
        if self.options.loadbasedll:
            all_pe = []

            # Load libs in memory
            for dll_fname in self.ALL_IMP_DLL:
                fname = os.path.join('win_dll', dll_fname)
                e_lib = vm_load_pe(self.jitter.vm, fname)

                libs.add_export_lib(e_lib, dll_fname)
                all_pe.append(e_lib)

            # Patch libs imports
            for pe in all_pe:
                preload_pe(self.jitter.vm, pe, libs)

        # Load main pe
        self.pe = vm_load_pe(self.jitter.vm, self.fname)

        # Fix pe imports
        preload_pe(self.jitter.vm, self.pe, libs)

        # Library calls handler
        self.jitter.add_lib_handler(libs, custom_methods)

        # Manage SEH
        if self.options.use_seh:
            win_api_x86_32_seh.main_pe_name = self.fname
            win_api_x86_32_seh.main_pe = self.pe
            win_api_x86_32_seh.loaded_modules = self.ALL_IMP_DLL
            win_api_x86_32_seh.init_seh(self.jitter)
            win_api_x86_32_seh.set_win_fs_0(self.jitter)

        self.entry_point =  self.pe.rva2virt(self.pe.Opthdr.AddressOfEntryPoint)
Exemple #6
0
    def __init__(self, custom_methods, *args, **kwargs):
        super(OS_Win, self).__init__(custom_methods, *args, **kwargs)

        # Import manager
        libs = libimp()
        self.libs = libs
        win_api_x86_32.winobjs.runtime_dll = libs

        # Load library
        if self.options.loadbasedll:
            all_pe = []

            # Load libs in memory
            for dll_fname in self.ALL_IMP_DLL:
                fname = os.path.join('win_dll', dll_fname)
                e_lib = vm_load_pe(self.jitter.vm, fname)

                libs.add_export_lib(e_lib, dll_fname)
                all_pe.append(e_lib)

            # Patch libs imports
            for pe in all_pe:
                preload_pe(self.jitter.vm, pe, libs)

        # Load main pe
        self.pe = vm_load_pe(self.jitter.vm, self.fname)

        # Fix pe imports
        preload_pe(self.jitter.vm, self.pe, libs)

        # Library calls handler
        self.jitter.add_lib_handler(libs, custom_methods)

        # Manage SEH
        if self.options.use_seh:
            win_api_x86_32_seh.main_pe_name = self.fname
            win_api_x86_32_seh.main_pe = self.pe
            win_api_x86_32_seh.loaded_modules = self.ALL_IMP_DLL
            win_api_x86_32_seh.init_seh(self.jitter)
            win_api_x86_32_seh.set_win_fs_0(self.jitter)

        self.entry_point = self.pe.rva2virt(self.pe.Opthdr.AddressOfEntryPoint)