From 9fcab687004603f8bb876ca16e66ff8702b4a79a Mon Sep 17 00:00:00 2001 From: Bernardo Damele Date: Fri, 15 Oct 2010 10:28:06 +0000 Subject: [PATCH] Minor adjustments --- lib/core/common.py | 3 ++- lib/core/dump.py | 4 ++-- lib/core/option.py | 17 ++++++++--------- sqlmap.conf | 11 ++++++++--- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/lib/core/common.py b/lib/core/common.py index 4c6abbaba..db389eda0 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -1437,12 +1437,13 @@ def getUnicode(value, encoding=None): >>> getUnicode(1) u'1' """ + if encoding is None: encoding = conf.dataEncoding if 'dataEncoding' in conf else "utf-8" if isinstance(value, basestring): return value if isinstance(value, unicode) else unicode(value, encoding, errors='replace') else: - return unicode(value) #encoding ignored for non-basestring instances + return unicode(value) # encoding ignored for non-basestring instances # http://boredzo.org/blog/archives/2007-01-06/longest-common-prefix-in-python-2 def longestCommonPrefix(*sequences): diff --git a/lib/core/dump.py b/lib/core/dump.py index 61c82215c..60e6cdf30 100644 --- a/lib/core/dump.py +++ b/lib/core/dump.py @@ -31,9 +31,9 @@ class Dump: self.__outputFP = None def __write(self, data, n=True): - text = "%s%s" % (data, "\n" if n else " ") - + text = "%s%s" % (data, "\n" if n else " ") dataToStdout(text) + self.__outputFP.write(text) self.__outputFP.flush() diff --git a/lib/core/option.py b/lib/core/option.py index 2f772effd..8ac515578 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -599,6 +599,7 @@ def __setHTTPProxy(): __scheme = __proxySplit[0] __hostname = __hostnamePort[0] __port = None + __proxyString = "" if len(__hostnamePort) == 2: try: @@ -619,9 +620,9 @@ def __setHTTPProxy(): raise sqlmapSyntaxException, errMsg # Reference: http://stackoverflow.com/questions/34079/how-to-specify-an-authenticated-proxy-for-a-python-http-connection - __proxyString = "%s@%s:%d" % (conf.pCred, __hostname, __port) - else: - __proxyString = "%s:%d" % (__hostname, __port) + __proxyString = "%s@" % conf.pCred + + __proxyString += "%s:%d" % (__hostname, __port) # Workaround for http://bugs.python.org/issue1424152 (urllib/urllib2: # HTTPS over (Squid) Proxy fails) as long as HTTP over SSL requests @@ -1184,19 +1185,17 @@ def __basicOptionValidation(): errMsg = "value for --stop (limitStop) option must be an integer value greater than zero (>0)" raise sqlmapSyntaxException, errMsg - if conf.limitStart is not None and isinstance(conf.limitStart, int) and conf.limitStart > 0 and\ + if conf.limitStart is not None and isinstance(conf.limitStart, int) and conf.limitStart > 0 and \ conf.limitStop is not None and isinstance(conf.limitStop, int) and conf.limitStop > 0 and conf.limitStop <= conf.limitStart: errMsg = "value for --start (limitStart) option must be smaller than value for --stop (limitStop) option" raise sqlmapSyntaxException, errMsg - if conf.cpuThrottle is not None and isinstance(conf.cpuThrottle, int) and (conf.cpuThrottle > 100 or\ - conf.cpuThrottle < 0): + if conf.cpuThrottle is not None and isinstance(conf.cpuThrottle, int) and (conf.cpuThrottle > 100 or conf.cpuThrottle < 0): errMsg = "value for --cpu-throttle (cpuThrottle) option must be in range [0,100]" raise sqlmapSyntaxException, errMsg - if conf.matchRatio is not None and isinstance(conf.matchRatio, float) and (conf.matchRatio > 1 or\ - conf.cpuThrottle < 0): - errMsg = "value for --ratio (matchRatio) option must be in range [0,1]" + if conf.thold is not None and isinstance(conf.thold, float) and (conf.thold > 1 or conf.cpuThrottle < 0): + errMsg = "value for --threshold (thold) option must be in range [0,1]" raise sqlmapSyntaxException, errMsg if conf.textOnly and conf.useNullConnection: diff --git a/sqlmap.conf b/sqlmap.conf index bcc142be8..de38b6b2b 100644 --- a/sqlmap.conf +++ b/sqlmap.conf @@ -75,7 +75,7 @@ headers = Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9 # Valid: Basic, Digest or NTLM aType = -# HTTP Authentication credentials. Useful only if the target url requires +# HTTP authentication credentials. Useful only if the target url requires # HTTP Basic, Digest or NTLM authentication and you have such data. # Syntax: username:password aCred = @@ -92,6 +92,11 @@ keepAlive = False # Syntax: http://address:port proxy = +# HTTP proxy authentication credentials. Useful only if the proxy requires +# HTTP Basic or Digest authentication and you have such data. +# Syntax: username:password +pCred = + # Ignore system default HTTP proxy # Valid: True or False ignoreProxy = False @@ -178,7 +183,7 @@ string = regexp = # String to be excluded by the page content before calculating the page -# MD5 hash +# MD5 hash. eString = # Regular expression matches to be excluded by the page content before @@ -187,7 +192,7 @@ eString = # (http://www.python.org/doc/2.5.2/lib/re-syntax.html) eRegexp = -# Page comparison threshold value (aka matchRatio) +# Page comparison threshold value. # Valid: 0.0-1.0 thold =