import requests
import sys
import urllib2

# Colors 
ColorNotFound = '\033[91m'
StopColor = '\033[0m'
ColorInformation = '\33[34m'
Found = '\033[92m'
Warning = '\33[33m'
def main(argv):	

	# Header to check 
	default_header = ['Strict-Transport-Security','X-Powered-By','Security-Policy','Content-Security-Policy','X-Frame-Options', 'Content-Type', 'X-XSS-Protection', 'Access-Control-Allow-Origin', 'Last-Modified', 'Access-Control-Allow-Credentials', 'Set-Cookie'];
	r = requests.get(sys.argv[1])

	# Get status code
	print(Found)
	print "Response status : ", r.status_code
	print(StopColor)

	# search for type of server 
	print( Found +"Server found : " + r.headers.get('Server') + StopColor)
	print(ColorInformation)
	# show headers from request
	print(r.headers)
	print(StopColor)

	# check if robots.txt exist
	checkRobot = requests.get(sys.argv[1] + "/robots.txt")
	if checkRobot.status_code != 200:
		print(ColorNotFound + "robots NOT FOUND" + StopColor)
	else:
		print( Found + "Robots.txt FOUND" + StopColor )
		print( "CONTENT : \n" + checkRobot.content + "\n" + StopColor)

	# try to match request with custom array
	in_dict(default_header, r.headers)


def in_dict(listHeader, ResponseHeader):

	for header in listHeader:
		print('-------------------------------------------')
		if header in ResponseHeader:
			print(Found+ "Header: "+ header + " FOUND" + StopColor)
			if("X-Powered-By" == header):
				print(Warning + "-----------------------")
				print("language used spotted")
				print("-----------------------" + StopColor)
		else:
			print(ColorNotFound + "Header: " + header + " NOT FOUND " + StopColor)
			if("X-XSS-Protection" == header):
				print(Warning + '------------------')
				print("xss should works")
				print('----------------------------' + StopColor)
			if("Strict-Transport-Security" == header):
				print(Warning + '-------------------')
				print("website can probably be called as http")
				print('-----------------------------' + StopColor)	

if __name__ == "__main__":

   main(sys.argv)
