|
40 | 40 | from lib.core.settings import INFERENCE_UNKNOWN_CHAR |
41 | 41 | from lib.core.settings import INFERENCE_GREATER_CHAR |
42 | 42 | from lib.core.settings import INFERENCE_EQUALS_CHAR |
| 43 | +from lib.core.settings import INFERENCE_NOT_EQUALS_CHAR |
43 | 44 | from lib.core.unescaper import unescaper |
44 | 45 | from lib.request.connect import Connect as Request |
45 | 46 |
|
@@ -144,6 +145,16 @@ def tryHint(idx): |
144 | 145 |
|
145 | 146 | return None |
146 | 147 |
|
| 148 | + def validateChar(idx, value): |
| 149 | + """ |
| 150 | + used in time based inferences (in case of delay compared values are not equal) |
| 151 | + """ |
| 152 | + forgedPayload = safeStringFormat(payload.replace(INFERENCE_GREATER_CHAR, INFERENCE_NOT_EQUALS_CHAR), (expressionUnescaped, idx, value)) |
| 153 | + queriesCount[0] += 1 |
| 154 | + result = Request.queryPage(forgedPayload, timeBasedCompare=timeBasedCompare, raise404=False) |
| 155 | + |
| 156 | + return not result |
| 157 | + |
147 | 158 | def getChar(idx, charTbl=asciiTbl, continuousOrder=True, expand=charsetType is None): |
148 | 159 | """ |
149 | 160 | continuousOrder means that distance between each two neighbour's |
@@ -171,7 +182,7 @@ def getChar(idx, charTbl=asciiTbl, continuousOrder=True, expand=charsetType is N |
171 | 182 |
|
172 | 183 | if result: |
173 | 184 | return chr(charTbl[0]) if charTbl[0] < 128 else decodeIntToUnicode(charTbl[0]) |
174 | | - else: |
| 185 | + else: |
175 | 186 | return None |
176 | 187 |
|
177 | 188 | maxChar = maxValue = charTbl[-1] |
@@ -230,7 +241,11 @@ def getChar(idx, charTbl=asciiTbl, continuousOrder=True, expand=charsetType is N |
230 | 241 | else: |
231 | 242 | retVal = minValue + 1 |
232 | 243 | if retVal in originalTbl or (retVal == ord('\n') and CHAR_INFERENCE_MARK in payload): |
233 | | - return chr(retVal) if retVal < 128 else decodeIntToUnicode(retVal) |
| 244 | + if timeBasedCompare and not validateChar(idx, retVal): |
| 245 | + logger.error("invalid character detected. retrying...") |
| 246 | + return getChar(idx, originalTbl, continuousOrder, expand) |
| 247 | + else: |
| 248 | + return chr(retVal) if retVal < 128 else decodeIntToUnicode(retVal) |
234 | 249 | else: |
235 | 250 | return None |
236 | 251 | else: |
|
0 commit comments