Skip to content

Instantly share code, notes, and snippets.

@dmgl
Last active September 11, 2019 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmgl/6f92c154ab93a7d9dd5ef5f5765e9498 to your computer and use it in GitHub Desktop.
Save dmgl/6f92c154ab93a7d9dd5ef5f5765e9498 to your computer and use it in GitHub Desktop.
How HTTP referer works
#!/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