Created
February 6, 2024 17:27
-
-
Save cmbuckley/d11544cca578b1a136d3b03f7ed9df0f to your computer and use it in GitHub Desktop.
Quick and dirty script to check Have I Been Pwned
This file contains hidden or 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 | |
echo 'This script checks the HIBP API to see if a password has been breached.' | |
echo 'Only the first 5 characters of the SHA1 hash of the password leave the device.' | |
echo | |
echo -n 'Password: ' | |
read -s password | |
hash=$(echo -n "$password" | sha1sum | cut -c 1-40) | |
echo ; echo | |
echo "Checking HIBP for hash range ${hash:0:5}..." | |
count=$(curl -Ss "https://api.pwnedpasswords.com/range/${hash:0:5}" | grep -i "${hash:5}" | cut -d: -f2 | tr -d '\r') | |
[ -z "$count" ] && echo 'Password not pwned' || echo "Password seen $count times before" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment