|
| 1 | +from argparse import ArgumentParser |
| 2 | +import os.path |
| 3 | + |
| 4 | +class cli_helper(object): |
| 5 | + @staticmethod |
| 6 | + def readable_file(parser, arg): |
| 7 | + if not os.path.exists(arg): |
| 8 | + parser.error("The file %s does not exist!" % arg) |
| 9 | + else: |
| 10 | + return open(arg, 'r') # return an open file handle |
| 11 | + |
| 12 | + |
| 13 | +class cli_argument_parser(object): |
| 14 | + def __init__(self): |
| 15 | + self._parser = self.setup_parser() |
| 16 | + |
| 17 | + def parse(self, argv): |
| 18 | + return self._parser.parse_args(argv) |
| 19 | + |
| 20 | + @staticmethod |
| 21 | + def setup_parser(): |
| 22 | + parser = ArgumentParser() |
| 23 | + |
| 24 | + parser.add_argument("-t", |
| 25 | + dest="target_hosts", |
| 26 | + required=True, |
| 27 | + help="Set a target range of addresses to target. Ex 10.11.1.1-255") |
| 28 | + |
| 29 | + parser.add_argument("-o", |
| 30 | + dest="output_directory", |
| 31 | + required=True, |
| 32 | + help="Set the output directory. Ex /root/Documents/labs/") |
| 33 | + |
| 34 | + parser.add_argument("-w", |
| 35 | + dest="wordlist", |
| 36 | + required=False, |
| 37 | + help="Set the wordlist to use for generated commands. Ex /usr/share/wordlist.txt", |
| 38 | + default=False) |
| 39 | + |
| 40 | + parser.add_argument("-p", |
| 41 | + dest="port", |
| 42 | + required=False, |
| 43 | + help="Set the port to use. Leave blank to use discovered ports. Useful to force virtual host scanning on non-standard webserver ports.", |
| 44 | + default=80) |
| 45 | + |
| 46 | + parser.add_argument("--pingsweep", |
| 47 | + dest="ping_sweep", |
| 48 | + action="store_true", |
| 49 | + help="Write a new target.txt by performing a ping sweep and discovering live hosts.", |
| 50 | + default=False) |
| 51 | + |
| 52 | + parser.add_argument("--dns","--dnssweep", |
| 53 | + dest="find_dns_servers", |
| 54 | + action="store_true", |
| 55 | + help="Find DNS servers from a list of targets.", |
| 56 | + default=False) |
| 57 | + |
| 58 | + parser.add_argument("--services", |
| 59 | + dest="perform_service_scan", |
| 60 | + action="store_true", |
| 61 | + help="Perform service scan over targets.", |
| 62 | + default=False) |
| 63 | + |
| 64 | + parser.add_argument("--hostnames", |
| 65 | + dest="hostname_scan", |
| 66 | + action="store_true", |
| 67 | + help="Attempt to discover target hostnames and write to 0-name.txt and hostnames.txt.", |
| 68 | + default=False) |
| 69 | + |
| 70 | + parser.add_argument("--snmp", |
| 71 | + dest="perform_snmp_walk", |
| 72 | + action="store_true", |
| 73 | + help="Perform service scan over targets.", |
| 74 | + default=False) |
| 75 | + |
| 76 | + parser.add_argument("--quick", |
| 77 | + dest="quick", |
| 78 | + action="store_true", |
| 79 | + required=False, |
| 80 | + help="Move to the next target after performing a quick scan and writing first-round recommendations.", |
| 81 | + default=False) |
| 82 | + |
| 83 | + parser.add_argument("--virtualhosts", |
| 84 | + dest="virtualhosts", |
| 85 | + action="store_true", |
| 86 | + required=False, |
| 87 | + help="Attempt to discover virtual hosts using the specified wordlist.", |
| 88 | + default=False) |
| 89 | + |
| 90 | + parser.add_argument('--ignore-http-codes', |
| 91 | + dest='ignore_http_codes', |
| 92 | + type=str, |
| 93 | + help='Comma separated list of http codes to ignore with virtual host scans.', |
| 94 | + default='404') |
| 95 | + |
| 96 | + parser.add_argument('--ignore-content-length', |
| 97 | + dest='ignore_content_length', |
| 98 | + type=int, |
| 99 | + help='Ignore content lengths of specificed amount. This may become useful when a server returns a static page on every virtual host guess.', |
| 100 | + default=0) |
| 101 | + |
| 102 | + parser.add_argument("--quiet", |
| 103 | + dest="quiet", |
| 104 | + action="store_true", |
| 105 | + help="Supress banner and headers to limit to comma dilimeted results only.", |
| 106 | + default=False) |
| 107 | + |
| 108 | + parser.add_argument("--no-udp", |
| 109 | + dest="no_udp_service_scan", |
| 110 | + action="store_true", |
| 111 | + help="Disable UDP services scan over targets.", |
| 112 | + default=False) |
| 113 | + return parser |
| 114 | + |
0 commit comments