Skip to content

Commit 5cacf20

Browse files
committed
Speeding up the post-processing of large dumps
1 parent 1825390 commit 5cacf20

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

lib/core/option.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,6 +1867,7 @@ def _setKnowledgeBaseAttributes(flushAll=True):
18671867
kb.cache.content = {}
18681868
kb.cache.encoding = {}
18691869
kb.cache.alphaBoundaries = None
1870+
kb.cache.hashRegex = None
18701871
kb.cache.intBoundaries = None
18711872
kb.cache.parsedDbms = {}
18721873
kb.cache.regex = {}

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty.six import unichr as _unichr
1919

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.4.4.8"
21+
VERSION = "1.4.4.9"
2222
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2323
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2424
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/utils/hash.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -741,17 +741,26 @@ def hashRecognition(value):
741741
if value and len(value) >= 8 and ' ' not in value: # Note: pre-filter condition (for optimization purposes)
742742
isOracle, isMySQL = Backend.isDbms(DBMS.ORACLE), Backend.isDbms(DBMS.MYSQL)
743743

744-
if isinstance(value, six.string_types):
744+
if kb.cache.hashRegex is None:
745+
parts = []
746+
745747
for name, regex in getPublicTypeMembers(HASH):
746748
# Hashes for Oracle and old MySQL look the same hence these checks
747749
if isOracle and regex == HASH.MYSQL_OLD or isMySQL and regex == HASH.ORACLE_OLD:
748750
continue
749751
elif regex == HASH.CRYPT_GENERIC:
750752
if any((value.lower() == value, value.upper() == value)):
751753
continue
752-
elif re.match(regex, value):
753-
retVal = regex
754-
break
754+
else:
755+
parts.append("(?P<%s>%s)" % (name, regex))
756+
757+
kb.cache.hashRegex = ('|'.join(parts)).replace("(?i)", "")
758+
759+
if isinstance(value, six.string_types):
760+
match = re.search(kb.cache.hashRegex, value, re.I)
761+
if match:
762+
algorithm, _ = [_ for _ in match.groupdict().items() if _[1] is not None][0]
763+
retVal = getattr(HASH, algorithm)
755764

756765
return retVal
757766

0 commit comments

Comments
 (0)