|
66 | 66 | from lib.core.settings import DUMMY_NON_SQLI_CHECK_APPENDIX
|
67 | 67 | from lib.core.settings import FORMAT_EXCEPTION_STRINGS
|
68 | 68 | from lib.core.settings import HEURISTIC_CHECK_ALPHABET
|
| 69 | +from lib.core.settings import IDS_WAF_CHECK_PAYLOAD |
| 70 | +from lib.core.settings import IDS_WAF_CHECK_RATIO |
| 71 | +from lib.core.settings import IDS_WAF_CHECK_TIMEOUT |
| 72 | +from lib.core.settings import NON_SQLI_CHECK_PREFIX_SUFFIX_LENGTH |
69 | 73 | from lib.core.settings import SUHOSIN_MAX_VALUE_LENGTH
|
70 | 74 | from lib.core.settings import SUPPORTED_DBMS
|
71 | 75 | from lib.core.settings import URI_HTTP_HEADER
|
72 | 76 | from lib.core.settings import UPPER_RATIO_BOUND
|
73 |
| -from lib.core.settings import IDS_WAF_CHECK_PAYLOAD |
74 |
| -from lib.core.settings import IDS_WAF_CHECK_RATIO |
75 |
| -from lib.core.settings import IDS_WAF_CHECK_TIMEOUT |
76 | 77 | from lib.core.threads import getCurrentThreadData
|
77 | 78 | from lib.request.connect import Connect as Request
|
78 | 79 | from lib.request.inject import checkBooleanExpression
|
@@ -932,23 +933,25 @@ def _(page):
|
932 | 933 |
|
933 | 934 | kb.heuristicMode = True
|
934 | 935 |
|
935 |
| - randStr1, randStr2 = randomStr(), randomStr() |
| 936 | + randStr1, randStr2 = randomStr(NON_SQLI_CHECK_PREFIX_SUFFIX_LENGTH), randomStr(NON_SQLI_CHECK_PREFIX_SUFFIX_LENGTH) |
936 | 937 | value = "%s%s%s" % (randStr1, DUMMY_NON_SQLI_CHECK_APPENDIX, randStr2)
|
937 | 938 | payload = "%s%s%s" % (prefix, "'%s" % value, suffix)
|
938 | 939 | payload = agent.payload(place, parameter, newValue=payload)
|
939 | 940 | page, _ = Request.queryPage(payload, place, content=True, raise404=False)
|
940 | 941 |
|
941 | 942 | paramType = conf.method if conf.method not in (None, HTTPMETHOD.GET, HTTPMETHOD.POST) else place
|
942 | 943 |
|
943 |
| - if value in (page or ""): |
| 944 | + if value.lower() in (page or "").lower(): |
944 | 945 | infoMsg = "heuristic (XSS) test shows that %s parameter " % paramType
|
945 | 946 | infoMsg += "'%s' might be vulnerable to cross-site scripting attacks" % parameter
|
946 | 947 | logger.info(infoMsg)
|
947 | 948 |
|
948 |
| - if re.search(r"(?i)Failed opening[^\n]+%s" % randStr1, page or ""): |
949 |
| - infoMsg = "heuristic (FI) test shows that %s parameter " % paramType |
950 |
| - infoMsg += "'%s' might be vulnerable to file inclusion attacks" % parameter |
951 |
| - logger.info(infoMsg) |
| 949 | + for match in re.finditer("(?i)[^\n]*(no such file|failed (to )?open)[^\n]*", page or ""): |
| 950 | + if randStr1.lower() in match.group(0).lower(): |
| 951 | + infoMsg = "heuristic (FI) test shows that %s parameter " % paramType |
| 952 | + infoMsg += "'%s' might be vulnerable to file inclusion attacks" % parameter |
| 953 | + logger.info(infoMsg) |
| 954 | + break |
952 | 955 |
|
953 | 956 | kb.heuristicMode = False
|
954 | 957 |
|
|
0 commit comments