From 288af6a961d6775633c94c4a91826cabe17a6e38 Mon Sep 17 00:00:00 2001 From: Tib3rius <48113936+Tib3rius@users.noreply.github.com> Date: Fri, 27 Aug 2021 09:31:33 -0400 Subject: [PATCH] Update autorecon.py Added forced service check. If no services are defined, AutoRecon will error out. --- autorecon.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/autorecon.py b/autorecon.py index 33fc353..effa2b6 100644 --- a/autorecon.py +++ b/autorecon.py @@ -439,6 +439,7 @@ class AutoRecon(object): 'accessible': False, 'verbose': 0 } + self.errors = False self.lock = asyncio.Lock() self.load_slug = None self.load_module = None @@ -937,6 +938,11 @@ async def scan_target(target): if services: pending.append(asyncio.create_task(asyncio.sleep(0))) + else: + error('No services were defined. Please check your service syntax: [tcp|udp]///[secure|insecure]') + heartbeat.cancel() + autorecon.errors = True + return else: for plugin in target.autorecon.plugin_types['port']: plugin_tag_set = set(plugin.tags) @@ -1526,6 +1532,12 @@ async def main(): timed_out = False while pending: done, pending = await asyncio.wait(pending, return_when=asyncio.FIRST_COMPLETED, timeout=1) + + # If something failed in scan_target, autorecon.errors will be true. + if autorecon.errors: + cancel_all_tasks(None, None) + sys.exit(1) + # Check if global timeout has occurred. if autorecon.config['timeout'] is not None: elapsed_seconds = round(time.time() - start_time)