text stringlengths 1 93.6k |
|---|
# Reference: https://stackoverflow.com/a/28052583
|
if hasattr(ssl, "_create_unverified_context"):
|
ssl._create_default_https_context = ssl._create_unverified_context
|
if options.proxy_file:
|
if os.path.isfile(options.proxy_file):
|
print(colorize("[o] loading proxy list..."))
|
with codecs.open(options.proxy_file, "rb", encoding="utf8") as f:
|
proxies.extend(re.sub(r"\s.*", "", _.strip()) for _ in f.read().strip().split('\n') if _.startswith("http"))
|
random.shuffle(proxies)
|
else:
|
exit(colorize("[x] file '%s' does not exist" % options.proxy_file))
|
cookie_jar = CookieJar()
|
opener = build_opener(HTTPCookieProcessor(cookie_jar))
|
install_opener(opener)
|
if options.proxy:
|
opener = build_opener(ProxyHandler({"http": options.proxy, "https": options.proxy}))
|
install_opener(opener)
|
if options.random_agent:
|
revision = random.randint(20, 64)
|
platform = random.sample(("X11; %s %s" % (random.sample(("Linux", "Ubuntu; Linux", "U; Linux", "U; OpenBSD", "U; FreeBSD"), 1)[0], random.sample(("amd64", "i586", "i686", "amd64"), 1)[0]), "Windows NT %s%s" % (random.sample(("5.0", "5.1", "5.2", "6.0", "6.1", "6.2", "6.3", "10.0"), 1)[0], random.sample(("", "; Win64", "; WOW64"), 1)[0]), "Macintosh; Intel Mac OS X 10.%s" % random.randint(1, 11)), 1)[0]
|
user_agent = "Mozilla/5.0 (%s; rv:%d.0) Gecko/20100101 Firefox/%d.0" % (platform, revision, revision)
|
HEADERS["User-Agent"] = user_agent
|
def format_name(waf):
|
return "%s%s" % (DATA_JSON["wafs"][waf]["name"], (" (%s)" % DATA_JSON["wafs"][waf]["company"]) if DATA_JSON["wafs"][waf]["name"] != DATA_JSON["wafs"][waf]["company"] else "")
|
def non_blind_check(raw, silent=False):
|
retval = False
|
match = re.search(WAF_RECOGNITION_REGEX, raw or "")
|
if match:
|
retval = True
|
for _ in match.groupdict():
|
if match.group(_):
|
waf = re.sub(r"\Awaf_", "", _)
|
non_blind.add(waf)
|
if not silent:
|
single_print(colorize("[+] non-blind match: '%s'%s" % (format_name(waf), 20 * ' ')))
|
return retval
|
def run():
|
global original
|
hostname = options.url.split("//")[-1].split('/')[0].split(':')[0]
|
if not hostname.replace('.', "").isdigit():
|
print(colorize("[i] checking hostname '%s'..." % hostname))
|
try:
|
socket.getaddrinfo(hostname, None)
|
except socket.gaierror:
|
exit(colorize("[x] host '%s' does not exist" % hostname))
|
results = ""
|
signature = b""
|
counter = 0
|
original = retrieve(options.url)
|
if 300 <= (original[HTTPCODE] or 0) < 400 and original[URL]:
|
original = retrieve(original[URL])
|
options.url = original[URL]
|
if original[HTTPCODE] is None:
|
exit(colorize("[x] missing valid response"))
|
if not any((options.string, options.code)) and original[HTTPCODE] >= 400:
|
non_blind_check(original[RAW])
|
if options.debug:
|
print("\r---%s" % (40 * ' '))
|
print(original[HTTPCODE], original[RAW])
|
print("---")
|
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 "")))
|
challenge = None
|
if all(_ in original[HTML].lower() for _ in ("eval", "<script")):
|
match = re.search(r"(?is)<body[^>]*>(.*)</body>", re.sub(r"(?is)<script.+?</script>", "", original[HTML]))
|
if re.search(r"(?i)<(body|div)", original[HTML]) is None or (match and len(match.group(1)) == 0):
|
challenge = re.search(r"(?is)<script.+</script>", original[HTML]).group(0).replace("\n", "\\n")
|
print(colorize("[x] anti-robot JS challenge detected ('%s%s')" % (challenge[:MAX_JS_CHALLENGE_SNAPLEN], "..." if len(challenge) > MAX_JS_CHALLENGE_SNAPLEN else "")))
|
protection_keywords = GENERIC_PROTECTION_KEYWORDS
|
protection_regex = GENERIC_PROTECTION_REGEX % '|'.join(keyword for keyword in protection_keywords if keyword not in original[HTML].lower())
|
print(colorize("[i] running basic heuristic test..."))
|
if not check_payload(HEURISTIC_PAYLOAD):
|
check = False
|
if options.url.startswith("https://"):
|
options.url = options.url.replace("https://", "http://")
|
check = check_payload(HEURISTIC_PAYLOAD)
|
if not check:
|
if non_blind_check(intrusive[RAW]):
|
exit(colorize("[x] unable to continue due to static responses%s" % (" (captcha)" if re.search(r"(?i)captcha", intrusive[RAW]) is not None else "")))
|
elif challenge is None:
|
exit(colorize("[x] host '%s' does not seem to be protected" % hostname))
|
else:
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.