more concise

This commit is contained in:
Miroslav Stampar 2011-06-08 14:35:23 +00:00
parent 6b81eef65a
commit 4a9640160e
9 changed files with 24 additions and 21 deletions

View File

@ -32,7 +32,7 @@ from lib.core.common import randomInt
from lib.core.common import randomStr from lib.core.common import randomStr
from lib.core.common import readInput from lib.core.common import readInput
from lib.core.common import showStaticWords from lib.core.common import showStaticWords
from lib.core.common import singleTimeLogMessage from lib.core.common import singleTimeWarnMessage
from lib.core.common import trimAlphaNum from lib.core.common import trimAlphaNum
from lib.core.common import wasLastRequestDBMSError from lib.core.common import wasLastRequestDBMSError
from lib.core.common import wasLastRequestHTTPError from lib.core.common import wasLastRequestHTTPError
@ -399,7 +399,7 @@ def checkSqlInjection(place, parameter, value):
warnMsg = "using unescaped version of the test " warnMsg = "using unescaped version of the test "
warnMsg += "because of zero knowledge of the " warnMsg += "because of zero knowledge of the "
warnMsg += "back-end DBMS" warnMsg += "back-end DBMS"
singleTimeLogMessage(warnMsg, logging.WARN, title) singleTimeWarnMessage(warnMsg, logging.WARN, title)
# Test for UNION query SQL injection # Test for UNION query SQL injection
reqPayload, vector = unionTest(comment, place, parameter, value, prefix, suffix) reqPayload, vector = unionTest(comment, place, parameter, value, prefix, suffix)

View File

@ -640,7 +640,10 @@ def filePathToString(filePath):
return strRepl return strRepl
def singleTimeLogMessage(message, level=logging.WARN, flag=None): def singleTimeWarnMessage(message):
singleTimeLogMessage(message, logging.WARN)
def singleTimeLogMessage(message, level=logging.INFO, flag=None):
if flag is None: if flag is None:
flag = hash(message) flag = hash(message)
@ -664,7 +667,7 @@ def dataToStdout(data, forceOutput=False):
warnMsg += "replacement with '?' character. Please, find " warnMsg += "replacement with '?' character. Please, find "
warnMsg += "proper character representation inside " warnMsg += "proper character representation inside "
warnMsg += "coresponding output files. " warnMsg += "coresponding output files. "
singleTimeLogMessage(warnMsg) singleTimeWarnMessage(warnMsg)
sys.stdout.write(output) sys.stdout.write(output)
else: else:

View File

@ -23,7 +23,7 @@ from lib.core.common import getUnicode
from lib.core.common import isWindowsDriveLetterPath from lib.core.common import isWindowsDriveLetterPath
from lib.core.common import posixToNtSlashes from lib.core.common import posixToNtSlashes
from lib.core.common import sanitizeAsciiString from lib.core.common import sanitizeAsciiString
from lib.core.common import singleTimeLogMessage from lib.core.common import singleTimeWarnMessage
from lib.core.data import conf from lib.core.data import conf
from lib.core.data import kb from lib.core.data import kb
from lib.core.data import logger from lib.core.data import logger
@ -140,7 +140,7 @@ def checkCharEncoding(encoding):
except LookupError: except LookupError:
warnMsg = "unknown web page charset '%s'. " % encoding warnMsg = "unknown web page charset '%s'. " % encoding
warnMsg += "Please report by e-mail to %s." % ML warnMsg += "Please report by e-mail to %s." % ML
singleTimeLogMessage(warnMsg, logging.WARN, encoding) singleTimeWarnMessage(warnMsg, logging.WARN, encoding)
encoding = None encoding = None
return encoding return encoding
@ -153,7 +153,7 @@ def getHeuristicCharEncoding(page):
retVal = detect(page)['encoding'] retVal = detect(page)['encoding']
infoMsg = "heuristics detected web page charset '%s'" % retVal infoMsg = "heuristics detected web page charset '%s'" % retVal
singleTimeLogMessage(infoMsg, logging.INFO, retVal) singleTimeWarnMessage(infoMsg, logging.INFO, retVal)
return retVal return retVal

