From a52dbc575b9c7a3ea156726b7555db78108b5f05 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Tue, 13 Nov 2012 10:21:11 +0100 Subject: [PATCH] Patch for an Issue #246 --- lib/controller/controller.py | 2 +- lib/core/option.py | 2 +- lib/core/target.py | 4 ++-- lib/request/connect.py | 12 ++++++------ 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/controller/controller.py b/lib/controller/controller.py index e7acd7b6c..2a971f38a 100644 --- a/lib/controller/controller.py +++ b/lib/controller/controller.py @@ -300,7 +300,7 @@ def start(): if conf.cookie: message += "\nCookie: %s" % conf.cookie - if conf.data: + if conf.data is not None: message += "\nPOST data: %s" % urlencode(conf.data) if conf.data else "" if conf.forms: diff --git a/lib/core/option.py b/lib/core/option.py index 7b977e62c..d2ce765b2 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1110,7 +1110,7 @@ def __setHTTPMethod(): Check and set the HTTP method to perform HTTP requests through. """ - conf.method = HTTPMETHOD.POST if conf.data else HTTPMETHOD.GET + conf.method = HTTPMETHOD.POST if conf.data is not None else HTTPMETHOD.GET debugMsg = "setting the HTTP method to %s" % conf.method logger.debug(debugMsg) diff --git a/lib/core/target.py b/lib/core/target.py index ec0bd8e9c..8941e6887 100644 --- a/lib/core/target.py +++ b/lib/core/target.py @@ -80,11 +80,11 @@ def __setRequestParams(): testableParameters = True # Perform checks on POST parameters - if conf.method == HTTPMETHOD.POST and not conf.data: + if conf.method == HTTPMETHOD.POST and conf.data is None: errMsg = "HTTP POST method depends on HTTP data value to be posted" raise sqlmapSyntaxException, errMsg - if conf.data: + if conf.data is not None: conf.method = HTTPMETHOD.POST if CUSTOM_INJECTION_MARK_CHAR in conf.data: # later processed diff --git a/lib/request/connect.py b/lib/request/connect.py index 1f494997b..5f5d6727b 100644 --- a/lib/request/connect.py +++ b/lib/request/connect.py @@ -210,7 +210,7 @@ class Connect: page = None _ = urlparse.urlsplit(url) - requestMsg = u"HTTP request [#%d]:\n%s " % (threadData.lastRequestUID, method or (HTTPMETHOD.POST if post else HTTPMETHOD.GET)) + requestMsg = u"HTTP request [#%d]:\n%s " % (threadData.lastRequestUID, method or (HTTPMETHOD.POST if post is not None else HTTPMETHOD.GET)) requestMsg += ("%s%s" % (_.path or "/", ("?%s" % _.query) if _.query else "")) if not any((refreshing, crawling)) else url responseMsg = u"HTTP response " requestHeaders = u"" @@ -291,7 +291,7 @@ class Connect: headers[HTTPHEADER.ACCEPT_ENCODING] = HTTP_ACCEPT_ENCODING_HEADER_VALUE if method != HTTPMETHOD.HEAD and kb.pageCompress else "identity" headers[HTTPHEADER.HOST] = host or getHostHeader(url) - if post and HTTPHEADER.CONTENT_TYPE not in headers: + if post is not None and HTTPHEADER.CONTENT_TYPE not in headers: headers[HTTPHEADER.CONTENT_TYPE] = POST_HINT_CONTENT_TYPES.get(kb.postHint, DEFAULT_CONTENT_TYPE) if headers.get(HTTPHEADER.CONTENT_TYPE) == POST_HINT_CONTENT_TYPES[POST_HINT.MULTIPART]: @@ -326,7 +326,7 @@ class Connect: cookies = conf.cj._cookies_for_request(req) requestHeaders += "\n%s" % ("Cookie: %s" % ";".join("%s=%s" % (getUnicode(cookie.name), getUnicode(cookie.value)) for cookie in cookies)) - if post: + if post is not None: if not getRequestHeader(req, HTTPHEADER.CONTENT_LENGTH): requestHeaders += "\n%s: %d" % (string.capwords(HTTPHEADER.CONTENT_LENGTH), len(post)) @@ -335,7 +335,7 @@ class Connect: requestMsg += "\n%s" % requestHeaders - if post: + if post is not None: requestMsg += "\n\n%s" % getUnicode(post) requestMsg += "\n" @@ -689,13 +689,13 @@ class Connect: get = re.sub("((\A|\W)%s=)([^%s]+)" % (name, delimiter), "\g<1>%s" % value, get) elif '%s=' % name in (post or ""): post = re.sub("((\A|\W)%s=)([^%s]+)" % (name, delimiter), "\g<1>%s" % value, post) - elif post: + elif post is not None: post += "%s%s=%s" % (delimiter, name, value) else: get += "%s%s=%s" % (delimiter, name, value) get = urlencode(get, limit=True) - if post: + if post is not None: if place not in (PLACE.POST, PLACE.CUSTOM_POST) and hasattr(post, UNENCODED_ORIGINAL_VALUE): post = getattr(post, UNENCODED_ORIGINAL_VALUE) elif not skipUrlEncode and kb.postHint not in POST_HINT_CONTENT_TYPES.keys():