From 1dfe558d3dc17d815428236b58042f2bcf65b30d Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Tue, 16 Mar 2010 13:11:44 +0000 Subject: [PATCH] Fix for Issue #177 --- lib/controller/controller.py | 11 +++++++++++ lib/core/common.py | 6 ++++++ lib/core/option.py | 2 ++ lib/request/connect.py | 4 ++-- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/controller/controller.py b/lib/controller/controller.py index cca867e7e..9695e252f 100644 --- a/lib/controller/controller.py +++ b/lib/controller/controller.py @@ -31,6 +31,8 @@ from lib.controller.checks import checkRegexp from lib.controller.checks import checkConnection from lib.core.common import paramToDict from lib.core.common import parseTargetUrl +from lib.core.common import pop +from lib.core.common import push from lib.core.common import readInput from lib.core.data import conf from lib.core.data import kb @@ -103,6 +105,10 @@ def start(): if kb.targetUrls and len(kb.targetUrls) > 1: infoMsg = "sqlmap got a total of %d targets" % len(kb.targetUrls) logger.info(infoMsg) + + if conf.multipleTargets: + push(conf.raise404) + conf.raise404 = False hostCount = 0 cookieStr = "" @@ -267,7 +273,12 @@ def start(): logger.error(e) else: logger.error(e) + if conf.multipleTargets: + conf.raise404 = pop() return + if conf.multipleTargets: + conf.raise404 = pop() + if conf.loggedToOut: logger.info("Fetched data logged to text files under '%s'" % conf.outputPath) diff --git a/lib/core/common.py b/lib/core/common.py index 8e365f209..2c85c0055 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -939,3 +939,9 @@ def posixToNtSlashes(filepath): def ntToPosixSlashes(filepath): return filepath.replace('\\', '/') + +def push(value): + conf.stack.append(value) + +def pop(): + return conf.stack.pop() \ No newline at end of file diff --git a/lib/core/option.py b/lib/core/option.py index f3182cdb9..9ed2778ba 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -957,12 +957,14 @@ def __setConfAttributes(): conf.path = None conf.port = None conf.progressWidth = 54 + conf.raise404 = True conf.retriesCount = 0 conf.scheme = None #conf.seqMatcher = difflib.SequenceMatcher(lambda x: x in " \t") conf.seqMatcher = difflib.SequenceMatcher(None) conf.seqLock = None conf.sessionFP = None + conf.stack = [] conf.start = True conf.threadContinue = True conf.threadException = False diff --git a/lib/request/connect.py b/lib/request/connect.py index 3742bf521..274610dd9 100644 --- a/lib/request/connect.py +++ b/lib/request/connect.py @@ -70,7 +70,7 @@ class Connect: direct = kwargs.get('direct', False) multipart = kwargs.get('multipart', False) silent = kwargs.get('silent', False) - raise404 = kwargs.get('raise404', True) + raise404 = kwargs.get('raise404', None) page = "" cookieStr = "" @@ -181,7 +181,7 @@ class Connect: errMsg = "not authorized, try to provide right HTTP " errMsg += "authentication type and valid credentials" raise sqlmapConnectionException, errMsg - elif e.code == 404 and raise404: + elif e.code == 404 and (raise404 or (raise404 is None and conf.raise404)): errMsg = "page not found" raise sqlmapConnectionException, errMsg else: