|
18 | 18 | from extra.safe2bin.safe2bin import safecharencode |
19 | 19 | from lib.core.agent import agent |
20 | 20 | from lib.core.common import asciifyUrl |
| 21 | +from lib.core.common import Backend |
21 | 22 | from lib.core.common import calculateDeltaSeconds |
22 | 23 | from lib.core.common import clearConsoleLine |
23 | 24 | from lib.core.common import cpuThrottle |
|
43 | 44 | from lib.core.dicts import POST_HINT_CONTENT_TYPES |
44 | 45 | from lib.core.enums import ADJUST_TIME_DELAY |
45 | 46 | from lib.core.enums import CUSTOM_LOGGING |
| 47 | +from lib.core.enums import DBMS |
46 | 48 | from lib.core.enums import HTTPHEADER |
47 | 49 | from lib.core.enums import HTTPMETHOD |
48 | 50 | from lib.core.enums import NULLCONNECTION |
49 | 51 | from lib.core.enums import PAYLOAD |
50 | 52 | from lib.core.enums import PLACE |
51 | 53 | from lib.core.enums import POST_HINT |
52 | 54 | from lib.core.enums import REDIRECTION |
| 55 | +from lib.core.enums import WEB_API |
53 | 56 | from lib.core.exception import SqlmapCompressionException |
54 | 57 | from lib.core.exception import SqlmapConnectionException |
55 | 58 | from lib.core.exception import SqlmapSyntaxException |
56 | 59 | from lib.core.exception import SqlmapValueException |
57 | 60 | from lib.core.settings import CUSTOM_INJECTION_MARK_CHAR |
58 | 61 | from lib.core.settings import DEFAULT_CONTENT_TYPE |
| 62 | +from lib.core.settings import DEFAULT_GET_POST_DELIMITER |
59 | 63 | from lib.core.settings import HTTP_ACCEPT_HEADER_VALUE |
60 | 64 | from lib.core.settings import HTTP_ACCEPT_ENCODING_HEADER_VALUE |
61 | 65 | from lib.core.settings import HTTP_SILENT_TIMEOUT |
|
66 | 70 | from lib.core.settings import MIN_TIME_RESPONSES |
67 | 71 | from lib.core.settings import IS_WIN |
68 | 72 | from lib.core.settings import LARGE_CHUNK_TRIM_MARKER |
| 73 | +from lib.core.settings import PAYLOAD_DELIMITER |
69 | 74 | from lib.core.settings import PERMISSION_DENIED_REGEX |
70 | 75 | from lib.core.settings import UNENCODED_ORIGINAL_VALUE |
71 | 76 | from lib.core.settings import URI_HTTP_HEADER |
@@ -617,6 +622,42 @@ def queryPage(value=None, place=None, content=False, getRatioValue=False, silent |
617 | 622 | payload = urlencode(payload, '%', False, True) if place in (PLACE.GET, PLACE.COOKIE, PLACE.URI) and not skipUrlEncode else payload |
618 | 623 | value = agent.replacePayload(value, payload) |
619 | 624 |
|
| 625 | + if conf.hpp: |
| 626 | + if not any(conf.url.lower().endswith(_.lower()) for _ in (WEB_API.ASP, WEB_API.ASPX)): |
| 627 | + warnMsg = "HTTP parameter pollution should work only against " |
| 628 | + warnMsg += "ASP(.NET) targets" |
| 629 | + singleTimeWarnMessage(warnMsg) |
| 630 | + if place in (PLACE.GET, PLACE.POST): |
| 631 | + _ = re.escape(PAYLOAD_DELIMITER) |
| 632 | + match = re.search("(\w+)=%s(.+?)%s" % (_, _), value) |
| 633 | + if match: |
| 634 | + parameter, content = match.groups() |
| 635 | + if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.MSSQL, DBMS.PGSQL): # DBMSes that support inline comments |
| 636 | + for splitter in (urlencode(' '), ' '): |
| 637 | + if splitter in content: |
| 638 | + prefix, suffix = ("*/", "/*") if splitter == ' ' else (urlencode(_) for _ in ("*/", "/*")) |
| 639 | + parts = content.split(splitter) |
| 640 | + parts[0] = "%s%s" % (parts[0], suffix) |
| 641 | + parts[-1] = "%s%s=%s%s" % (DEFAULT_GET_POST_DELIMITER, parameter, prefix, parts[-1]) |
| 642 | + for i in xrange(1, len(parts) - 1): |
| 643 | + parts[i] = "%s%s=%s%s%s" % (DEFAULT_GET_POST_DELIMITER, parameter, prefix, parts[i], suffix) |
| 644 | + payload = "".join(parts) |
| 645 | + value = agent.replacePayload(value, payload) |
| 646 | + break |
| 647 | + else: |
| 648 | + for splitter in (urlencode(','), ','): # generic |
| 649 | + if splitter in content: |
| 650 | + parts = content.split(splitter) |
| 651 | + for i in xrange(1, len(parts)): |
| 652 | + parts[i] = "%s%s=%s" % (DEFAULT_GET_POST_DELIMITER, parameter, parts[i]) |
| 653 | + payload = "".join(parts) |
| 654 | + value = agent.replacePayload(value, payload) |
| 655 | + break |
| 656 | + else: |
| 657 | + warnMsg = "HTTP parameter pollution works only with regular " |
| 658 | + warnMsg += "GET and POST parameters" |
| 659 | + singleTimeWarnMessage(warnMsg) |
| 660 | + |
620 | 661 | if place: |
621 | 662 | value = agent.removePayloadDelimiters(value) |
622 | 663 |
|
@@ -669,7 +710,7 @@ def _randomizeParameter(paramString, randomParameter): |
669 | 710 | cookie = _randomizeParameter(cookie, randomParameter) |
670 | 711 |
|
671 | 712 | if conf.evalCode: |
672 | | - delimiter = conf.pDel or "&" |
| 713 | + delimiter = conf.pDel or DEFAULT_GET_POST_DELIMITER |
673 | 714 | variables = {} |
674 | 715 | originals = {} |
675 | 716 |
|
|
0 commit comments