#!/usr/bin/env python # A little script I threw together to facilitate quick and dirty web requests # for use during web app pen tests. It will likely grow. I already have a number # of features I want to add so check back for an updated version. # # This program is in the public domain. Do whatever you want with it. # # Run with a -h to see the help. import sys import httplib from optparse import OptionParser def main(): # Supported options usage = "usage: %prog [options] hostname.domainname.tld" parser = OptionParser(usage) parser.add_option("-f", "--file", default="/", \ help="path and file on remote host (i.e. /secure/index.php)") parser.add_option("-s", "--ssl", dest="use_ssl", \ action="store_true", default=False, help="use SSL/TLS") parser.add_option("-d", "--headers", dest="headers_only", \ action="store_true", default=False, help="return headers only") parser.add_option("-m", "--method", dest="method", \ help="request method (default is GET)", default="GET") (options, args) = parser.parse_args() if len(args) != 1: parser.error("incorrect number of arguments") print usage else: get(args[0], options.use_ssl, options.headers_only, \ options.method, options.file) # Where the action is. Send the request to the given server and # dump the response to stdout. def get(site, use_ssl, headers_only, method, file): if use_ssl: conn = httplib.HTTPSConnection(site) else: conn = httplib.HTTPConnection(site) conn.request(method, file) resp = conn.getresponse() if headers_only: resp_headers = resp.getheaders() i = 0 while i < len(resp_headers): print str(resp_headers[i]) i += 1 else: print resp.read() if __name__ == "__main__": main()