Wednesday, February 29, 2012

Python - HTTP Server Information

Description: This Python script will show HTTP information on target host.

#!/usr/bin/env python

# http://kuntoaji.blogspot.com

import urllib2, sys, re
from time import sleep

def serverInfo(server):
        try:
                print "[-]building request"
                req = urllib2.Request(server)
                sleep(2)
                print "[-]sending request"
                url = urllib2.urlopen(req)
                print "[-]getting information...\n"
                server_info = url.info()
                sleep(2)
                return server_info
        except (urllib2.URLError):
                status = "address not found"
                return status

def welcomeBro():
        print "[+] --------------------------------"
        print "[+] Get HTTP server infomation"
        print "[+] --------------------------------\n"

def error():
        print "error bro!"
        print "usage: python httpserverinfo.py [target host]\n"

if (__name__ == "__main__"):
        welcomeBro()

        if (len(sys.argv) == 2):
                server = sys.argv[1]
                if (not (re.search("http://", server))):
                        server = "http://"+server
                print serverInfo(server)
        else:
                error()

Artikel Terkait

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...