hash_1_4.py 615 B

12345678910111213141516
  1. def mssql_passwd(password, salt, uppercase=False):
  2. """
  3. Reference(s):
  4. http://www.leidecker.info/projects/phrasendrescher/mssql.c
  5. https://www.evilfingers.com/tools/GSAuditor.php
  6. >>> mssql_passwd(password='testpass', salt='4086ceb6', uppercase=False)
  7. '0x01004086ceb60c90646a8ab9889fe3ed8e5c150b5460ece8425a'
  8. """
  9. binsalt = hexdecode(salt)
  10. unistr = "".join(map(lambda c: ("%s\0" if ord(c) < 256 else "%s") % utf8encode(c), password))
  11. retVal = "0100%s%s" % (salt, sha1(unistr + binsalt).hexdigest())
  12. return "0x%s" % (retVal.upper() if uppercase else retVal.lower())