From ae4ea0af45c52000d6c79f2d85ceacd59024a3ed Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Thu, 7 Apr 2011 13:57:07 +0000 Subject: [PATCH] fix for a bug reported by m4l1c3 (AttributeError: 'NoneType' object has no attribute 'replace') --- lib/core/common.py | 7 +++++++ lib/core/option.py | 6 ------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/core/common.py b/lib/core/common.py index e55cb82e5..787b5d50e 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -50,6 +50,7 @@ from lib.core.convert import htmlunescape from lib.core.convert import urldecode from lib.core.convert import urlencode from lib.core.enums import DBMS +from lib.core.enums import HTTPHEADER from lib.core.enums import PLACE from lib.core.enums import PAYLOAD from lib.core.enums import SORTORDER @@ -1012,6 +1013,12 @@ def parseTargetUrl(): conf.url = "%s://%s:%d%s" % (conf.scheme, conf.hostname, conf.port, conf.path) conf.url = conf.url.replace(URI_QUESTION_MARKER, '?') + if not conf.referer and conf.level >= 3: + debugMsg = "setting the HTTP Referer header to the target url" + logger.debug(debugMsg) + conf.httpHeaders = filter(lambda (key, value): key != HTTPHEADER.REFERER, conf.httpHeaders) + conf.httpHeaders.append((HTTPHEADER.REFERER, conf.url)) + def expandAsteriskForColumns(expression): # If the user provided an asterisk rather than the column(s) # name, sqlmap will retrieve the columns itself and reprocess diff --git a/lib/core/option.py b/lib/core/option.py index 299e3dde4..a490e5e90 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1079,12 +1079,6 @@ def __setHTTPReferer(): conf.httpHeaders.append((HTTPHEADER.REFERER, conf.referer)) - elif conf.level >= 3: - debugMsg = "setting the default HTTP Referer header" - logger.debug(debugMsg) - - conf.httpHeaders.append((HTTPHEADER.REFERER, conf.url)) - def __setHTTPCookies(): """ Set the HTTP Cookie header