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:

June 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jun 1st
    0 Files
  • 2
    Jun 2nd
    0 Files
  • 3
    Jun 3rd
    18 Files
  • 4
    Jun 4th
    21 Files
  • 5
    Jun 5th
    0 Files
  • 6
    Jun 6th
    57 Files
  • 7
    Jun 7th
    6 Files
  • 8
    Jun 8th
    0 Files
  • 9
    Jun 9th
    0 Files
  • 10
    Jun 10th
    12 Files
  • 11
    Jun 11th
    27 Files
  • 12
    Jun 12th
    38 Files
  • 13
    Jun 13th
    16 Files
  • 14
    Jun 14th
    14 Files
  • 15
    Jun 15th
    0 Files
  • 16
    Jun 16th
    0 Files
  • 17
    Jun 17th
    16 Files
  • 18
    Jun 18th
    26 Files
  • 19
    Jun 19th
    15 Files
  • 20
    Jun 20th
    18 Files
  • 21
    Jun 21st
    0 Files
  • 22
    Jun 22nd
    0 Files
  • 23
    Jun 23rd
    0 Files
  • 24
    Jun 24th
    0 Files
  • 25
    Jun 25th
    0 Files
  • 26
    Jun 26th
    0 Files
  • 27
    Jun 27th
    0 Files
  • 28
    Jun 28th
    0 Files
  • 29
    Jun 29th
    0 Files
  • 30
    Jun 30th
    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