Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f21388d

Browse files
committed
Minor optimization
1 parent f38a2c2 commit f21388d

2 files changed

Lines changed: 23 additions & 13 deletions

File tree

lib/core/settings.py

Lines changed: 2 additions & 2 deletions
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.1.60"
21+
VERSION = "1.4.1.61"
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)
@@ -683,7 +683,7 @@
683683
SLOW_ORDER_COUNT_THRESHOLD = 10000
684684

685685
# Give up on hash recognition if nothing was found in first given number of rows
686-
HASH_RECOGNITION_QUIT_THRESHOLD = 10000
686+
HASH_RECOGNITION_QUIT_THRESHOLD = 1000
687687

688688
# Regular expression used for automatic hex conversion and hash cracking of (RAW) binary column values
689689
HASH_BINARY_COLUMNS_REGEX = r"(?i)pass|psw|hash"

lib/utils/hash.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -727,21 +727,31 @@ def attackDumpedTable():
727727
table[column]['length'] = max(table[column]['length'], len(table[column]['values'][i]))
728728

729729
def hashRecognition(value):
730+
"""
731+
>>> hashRecognition("179ad45c6ce2cb97cf1029e212046e81") == HASH.MD5_GENERIC
732+
True
733+
>>> hashRecognition("S:2BFCFDF5895014EE9BB2B9BA067B01E0389BB5711B7B5F82B7235E9E182C") == HASH.ORACLE
734+
True
735+
>>> hashRecognition("foobar") == None
736+
True
737+
"""
738+
730739
retVal = None
731740

732-
isOracle, isMySQL = Backend.isDbms(DBMS.ORACLE), Backend.isDbms(DBMS.MYSQL)
741+
if value and len(value) >= 8 and ' ' not in value: # Note: pre-filter condition (for optimization purposes)
742+
isOracle, isMySQL = Backend.isDbms(DBMS.ORACLE), Backend.isDbms(DBMS.MYSQL)
733743

734-
if isinstance(value, six.string_types):
735-
for name, regex in getPublicTypeMembers(HASH):
736-
# Hashes for Oracle and old MySQL look the same hence these checks
737-
if isOracle and regex == HASH.MYSQL_OLD or isMySQL and regex == HASH.ORACLE_OLD:
738-
continue
739-
elif regex == HASH.CRYPT_GENERIC:
740-
if any((value.lower() == value, value.upper() == value)):
744+
if isinstance(value, six.string_types):
745+
for name, regex in getPublicTypeMembers(HASH):
746+
# Hashes for Oracle and old MySQL look the same hence these checks
747+
if isOracle and regex == HASH.MYSQL_OLD or isMySQL and regex == HASH.ORACLE_OLD:
741748
continue
742-
elif re.match(regex, value):
743-
retVal = regex
744-
break
749+
elif regex == HASH.CRYPT_GENERIC:
750+
if any((value.lower() == value, value.upper() == value)):
751+
continue
752+
elif re.match(regex, value):
753+
retVal = regex
754+
break
745755

746756
return retVal
747757

0 commit comments

Comments
 (0)