MCPcopy Create free account
hub / github.com/AutoRecon/AutoRecon / VirtualHost

Class VirtualHost

autorecon/default-plugins/virtual-host-enumeration.py:7–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5urllib3.disable_warnings()
6
7class VirtualHost(ServiceScan):
8
9 def __init__(self):
10 super().__init__()
11 self.name = 'Virtual Host Enumeration'
12 self.slug = 'vhost-enum'
13 self.tags = ['default', 'safe', 'http', 'long']
14
15 def configure(self):
16 self.add_option('hostname', help='The hostname to use as the base host (e.g. example.com) for virtual host enumeration. Default: %(default)s')
17 self.add_list_option('wordlist', default=['/usr/share/seclists/Discovery/DNS/subdomains-top1million-110000.txt'], help='The wordlist(s) to use when enumerating virtual hosts. Separate multiple wordlists with spaces. Default: %(default)s')
18 self.add_option('threads', default=10, help='The number of threads to use when enumerating virtual hosts. Default: %(default)s')
19 self.match_service_name('^http')
20 self.match_service_name('^nacn_http$', negative_match=True)
21
22 async def run(self, service):
23 hostnames = []
24 if self.get_option('hostname'):
25 hostnames.append(self.get_option('hostname'))
26 if service.target.type == 'hostname' and service.target.address not in hostnames:
27 hostnames.append(service.target.address)
28 if self.get_global('domain') and self.get_global('domain') not in hostnames:
29 hostnames.append(self.get_global('domain'))
30
31 if len(hostnames) > 0:
32 for wordlist in self.get_option('wordlist'):
33 name = os.path.splitext(os.path.basename(wordlist))[0]
34 for hostname in hostnames:
35 try:
36 wildcard = requests.get(
37 ('https' if service.secure else 'http') + '://' + service.target.address + ':' + str(service.port) + '/',
38 headers={'Host': ''.join(random.choice(string.ascii_letters) for _ in range(20)) + '.' + hostname},
39 verify=False,
40 allow_redirects=False
41 )
42 size = str(len(wildcard.content))
43 except requests.exceptions.RequestException as e:
44 service.error(f"[!] Wildcard request failed for {hostname}: {e}")
45 continue
46
47 await service.execute(
48 'ffuf -u {http_scheme}://' + hostname + ':{port}/ -t ' + str(self.get_option('threads')) +
49 ' -w ' + wordlist + ' -H "Host: FUZZ.' + hostname + '" -mc all -fs ' + size +
50 ' -r -noninteractive -s | tee "{scandir}/{protocol}_{port}_{http_scheme}_' + hostname + '_vhosts_' + name + '.txt"'
51 )
52 else:
53 service.info('The target was not a hostname, nor was a hostname provided as an option. Skipping virtual host enumeration.')

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected