Code cleanup

This commit is contained in:
Bernardo Damele 2011-01-18 23:05:32 +00:00
parent eda0b41859
commit 33485198e1

View File

@ -1583,9 +1583,9 @@ def wasLastRequestDelayed():
Returns True if the last web request resulted in a time-delay Returns True if the last web request resulted in a time-delay
""" """
# 99.9999999997440% of all non time-based sql injection # 99.9999999997440% of all non time-based sql injection affected
# affected response times should be inside +-7*stdev([normal response times]) # response times should be inside +-7*stdev([normal response times])
# (Math reference: http://www.answers.com/topic/standard-deviation) # Math reference: http://www.answers.com/topic/standard-deviation
deviation = stdev(kb.responseTimes) deviation = stdev(kb.responseTimes)
threadData = getCurrentThreadData() threadData = getCurrentThreadData()
@ -1607,17 +1607,20 @@ def wasLastRequestDelayed():
def adjustTimeDelay(lastQueryDuration, lowerStdLimit): def adjustTimeDelay(lastQueryDuration, lowerStdLimit):
""" """
Adjusts time delay in time based data retrieval Adjusts time delay in time-based data retrieval
""" """
candidate = 1 + int(round((1 - (lastQueryDuration - lowerStdLimit) / lastQueryDuration) * conf.timeSec)) candidate = 1 + int(round((1 - (lastQueryDuration - lowerStdLimit) / lastQueryDuration) * conf.timeSec))
if candidate: if candidate:
kb.delayCandidates = [candidate] + kb.delayCandidates[:-1] kb.delayCandidates = [candidate] + kb.delayCandidates[:-1]
if all([x == candidate for x in kb.delayCandidates]) and candidate < conf.timeSec: if all([x == candidate for x in kb.delayCandidates]) and candidate < conf.timeSec:
print print
warnMsg = "adjusting time delay to %d second%s" % (candidate, 's' if candidate > 1 else '') warnMsg = "adjusting time delay to %d second%s" % (candidate, 's' if candidate > 1 else '')
logger.warn(warnMsg) logger.warn(warnMsg)
conf.timeSec = candidate conf.timeSec = candidate
def extractErrorMessage(page): def extractErrorMessage(page):
@ -1709,8 +1712,11 @@ def logHTTPTraffic(requestLogMsg, responseLogMsg):
kb.locks.logLock.release() kb.locks.logLock.release()
# cross-linked method
def getPageTemplate(payload, place): def getPageTemplate(payload, place):
"""
Cross-linked method
"""
pass pass
def getPublicTypeMembers(type_, onlyValues=False): def getPublicTypeMembers(type_, onlyValues=False):
@ -2123,7 +2129,7 @@ def openFile(filename, mode='r'):
return codecs.open(filename, mode, conf.dataEncoding) return codecs.open(filename, mode, conf.dataEncoding)
except IOError: except IOError:
errMsg = "there has been a file opening error for filename '%s'. " % filename errMsg = "there has been a file opening error for filename '%s'. " % filename
errMsg += "Please check %s permissions on a file " % ("write" if mode and\ errMsg += "Please check %s permissions on a file " % ("write" if \
('w' in mode or 'a' in mode or '+' in mode) else "read") mode and ('w' in mode or 'a' in mode or '+' in mode) else "read")
errMsg += "and that it's not locked by another process." errMsg += "and that it's not locked by another process."
raise sqlmapFilePathException, errMsg raise sqlmapFilePathException, errMsg