Minor PEPing

This commit is contained in:
Miroslav Stampar 2018-03-13 11:25:26 +01:00
parent ae2b02952f
commit 8166a4eeb8
3 changed files with 16 additions and 16 deletions

View File

@ -1443,13 +1443,14 @@ def parseTargetUrl():
conf.hostname = conf.hostname.strip("[]").replace(kb.customInjectionMark, "") conf.hostname = conf.hostname.strip("[]").replace(kb.customInjectionMark, "")
try: try:
_ = conf.hostname.encode("idna") conf.hostname.encode("idna")
except LookupError: conf.hostname.encode(UNICODE_ENCODING)
_ = conf.hostname.encode(UNICODE_ENCODING) except (LookupError, UnicodeError):
except UnicodeError: invalid = True
_ = None else:
invalid = False
if any((_ is None, re.search(r"\s", conf.hostname), '..' in conf.hostname, conf.hostname.startswith('.'), '\n' in originalUrl)): if any((invalid, re.search(r"\s", conf.hostname), '..' in conf.hostname, conf.hostname.startswith('.'), '\n' in originalUrl)):
errMsg = "invalid target URL ('%s')" % originalUrl errMsg = "invalid target URL ('%s')" % originalUrl
raise SqlmapSyntaxException(errMsg) raise SqlmapSyntaxException(errMsg)
@ -2994,7 +2995,7 @@ def setOptimize():
Sets options turned on by switch '-o' Sets options turned on by switch '-o'
""" """
#conf.predictOutput = True # conf.predictOutput = True
conf.keepAlive = True conf.keepAlive = True
conf.threads = 3 if conf.threads < 3 else conf.threads conf.threads = 3 if conf.threads < 3 else conf.threads
conf.nullConnection = not any((conf.data, conf.textOnly, conf.titles, conf.string, conf.notString, conf.regexp, conf.tor)) conf.nullConnection = not any((conf.data, conf.textOnly, conf.titles, conf.string, conf.notString, conf.regexp, conf.tor))
@ -3198,9 +3199,7 @@ def showHttpErrorCodes():
if kb.httpErrorCodes: if kb.httpErrorCodes:
warnMsg = "HTTP error codes detected during run:\n" warnMsg = "HTTP error codes detected during run:\n"
warnMsg += ", ".join("%d (%s) - %d times" % (code, httplib.responses[code] \ warnMsg += ", ".join("%d (%s) - %d times" % (code, httplib.responses[code] if code in httplib.responses else '?', count) for code, count in kb.httpErrorCodes.items())
if code in httplib.responses else '?', count) \
for code, count in kb.httpErrorCodes.items())
logger.warn(warnMsg) logger.warn(warnMsg)
if any((str(_).startswith('4') or str(_).startswith('5')) and _ != httplib.INTERNAL_SERVER_ERROR and _ != kb.originalCode for _ in kb.httpErrorCodes.keys()): if any((str(_).startswith('4') or str(_).startswith('5')) and _ != httplib.INTERNAL_SERVER_ERROR and _ != kb.originalCode for _ in kb.httpErrorCodes.keys()):
msg = "too many 4xx and/or 5xx HTTP error codes " msg = "too many 4xx and/or 5xx HTTP error codes "
@ -3216,8 +3215,7 @@ def openFile(filename, mode='r', encoding=UNICODE_ENCODING, errors="replace", bu
return codecs.open(filename, mode, encoding, errors, buffering) return codecs.open(filename, mode, encoding, errors, buffering)
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 \ errMsg += "Please check %s permissions on a file " % ("write" if mode and ('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 SqlmapSystemException(errMsg) raise SqlmapSystemException(errMsg)
@ -4350,7 +4348,9 @@ def prioritySortColumns(columns):
['userid', 'name', 'password'] ['userid', 'name', 'password']
""" """
_ = lambda x: x and "id" in x.lower() def _(column):
return column and "id" in column.lower()
return sorted(sorted(columns, key=len), lambda x, y: -1 if _(x) and not _(y) else 1 if not _(x) and _(y) else 0) return sorted(sorted(columns, key=len), lambda x, y: -1 if _(x) and not _(y) else 1 if not _(x) and _(y) else 0)
def getRequestHeader(request, name): def getRequestHeader(request, name):

View File

@ -19,7 +19,7 @@ from lib.core.enums import DBMS_DIRECTORY_NAME
from lib.core.enums import OS from lib.core.enums import OS
# sqlmap version (<major>.<minor>.<month>.<monthly commit>) # sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.2.3.21" VERSION = "1.2.3.22"
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE) VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

View File

@ -27,7 +27,7 @@ a7b0c8e5a18a3abe8803999dcfc4664f lib/controller/handler.py
1e5532ede194ac9c083891c2f02bca93 lib/controller/__init__.py 1e5532ede194ac9c083891c2f02bca93 lib/controller/__init__.py
052c368ae6ca09362a19376c8483fa85 lib/core/agent.py 052c368ae6ca09362a19376c8483fa85 lib/core/agent.py
591c66fa439a48b7d8b5b581437cd14d lib/core/bigarray.py 591c66fa439a48b7d8b5b581437cd14d lib/core/bigarray.py
6e41ff058eb86b824215c19a3ae4de3c lib/core/common.py 33c03aad7f4c6e7241b6f204560e69ca lib/core/common.py
2910524e4478be6b5893fb9d851a62ec lib/core/convert.py 2910524e4478be6b5893fb9d851a62ec lib/core/convert.py
9f87391b6a3395f7f50830b391264f27 lib/core/data.py 9f87391b6a3395f7f50830b391264f27 lib/core/data.py
72016ea5c994a711a262fd64572a0fcd lib/core/datatype.py 72016ea5c994a711a262fd64572a0fcd lib/core/datatype.py
@ -46,7 +46,7 @@ ffa5f01f39b17c8d73423acca6cfe86a lib/core/readlineng.py
0c3eef46bdbf87e29a3f95f90240d192 lib/core/replication.py 0c3eef46bdbf87e29a3f95f90240d192 lib/core/replication.py
a7db43859b61569b601b97f187dd31c5 lib/core/revision.py a7db43859b61569b601b97f187dd31c5 lib/core/revision.py
fcb74fcc9577523524659ec49e2e964b lib/core/session.py fcb74fcc9577523524659ec49e2e964b lib/core/session.py
aef027eeb51df0bb7330bf35725dba66 lib/core/settings.py 053e81e44a3df054a3ffd39d58de7079 lib/core/settings.py
d0adc28a38e43a787df4471f7f027413 lib/core/shell.py d0adc28a38e43a787df4471f7f027413 lib/core/shell.py
63491be462c515a1a3880c27c2acc4a2 lib/core/subprocessng.py 63491be462c515a1a3880c27c2acc4a2 lib/core/subprocessng.py
3cc852f927833895361973fbcfd156d2 lib/core/target.py 3cc852f927833895361973fbcfd156d2 lib/core/target.py