Tag Archives: response

Ruby – URL Monitoring

0
Filed under ruby
Tagged as , , , , , , ,

Author: Isaacs
Site: http://gist.github.com/237575
Summary: print out the URLs requested system wide on the main network interface.


ruby,code,code,snippet

Python – Show HTTP Status Code and HTTP Status Message

0
Filed under python
Tagged as , , , , , , , , ,

Author: slac3dork
Site: http://snippet.c0de.me
Summary: Python script to get HTTP status code and HTTP status code. This script is very useful to check your REST Web Service status code and status message. Tested on Linux.
Usage: python httpstatus.py -m HTTP_METHOD -t YOUR_TARGET_HOST

#!/usr/bin/python
#
#  _________      .__       .____   _______
# /   _____/ ____ |__|_____ |    |  \   _  \    ____
# \_____  \ /    \|  \____ \|    |  /  /_\  \  / ___\
# /        \   |  \  |  |_> >    |__\  \_/   \/ /_/  >
#/_______  /___|  /__|   __/|_______ \_____  /\___  /
#        \/     \/   |__|           \/     \//_____/
# http://snippet.c0de.me
# slac3dork[at]gmail[dot]com  

import httplib, re
from optparse import OptionParser
from time import sleep

class HTTPStatus:
	def __init__(self):
		self.host = ""
		self.path = ""
		self.http_method = ""

		usage = "usage: %prog -m method -t target"
		parser = OptionParser(usage=usage)
		parser.add_option("-m", "--method", dest="method",
				help="HTTP method: GET, POST, PUT, DELETE", metavar="http_method")
		parser.add_option("-t", "--target", dest="target",
				help="Your target host", metavar="target_host")
		(opts, args) = parser.parse_args()

		if opts.target:
			self.host = opts.target

			if re.search("http://", self.host):
				self.host = self.host.split("http://", 1)
				self.host = self.host[1]

			# extract hostname & path
			try:
				self.host = self.host.split("/", 1)
				self.path = "/"+self.host[1]
				self.host = self.host[0]
			except:
				self.host = self.host[0]
				self.path = "/"

		if opts.method:
			self.http_method = opts.method

	def getTarget(self):
		return self.host+self.path

	def getHTTPMethod(self):
		method_name = ""
		if re.match("(GET|POST|PUT|DELETE)", self.http_method):
			method_name = self.http_method
		return method_name

	def sendRequest(self):
		try:
			print "[!] building Connection..."
			conn = httplib.HTTPConnection(self.host)
			sleep(1)
			print "[!] Sending Request..."
			conn.request(self.http_method, self.path)
			sleep(1)
			print "[!] Reading Response...\n"
			resp = conn.getresponse()
			sleep(1)
			print "[+] Summary"
			print "[+] ---------------------------"
			print "[+] Target: http://"+self.host+self.path
			print "[+] Status Code:", resp.status
			print "[+] Status Message:", resp.reason
			print "[+] ---------------------------\n"
			conn.close()
		except:
			print "[-] Error! Check Your Internet Connection and target host."

if __name__ == "__main__":
	print "\n[+] ---------------------------------------------------"
	print "[+] Show HTTP Status Code and HTTP Status Message"
	print "[+] httpstatus.py - slac3dork@gmail.com"
	print "[+] Coded by: slac3dork"
	print "[+] ---------------------------------------------------\n"
	sleep(2)
	obj = HTTPStatus()
	target = obj.getTarget()
	method = obj.getHTTPMethod()
	if target and method:
		obj.sendRequest()



python,logo,banner

Python – Get HTTP Server Information

0
Filed under python
Tagged as , , , , , , ,

Author: slac3dork
Site: http://snippet.c0de.me
Summary: A python code that will print HTTP Server Response message. For educational purpose only. Tested on Linux.
Usage: python httpserverinfo.py <target_server>

#!/usr/bin/python
#
#  _________      .__       .____   _______
# /   _____/ ____ |__|_____ |    |  \   _  \    ____
# \_____  \ /    \|  \____ \|    |  /  /_\  \  / ___\
# /        \   |  \  |  |_> >    |__\  \_/   \/ /_/  >
#/_______  /___|  /__|   __/|_______ \_____  /\___  /
#        \/     \/   |__|           \/     \//_____/
# http://snippet.c0de.me
# slac3dork@gmail.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 "[+] Getting HTTP server infomation"
	print "[+] httserverinfo.py"
	print "[+] Coded By slac3dork"
	print "[+] Greetz to low1z"
	print "[+] --------------------------------\n"

def error():
	print "error bro!"
	print "hey, you don't know how to use this?"
	print "usage: python httpserverinfo.py <target>\n"
	print "target example: http://google.com"

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()



python,logo,banner