Guest User

Untitled

a guest
Jan 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import tempfile
  4. import os
  5. import string
  6. import random
  7.  
  8.  
  9. def randstr():
  10. return ''.join(random.choice(string.ascii_uppercase + string.digits + string.ascii_lowercase) for _ in range(10))
  11.  
  12. code = "require 'LFA'\n"
  13. code += "syscall 1, 1, \"hello\\n\", 6\n\n"
  14.  
  15. max = 600 # 600 linex should be more than enough ;)
  16.  
  17. print "Enter your code, enter the string END_OF_PWN to finish "
  18.  
  19. while max:
  20.  
  21. new_code = raw_input("code> ")
  22. if new_code == "END_OF_PWN":
  23. break
  24. code += new_code + "\n"
  25. max -= 1
  26.  
  27. name = "/tmp/%s" % randstr()
  28.  
  29. with open(name, "w+") as f:
  30. f.write(code)
  31.  
  32. flag = open("flag", "r")
  33.  
  34. os.dup2(flag.fileno(), 1023)
  35. flag.close()
  36. cmd = "timeout 40 ruby %s" % name
  37. os.system(cmd)
Add Comment
Please, Sign In to add comment