Skip to content

Commit 3a86b52

Browse files
author
Michael Skelton
committed
Added --ssl flag to replace port 443 detection
1 parent b1fdae1 commit 3a86b52

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

VHostScan.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,21 @@ def main():
1616
print_banner()
1717
parser = ArgumentParser()
1818
parser.add_argument("-t", dest="target_hosts", required=True, help="Set a target range of addresses to target. Ex 10.11.1.1-255" )
19-
parser.add_argument("-w", dest="wordlist", required=False, help="Set the wordlist to use for generated commands. Ex /usr/share/wordlist.txt", default="./wordlists/virtual-host-scanning.txt")
19+
parser.add_argument("-w", dest="wordlist", required=False, type=str, help="Set the wordlist to use for generated commands. Ex /usr/share/wordlist.txt", default="./wordlists/virtual-host-scanning.txt")
2020
parser.add_argument("-p", dest="port", required=False, help="Set the port to use. Leave blank to use discovered ports. Useful to force virtual host scanning on non-standard webserver ports (default 80).", default=80)
2121

2222
parser.add_argument('--ignore-http-codes', dest='ignore_http_codes', type=str, help='Comma separated list of http codes to ignore with virtual host scans (default 404).', default='404')
2323
parser.add_argument('--ignore-content-length', dest='ignore_content_length', type=int, help='Ignore content lengths of specificed amount. This may become useful when a server returns a static page on every virtual host guess.', default=0)
2424
parser.add_argument('--unique-depth', dest='unique_depth', type=int, help='Show likely matches of page content that is found x times (default 1).', default=1)
25+
parser.add_argument("--ssl", dest="ssl", action="store_true", help="If set then connections will be made over HTTPS instead of HTTP.", default=False)
2526
arguments = parser.parse_args()
27+
2628

27-
scanner = virtual_host_scanner(arguments.target_hosts, arguments.port, arguments.unique_depth, arguments.ignore_http_codes, arguments.ignore_content_length, arguments.wordlist)
28-
scanner.scan()
2929

30+
scanner = virtual_host_scanner(arguments.target_hosts, arguments.port, arguments.ssl, arguments.unique_depth, arguments.ignore_http_codes, arguments.ignore_content_length, arguments.wordlist)
31+
scanner.scan()
32+
33+
print("\n[+] Most likely matches with a unique count of %s or less:" % arguments.unique_depth)
3034
for p in scanner.likely_matches(): print(" [>] %s" % p)
3135

3236
if __name__ == "__main__":

lib/core/virtual_host_scanner.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,20 @@ class virtual_host_scanner(object):
1717
output: folder to write output file to
1818
"""
1919

20-
def __init__(self, target, port=80, unique_depth=1, ignore_http_codes='404', ignore_content_length=0,
20+
def __init__(self, target, port=80, ssl=False, unique_depth=1, ignore_http_codes='404', ignore_content_length=0,
2121
wordlist="./wordlists/virtual-host-scanning.txt"):
2222
self.target = target
2323
self.port = port
2424
self.ignore_http_codes = list(map(int, ignore_http_codes.replace(' ', '').split(',')))
2525
self.ignore_content_length = ignore_content_length
2626
self.wordlist = wordlist
2727
self.unique_depth = unique_depth
28-
28+
self.ssl = ssl
29+
2930
self.completed_scan=False
3031
self.results = []
3132

33+
3234
def scan(self):
3335
print("[+] Starting virtual host scan for %s using port %s and wordlist %s" % (self.target, str(self.port), self.wordlist))
3436
print("[>] Ignoring HTTP codes: %s" % (self.ignore_http_codes))
@@ -49,8 +51,7 @@ def scan(self):
4951
'Accept': '*/*'
5052
}
5153

52-
# todo: to be made redundant/replaced with a --ssl flag? Current implementation limits ssl severely
53-
dest_url = '{}://{}:{}/'.format('https' if int(self.port) == 443 else 'http', self.target, self.port)
54+
dest_url = '{}://{}:{}/'.format('https' if self.ssl else 'http', self.target, self.port)
5455

5556
try:
5657
res = requests.get(dest_url, headers=headers, verify=False)
@@ -85,8 +86,6 @@ def likely_matches(self):
8586
print("[!] Likely matches cannot be printed as a scan has not yet been run.")
8687
return
8788

88-
print("\n[+] Most likely matches with a unique count of %s or less:" % self.unique_depth)
89-
9089
# segment results from previous scan into usable results
9190
segmented_data={}
9291
for item in self.results:

0 commit comments

Comments
 (0)