Last active
September 11, 2019 12:20
-
-
Save dmgl/6f92c154ab93a7d9dd5ef5f5765e9498 to your computer and use it in GitHub Desktop.
How HTTP referer works
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
#!/usr/bin/env python | |
# save this file and run `python how_referer_header_works.py` | |
# to stop you can use commnad `lsof -i tcp:9999` and kill pid | |
# usage: make public post on any site with hlink href http://0.0.0.0:9999 and click on it | |
# or `curl 0.0.0.0:9999 --referer google.com -H "X-Something: Yeah-yeah-yeah"` | |
# see output of script with headers section (custom referer) | |
import SimpleHTTPServer | |
import SocketServer | |
import logging | |
PORT = 9999 | |
class GetHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
def do_GET(self): | |
logging.error(self.headers) | |
SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self) | |
Handler = GetHandler | |
httpd = SocketServer.TCPServer(("", PORT), Handler) | |
httpd.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment