hash_1_5.py 781 B

1234567891011121314151617
  1. def mssql_old_passwd(password, salt, uppercase=True): # prior to version '2005'
  2. """
  3. Reference(s):
  4. www.exploit-db.com/download_pdf/15537/
  5. http://www.leidecker.info/projects/phrasendrescher/mssql.c
  6. https://www.evilfingers.com/tools/GSAuditor.php
  7. >>> mssql_old_passwd(password='testpass', salt='4086ceb6', uppercase=True)
  8. '0x01004086CEB60C90646A8AB9889FE3ED8E5C150B5460ECE8425AC7BB7255C0C81D79AA5D0E93D4BB077FB9A51DA0'
  9. """
  10. binsalt = hexdecode(salt)
  11. unistr = "".join(map(lambda c: ("%s\0" if ord(c) < 256 else "%s") % utf8encode(c), password))
  12. retVal = "0100%s%s%s" % (salt, sha1(unistr + binsalt).hexdigest(), sha1(unistr.upper() + binsalt).hexdigest())
  13. return "0x%s" % (retVal.upper() if uppercase else retVal.lower())