Skip to content

Commit

Permalink
Merge pull request #12 from codingo/timk-base-host
Browse files Browse the repository at this point in the history
Added -b and -r options to override host and port used in headers
  • Loading branch information
timkent authored Sep 13, 2017
2 parents 4e574fc + f2b4550 commit f461aad
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
8 changes: 5 additions & 3 deletions VHostScan.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def print_banner():
print("+-+-+-+-+-+-+-+-+-+ v. 0.1")
print("+-+-+-+-+-+-+-+-+-+ v. 0.2")
print("|V|H|o|s|t|S|c|a|n| Developed by @codingo_ & @__timk")
print("+-+-+-+-+-+-+-+-+-+ https://github.com/codingo/VHostScan\n")

Expand All @@ -16,8 +16,10 @@ def main():
print_banner()
parser = ArgumentParser()
parser.add_argument("-t", dest="target_hosts", required=True, help="Set a target range of addresses to target. Ex 10.11.1.1-255" )
parser.add_argument("-b", dest="base_host", required=False, help="Set host to be used during substitution in wordlist (default to TARGET).", default=False)
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")
parser.add_argument("-p", dest="port", required=False, help="Set the port to use (default 80).", default=80)
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)

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')
parser.add_argument('--ignore-content-length', dest='ignore_content_length', type=int, help='Ignore content lengths of specificed amount.', default=0)
Expand All @@ -39,7 +41,7 @@ def main():
if(arguments.ignore_content_length > 0):
print("[>] Ignoring Content length: %s" % (arguments.ignore_content_length))

scanner = virtual_host_scanner(arguments.target_hosts, arguments.port, arguments.ssl, arguments.unique_depth,
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)

scanner.scan()
Expand All @@ -48,4 +50,4 @@ def main():
for p in scanner.likely_matches(): print(" [>] %s" % p)

if __name__ == "__main__":
main()
main()
18 changes: 13 additions & 5 deletions lib/core/virtual_host_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ class virtual_host_scanner(object):
output: folder to write output file to
"""

def __init__(self, target, port=80, ssl=False, unique_depth=1, ignore_http_codes='404', ignore_content_length=0,
def __init__(self, target, base_host, port=80, real_port=80, ssl=False, unique_depth=1, ignore_http_codes='404', ignore_content_length=0,
wordlist="./wordlists/virtual-host-scanning.txt"):
self.target = target
self.port = port
self.base_host = base_host
self.port = int(port)
self.real_port = int(real_port)
self.ignore_http_codes = list(map(int, ignore_http_codes.replace(' ', '').split(',')))
self.ignore_content_length = ignore_content_length
self.wordlist = wordlist
Expand All @@ -34,11 +36,17 @@ def __init__(self, target, port=80, ssl=False, unique_depth=1, ignore_http_codes
def scan(self):
virtual_host_list = open(self.wordlist).read().splitlines()

if not self.base_host:
self.base_host = self.target

if not self.real_port:
self.real_port = self.port

for virtual_host in virtual_host_list:
hostname = virtual_host.replace('%s', self.target)
hostname = virtual_host.replace('%s', self.base_host)

headers = {
'Host': hostname if self.port == 80 else '{}:{}'.format(hostname, self.port),
'Host': hostname if self.real_port == 80 else '{}:{}'.format(hostname, self.real_port),
'Accept': '*/*'
}

Expand Down Expand Up @@ -87,4 +95,4 @@ def likely_matches(self):
segmented_data = dataframe.groupby("val_col").filter(lambda x: len(x) <= self.unique_depth)
matches = ((segmented_data["key_col"].values).tolist())

return matches
return matches

0 comments on commit f461aad

Please sign in to comment.