-
-
Save michaeljensen/930bf1ac768fe301585da5f3a8ddbdc6 to your computer and use it in GitHub Desktop.
Simple bash script to safely check passwords against the pwnedpasswords.com API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get a password from the user... | |
while read -s -p "Enter password to check or Ctrl-C to quit: " pass2check | |
do | |
# Output a blank line to clean up output... | |
echo | |
# Get the SHA1 of the entered password... | |
sha1sum_output=`echo -n "${pass2check}" | sha1sum` | |
# Pull apart the head and tail as needed by the pwnedpasswords API... | |
hash_prefix=${sha1sum_output:0:5} | |
hash_tail=${sha1sum_output:5:35} | |
#echo "SHA1: ${sha1sum_output} PREFIX: ${hash_prefix} TAIL: ${hash_tail}" | |
# Download that chunk of the hash table and look for a match (output if found) | |
wget --quiet "https://api.pwnedpasswords.com/range/${hash_prefix}" -O - | grep -i "${hash_tail}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment