()
| 286 | return message |
| 287 | |
| 288 | def parse_args(): |
| 289 | global options |
| 290 | |
| 291 | parser = optparse.OptionParser(version=VERSION) |
| 292 | parser.add_option("--delay", dest="delay", type=int, help="Delay (sec) between tests (default: 0)") |
| 293 | parser.add_option("--timeout", dest="timeout", type=int, help="Response timeout (sec) (default: 10)") |
| 294 | parser.add_option("--proxy", dest="proxy", help="HTTP proxy address (e.g. \"http://127.0.0.1:8080\")") |
| 295 | parser.add_option("--proxy-file", dest="proxy_file", help="Load (rotating) HTTP(s) proxy list from a file") |
| 296 | parser.add_option("--random-agent", dest="random_agent", action="store_true", help="Use random HTTP User-Agent header value") |
| 297 | parser.add_option("--code", dest="code", type=int, help="Expected HTTP code in rejected responses") |
| 298 | parser.add_option("--string", dest="string", help="Expected string in rejected responses") |
| 299 | parser.add_option("--post", dest="post", action="store_true", help="Use POST body for sending payloads") |
| 300 | parser.add_option("--debug", dest="debug", action="store_true", help=optparse.SUPPRESS_HELP) |
| 301 | parser.add_option("--fast", dest="fast", action="store_true", help=optparse.SUPPRESS_HELP) |
| 302 | parser.add_option("--lock", dest="lock", action="store_true", help=optparse.SUPPRESS_HELP) |
| 303 | |
| 304 | # Dirty hack(s) for help message |
| 305 | def _(self, *args): |
| 306 | retval = parser.formatter._format_option_strings(*args) |
| 307 | if len(retval) > MAX_HELP_OPTION_LENGTH: |
| 308 | retval = ("%%.%ds.." % (MAX_HELP_OPTION_LENGTH - parser.formatter.indent_increment)) % retval |
| 309 | return retval |
| 310 | |
| 311 | parser.usage = "python %s <host|url>" % parser.usage |
| 312 | parser.formatter._format_option_strings = parser.formatter.format_option_strings |
| 313 | parser.formatter.format_option_strings = type(parser.formatter.format_option_strings)(_, parser) |
| 314 | |
| 315 | for _ in ("-h", "--version"): |
| 316 | option = parser.get_option(_) |
| 317 | option.help = option.help.capitalize() |
| 318 | |
| 319 | try: |
| 320 | options, _ = parser.parse_args() |
| 321 | except SystemExit: |
| 322 | raise |
| 323 | |
| 324 | if len(sys.argv) > 1: |
| 325 | url = sys.argv[-1] |
| 326 | if not url.startswith("http"): |
| 327 | url = "http://%s" % url |
| 328 | options.url = url |
| 329 | else: |
| 330 | parser.print_help() |
| 331 | raise SystemExit |
| 332 | |
| 333 | for key in DEFAULTS: |
| 334 | if getattr(options, key, None) is None: |
| 335 | setattr(options, key, DEFAULTS[key]) |
| 336 | |
| 337 | def load_data(): |
| 338 | global WAF_RECOGNITION_REGEX |
no test coverage detected
searching dependent graphs…