Skip to content

Commit b1e3306

Browse files
committed
Added functionality for pipeing in wordlist information
1 parent 787dd4c commit b1e3306

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

VHostScan.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def main():
1717
print_banner()
1818
parser = ArgumentParser()
1919
parser.add_argument("-t", dest="target_hosts", required=True, help="Set a target range of addresses to target. Ex 10.11.1.1-255" )
20-
parser.add_argument("-w", dest="wordlist", required=False, type=str, help="Set the wordlist to use (default ./wordlists/virtual-host-scanning.txt)", default="./wordlists/virtual-host-scanning.txt")
20+
parser.add_argument("-w", dest="wordlist", required=False, type=str, help="Set the wordlist to use (default ./wordlists/virtual-host-scanning.txt)")
2121
parser.add_argument("-b", dest="base_host", required=False, help="Set host to be used during substitution in wordlist (default to TARGET).", default=False)
2222
parser.add_argument("-p", dest="port", required=False, help="Set the port to use (default 80).", default=80)
2323
parser.add_argument("-r", dest="real_port", required=False, help="The real port of the webserver to use in headers when not 80 (see RFC2616 14.23), useful when pivoting through ssh/nc etc (default to PORT).", default=False)
@@ -28,20 +28,24 @@ def main():
2828
parser.add_argument("--ssl", dest="ssl", action="store_true", help="If set then connections will be made over HTTPS instead of HTTP (default http).", default=False)
2929
parser.add_argument("-oN", dest="output_normal", help="Normal output printed to a file when the -oN option is specified with a filename argument." )
3030
parser.add_argument("-", dest="stdin", action="store_true", help="By passing a blank '-' you tell VHostScan to expect input from stdin (pipe).", default=False)
31-
arguments = parser.parse_args()
32-
33-
if not os.path.exists(arguments.wordlist):
34-
print("[!] Wordlist %s doesn't exist, ending scan." % arguments.wordlistt)
35-
sys.exit()
36-
31+
32+
arguments = parser.parse_args()
33+
wordlist = ""
34+
3735
if(arguments.stdin):
3836
for line in sys.stdin:
39-
print("DEBUG (stdin): %s" % line)
40-
return
37+
wordlist += line
38+
elif(arguments.stdin and arguments.wordlist):
39+
if not os.path.exists(arguments.wordlist):
40+
print("[!] Wordlist %s doesn't exist and can't be appended to stdin." % arguments.wordlistt)
41+
else:
42+
wordlist += open("./wordlists/virtual-host-scanning.txt").read().splitlines()
43+
else:
44+
wordlist = open("./wordlists/virtual-host-scanning.txt").read().splitlines()
4145

4246
print("[+] Starting virtual host scan for %s using port %s and wordlist %s" % (arguments.target_hosts,
4347
str(arguments.port),
44-
arguments.wordlist))
48+
"placeholder"))
4549

4650
if(arguments.ssl):
4751
print("[>] SSL flag set, sending all results over HTTPS")
@@ -51,7 +55,8 @@ def main():
5155
if(arguments.ignore_content_length > 0):
5256
print("[>] Ignoring Content length: %s" % (arguments.ignore_content_length))
5357

54-
scanner = virtual_host_scanner(arguments.target_hosts, arguments.base_host, arguments.port, arguments.real_port, arguments.ssl, arguments.unique_depth, arguments.ignore_http_codes, arguments.ignore_content_length, arguments.wordlist)
58+
scanner = virtual_host_scanner( arguments.target_hosts, arguments.base_host, wordlist, arguments.port, arguments.real_port, arguments.ssl,
59+
arguments.unique_depth, arguments.ignore_http_codes, arguments.ignore_content_length)
5560

5661
scanner.scan()
5762
output = output_helper(scanner)

lib/core/virtual_host_scanner.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ class virtual_host_scanner(object):
1919
output: folder to write output file to
2020
"""
2121

22-
def __init__(self, target, base_host, port=80, real_port=80, ssl=False, unique_depth=1, ignore_http_codes='404', ignore_content_length=0,
23-
wordlist="./wordlists/virtual-host-scanning.txt"):
22+
def __init__(self, target, base_host, wordlist, port=80, real_port=80, ssl=False, unique_depth=1, ignore_http_codes='404', ignore_content_length=0):
2423
self.target = target
2524
self.base_host = base_host
2625
self.port = int(port)
@@ -40,16 +39,15 @@ def __init__(self, target, base_host, port=80, real_port=80, ssl=False, unique_d
4039
# store associated data for discovered hosts in array for oN, oJ, etc'
4140
self.hosts = []
4241

43-
def scan(self):
44-
virtual_host_list = open(self.wordlist).read().splitlines()
4542

43+
def scan(self):
4644
if not self.base_host:
4745
self.base_host = self.target
4846

4947
if not self.real_port:
5048
self.real_port = self.port
5149

52-
for virtual_host in virtual_host_list:
50+
for virtual_host in self.wordlist:
5351
hostname = virtual_host.replace('%s', self.base_host)
5452

5553
headers = {

0 commit comments

Comments
 (0)