Skip to content

Instantly share code, notes, and snippets.

@jstnkndy
Created September 15, 2022 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jstnkndy/cc3dc2ea6e9fcd961854e377f625d9d0 to your computer and use it in GitHub Desktop.
Save jstnkndy/cc3dc2ea6e9fcd961854e377f625d9d0 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
'''
This script can be used to identify passwords that are being used across multiple accounts.
Example: python3 password_reuse.py <file in username:hash format>
'''
import sys
from pprint import pprint
from collections import defaultdict
if len(sys.argv) != 2:
print('Usage: {} <hash file in username:hash format>'.format(sys.argv[0]))
sys.exit()
hash_file = sys.argv[1]
data = [line.rstrip() for line in open(hash_file).readlines()]
d = defaultdict(list)
for line in data:
username, password_hash = line.split(":")
d[password_hash].append(username)
for nt_hash in d:
if len(d[nt_hash]) > 1:
print("{} - {}".format(nt_hash, d[nt_hash]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment