diff --git a/lib/controller/checks.py b/lib/controller/checks.py index cfb30d8a7..a5fa55938 100644 --- a/lib/controller/checks.py +++ b/lib/controller/checks.py @@ -23,6 +23,7 @@ from lib.core.common import findDynamicContent from lib.core.common import Format from lib.core.common import getComparePageRatio from lib.core.common import getCompiledRegex +from lib.core.common import getLastRequestHTTPError from lib.core.common import getSortedInjectionTests from lib.core.common import getUnicode from lib.core.common import intersect @@ -658,25 +659,30 @@ def checkDynParam(place, parameter, value): """ kb.matchRatio = None + dynResult = None + randInt = randomInt() infoMsg = "testing if %s parameter '%s' is dynamic" % (place, parameter) logger.info(infoMsg) - randInt = randomInt() - payload = agent.payload(place, parameter, value, getUnicode(randInt)) - dynResult = Request.queryPage(payload, place, raise404=False) + try: + payload = agent.payload(place, parameter, value, getUnicode(randInt)) + dynResult = Request.queryPage(payload, place, raise404=False) - if True == dynResult: - return False + if not dynResult: + infoMsg = "confirming that %s parameter '%s' is dynamic" % (place, parameter) + logger.info(infoMsg) - infoMsg = "confirming that %s parameter '%s' is dynamic" % (place, parameter) - logger.info(infoMsg) + randInt = randomInt() + payload = agent.payload(place, parameter, value, getUnicode(randInt)) + dynResult = Request.queryPage(payload, place, raise404=False) + except sqlmapConnectionException: + pass - randInt = randomInt() - payload = agent.payload(place, parameter, value, getUnicode(randInt)) - dynResult = Request.queryPage(payload, place, raise404=False) - - return not dynResult + if dynResult is None: + return None + else: + return not dynResult def checkDynamicContent(firstPage, secondPage): """ @@ -965,7 +971,7 @@ def checkConnection(suppressOutput=False): warnMsg += "which could interfere with the results of the tests" logger.warn(warnMsg) elif wasLastRequestHTTPError(): - warnMsg = "the web server responded with an HTTP error code " + warnMsg = "the web server responded with an HTTP error code (%d) " % getLastRequestHTTPError() warnMsg += "which could interfere with the results of the tests" logger.warn(warnMsg) else: diff --git a/lib/core/common.py b/lib/core/common.py index b9892caf4..1272fb6ae 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -2173,6 +2173,14 @@ def adjustTimeDelay(lastQueryDuration, lowerStdLimit): singleTimeLogMessage(infoMsg) kb.adjustTimeDelay = False +def getLastRequestHTTPError(): + """ + Returns last HTTP error code + """ + + threadData = getCurrentThreadData() + return threadData.lastHTTPError[1] if threadData.lastHTTPError else None + def extractErrorMessage(page): """ Returns reported error message from page if it founds one