View File

@ -29,7 +29,7 @@ from lib.core.common import logHTTPTraffic
from lib.core.common import parseTargetUrl from lib.core.common import parseTargetUrl
from lib.core.common import readInput from lib.core.common import readInput
from lib.core.common import removeReflectiveValues from lib.core.common import removeReflectiveValues
from lib.core.common import singleTimeLogMessage from lib.core.common import singleTimeWarnMessage
from lib.core.common import stdev from lib.core.common import stdev
from lib.core.common import urlEncodeCookieValues from lib.core.common import urlEncodeCookieValues
from lib.core.common import wasLastRequestDelayed from lib.core.common import wasLastRequestDelayed
@ -413,16 +413,16 @@ class Connect:
warnMsg += "without flag T in --technique option " warnMsg += "without flag T in --technique option "
warnMsg += "(e.g. --flush-session --technique=BEUS) or try to " warnMsg += "(e.g. --flush-session --technique=BEUS) or try to "
warnMsg += "lower the --time-sec value (e.g. --time-sec=2)" warnMsg += "lower the --time-sec value (e.g. --time-sec=2)"
singleTimeLogMessage(warnMsg) singleTimeWarnMessage(warnMsg)
elif kb.originalPage is None: elif kb.originalPage is None:
warnMsg = "if the problem persists please try to rerun " warnMsg = "if the problem persists please try to rerun "
warnMsg += "with the --random-agent switch turned on " warnMsg += "with the --random-agent switch turned on "
warnMsg += "and/or try to use proxy switches (--ignore-proxy, --proxy,...)" warnMsg += "and/or try to use proxy switches (--ignore-proxy, --proxy,...)"
singleTimeLogMessage(warnMsg) singleTimeWarnMessage(warnMsg)
elif conf.threads > 1: elif conf.threads > 1:
warnMsg = "if the problem persists please try to lower " warnMsg = "if the problem persists please try to lower "
warnMsg += "the number of used threads (--threads)" warnMsg += "the number of used threads (--threads)"
singleTimeLogMessage(warnMsg) singleTimeWarnMessage(warnMsg)
time.sleep(1) time.sleep(1)

View File

@ -25,7 +25,7 @@ from lib.core.common import pushValue
from lib.core.common import readInput from lib.core.common import readInput
from lib.core.common import replaceNewlineTabs from lib.core.common import replaceNewlineTabs
from lib.core.common import safeStringFormat from lib.core.common import safeStringFormat
from lib.core.common import singleTimeLogMessage from lib.core.common import singleTimeWarnMessage
from lib.core.common import unhandledExceptionMessage from lib.core.common import unhandledExceptionMessage
from lib.core.data import conf from lib.core.data import conf
from lib.core.data import kb from lib.core.data import kb
@ -116,7 +116,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
if conf.threads == 1 and not timeBasedCompare: if conf.threads == 1 and not timeBasedCompare:
warnMsg = "running in a single-thread mode. please consider usage of " warnMsg = "running in a single-thread mode. please consider usage of "
warnMsg += "--threads option to declare higher number of threads" warnMsg += "--threads option to declare higher number of threads"
singleTimeLogMessage(warnMsg) singleTimeWarnMessage(warnMsg)
if conf.verbose in (1, 2) and not showEta: if conf.verbose in (1, 2) and not showEta:
if isinstance(length, int) and conf.threads > 1: if isinstance(length, int) and conf.threads > 1:

View File

