Implements support of old OsCommerce hashing

This commit is contained in:
Miroslav Stampar
2025-07-26 15:17:55 +02:00
parent 8241cf6ea1
commit 26d0b3b23b
4 changed files with 22 additions and 6 deletions

View File

@@ -192,6 +192,7 @@ class HASH(object):
APACHE_SHA1 = r'\A\{SHA\}[a-zA-Z0-9+/]+={0,2}\Z'
VBULLETIN = r'\A[0-9a-fA-F]{32}:.{30}\Z'
VBULLETIN_OLD = r'\A[0-9a-fA-F]{32}:.{3}\Z'
OSCOMMERCE_OLD = r'\A[0-9a-fA-F]{32}:.{2}\Z'
SSHA = r'\A\{SSHA\}[a-zA-Z0-9+/]+={0,2}\Z'
SSHA256 = r'\A\{SSHA256\}[a-zA-Z0-9+/]+={0,2}\Z'
SSHA512 = r'\A\{SSHA512\}[a-zA-Z0-9+/]+={0,2}\Z'

View File

@@ -19,7 +19,7 @@ from lib.core.enums import OS
from thirdparty import six
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.9.7.13"
VERSION = "1.9.7.14"
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)

View File

@@ -478,6 +478,16 @@ def vbulletin_passwd(password, salt, **kwargs):
return "%s:%s" % (md5(binascii.hexlify(md5(getBytes(password)).digest()) + getBytes(salt)).hexdigest(), salt)
def oscommerce_old_passwd(password, salt, **kwargs):
"""
Reference: http://ryanuber.com/09-24-2010/os-commerce-password-hashing.html
>>> oscommerce_old_passwd(password='testpass', salt='6b')
'16d39816e4545b3179f86f2d2d549af4:6b'
"""
return "%s:%s" % (md5(getBytes(salt) + getBytes(password)).hexdigest(), salt)
def phpass_passwd(password, salt, count, prefix, **kwargs):
"""
Reference(s):
@@ -570,6 +580,7 @@ __functions__ = {
HASH.APACHE_SHA1: apache_sha1_passwd,
HASH.VBULLETIN: vbulletin_passwd,
HASH.VBULLETIN_OLD: vbulletin_passwd,
HASH.OSCOMMERCE_OLD: oscommerce_old_passwd,
HASH.SSHA: ssha_passwd,
HASH.SSHA256: ssha256_passwd,
HASH.SSHA512: ssha512_passwd,
@@ -1055,7 +1066,7 @@ def dictionaryAttack(attack_dict):
item = [(user, hash_), {"salt": hash_[0:2]}]
elif hash_regex in (HASH.UNIX_MD5_CRYPT, HASH.APACHE_MD5_CRYPT):
item = [(user, hash_), {"salt": hash_.split('$')[2], "magic": "$%s$" % hash_.split('$')[1]}]
elif hash_regex in (HASH.JOOMLA, HASH.VBULLETIN, HASH.VBULLETIN_OLD):
elif hash_regex in (HASH.JOOMLA, HASH.VBULLETIN, HASH.VBULLETIN_OLD, HASH.OSCOMMERCE_OLD):
item = [(user, hash_), {"salt": hash_.split(':')[-1]}]
elif hash_regex in (HASH.DJANGO_MD5, HASH.DJANGO_SHA1):
item = [(user, hash_), {"salt": hash_.split('$')[1]}]
@@ -1302,8 +1313,12 @@ def crackHashFile(hashFile):
i = 0
attack_dict = {}
check = None
for line in getFileItems(conf.hashFile):
if ':' in line:
if check is None and not attack_dict and ':' in line:
check = any(re.search(_, line) for _ in getPublicTypeMembers(HASH, True))
if ':' in line and check is False:
user, hash_ = line.split(':', 1)
attack_dict[user] = [hash_]
else: