Skip to content

Instantly share code, notes, and snippets.

@matterpreter
Last active April 19, 2019 15:43
Show Gist options
  • Save matterpreter/76552062f3ddc1e157e46f4e4f7797a9 to your computer and use it in GitHub Desktop.
Save matterpreter/76552062f3ddc1e157e46f4e4f7797a9 to your computer and use it in GitHub Desktop.
Port of hashmash to support Python3
#!/usr/bin/env python3
import sys
def usage():
print('HashMash - decrypted password to username matcher')
print('')
print('$ python3 %s <Hash File> <OCL Hashcat Decrypted File>' % sys.argv[0])
print('')
print('User Hash File format is user:hash (or JTR NTLM)')
print('OCL Decrypted Pasword File format is, hash:password')
print('')
sys.exit(1)
if len(sys.argv) != 3:
print('[ERROR]\tWrong number of arguments')
usage()
try:
hash_file = open(sys.argv[1])
pass_file = open(sys.argv[2])
except IOError:
print('[ERROR]\tInvalid input files, please review..')
usage()
passDict = dict(line.split(':', 1) for line in pass_file)
hashes = hash_file.readlines()
for cracked_hash, passwd in passDict.items():
for hashItem in hashes:
if len(hashItem) > 0:
hashList = hashItem.split(':')
if len(hashList) == 7 or len(hashList) == 4:
user_name, user_hash = (hashList[0], hashList[3])
else:
user_name, user_hash = (hashList[0], hashList[1])
if cracked_hash.upper().strip() == user_hash.upper().strip():
print('%s:%s' % (user_name.strip(), passwd.strip()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment