forked from brannondorsey/naive-hashcat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
match-creds.py
34 lines (30 loc) · 1.6 KB
/
match-creds.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
import argparse
def parse_args():
parser = argparse.ArgumentParser(description='Match credentials in a leaked username:hash formatted'
' file with cracked passwords in a potfile')
parser.add_argument('-a', '--accounts', type=str, required=True,
help='leaked accounts file with one "username:hash" per line')
parser.add_argument('-p', '--potfile', type=str, required=True,
help='hashcat potfile')
parser.add_argument('-d', '--delimiter', type=str, default=':',
help='character or string that seperates usernames from passwords')
args = parser.parse_args()
if not os.path.exists(args.accounts):
parser.error('{} file does not exist'.format(args.accounts))
if not os.path.exists(args.potfile):
parser.error('{} file does not exist'.format(args.potfile))
return args
if __name__ == '__main__':
args = parse_args()
with open(args.accounts, 'r') as f:
hash_to_username = { hsh: username for username, hsh in \
[l.split(args.delimiter,1) for l in f.read().split('\n') \
if len(l.split(args.delimiter,1)) > 1] }
# print(hash_to_username)
with open(args.potfile, 'r') as f:
hash_to_pw = { hsh: pw for hsh, pw in [l.split(':',1) for l in f.read().split('\n') \
if len(l.split(':',1)) > 1]}
for hsh, username in hash_to_username.items():
if hsh in hash_to_pw:
print('{}:{}'.format(username, hash_to_pw[hsh]))