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