mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-28 20:43:49 +03:00
minor refactoring
This commit is contained in:
parent
b71a81041d
commit
c20546dcaa
|
@ -1804,19 +1804,12 @@ def stdev(values):
|
|||
|
||||
key = (values[0], values[-1], len(values))
|
||||
|
||||
retVal = None
|
||||
|
||||
if key in kb.cache.stdev:
|
||||
retVal = kb.cache.stdev[key]
|
||||
else:
|
||||
summa = 0.0
|
||||
avg = average(values)
|
||||
|
||||
for value in values:
|
||||
value = value or 0
|
||||
summa += pow(value - avg, 2)
|
||||
|
||||
retVal = sqrt(summa/(len(values) - 1))
|
||||
_ = reduce(lambda x, y: x + pow((y or 0) - avg, 2), values, 0.0)
|
||||
retVal = sqrt(_/(len(values) - 1))
|
||||
kb.cache.stdev[key] = retVal
|
||||
|
||||
return retVal
|
||||
|
@ -2241,6 +2234,9 @@ def logHTTPTraffic(requestLogMsg, responseLogMsg):
|
|||
Logs HTTP traffic to the output file
|
||||
"""
|
||||
|
||||
if not conf.trafficFile:
|
||||
return
|
||||
|
||||
kb.locks.logLock.acquire()
|
||||
|
||||
dataToTrafficFile("%s%s" % (requestLogMsg, os.linesep))
|
||||
|
|
|
@ -36,6 +36,11 @@ class DBMS:
|
|||
SYBASE = "Sybase"
|
||||
DB2 = "IBM DB2"
|
||||
|
||||
class CUSTOM_LOGGING:
|
||||
PAYLOAD = 9
|
||||
TRAFFIC_OUT = 8
|
||||
TRAFFIC_IN = 7
|
||||
|
||||
class OS:
|
||||
LINUX = "Linux"
|
||||
WINDOWS = "Windows"
|
||||
|
|
|
@ -60,6 +60,7 @@ from lib.core.data import queries
|
|||
from lib.core.datatype import AttribDict
|
||||
from lib.core.datatype import InjectionDict
|
||||
from lib.core.defaults import defaults
|
||||
from lib.core.enums import CUSTOM_LOGGING
|
||||
from lib.core.enums import DBMS
|
||||
from lib.core.enums import HTTPHEADER
|
||||
from lib.core.enums import HTTPMETHOD
|
||||
|
@ -1648,11 +1649,11 @@ def __setVerbosity():
|
|||
elif conf.verbose == 2:
|
||||
logger.setLevel(logging.DEBUG)
|
||||
elif conf.verbose == 3:
|
||||
logger.setLevel(9)
|
||||
logger.setLevel(CUSTOM_LOGGING.PAYLOAD)
|
||||
elif conf.verbose == 4:
|
||||
logger.setLevel(8)
|
||||
logger.setLevel(CUSTOM_LOGGING.TRAFFIC_OUT)
|
||||
elif conf.verbose >= 5:
|
||||
logger.setLevel(7)
|
||||
logger.setLevel(CUSTOM_LOGGING.TRAFFIC_IN)
|
||||
|
||||
def __mergeOptions(inputOptions, overrideOptions):
|
||||
"""
|
||||
|
|
|
@ -12,6 +12,7 @@ import os
|
|||
import subprocess
|
||||
import sys
|
||||
|
||||
from lib.core.enums import CUSTOM_LOGGING
|
||||
from lib.core.enums import DBMS
|
||||
from lib.core.enums import PLACE
|
||||
from lib.core.revision import getRevisionNumber
|
||||
|
@ -33,9 +34,9 @@ LOWER_RATIO_BOUND = 0.02
|
|||
UPPER_RATIO_BOUND = 0.98
|
||||
|
||||
# sqlmap logger
|
||||
logging.addLevelName(9, "PAYLOAD")
|
||||
logging.addLevelName(8, "TRAFFIC OUT")
|
||||
logging.addLevelName(7, "TRAFFIC IN")
|
||||
logging.addLevelName(CUSTOM_LOGGING.PAYLOAD, "PAYLOAD")
|
||||
logging.addLevelName(CUSTOM_LOGGING.TRAFFIC_OUT, "TRAFFIC OUT")
|
||||
logging.addLevelName(CUSTOM_LOGGING.TRAFFIC_IN, "TRAFFIC IN")
|
||||
|
||||
LOGGER = logging.getLogger("sqlmapLog")
|
||||
LOGGER_HANDLER = logging.StreamHandler(sys.stdout)
|
||||
|
|
|
@ -44,6 +44,7 @@ from lib.core.convert import urlencode
|
|||
from lib.core.data import conf
|
||||
from lib.core.data import kb
|
||||
from lib.core.data import logger
|
||||
from lib.core.enums import CUSTOM_LOGGING
|
||||
from lib.core.enums import HTTPHEADER
|
||||
from lib.core.enums import HTTPMETHOD
|
||||
from lib.core.enums import NULLCONNECTION
|
||||
|
@ -300,7 +301,7 @@ class Connect:
|
|||
|
||||
threadData.lastRequestMsg = requestMsg
|
||||
|
||||
logger.log(8, requestMsg)
|
||||
logger.log(CUSTOM_LOGGING.TRAFFIC_OUT, requestMsg)
|
||||
|
||||
conn = urllib2.urlopen(req)
|
||||
|
||||
|
@ -426,7 +427,7 @@ class Connect:
|
|||
elif conf.verbose > 5:
|
||||
responseMsg += "%s\n\n%s\n" % (logHeaders, page)
|
||||
|
||||
logger.log(7, responseMsg)
|
||||
logger.log(CUSTOM_LOGGING.TRAFFIC_IN, responseMsg)
|
||||
|
||||
if e.code == httplib.UNAUTHORIZED:
|
||||
errMsg = "not authorized, try to provide right HTTP "
|
||||
|
@ -516,7 +517,7 @@ class Connect:
|
|||
elif conf.verbose > 5:
|
||||
responseMsg += "%s\n\n%s\n" % (logHeaders, page)
|
||||
|
||||
logger.log(7, responseMsg)
|
||||
logger.log(CUSTOM_LOGGING.TRAFFIC_IN, responseMsg)
|
||||
|
||||
return page, responseHeaders, code
|
||||
|
||||
|
@ -556,7 +557,7 @@ class Connect:
|
|||
|
||||
value = agent.replacePayload(value, payload)
|
||||
|
||||
logger.log(9, payload)
|
||||
logger.log(CUSTOM_LOGGING.PAYLOAD, payload)
|
||||
|
||||
if place == PLACE.COOKIE and conf.cookieUrlencode:
|
||||
value = agent.removePayloadDelimiters(value)
|
||||
|
|
Loading…
Reference in New Issue
Block a user