Advertisement
pushrbx

Nightmare Python Challenge

May 12th, 2014
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. #!/usr/bin/python -u
  2. '''
  3. You may wish to refer to solutions to the pCTF 2013 "pyjail" problem if
  4. you choose to attempt this problem, BUT IT WON'T HELP HAHAHA.
  5. '''
  6.  
  7. from imp import acquire_lock
  8. from threading import Thread
  9. from sys import modules, stdin, stdout
  10.  
  11. # No more importing!
  12. x = Thread(target = acquire_lock, args = ())
  13. x.start()
  14. x.join()
  15. del x
  16. del acquire_lock
  17. del Thread
  18.  
  19. # No more modules!
  20. for k, v in modules.iteritems():
  21.     if v == None: continue
  22.     if k == '__main__':
  23.         print v.__dict__
  24.         continue
  25.     v.__dict__.clear()
  26.  
  27. del k, v
  28.  
  29. __main__ = modules['__main__']
  30. modules.clear()
  31. del modules
  32.  
  33. # No more anything!
  34. del __builtins__, __doc__, __file__, __name__, __package__
  35.  
  36. print >> stdout, "Get a shell. The flag is NOT in ./key, ./flag, etc."
  37. while 1:
  38.     exec 'print >> stdout, ' + stdin.readline() in {'stdout':stdout}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement