Created
January 6, 2022 11:28
-
-
Save Luavis/55f54e66010a8a2d74b1bfe1295a4ed0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ctypes | |
from ctypes import CDLL, CFUNCTYPE, c_int, c_void_p, c_char_p | |
libc = CDLL('libc.so.6') | |
CSIGNAL = 0x000000ff | |
CLONE_VM = 0x00000100 | |
CLONE_FS = 0x00000200 | |
CLONE_FILES = 0x00000400 | |
CLONE_SIGHAND = 0x00000800 | |
CLONE_PIDFD = 0x00001000 | |
CLONE_PTRACE = 0x00002000 | |
CLONE_VFORK = 0x00004000 | |
CLONE_PARENT = 0x00008000 | |
CLONE_THREAD = 0x00010000 | |
CLONE_NEWNS = 0x00020000 | |
CLONE_SYSVSEM = 0x00040000 | |
CLONE_SETTLS = 0x00080000 | |
CLONE_PARENT_SETTID = 0x00100000 | |
CLONE_CHILD_CLEARTID = 0x00200000 | |
CLONE_DETACHED = 0x00400000 | |
CLONE_UNTRACED = 0x00800000 | |
CLONE_CHILD_SETTID = 0x01000000 | |
CLONE_NEWCGROUP = 0x02000000 | |
CLONE_NEWUTS = 0x04000000 | |
CLONE_NEWIPC = 0x08000000 | |
CLONE_NEWUSER = 0x10000000 | |
CLONE_NEWPID = 0x20000000 | |
CLONE_NEWNET = 0x40000000 | |
CLONE_IO = 0x80000000 | |
def clone(main, st_size=1024, flags=0): | |
main_f = CFUNCTYPE(c_int)(main) | |
stack = c_char_p(bytes(st_size * 1024)) | |
return libc.clone( | |
main_f, | |
c_void_p(ctypes.cast(stack, c_void_p).value + st_size * 1024), | |
flags) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment