2019-03-21 16:00:09 +03:00
|
|
|
#!/usr/bin/env python2
|
2016-05-27 17:34:41 +03:00
|
|
|
|
|
|
|
"""
|
2019-01-05 23:38:52 +03:00
|
|
|
Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/)
|
2017-10-11 15:50:46 +03:00
|
|
|
See the file 'LICENSE' for copying permission
|
2016-05-27 17:34:41 +03:00
|
|
|
"""
|
|
|
|
|
2017-12-13 17:31:35 +03:00
|
|
|
import re
|
|
|
|
|
2019-04-08 23:56:31 +03:00
|
|
|
from lib.core.common import getUnicode
|
2017-12-13 17:31:35 +03:00
|
|
|
from lib.core.data import kb
|
|
|
|
from lib.core.settings import GENERIC_PROTECTION_REGEX
|
2019-01-26 14:36:03 +03:00
|
|
|
from lib.core.settings import IPS_WAF_CHECK_PAYLOAD
|
2016-05-27 17:34:41 +03:00
|
|
|
from lib.core.settings import WAF_ATTACK_VECTORS
|
|
|
|
|
|
|
|
__product__ = "Generic (Unknown)"
|
|
|
|
|
|
|
|
def detect(get_page):
|
|
|
|
retval = False
|
|
|
|
|
2017-12-13 17:31:35 +03:00
|
|
|
original, _, code = get_page()
|
|
|
|
if original is None or code >= 400:
|
2016-05-27 17:34:41 +03:00
|
|
|
return False
|
|
|
|
|
|
|
|
for vector in WAF_ATTACK_VECTORS:
|
2017-12-13 17:31:35 +03:00
|
|
|
page, headers, code = get_page(get=vector)
|
2016-05-27 17:34:41 +03:00
|
|
|
|
2019-01-26 14:36:03 +03:00
|
|
|
if code >= 400 or (IPS_WAF_CHECK_PAYLOAD in vector and (code is None or re.search(GENERIC_PROTECTION_REGEX, page or "") and not re.search(GENERIC_PROTECTION_REGEX, original or ""))):
|
2017-09-18 00:12:57 +03:00
|
|
|
if code is not None:
|
2019-04-08 23:56:31 +03:00
|
|
|
kb.wafSpecificResponse = "HTTP/1.1 %s\n%s\n%s" % (code, "".join(getUnicode(_) for _ in (headers.headers if headers else {}) or [] if not _.startswith("URI")), getUnicode(page or ""))
|
2017-09-18 00:12:57 +03:00
|
|
|
|
2016-05-27 17:34:41 +03:00
|
|
|
retval = True
|
|
|
|
break
|
|
|
|
|
|
|
|
return retval
|