From d8c62e0beb7e4f4543dc9a76688bac49a728d291 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Fri, 3 May 2019 01:20:10 +0200 Subject: [PATCH] Minor update --- extra/safe2bin/safe2bin.py | 2 +- extra/shutils/drei.sh | 10 +++++----- extra/shutils/modernize.sh | 8 ++++++++ lib/core/option.py | 4 ++-- lib/core/settings.py | 2 +- lib/request/httpshandler.py | 2 +- lib/utils/hash.py | 2 +- thirdparty/odict/ordereddict.py | 8 ++++---- 8 files changed, 23 insertions(+), 15 deletions(-) create mode 100755 extra/shutils/modernize.sh diff --git a/extra/safe2bin/safe2bin.py b/extra/safe2bin/safe2bin.py index 3406f1b6c..1aca82d4d 100644 --- a/extra/safe2bin/safe2bin.py +++ b/extra/safe2bin/safe2bin.py @@ -34,7 +34,7 @@ HEX_ENCODED_CHAR_REGEX = r"(?P\\x[0-9A-Fa-f]{2})" SAFE_ENCODE_SLASH_REPLACEMENTS = "\t\n\r\x0b\x0c" # Characters that don't need to be safe encoded -SAFE_CHARS = "".join(filter(lambda _: _ not in SAFE_ENCODE_SLASH_REPLACEMENTS, string.printable.replace('\\', ''))) +SAFE_CHARS = "".join([_ for _ in string.printable.replace('\\', '') if _ not in SAFE_ENCODE_SLASH_REPLACEMENTS]) # Prefix used for hex encoded values HEX_ENCODED_PREFIX = r"\x" diff --git a/extra/shutils/drei.sh b/extra/shutils/drei.sh index ef4b51479..7bd3ab68a 100755 --- a/extra/shutils/drei.sh +++ b/extra/shutils/drei.sh @@ -5,9 +5,9 @@ # Stress test against Python3 -# export SQLMAP_DREI=1 -# for i in $(find . -iname "*.py" | grep -v __init__); do python3 -c 'import '`echo $i | cut -d '.' -f 2 | cut -d '/' -f 2- | sed 's/\//./g'`''; done -# unset SQLMAP_DREI -# source `dirname "$0"`"/junk.sh" +export SQLMAP_DREI=1 +for i in $(find . -iname "*.py" | grep -v __init__); do python3 -c 'import '`echo $i | cut -d '.' -f 2 | cut -d '/' -f 2- | sed 's/\//./g'`''; done +unset SQLMAP_DREI +source `dirname "$0"`"/junk.sh" -for i in $(find . -iname "*.py" | grep -v __init__); do timeout 10 pylint --py3k $i; done 2>&1 | grep -v -E 'absolute_import|No config file' +# for i in $(find . -iname "*.py" | grep -v __init__); do timeout 10 pylint --py3k $i; done 2>&1 | grep -v -E 'absolute_import|No config file' diff --git a/extra/shutils/modernize.sh b/extra/shutils/modernize.sh new file mode 100755 index 000000000..ac5cab002 --- /dev/null +++ b/extra/shutils/modernize.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/) +# See the file 'LICENSE' for copying permission + +# sudo pip install modernize + +for i in $(find . -iname "*.py" | grep -v __init__); do python-modernize $i 2>&1 | grep -E '^[+-]' | grep -v range | grep -v absolute_import; done diff --git a/lib/core/option.py b/lib/core/option.py index c77a55967..1d2f67f9e 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -533,7 +533,7 @@ def _setMetasploit(): retVal = None try: - from _winreg import ConnectRegistry, OpenKey, QueryValueEx, HKEY_LOCAL_MACHINE + from six.moves.winreg import ConnectRegistry, OpenKey, QueryValueEx, HKEY_LOCAL_MACHINE _ = ConnectRegistry(None, HKEY_LOCAL_MACHINE) _ = OpenKey(_, key) retVal = QueryValueEx(_, value)[0] @@ -2063,7 +2063,7 @@ def _useWizardInterface(): message = "%s data (--data) [Enter for None]: " % ((conf.method if conf.method != HTTPMETHOD.GET else conf.method) or HTTPMETHOD.POST) conf.data = readInput(message, default=None) - if not (filter(lambda _: '=' in unicode(_), (conf.url, conf.data)) or '*' in conf.url): + if not (any('=' in _ for _ in (conf.url, conf.data)) or '*' in conf.url): warnMsg = "no GET and/or %s parameter(s) found for testing " % ((conf.method if conf.method != HTTPMETHOD.GET else conf.method) or HTTPMETHOD.POST) warnMsg += "(e.g. GET parameter 'id' in 'http://www.site.com/vuln.php?id=1'). " if not conf.crawlDepth and not conf.forms: diff --git a/lib/core/settings.py b/lib/core/settings.py index c2db70be4..9014379ed 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -18,7 +18,7 @@ from lib.core.enums import OS from thirdparty import six # sqlmap version (...) -VERSION = "1.3.5.8" +VERSION = "1.3.5.9" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" 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) diff --git a/lib/request/httpshandler.py b/lib/request/httpshandler.py index 2a98d6aba..9cc2d6aa5 100644 --- a/lib/request/httpshandler.py +++ b/lib/request/httpshandler.py @@ -51,7 +51,7 @@ class HTTPSConnection(_http_client.HTTPSConnection): # Reference(s): https://docs.python.org/2/library/ssl.html#ssl.SSLContext # https://www.mnot.net/blog/2014/12/27/python_2_and_tls_sni if re.search(r"\A[\d.]+\Z", self.host) is None and kb.tlsSNI.get(self.host) is not False and not any((conf.proxy, conf.tor)) and hasattr(ssl, "SSLContext"): - for protocol in filter(lambda _: _ >= ssl.PROTOCOL_TLSv1, _protocols): + for protocol in [_ for _ in _protocols if _ >= ssl.PROTOCOL_TLSv1]: try: sock = create_sock() context = ssl.SSLContext(protocol) diff --git a/lib/utils/hash.py b/lib/utils/hash.py index e9780be3a..0f5561603 100644 --- a/lib/utils/hash.py +++ b/lib/utils/hash.py @@ -1099,7 +1099,7 @@ def dictionaryAttack(attack_dict): while not retVal.empty(): user, hash_, word = item = retVal.get(block=False) - attack_info = filter(lambda _: _[0][0] != user or _[0][1] != hash_, attack_info) + attack_info = [_ for _ in attack_info if _[0][0] != user or _[0][1] != hash_] hashDBWrite(hash_, word) results.append(item) diff --git a/thirdparty/odict/ordereddict.py b/thirdparty/odict/ordereddict.py index c2b771926..9396e9b05 100644 --- a/thirdparty/odict/ordereddict.py +++ b/thirdparty/odict/ordereddict.py @@ -73,9 +73,9 @@ class OrderedDict(dict, DictMixin): if not self: raise KeyError('dictionary is empty') if last: - key = reversed(self).next() + key = next(reversed(self)) else: - key = iter(self).next() + key = next(iter(self)) value = self.pop(key) return key, value @@ -104,7 +104,7 @@ class OrderedDict(dict, DictMixin): def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) - return '%s(%r)' % (self.__class__.__name__, self.items()) + return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @@ -127,4 +127,4 @@ class OrderedDict(dict, DictMixin): return dict.__eq__(self, other) def __ne__(self, other): - return not self == other \ No newline at end of file + return not self == other