()
| 409 | return retval |
| 410 | |
| 411 | def run(): |
| 412 | global original |
| 413 | |
| 414 | hostname = options.url.split("//")[-1].split('/')[0].split(':')[0] |
| 415 | |
| 416 | if not hostname.replace('.', "").isdigit(): |
| 417 | print(colorize("[i] checking hostname '%s'..." % hostname)) |
| 418 | try: |
| 419 | socket.getaddrinfo(hostname, None) |
| 420 | except socket.gaierror: |
| 421 | exit(colorize("[x] host '%s' does not exist" % hostname)) |
| 422 | |
| 423 | results = "" |
| 424 | signature = b"" |
| 425 | counter = 0 |
| 426 | original = retrieve(options.url) |
| 427 | |
| 428 | if 300 <= (original[HTTPCODE] or 0) < 400 and original[URL]: |
| 429 | original = retrieve(original[URL]) |
| 430 | |
| 431 | options.url = original[URL] |
| 432 | |
| 433 | if original[HTTPCODE] is None: |
| 434 | exit(colorize("[x] missing valid response")) |
| 435 | |
| 436 | if not any((options.string, options.code)) and original[HTTPCODE] >= 400: |
| 437 | non_blind_check(original[RAW]) |
| 438 | if options.debug: |
| 439 | print("\r---%s" % (40 * ' ')) |
| 440 | print(original[HTTPCODE], original[RAW]) |
| 441 | print("---") |
| 442 | exit(colorize("[x] access to host '%s' seems to be restricted%s" % (hostname, (" (%d: '<title>%s</title>')" % (original[HTTPCODE], original[TITLE].strip())) if original[TITLE] else ""))) |
| 443 | |
| 444 | challenge = None |
| 445 | if all(_ in original[HTML].lower() for _ in ("eval", "<script")): |
| 446 | match = re.search(r"(?is)<body[^>]*>(.*)</body>", re.sub(r"(?is)<script.+?</script>", "", original[HTML])) |
| 447 | if re.search(r"(?i)<(body|div)", original[HTML]) is None or (match and len(match.group(1)) == 0): |
| 448 | challenge = re.search(r"(?is)<script.+</script>", original[HTML]).group(0).replace("\n", "\\n") |
| 449 | print(colorize("[x] anti-robot JS challenge detected ('%s%s')" % (challenge[:MAX_JS_CHALLENGE_SNAPLEN], "..." if len(challenge) > MAX_JS_CHALLENGE_SNAPLEN else ""))) |
| 450 | |
| 451 | protection_keywords = GENERIC_PROTECTION_KEYWORDS |
| 452 | protection_regex = GENERIC_PROTECTION_REGEX % '|'.join(keyword for keyword in protection_keywords if keyword not in original[HTML].lower()) |
| 453 | |
| 454 | print(colorize("[i] running basic heuristic test...")) |
| 455 | if not check_payload(HEURISTIC_PAYLOAD): |
| 456 | check = False |
| 457 | if options.url.startswith("https://"): |
| 458 | options.url = options.url.replace("https://", "http://") |
| 459 | check = check_payload(HEURISTIC_PAYLOAD) |
| 460 | if not check: |
| 461 | if non_blind_check(intrusive[RAW]): |
| 462 | exit(colorize("[x] unable to continue due to static responses%s" % (" (captcha)" if re.search(r"(?i)captcha", intrusive[RAW]) is not None else ""))) |
| 463 | elif challenge is None: |
| 464 | exit(colorize("[x] host '%s' does not seem to be protected" % hostname)) |
| 465 | else: |
| 466 | exit(colorize("[x] response not changing without JS challenge solved")) |
| 467 | |
| 468 | if options.fast and not non_blind: |
no test coverage detected