Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #run python3 main.py
  2. from ctypes import *
  3. import subprocess
  4. import os
  5. libc = cdll.LoadLibrary('libc.so.6')
  6.  
  7. class Deff:
  8. def __init__(self, *args, **kwargs):
  9. self.CLONE_NEWNS=0x00020000
  10. self.CLONE_NEWUTS=0x04000000
  11. self.CLONE_NEWIPC=0x08000000
  12. self.CLONE_NEWUSER=0x10000000
  13. self.CLONE_NEWPID=0x20000000
  14. self.CLONE_NEWNET=0x40000000
  15. self.CLONE_IO=0x80000000
  16. return super().__init__(*args, **kwargs)
  17.  
  18. def clone(fn, flags=0):
  19. def stub():
  20. return fn() or 0
  21.  
  22. stack = bytes(0x100000)
  23. ret = libc.clone(CFUNCTYPE(c_int)(stub), c_void_p(cast(stack, c_void_p).value + len(stack)), flags)
  24. if ret == -1:
  25. _errno = get_errno() or errno.EPERM
  26. raise OSError(_errno, os.strerror(_errno))
  27.  
  28. def testp():
  29. cmd = "/bin/bash"
  30. #subprocess.call(cmd, stdout=subprocess.PIPE, shell=True, check=True)
  31. #subprocess.run(cmd,shell=True,check=True)
  32. os.system("/bin/bash")
  33. deff = Deff()
  34. flag = deff.CLONE_NEWNET|deff.CLONE_NEWNS| deff.CLONE_NEWPID | deff.CLONE_NEWUSER | deff.CLONE_NEWUTS
  35. clone(testp, 0)
  36. #print(deff.CLONE_NEWUTS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement