|
5 | 5 | See the file 'doc/COPYING' for copying permission |
6 | 6 | """ |
7 | 7 |
|
| 8 | +import re |
8 | 9 | import threading |
9 | 10 | import time |
10 | 11 |
|
|
45 | 46 | from lib.core.settings import NULL |
46 | 47 | from lib.core.settings import PARTIAL_HEX_VALUE_MARKER |
47 | 48 | from lib.core.settings import PARTIAL_VALUE_MARKER |
| 49 | +from lib.core.settings import PAYLOAD_DELIMITER |
48 | 50 | from lib.core.settings import RANDOM_INTEGER_MARKER |
49 | 51 | from lib.core.settings import VALID_TIME_CHARS_RUN_THRESHOLD |
50 | 52 | from lib.core.threads import getCurrentThreadData |
@@ -201,13 +203,15 @@ def validateChar(idx, value): |
201 | 203 | Used in inference - in time-based SQLi if original and retrieved value are not equal there will be a deliberate delay |
202 | 204 | """ |
203 | 205 |
|
| 206 | + validationPayload = re.sub(r"(%s.*?)%s(.*?%s)" % (PAYLOAD_DELIMITER, INFERENCE_GREATER_CHAR, PAYLOAD_DELIMITER), r"\g<1>%s\g<2>" % INFERENCE_NOT_EQUALS_CHAR, payload) |
| 207 | + |
204 | 208 | if "'%s'" % CHAR_INFERENCE_MARK not in payload: |
205 | | - forgedPayload = safeStringFormat(payload.replace(INFERENCE_GREATER_CHAR, INFERENCE_NOT_EQUALS_CHAR), (expressionUnescaped, idx, value)) |
| 209 | + forgedPayload = safeStringFormat(validationPayload, (expressionUnescaped, idx, value)) |
206 | 210 | else: |
207 | 211 | # e.g.: ... > '%c' -> ... > ORD(..) |
208 | 212 | markingValue = "'%s'" % CHAR_INFERENCE_MARK |
209 | 213 | unescapedCharValue = unescaper.escape("'%s'" % decodeIntToUnicode(value)) |
210 | | - forgedPayload = safeStringFormat(payload.replace(INFERENCE_GREATER_CHAR, INFERENCE_NOT_EQUALS_CHAR), (expressionUnescaped, idx)).replace(markingValue, unescapedCharValue) |
| 214 | + forgedPayload = safeStringFormat(validationPayload, (expressionUnescaped, idx)).replace(markingValue, unescapedCharValue) |
211 | 215 |
|
212 | 216 | result = not Request.queryPage(forgedPayload, timeBasedCompare=timeBasedCompare, raise404=False) |
213 | 217 |
|
|
0 commit comments