@ -24,7 +24,7 @@ from lib.core.common import popValue
from lib.core.common import pushValue from lib.core.common import pushValue
from lib.core.common import randomStr from lib.core.common import randomStr
from lib.core.common import removeReflectiveValues from lib.core.common import removeReflectiveValues
from lib.core.common import singleTimeLogMessage from lib.core.common import singleTimeWarnMessage
from lib.core.common import stdev from lib.core.common import stdev
from lib.core.common import wasLastRequestDBMSError from lib.core.common import wasLastRequestDBMSError
from lib.core.data import conf from lib.core.data import conf
@ -214,7 +214,7 @@ def __unionTestByCharBruteforce(comment, place, parameter, value, prefix, suffix
warnMsg = "please consider usage of --union-char option " warnMsg = "please consider usage of --union-char option "
warnMsg += "(e.g. --union-char=1) and/or try to force " warnMsg += "(e.g. --union-char=1) and/or try to force "
warnMsg += "back-end DBMS (e.g. --dbms=mysql) to make it work" warnMsg += "back-end DBMS (e.g. --dbms=mysql) to make it work"
singleTimeLogMessage(warnMsg) singleTimeWarnMessage(warnMsg)
return validPayload, vector return validPayload, vector

View File

@ -25,7 +25,7 @@ from lib.core.common import isNumPosStrValue
from lib.core.common import listToStrValue from lib.core.common import listToStrValue
from lib.core.common import parseUnionPage from lib.core.common import parseUnionPage
from lib.core.common import removeReflectiveValues from lib.core.common import removeReflectiveValues
from lib.core.common import singleTimeLogMessage from lib.core.common import singleTimeWarnMessage
from lib.core.convert import safecharencode from lib.core.convert import safecharencode
from lib.core.data import conf from lib.core.data import conf
from lib.core.data import kb from lib.core.data import kb
@ -94,7 +94,7 @@ def __oneShotUnionUse(expression, unpack=True):
warnMsg = "if the problem persists with 'None' values please try to use " warnMsg = "if the problem persists with 'None' values please try to use "
warnMsg += "hidden switch --no-cast (fixing problems with some collation " warnMsg += "hidden switch --no-cast (fixing problems with some collation "
warnMsg += "issues)" warnMsg += "issues)"
singleTimeLogMessage(warnMsg) singleTimeWarnMessage(warnMsg)
return output return output

View File

@ -7,7 +7,7 @@ Copyright (c) 2006-2011 sqlmap developers (http://sqlmap.sourceforge.net/)
See the file 'doc/COPYING' for copying permission See the file 'doc/COPYING' for copying permission
""" """
from lib.core.common import singleTimeLogMessage from lib.core.common import singleTimeWarnMessage
from lib.core.common import randomStr from lib.core.common import randomStr
from lib.core.data import conf from lib.core.data import conf
from lib.core.data import kb from lib.core.data import kb
@ -97,7 +97,7 @@ class Filesystem(GenericFilesystem):
warnMsg = "expect junk characters inside the " warnMsg = "expect junk characters inside the "
warnMsg += "file as a leftover from UNION query" warnMsg += "file as a leftover from UNION query"
singleTimeLogMessage(warnMsg) singleTimeWarnMessage(warnMsg)
def stackedWriteFile(self, wFile, dFile, fileType, confirm=True): def stackedWriteFile(self, wFile, dFile, fileType, confirm=True):
debugMsg = "creating a support table to write the hexadecimal " debugMsg = "creating a support table to write the hexadecimal "

View File

@ -30,7 +30,7 @@ from lib.core.common import randomStr
from lib.core.common import readInput from lib.core.common import readInput
from lib.core.common import safeStringFormat from lib.core.common import safeStringFormat
from lib.core.common import safeSQLIdentificatorNaming from lib.core.common import safeSQLIdentificatorNaming
from lib.core.common import singleTimeLogMessage from lib.core.common import singleTimeWarnMessage
from lib.core.common import strToHex from lib.core.common import strToHex
from lib.core.common import unArrayizeValue from lib.core.common import unArrayizeValue
from lib.core.common import unsafeSQLIdentificatorNaming from lib.core.common import unsafeSQLIdentificatorNaming
@ -1410,7 +1410,7 @@ class Enumeration:
if (i + 1) < conf.limitStart: if (i + 1) < conf.limitStart:
warnMsg = "skipping first %d pivot " % conf.limitStart warnMsg = "skipping first %d pivot " % conf.limitStart
warnMsg += "point values" warnMsg += "point values"
singleTimeLogMessage(warnMsg) singleTimeWarnMessage(warnMsg)
break break
elif (i + 1) > conf.limitStop: elif (i + 1) > conf.limitStop:
breakRetrieval = True breakRetrieval = True