|
170 | 170 | from lib.core.settings import REFLECTED_REPLACEMENT_TIMEOUT |
171 | 171 | from lib.core.settings import REFLECTED_VALUE_MARKER |
172 | 172 | from lib.core.settings import REFLECTIVE_MISS_THRESHOLD |
| 173 | +from lib.core.settings import REPLACEMENT_MARKER |
173 | 174 | from lib.core.settings import SENSITIVE_DATA_REGEX |
174 | 175 | from lib.core.settings import SENSITIVE_OPTIONS |
175 | 176 | from lib.core.settings import STDIN_PIPE_DASH |
@@ -4149,6 +4150,11 @@ def _(value): |
4149 | 4150 | payload = getUnicode(urldecode(payload.replace(PAYLOAD_DELIMITER, ""), convall=True)) |
4150 | 4151 | regex = _(filterStringValue(payload, r"[A-Za-z0-9]", encodeStringEscape(REFLECTED_REPLACEMENT_REGEX))) |
4151 | 4152 |
|
| 4153 | + # NOTE: special case when part of the result shares the same output as the payload (e.g. ?id=1... and "sqlmap/1.0-dev (http://sqlmap.org)") |
| 4154 | + preserve = extractRegexResult(r"%s(?P<result>.+?)%s" % (kb.chars.start, kb.chars.stop), content) |
| 4155 | + if preserve: |
| 4156 | + content = content.replace(preserve, REPLACEMENT_MARKER) |
| 4157 | + |
4152 | 4158 | if regex != payload: |
4153 | 4159 | if all(part.lower() in content.lower() for part in filterNone(regex.split(REFLECTED_REPLACEMENT_REGEX))[1:]): # fast optimization check |
4154 | 4160 | parts = regex.split(REFLECTED_REPLACEMENT_REGEX) |
@@ -4219,6 +4225,9 @@ def _thread(regex): |
4219 | 4225 | debugMsg = "turning off reflection removal mechanism (for optimization purposes)" |
4220 | 4226 | logger.debug(debugMsg) |
4221 | 4227 |
|
| 4228 | + if preserve and retVal: |
| 4229 | + retVal = retVal.replace(REPLACEMENT_MARKER, preserve) |
| 4230 | + |
4222 | 4231 | except (MemoryError, SystemError): |
4223 | 4232 | kb.reflectiveMechanism = False |
4224 | 4233 | if not suppressWarning: |
|
0 commit comments