Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # coding=utf-8
- import os
- import hashlib
- import binascii
- hashdir = "./hc-testing"
- passwords = [ '1',
- '4ä',
- 'LL+',
- 'M45m',
- '++=z6',
- 'U!Nzc4',
- 'fbz4ö!f',
- '=c4m8tN2',
- 'YM8346bFD',
- '::c345nb§V',
- '<Xw34b)"f+r',
- 'Nvoi6456nbGF',
- 'LKJN1v^nvb$bC',
- ')M4b6nUbpLw000',
- '9348b5npBNZ5nk4',
- 'kj5093Nßchn34V3,',
- 'l8zNVB54!n5á6L"nb', ]
- hex = binascii.hexlify
- unhex = binascii.unhexlify
- def writeDict(filename="dict"):
- """Save dictionary in the hashdir"""
- handle=open(os.path.join(hashdir, filename), "w+")
- for pw in passwords:
- handle.write(pw+"\n")
- handle.close()
- def loadDict(file):
- """Load passwords from file, doNät use the build in ones"""
- global passwords
- with open(file) as handle:
- passwords = handle.readlines()
- passwords = map(lambda x: x.strip("\r\n"), passwords)
- class hashwrapper(object):
- """Interface"""
- def __init__(self, salt):
- self.salt = salt
- self.realSalt = salt
- self.hashobj = hashlib.md5()
- def updateSalt(self, newSalt):
- self.salt = newSalt
- self.realSalt = newSalt
- def update(self, passwd):
- raise(UserWarning("Implementation error, "+
- "update() has to be overwritten!"))
- def digest(self):
- return self.hashobj.digest()
- class wrap_m10(hashwrapper):
- """md5(md5($pass).md5($salt))"""
- def __init__(self, salt="abcdef"):
- hashwrapper.__init__(self, salt)
- self.updateSalt(self.salt)
- def updateSalt(self, newSalt):
- hashwrapper.updateSalt(self, newSalt)
- updateSalt = hashlib.md5()
- updateSalt.update(self.salt)
- self.salt = hex(updateSalt.digest())
- def update(self, passwd):
- pw = hashlib.md5()
- pw.update(passwd)
- self.hashobj.update(hex(pw.digest())+self.salt)
- class wrap_m11(hashwrapper):
- """Joomla"""
- def __init__(self, salt="abcdef"):
- hashwrapper.__init__(self, salt)
- def update(self, passwd):
- self.hashobj.update(passwd+self.salt)
- class wrap_m21(hashwrapper):
- """OSC"""
- def __init__(self, salt="abcdef"):
- hashwrapper.__init__(self, salt)
- def update(self, passwd):
- self.hashobj.update(passwd+self.salt)
- hashtypes = { 0: hashlib.md5(),
- 10: wrap_m10(),
- 11: wrap_m11(),
- 21: wrap_m21(),
- 100: hashlib.sha1(),
- }
- if __name__=="__main__":
- for mode in hashtypes:
- handle=open(os.path.join(hashdir, str(mode)+".hash"), "w+")
- for pw in passwords:
- new = hashtypes[mode]
- new.update(pw)
- try:
- salt = ":"+new.realSalt+"\n"
- except:
- salt = "\n"
- handle.write(hex(new.digest())+salt)
- handle.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement