hash_1_6.py 640 B

123456789101112131415
  1. def mssql_new_passwd(password, salt, uppercase=False):
  2. """
  3. Reference(s):
  4. http://hashcat.net/forum/thread-1474.html
  5. >>> mssql_new_passwd(password='testpass', salt='4086ceb6', uppercase=False)
  6. '0x02004086ceb6eb051cdbc5bdae68ffc66c918d4977e592f6bdfc2b444a7214f71fa31c35902c5b7ae773ed5f4c50676d329120ace32ee6bc81c24f70711eb0fc6400e85ebf25'
  7. """
  8. binsalt = hexdecode(salt)
  9. unistr = "".join(map(lambda c: ("%s\0" if ord(c) < 256 else "%s") % utf8encode(c), password))
  10. retVal = "0200%s%s" % (salt, sha512(unistr + binsalt).hexdigest())
  11. return "0x%s" % (retVal.upper() if uppercase else retVal.lower())