From 0beb2ad7c12c51c88e255f2af7ce9f466f59e673 Mon Sep 17 00:00:00 2001 From: Tib3rius <48113936+Tib3rius@users.noreply.github.com> Date: Thu, 30 Sep 2021 13:43:55 -0400 Subject: [PATCH] Bug fixes. Fixed bug in Curl Robots where file would get created despite no robots.txt existing. Fixed bug where manual command exceptions would not get caught. --- autorecon/default-plugins/http_server.py | 5 +++-- autorecon/main.py | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/autorecon/default-plugins/http_server.py b/autorecon/default-plugins/http_server.py index 97bcc1f..479f966 100644 --- a/autorecon/default-plugins/http_server.py +++ b/autorecon/default-plugins/http_server.py @@ -68,10 +68,11 @@ class CurlRobots(ServiceScan): async def run(self, service): if service.protocol == 'tcp': - _, stdout, _ = await service.execute('curl -sSikf {http_scheme}://{addressv6}:{port}/robots.txt', future_outfile='{protocol}_{port}_{http_scheme}_curl-robots.txt') + process, stdout, _ = await service.execute('curl -sSikf {http_scheme}://{addressv6}:{port}/robots.txt', future_outfile='{protocol}_{port}_{http_scheme}_curl-robots.txt') + lines = await stdout.readlines() - if lines: + if process.returncode == 0 and lines: filename = fformat('{scandir}/{protocol}_{port}_{http_scheme}_curl-robots.txt') with open(filename, mode='wt', encoding='utf8') as robots: robots.write('\n'.join(lines)) diff --git a/autorecon/main.py b/autorecon/main.py index 5b6a62b..c482c2a 100644 --- a/autorecon/main.py +++ b/autorecon/main.py @@ -17,7 +17,7 @@ from autorecon.io import slugify, e, fformat, cprint, debug, info, warn, error, from autorecon.plugins import Pattern, PortScan, ServiceScan, Report, AutoRecon from autorecon.targets import Target, Service -VERSION = "2.0.1" +VERSION = "2.0.2" if not os.path.exists(config['config_dir']): shutil.rmtree(config['config_dir'], ignore_errors=True, onerror=None) @@ -627,7 +627,12 @@ async def scan_target(target): for member_name, _ in inspect.getmembers(plugin, predicate=inspect.ismethod): if member_name == 'manual': - plugin.manual(service, plugin_was_run) + try: + plugin.manual(service, plugin_was_run) + except Exception as ex: + exc_type, exc_value, exc_tb = sys.exc_info() + error_text = ''.join(traceback.format_exception(exc_type, exc_value, exc_tb)[-2:]) + cprint('Error: Service scan {bblue}' + plugin.name + ' {green}(' + plugin_tag + '){rst} running against {byellow}' + target.address + '{rst} produced an exception:\n\n' + error_text, color=Fore.RED, char='!', printmsg=True) if service.manual_commands: plugin_run = False