From 2fa4b226454520e1f0b6b17742d7b2ca22b13873 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Mon, 30 May 2016 17:47:08 +0200 Subject: [PATCH] Patch for URL encoding cookie values (asking the user to choose) --- lib/core/option.py | 1 + lib/core/settings.py | 2 +- lib/request/connect.py | 15 +++++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/core/option.py b/lib/core/option.py index 20520ef30..cda8ad03a 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1823,6 +1823,7 @@ def _setKnowledgeBaseAttributes(flushAll=True): kb.columnExistsChoice = None kb.commonOutputs = None + kb.cookieEncodeChoice = None kb.counters = {} kb.data = AttribDict() kb.dataOutputFlag = False diff --git a/lib/core/settings.py b/lib/core/settings.py index 1d6a45e6e..e9175ffb8 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -19,7 +19,7 @@ from lib.core.enums import OS from lib.core.revision import getRevisionNumber # sqlmap version (...) -VERSION = "1.0.5.112" +VERSION = "1.0.5.113" REVISION = getRevisionNumber() STABLE = VERSION.count('.') <= 2 VERSION_STRING = "sqlmap/%s#%s" % (VERSION, "stable" if STABLE else "dev") diff --git a/lib/request/connect.py b/lib/request/connect.py index d8f22b46b..92625639e 100644 --- a/lib/request/connect.py +++ b/lib/request/connect.py @@ -794,8 +794,19 @@ class Connect(object): else: # GET, POST, URI and Cookie payload needs to be thoroughly URL encoded if (place in (PLACE.GET, PLACE.URI, PLACE.COOKIE) or place == PLACE.CUSTOM_HEADER and value.split(',')[0] == HTTP_HEADER.COOKIE) and not conf.skipUrlEncode or place in (PLACE.POST, PLACE.CUSTOM_POST) and kb.postUrlEncode: - payload = urlencode(payload, '%', False, place != PLACE.URI) # spaceplus is handled down below - value = agent.replacePayload(value, payload) + skip = False + + if place == PLACE.COOKIE or place == PLACE.CUSTOM_HEADER and value.split(',')[0] == HTTP_HEADER.COOKIE: + if kb.cookieEncodeChoice is None: + msg = "do you want to URL encode cookie values (implementation specific)? %s" % ("[Y/n]" if not conf.url.endswith(".aspx") else "[y/N]") # Reference: https://support.microsoft.com/en-us/kb/313282 + choice = readInput(msg, default='Y' if not conf.url.endswith(".aspx") else 'N') + kb.cookieEncodeChoice = choice.upper().strip() == "Y" + if not kb.cookieEncodeChoice: + skip = True + + if not skip: + payload = urlencode(payload, '%', False, place != PLACE.URI) # spaceplus is handled down below + value = agent.replacePayload(value, payload) if conf.hpp: if not any(conf.url.lower().endswith(_.lower()) for _ in (WEB_API.ASP, WEB_API.ASPX)):