Not Just Paranoid

Another site by Pete Maynard

Script to get HTTP Headers

The below script uses urllib2 to connect to the given URL(s) then prints out the HTTP headers.

http-server-header.py

#:/bin/python
import urllib2, sys

if len(sys.argv) == 1:
    print "Please feed me a URL...\n\n<3\n"
    sys.exit(0)

for url in sys.argv[1:]:
    r = urllib2.urlopen(url)
    print 'URL: ' + url + '\n' + str(r.info())

An example of it working is shown below. From a “security through obscurity” view, you’d want to conceal your HTTP server information.

$ python ~/http-server-header.py http://nationpigeon.com
    URL: http://nationpigeon.com
    Server: nginx/1.2.1
    Date: Mon, 05 Aug 2013 01:10:19 GMT
    Content-Type: text/html
    Content-Length: 650
    Last-Modified: Mon, 29 Jul 2013 08:46:57 GMT
    Connection: close
    Accept-Ranges: bytes

2 Aug 2013 | Tags ( Python HTTP HTTP Headers )

Website Last Updated on 13 Oct 2020 (CC BY-SA 4.0)

This site uses JQuery and nanogallery2 hosted by jsdelivr.net
for the Flickr photo feed and GoatCounter for user insights.