MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / init

Function init

thirdparty/identywaf/identYwaf.py:357–393  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

355 exit(colorize("[x] file '%s' is missing" % DATA_JSON_FILE))
356
357def init():
358 os.chdir(os.path.abspath(os.path.dirname(__file__)))
359
360 # Reference: http://blog.mathieu-leplatre.info/python-utf-8-print-fails-when-redirecting-stdout.html
361 if not PY3 and not IS_TTY:
362 sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout)
363
364 print(colorize("[o] initializing handlers..."))
365
366 # Reference: https://stackoverflow.com/a/28052583
367 if hasattr(ssl, "_create_unverified_context"):
368 ssl._create_default_https_context = ssl._create_unverified_context
369
370 if options.proxy_file:
371 if os.path.isfile(options.proxy_file):
372 print(colorize("[o] loading proxy list..."))
373
374 with open(options.proxy_file, "r") as f:
375 proxies.extend(re.sub(r"\s.*", "", _.strip()) for _ in f.read().strip().split('\n') if _.startswith("http"))
376 random.shuffle(proxies)
377 else:
378 exit(colorize("[x] file '%s' does not exist" % options.proxy_file))
379
380
381 cookie_jar = CookieJar()
382 opener = build_opener(HTTPCookieProcessor(cookie_jar))
383 install_opener(opener)
384
385 if options.proxy:
386 opener = build_opener(ProxyHandler({"http": options.proxy, "https": options.proxy}))
387 install_opener(opener)
388
389 if options.random_agent:
390 revision = random.randint(20, 64)
391 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]
392 user_agent = "Mozilla/5.0 (%s; rv:%d.0) Gecko/20100101 Firefox/%d.0" % (platform, revision, revision)
393 HEADERS["User-Agent"] = user_agent
394
395def format_name(waf):
396 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 "")

Callers 1

mainFunction · 0.70

Calls 4

colorizeFunction · 0.85
exitFunction · 0.85
extendMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…