@@ -158,6 +158,22 @@ def mssql_old_passwd(password, salt, uppercase=True): # prior to version '2005'
158158
159159 return "0x%s" % (retVal .upper () if uppercase else retVal .lower ())
160160
161+ def mssql_new_passwd (password , salt , uppercase = False ):
162+ """
163+ Reference(s):
164+ http://hashcat.net/forum/thread-1474.html
165+
166+ >>> mssql_new_passwd(password='testpass', salt='4086ceb6', uppercase=False)
167+ '0x02004086ceb6eb051cdbc5bdae68ffc66c918d4977e592f6bdfc2b444a7214f71fa31c35902c5b7ae773ed5f4c50676d329120ace32ee6bc81c24f70711eb0fc6400e85ebf25'
168+ """
169+
170+ binsalt = hexdecode (salt )
171+ unistr = "" .join (map (lambda c : ("%s\0 " if ord (c ) < 256 else "%s" ) % utf8encode (c ), password ))
172+
173+ retVal = "0200%s%s" % (salt , sha512 (unistr + binsalt ).hexdigest ())
174+
175+ return "0x%s" % (retVal .upper () if uppercase else retVal .lower ())
176+
161177def oracle_passwd (password , salt , uppercase = True ):
162178 """
163179 Reference(s):
@@ -326,6 +342,7 @@ def _encode64(input_, count):
326342 HASH .POSTGRES : postgres_passwd ,
327343 HASH .MSSQL : mssql_passwd ,
328344 HASH .MSSQL_OLD : mssql_old_passwd ,
345+ HASH .MSSQL_NEW : mssql_new_passwd ,
329346 HASH .ORACLE : oracle_passwd ,
330347 HASH .ORACLE_OLD : oracle_old_passwd ,
331348 HASH .MD5_GENERIC : md5_generic_passwd ,
@@ -671,7 +688,7 @@ def dictionaryAttack(attack_dict):
671688 item = [(user , hash_ ), {'username' : user }]
672689 elif hash_regex in (HASH .ORACLE ):
673690 item = [(user , hash_ ), {'salt' : hash_ [- 20 :]}]
674- elif hash_regex in (HASH .MSSQL , HASH .MSSQL_OLD ):
691+ elif hash_regex in (HASH .MSSQL , HASH .MSSQL_OLD , HASH . MSSQL_NEW ):
675692 item = [(user , hash_ ), {'salt' : hash_ [6 :14 ]}]
676693 elif hash_regex in (HASH .CRYPT_GENERIC ):
677694 item = [(user , hash_ ), {'salt' : hash_ [0 :2 ]}]
0 commit comments