Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 23117e7

Browse files
committed
minor improvement
1 parent 5e853ca commit 23117e7

2 files changed

Lines changed: 27 additions & 13 deletions

File tree

lib/controller/checks.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from lib.core.common import Format
2424
from lib.core.common import getComparePageRatio
2525
from lib.core.common import getCompiledRegex
26+
from lib.core.common import getLastRequestHTTPError
2627
from lib.core.common import getSortedInjectionTests
2728
from lib.core.common import getUnicode
2829
from lib.core.common import intersect
@@ -658,25 +659,30 @@ def checkDynParam(place, parameter, value):
658659
"""
659660

660661
kb.matchRatio = None
662+
dynResult = None
663+
randInt = randomInt()
661664

662665
infoMsg = "testing if %s parameter '%s' is dynamic" % (place, parameter)
663666
logger.info(infoMsg)
664667

665-
randInt = randomInt()
666-
payload = agent.payload(place, parameter, value, getUnicode(randInt))
667-
dynResult = Request.queryPage(payload, place, raise404=False)
668-
669-
if True == dynResult:
670-
return False
668+
try:
669+
payload = agent.payload(place, parameter, value, getUnicode(randInt))
670+
dynResult = Request.queryPage(payload, place, raise404=False)
671671

672-
infoMsg = "confirming that %s parameter '%s' is dynamic" % (place, parameter)
673-
logger.info(infoMsg)
672+
if not dynResult:
673+
infoMsg = "confirming that %s parameter '%s' is dynamic" % (place, parameter)
674+
logger.info(infoMsg)
674675

675-
randInt = randomInt()
676-
payload = agent.payload(place, parameter, value, getUnicode(randInt))
677-
dynResult = Request.queryPage(payload, place, raise404=False)
676+
randInt = randomInt()
677+
payload = agent.payload(place, parameter, value, getUnicode(randInt))
678+
dynResult = Request.queryPage(payload, place, raise404=False)
679+
except sqlmapConnectionException:
680+
pass
678681

679-
return not dynResult
682+
if dynResult is None:
683+
return None
684+
else:
685+
return not dynResult
680686

681687
def checkDynamicContent(firstPage, secondPage):
682688
"""
@@ -965,7 +971,7 @@ def checkConnection(suppressOutput=False):
965971
warnMsg += "which could interfere with the results of the tests"
966972
logger.warn(warnMsg)
967973
elif wasLastRequestHTTPError():
968-
warnMsg = "the web server responded with an HTTP error code "
974+
warnMsg = "the web server responded with an HTTP error code (%d) " % getLastRequestHTTPError()
969975
warnMsg += "which could interfere with the results of the tests"
970976
logger.warn(warnMsg)
971977
else:

lib/core/common.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2173,6 +2173,14 @@ def adjustTimeDelay(lastQueryDuration, lowerStdLimit):
21732173
singleTimeLogMessage(infoMsg)
21742174
kb.adjustTimeDelay = False
21752175

2176+
def getLastRequestHTTPError():
2177+
"""
2178+
Returns last HTTP error code
2179+
"""
2180+
2181+
threadData = getCurrentThreadData()
2182+
return threadData.lastHTTPError[1] if threadData.lastHTTPError else None
2183+
21762184
def extractErrorMessage(page):
21772185
"""
21782186
Returns reported error message from page if it founds one

0 commit comments

Comments
 (0)