Skip to content

Instantly share code, notes, and snippets.

@Mic92
Last active February 7, 2019 11:39
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 Mic92/33bbac24601ce87453ac7453b6976a4c to your computer and use it in GitHub Desktop.
Save Mic92/33bbac24601ce87453ac7453b6976a4c to your computer and use it in GitHub Desktop.
Check CSV export of a keepassx database against haveibeenpwnd (k-anonymized)
#!/usr/bin/env python3
import csv
import sys
# https://github.com/lionheart/pwnedpasswords
import pwnedpasswords
def main():
if len(sys.argv) == 0:
print("USAGE: %s keepass-passwords.csv", sys.argv[0])
sys.exit(1)
with open(sys.argv[1]) as f:
reader = csv.DictReader(f)
for line in reader:
password = line.get("Password", "")
if password == "": continue
pwned = pwnedpasswords.check(password)
if pwned != 0:
title = line.get("Title", "")
print("Password %s for %s is insecure" % (password, title))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment