(self, output_elf=None)
return bool(FileUtil(output_elf).putdata(ld_data, 'wb'))
Patch ld.so
Patch ld.so
Patch ld . so
def patch_ld(self, output_elf=None):
        """Patch ld.so"""
        elf_loader = self.get_container_loader()
        if FileUtil(self._container_ld_so_orig).size() == -1:
            status = FileUtil(elf_loader).copyto(self._container_ld_so_orig)
            if not status:
                return False

        ld_data = FileUtil(self._container_ld_so_orig).getdata('rb')
        if not ld_data:
            ld_data = FileUtil(elf_loader).getdata('rb')
            if not ld_data:
                return False

        nul_etc = "\x00/\x00\x00\x00\x00\x00\x00\x00\x00\x00".encode()
        nul_lib = "\x00/\x00\x00\x00".encode()
        nul_usr = "\x00/\x00\x00\x00".encode()
        etc = "\x00/etc/ld.so".encode()
        lib = "\x00/lib".encode()
        usr = "\x00/usr".encode()
        ld_data = ld_data.replace(etc, nul_etc).\
            replace(lib, nul_lib).replace(usr, nul_usr)
        ld_library_path_orig = "\x00LD_LIBRARY_PATH\x00".encode()
        ld_library_path_new = "\x00LD_LIBRARY_REAL\x00".encode()
        ld_data = ld_data.replace(ld_library_path_orig, ld_library_path_new)
        if output_elf is None:
            return bool(FileUtil(elf_loader).putdata(ld_data, 'wb'))

        return bool(FileUtil(output_elf).putdata(ld_data, 'wb'))
def patch_ld ( self , output_elf = None ) : elf_loader = self . get_container_loader ( ) if FileUtil ( self . _container_ld_so_orig ) . size ( ) == - 1 : status = FileUtil ( elf_loader ) . copyto ( self . _container_ld_so_orig ) if not status : return False ld_data = FileUtil ( self . _container_ld_so_orig ) . getdata ( 'rb' ) if not ld_data : ld_data = FileUtil ( elf_loader ) . getdata ( 'rb' ) if not ld_data : return False nul_etc = "\x00/\x00\x00\x00\x00\x00\x00\x00\x00\x00" . encode ( ) nul_lib = "\x00/\x00\x00\x00" . encode ( ) nul_usr = "\x00/\x00\x00\x00" . encode ( ) etc = "\x00/etc/ld.so" . encode ( ) lib = "\x00/lib" . encode ( ) usr = "\x00/usr" . encode ( ) ld_data = ld_data . replace ( etc , nul_etc ) . replace ( lib , nul_lib ) . replace ( usr , nul_usr ) ld_library_path_orig = "\x00LD_LIBRARY_PATH\x00" . encode ( ) ld_library_path_new = "\x00LD_LIBRARY_REAL\x00" . encode ( ) ld_data = ld_data . replace ( ld_library_path_orig , ld_library_path_new ) if output_elf is None : return bool ( FileUtil ( elf_loader ) . putdata ( ld_data , 'wb' ) ) return bool ( FileUtil ( output_elf ) . putdata ( ld_data , 'wb' ) )