Skip to content

Instantly share code, notes, and snippets.

@cbodley
Created March 16, 2018 12:59
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 cbodley/3e6003450b0e9a13b92df374513330f5 to your computer and use it in GitHub Desktop.
Save cbodley/3e6003450b0e9a13b92df374513330f5 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import argparse
import socket
parser = argparse.ArgumentParser()
parser.add_argument('hostname', help='Hostname of the http server')
parser.add_argument('port', type=int, help='Port number of the http server')
args = parser.parse_args()
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((args.hostname, args.port))
# send http message with incomplete Host header
sock.send('GET / HTTP/1.1\r\nHost\r\n\r\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment