From 5dc7630e0f8abdb1dd4c4e32de2800a4f2fc4cbf Mon Sep 17 00:00:00 2001 From: Tib3rius <48113936+Tib3rius@users.noreply.github.com> Date: Wed, 15 Sep 2021 14:07:16 -0400 Subject: [PATCH] Bug fixes. Renamed the outdir variable back to output to avoid inconsistencies with config. Renamed --targets to --target-file again for consistency. --- README.md | 21 +++++++++++---------- autorecon/config.py | 4 ++-- autorecon/default-plugins/reporting.py | 4 ++-- autorecon/main.py | 14 +++++++------- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 7de5047..9c47b5a 100644 --- a/README.md +++ b/README.md @@ -147,14 +147,15 @@ AutoRecon uses Python 3 specific functionality and does not support Python 2. ``` usage: autorecon [-t TARGET_FILE] [-p PORTS] [-m MAX_SCANS] [-mp MAX_PORT_SCANS] [-c CONFIG_FILE] [-g GLOBAL_FILE] [--tags TAGS] [--exclude-tags TAGS] [--port-scans PLUGINS] [--service-scans PLUGINS] - [--reports PLUGINS] [--plugins-dir PLUGINS_DIR] [--add-plugins-dir PLUGINS_DIR] [-l [TYPE]] [-o OUTDIR] - [--single-target] [--only-scans-dir] [--create-port-dirs] [--heartbeat HEARTBEAT] [--timeout TIMEOUT] - [--target-timeout TARGET_TIMEOUT] [--nmap NMAP | --nmap-append NMAP_APPEND] [--proxychains] - [--disable-sanity-checks] [--disable-keyboard-control] [--force-services SERVICE [SERVICE ...]] - [--accessible] [-v] [--version] [--curl.path VALUE] - [--dirbuster.tool {feroxbuster,gobuster,dirsearch,ffuf,dirb}] [--dirbuster.wordlist VALUE [VALUE ...]] - [--dirbuster.threads VALUE] [--dirbuster.ext VALUE] [--onesixtyone.community-strings VALUE] - [--global.username-wordlist VALUE] [--global.password-wordlist VALUE] [--global.domain VALUE] [-h] + [--reports PLUGINS] [--plugins-dir PLUGINS_DIR] [--add-plugins-dir PLUGINS_DIR] [-l [TYPE]] + [-o OUTPUT] [--single-target] [--only-scans-dir] [--create-port-dirs] [--heartbeat HEARTBEAT] + [--timeout TIMEOUT] [--target-timeout TARGET_TIMEOUT] [--nmap NMAP | --nmap-append NMAP_APPEND] + [--proxychains] [--disable-sanity-checks] [--disable-keyboard-control] + [--force-services SERVICE [SERVICE ...]] [--accessible] [-v] [--version] [--curl.path VALUE] + [--dirbuster.tool {feroxbuster,gobuster,dirsearch,ffuf,dirb}] + [--dirbuster.wordlist VALUE [VALUE ...]] [--dirbuster.threads VALUE] [--dirbuster.ext VALUE] + [--onesixtyone.community-strings VALUE] [--global.username-wordlist VALUE] + [--global.password-wordlist VALUE] [--global.domain VALUE] [-h] [targets ...] Network reconnaissance tool to port scan and automatically enumerate services found on multiple targets. @@ -164,7 +165,7 @@ positional arguments: foo.bar) to scan. optional arguments: - -t TARGET_FILE, --targets TARGET_FILE + -t TARGET_FILE, --target-file TARGET_FILE Read targets from file. -p PORTS, --ports PORTS Comma separated list of ports / port ranges to scan. Specify TCP/UDP ports by prepending list @@ -197,7 +198,7 @@ optional arguments: The location of an additional plugins directory to add to the main one. Default: None -l [TYPE], --list [TYPE] List all plugins or plugins of a specific type. e.g. --list, --list port, --list service - -o OUTDIR, --output OUTDIR + -o OUTPUT, --output OUTPUT The output directory for results. Default: results --single-target Only scan a single target. A directory named after the target will not be created. Instead, the directory structure will be created within the output directory. Default: False diff --git a/autorecon/config.py b/autorecon/config.py index 1c2afe2..f981b1c 100644 --- a/autorecon/config.py +++ b/autorecon/config.py @@ -13,7 +13,7 @@ configurable_keys = [ 'reports', 'plugins_dir', 'add_plugins-dir', - 'outdir', + 'output', 'single_target', 'only_scans_dir', 'create_port_dirs', @@ -53,7 +53,7 @@ config = { 'reports': None, 'plugins_dir': None, 'add_plugins_dir': None, - 'outdir': 'results', + 'output': 'results', 'single_target': False, 'only_scans_dir': False, 'create_port_dirs': False, diff --git a/autorecon/default-plugins/reporting.py b/autorecon/default-plugins/reporting.py index e5b87be..f4fe429 100644 --- a/autorecon/default-plugins/reporting.py +++ b/autorecon/default-plugins/reporting.py @@ -12,7 +12,7 @@ class CherryTree(Report): async def run(self, targets): if len(targets) > 1: - report = os.path.join(config['outdir'], 'report.xml.ctd') + report = os.path.join(config['output'], 'report.xml.ctd') elif len(targets) == 1: report = os.path.join(targets[0].reportdir, 'report.xml.ctd') else: @@ -98,7 +98,7 @@ class Markdown(Report): async def run(self, targets): if len(targets) > 1: - report = os.path.join(config['outdir'], 'report.md') + report = os.path.join(config['output'], 'report.md') elif len(targets) == 1: report = os.path.join(targets[0].reportdir, 'report.md') else: diff --git a/autorecon/main.py b/autorecon/main.py index ecf9f79..4611d6f 100644 --- a/autorecon/main.py +++ b/autorecon/main.py @@ -364,12 +364,12 @@ async def generate_report(plugin, targets): raise Exception(cprint('Error: Report plugin {bblue}' + plugin.name + ' {green}(' + plugin.slug + '){rst} produced an exception:\n\n' + error_text, color=Fore.RED, char='!', printmsg=False)) async def scan_target(target): - os.makedirs(os.path.abspath(config['outdir']), exist_ok=True) + os.makedirs(os.path.abspath(config['output']), exist_ok=True) if config['single_target']: - basedir = os.path.abspath(config['outdir']) + basedir = os.path.abspath(config['output']) else: - basedir = os.path.abspath(os.path.join(config['outdir'], target.address)) + basedir = os.path.abspath(os.path.join(config['output'], target.address)) os.makedirs(basedir, exist_ok=True) target.basedir = basedir @@ -757,12 +757,12 @@ async def run(): parser = argparse.ArgumentParser(add_help=False, description='Network reconnaissance tool to port scan and automatically enumerate services found on multiple targets.') parser.add_argument('targets', action='store', help='IP addresses (e.g. 10.0.0.1), CIDR notation (e.g. 10.0.0.1/24), or resolvable hostnames (e.g. foo.bar) to scan.', nargs='*') - parser.add_argument('-t', '--targets', action='store', type=str, default='', dest='target_file', help='Read targets from file.') + parser.add_argument('-t', '--target-file', action='store', type=str, default='', help='Read targets from file.') parser.add_argument('-p', '--ports', action='store', type=str, help='Comma separated list of ports / port ranges to scan. Specify TCP/UDP ports by prepending list with T:/U: To scan both TCP/UDP, put port(s) at start or specify B: e.g. 53,T:21-25,80,U:123,B:123. Default: %(default)s') parser.add_argument('-m', '--max-scans', action='store', type=int, help='The maximum number of concurrent scans to run. Default: %(default)s') parser.add_argument('-mp', '--max-port-scans', action='store', type=int, help='The maximum number of concurrent port scans to run. Default: 10 (approx 20%% of max-scans unless specified)') parser.add_argument('-c', '--config', action='store', type=str, default=config_file, dest='config_file', help='Location of AutoRecon\'s config file. Default: %(default)s') - parser.add_argument('-g', '--global-file', action='store', type=str, dest='global_file', help='Location of AutoRecon\'s global file. Default: %(default)s') + parser.add_argument('-g', '--global-file', action='store', type=str, help='Location of AutoRecon\'s global file. Default: %(default)s') parser.add_argument('--tags', action='store', type=str, default='default', help='Tags to determine which plugins should be included. Separate tags by a plus symbol (+) to group tags together. Separate groups with a comma (,) to create multiple groups. For a plugin to be included, it must have all the tags specified in at least one group. Default: %(default)s') parser.add_argument('--exclude-tags', action='store', type=str, default='', metavar='TAGS', help='Tags to determine which plugins should be excluded. Separate tags by a plus symbol (+) to group tags together. Separate groups with a comma (,) to create multiple groups. For a plugin to be excluded, it must have all the tags specified in at least one group. Default: %(default)s') parser.add_argument('--port-scans', action='store', type=str, metavar='PLUGINS', help='Override --tags / --exclude-tags for the listed PortScan plugins (comma separated). Default: %(default)s') @@ -771,7 +771,7 @@ async def run(): parser.add_argument('--plugins-dir', action='store', type=str, help='The location of the plugins directory. Default: %(default)s') parser.add_argument('--add-plugins-dir', action='store', type=str, metavar='PLUGINS_DIR', help='The location of an additional plugins directory to add to the main one. Default: %(default)s') parser.add_argument('-l', '--list', action='store', nargs='?', const='plugins', metavar='TYPE', help='List all plugins or plugins of a specific type. e.g. --list, --list port, --list service') - parser.add_argument('-o', '--output', action='store', dest='outdir', help='The output directory for results. Default: %(default)s') + parser.add_argument('-o', '--output', action='store', help='The output directory for results. Default: %(default)s') parser.add_argument('--single-target', action='store_true', help='Only scan a single target. A directory named after the target will not be created. Instead, the directory structure will be created within the output directory. Default: %(default)s') parser.add_argument('--only-scans-dir', action='store_true', help='Only create the "scans" directory for results. Other directories (e.g. exploit, loot, report) will not be created. Default: %(default)s') parser.add_argument('--create-port-dirs', action='store_true', help='Create directories for ports within the "scans" directory (e.g. scans/tcp80, scans/udp53) and store results in these directories. Default: %(default)s') @@ -1190,7 +1190,7 @@ async def run(): if len(args.target_file) > 0: if not os.path.isfile(args.target_file): - error('The target file ' + args.target_file + ' was not found.') + error('The target file "' + args.target_file + '" was not found.') sys.exit(1) try: with open(args.target_file, 'r') as f: