what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

GetHTTPStatus Scanning Script

GetHTTPStatus Scanning Script
Posted Jan 31, 2011
Authored by Sebastien Damaye

GetHTTPStatus is a simple python script that scans a set of provided URLs and returns the status codes provided. It has the ability to use cookies if needed.

tags | tool, scanner, python
systems | unix
SHA-256 | e2bc79b48cf3e7d09e13850c55cc2f6ce1a7c571a8ea3f55dd7677e2e33084aa

GetHTTPStatus Scanning Script

Change Mirror Download
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
pygetstatus.py
Sebastien Damaye (www.aldeid.com)
2011-01-30


This program opens a socket to a target (web server) and sends HEAD requests for
a list of URLs provided. For each URL, the returned status is displayed (e.g.
200 for OK, 404 for Not Found, ...)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

import httplib
import socket
import sys
import os
from optparse import OptionParser

class Scan:
def __init__(self, fileUrls, target, port=80, cookie=''):
"""Perform some checks
"""
self.fileUrls = fileUrls
if not os.path.exists(self.fileUrls):
print ("File %s not found. Please check location." % self.fileUrls)
sys.exit(2)
self.target = target
self.port = port
self.cookie = cookie

def getStatus(self):
"""Get the status of requests provided in fileUrls
"""
urls = open(self.fileUrls, "r")
if self.cookie:
params = {}
headers = {"Cookie": self.cookie}

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((self.target, self.port))

for iurl in urls:
url = iurl.split('\n')[0]
conn = httplib.HTTPConnection(self.target, self.port)
try:
if self.cookie:
conn.request('HEAD', url, params, headers)
else:
conn.request('HEAD', url)
except:
print "***Error: Unable to connect"
else:
res = conn.getresponse()
print "%s;%s" % (url,res.status)
conn.close

s.close()
urls.close()

if __name__ == '__main__':
usage = "usage: %prog -t <target> -u <fileUrls> [options]"
parser = OptionParser(usage)
parser.add_option("-t", "--target", dest="target",
help="host to connect to (e.g. 192.168.100.14)")
parser.add_option("-p", "--port", dest="port", default=80,
help="port to connect to (default: 80)")
parser.add_option("-u", "--url", dest="fileUrls",
help="file that contains URLs (one per line)")
parser.add_option("-c", '--cookie', dest="cookie", default='',
help="eventual cookie to use (syntax: ""key=value"", e.g. ""PHPSESSID=abcdefghj"")")
(options, args) = parser.parse_args(sys.argv)
if not options.target:
parser.error("Target missing. Use -t <target>.")
if not options.fileUrls:
parser.error("URLs file missing. Use -u <fileUrls>.")

oScan = Scan(options.fileUrls, options.target, options.port, options.cookie)
oScan.getStatus()
del oScan
Login or Register to add favorites

File Archive:

March 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Mar 1st
    16 Files
  • 2
    Mar 2nd
    0 Files
  • 3
    Mar 3rd
    0 Files
  • 4
    Mar 4th
    32 Files
  • 5
    Mar 5th
    28 Files
  • 6
    Mar 6th
    42 Files
  • 7
    Mar 7th
    17 Files
  • 8
    Mar 8th
    13 Files
  • 9
    Mar 9th
    0 Files
  • 10
    Mar 10th
    0 Files
  • 11
    Mar 11th
    15 Files
  • 12
    Mar 12th
    19 Files
  • 13
    Mar 13th
    21 Files
  • 14
    Mar 14th
    38 Files
  • 15
    Mar 15th
    15 Files
  • 16
    Mar 16th
    0 Files
  • 17
    Mar 17th
    0 Files
  • 18
    Mar 18th
    10 Files
  • 19
    Mar 19th
    0 Files
  • 20
    Mar 20th
    0 Files
  • 21
    Mar 21st
    0 Files
  • 22
    Mar 22nd
    0 Files
  • 23
    Mar 23rd
    0 Files
  • 24
    Mar 24th
    0 Files
  • 25
    Mar 25th
    0 Files
  • 26
    Mar 26th
    0 Files
  • 27
    Mar 27th
    0 Files
  • 28
    Mar 28th
    0 Files
  • 29
    Mar 29th
    0 Files
  • 30
    Mar 30th
    0 Files
  • 31
    Mar 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close