Missed Services Collection

Added feature to collect services which AutoRecon "missed" (i.e. doesn't have plugins for) and report them at the end.
This commit is contained in:
Tib3rius 2021-08-13 18:53:59 -04:00
parent f828b08abc
commit abbb455a8c
2 changed files with 22 additions and 7 deletions

View File

@ -305,6 +305,7 @@ class ServiceScan(Plugin):
self.ignore_ports = {'tcp':[], 'udp':[]} self.ignore_ports = {'tcp':[], 'udp':[]}
self.service_names = [] self.service_names = []
self.ignore_service_names = [] self.ignore_service_names = []
self.match_all_service_names_boolean = False
self.run_once_boolean = False self.run_once_boolean = False
self.require_ssl_boolean = False self.require_ssl_boolean = False
@ -354,6 +355,10 @@ class ServiceScan(Plugin):
def run_once(self, boolean): def run_once(self, boolean):
self.run_once_boolean = boolean self.run_once_boolean = boolean
@final
def match_all_service_names(self, boolean):
self.match_all_service_names_boolean = boolean
class AutoRecon(object): class AutoRecon(object):
def __init__(self): def __init__(self):
@ -908,10 +913,14 @@ async def scan_target(target):
heading = False heading = False
for plugin in target.autorecon.plugin_types['service']: for plugin in target.autorecon.plugin_types['service']:
plugin_service_match = False
plugin_tag = service.tag() + '/' + plugin.slug plugin_tag = service.tag() + '/' + plugin.slug
for s in plugin.service_names: for s in plugin.service_names:
if re.search(s, service.name): if re.search(s, service.name):
plugin_service_match = True
if plugin.match_all_service_names_boolean or plugin_service_match:
plugin_tag_set = set(plugin.tags) plugin_tag_set = set(plugin.tags)
matching_tags = False matching_tags = False
@ -941,15 +950,18 @@ async def scan_target(target):
# Skip plugin if require_ssl_boolean and port is not secure # Skip plugin if require_ssl_boolean and port is not secure
if plugin.require_ssl_boolean and not service.secure: if plugin.require_ssl_boolean and not service.secure:
plugin_service_match = False
continue continue
# Skip plugin if service port is in ignore_ports: # Skip plugin if service port is in ignore_ports:
if port in plugin.ignore_ports[protocol]: if port in plugin.ignore_ports[protocol]:
plugin_service_match = False
warn('{byellow}[' + plugin_tag + ' against ' + target.address + ']{srst} Plugin cannot be run against ' + protocol + ' port ' + str(port) + '. Skipping.{rst}') warn('{byellow}[' + plugin_tag + ' against ' + target.address + ']{srst} Plugin cannot be run against ' + protocol + ' port ' + str(port) + '. Skipping.{rst}')
continue continue
# Skip plugin if plugin has required ports and service port is not in them: # Skip plugin if plugin has required ports and service port is not in them:
if plugin.ports[protocol] and port not in plugin.ports[protocol]: if plugin.ports[protocol] and port not in plugin.ports[protocol]:
plugin_service_match = False
warn('{byellow}[' + plugin_tag + ' against ' + target.address + ']{srst} Plugin can only run on specific ports. Skipping.{rst}') warn('{byellow}[' + plugin_tag + ' against ' + target.address + ']{srst} Plugin can only run on specific ports. Skipping.{rst}')
continue continue
@ -974,6 +986,9 @@ async def scan_target(target):
break break
if plugin_service_match:
service_match = True
for plugin in matching_plugins: for plugin in matching_plugins:
plugin_tag = service.tag() + '/' + plugin.slug plugin_tag = service.tag() + '/' + plugin.slug
@ -989,10 +1004,10 @@ async def scan_target(target):
pending.add(asyncio.create_task(service_scan(plugin, service))) pending.add(asyncio.create_task(service_scan(plugin, service)))
#if not service_match: if not service_match:
# warn('{byellow}[' + target.address + ']{srst} Service ' + service.full_tag() + ' did not match any plugins.{rst}') warn('{byellow}[' + target.address + ']{srst} Service ' + service.full_tag() + ' did not match any plugins based on the service name.{rst}')
# if service.full_tag() not in target.autorecon.missing_services: if service.full_tag() not in target.autorecon.missing_services:
# target.autorecon.missing_services.append(service.full_tag()) target.autorecon.missing_services.append(service.full_tag())
heartbeat.cancel() heartbeat.cancel()
elapsed_time = calculate_elapsed_time(start_time) elapsed_time = calculate_elapsed_time(start_time)
@ -1411,8 +1426,8 @@ async def main():
elapsed_time = calculate_elapsed_time(start_time) elapsed_time = calculate_elapsed_time(start_time)
info('{bright}Finished scanning all targets in ' + elapsed_time + '!{rst}') info('{bright}Finished scanning all targets in ' + elapsed_time + '!{rst}')
#if autorecon.missing_services: if autorecon.missing_services:
# warn('{byellow}AutoRecon identified the following services, but could not match them to any plugins. Please report these to Tib3rius: ' + ', '.join(autorecon.missing_services) + '{rst}') warn('{byellow}AutoRecon identified the following services, but could not match them to any plugins based on the service name. Please report these to Tib3rius: ' + ', '.join(autorecon.missing_services) + '{rst}')
if __name__ == '__main__': if __name__ == '__main__':
signal.signal(signal.SIGINT, cancel_all_tasks) signal.signal(signal.SIGINT, cancel_all_tasks)

View File

@ -8,7 +8,7 @@ class SSLScan(ServiceScan):
self.tags = ['default', 'ssl', 'tls'] self.tags = ['default', 'ssl', 'tls']
def configure(self): def configure(self):
self.match_service_name('.+') self.match_all_service_names(True)
self.require_ssl(True) self.require_ssl(True)
async def run(self, service): async def run(self, service):