diff --git a/lib/core/option.py b/lib/core/option.py index 336a20271..e86afd5d0 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1867,6 +1867,7 @@ def _setKnowledgeBaseAttributes(flushAll=True): kb.cache.content = {} kb.cache.encoding = {} kb.cache.alphaBoundaries = None + kb.cache.hashRegex = None kb.cache.intBoundaries = None kb.cache.parsedDbms = {} kb.cache.regex = {} diff --git a/lib/core/settings.py b/lib/core/settings.py index e1372f902..0a9c48c58 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -18,7 +18,7 @@ from lib.core.enums import OS from thirdparty.six import unichr as _unichr # sqlmap version (...) -VERSION = "1.4.4.8" +VERSION = "1.4.4.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/utils/hash.py b/lib/utils/hash.py index 25e84936f..e11c448a3 100644 --- a/lib/utils/hash.py +++ b/lib/utils/hash.py @@ -741,7 +741,9 @@ def hashRecognition(value): if value and len(value) >= 8 and ' ' not in value: # Note: pre-filter condition (for optimization purposes) isOracle, isMySQL = Backend.isDbms(DBMS.ORACLE), Backend.isDbms(DBMS.MYSQL) - if isinstance(value, six.string_types): + if kb.cache.hashRegex is None: + parts = [] + for name, regex in getPublicTypeMembers(HASH): # Hashes for Oracle and old MySQL look the same hence these checks if isOracle and regex == HASH.MYSQL_OLD or isMySQL and regex == HASH.ORACLE_OLD: @@ -749,9 +751,16 @@ def hashRecognition(value): elif regex == HASH.CRYPT_GENERIC: if any((value.lower() == value, value.upper() == value)): continue - elif re.match(regex, value): - retVal = regex - break + else: + parts.append("(?P<%s>%s)" % (name, regex)) + + kb.cache.hashRegex = ('|'.join(parts)).replace("(?i)", "") + + if isinstance(value, six.string_types): + match = re.search(kb.cache.hashRegex, value, re.I) + if match: + algorithm, _ = [_ for _ in match.groupdict().items() if _[1] is not None][0] + retVal = getattr(HASH, algorithm) return retVal