hibp-sha1-check.py
· 989 B · Python
Raw
#!/usr/bin/env python
# input files:
# - hashlist.txt, a file containing the user hashes to check, in format username:hash, one per line.
# (or change the input to whatever you need it as)
# - pwned-passwords-sha1-ordered-by-count-v4.txt, get this from https://haveibeenpwned.com/Passwords
# any format is fine, just update the file name below
# the script will output percentage of the password file completed to stdout. compare this against your
# original password list, or modify the block at the end to further process the data
import os.path
inp_users = "hashlist.txt"
inp_passwords = "pwned-passwords-sha1-ordered-by-count-v4.txt"
with open(inp_users) as f:
d = {hash:user for user,hash in (l.strip().split(":") for l in f.readlines())}
out = []
filesize = os.path.getsize(inp_passwords)
with open(inp_passwords) as f:
t=0
for line in f:
if line.split(":")[0] in d:
out.append(line)
t+=len(line)
print((t/filesize)*100,end="\r")
print("\n".join(out))
| 1 | #!/usr/bin/env python |
| 2 | # input files: |
| 3 | # - hashlist.txt, a file containing the user hashes to check, in format username:hash, one per line. |
| 4 | # (or change the input to whatever you need it as) |
| 5 | # - pwned-passwords-sha1-ordered-by-count-v4.txt, get this from https://haveibeenpwned.com/Passwords |
| 6 | # any format is fine, just update the file name below |
| 7 | # the script will output percentage of the password file completed to stdout. compare this against your |
| 8 | # original password list, or modify the block at the end to further process the data |
| 9 | import os.path |
| 10 | inp_users = "hashlist.txt" |
| 11 | inp_passwords = "pwned-passwords-sha1-ordered-by-count-v4.txt" |
| 12 | with open(inp_users) as f: |
| 13 | d = {hash:user for user,hash in (l.strip().split(":") for l in f.readlines())} |
| 14 | |
| 15 | out = [] |
| 16 | filesize = os.path.getsize(inp_passwords) |
| 17 | with open(inp_passwords) as f: |
| 18 | t=0 |
| 19 | for line in f: |
| 20 | if line.split(":")[0] in d: |
| 21 | out.append(line) |
| 22 | t+=len(line) |
| 23 | print((t/filesize)*100,end="\r") |
| 24 | |
| 25 | print("\n".join(out)) |