#!/usr/bin/python

# HTExploit - Written by Matias Katz (@matiaskatz)
# Presented at Black Hat US 2012 Conference
# Team Leader: Maximiliano Soler (@maxisoler)
# Homepage: www.htexploit.org

version = "0.77"

import ConfigParser, optparse, os, signal, sys
from lib import Ascii
from lib import Conn
from lib import Detect
from lib import FullList
#from lib import SQLi

#Signal catcher for CTRL+C
def signal_handler(signal, frame):
        print "\n[x] Program Aborted by user.\n"
        sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)

#Print the app title, in a random Ascii art
title = Ascii.Title(version)
print title

#Set app parameters and show them on screen
usage = "Usage: %prog -u [URL] [options]"
parser = optparse.OptionParser(usage=usage)
parser.add_option("-u", "--url", action="store", type="string", dest="url", help="**REQUIRED** - Specify the URL to scan")
parser.add_option("-o", "--output", action="store", type="string", dest="output", help="Specify the output directory (Default: Random)")
parser.add_option("-w", "--wordlist", action="store", dest="wordlist", help="Specify the wordlist to use (Default: '/usr/share/htexploit/res/FullList')")
parser.add_option("-v", "--verbose", action="count", dest="verbose", help="Verbosity level (Default: 0)")
parser.set_defaults(module="detect")
parser.set_defaults(wordlist="/usr/share/htexploit/res/FullList")
parser.set_defaults(verbose=0)
(options, args) = parser.parse_args()

#Set variables according to parameters
if options.url == None:
        parser.print_help()
	print
        sys.exit()
if not options.url.startswith("http://") or options.url.startswith("https://"):
	options.url = "http://" + options.url
if options.output == None:
	outdir = options.output
else:
	outdir = os.path.abspath(options.output)
url = options.url + "/"
wordlist = os.path.abspath(options.wordlist)

#Call the detection scan module
Detect.Scan(url,options.verbose,outdir,wordlist)
