Skip to content

Instantly share code, notes, and snippets.

@jamiepenney
Last active February 21, 2018 23:14
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 jamiepenney/e4b16224ee30172eaa8b10b8817af639 to your computer and use it in GitHub Desktop.
Save jamiepenney/e4b16224ee30172eaa8b10b8817af639 to your computer and use it in GitHub Desktop.
Check the pwnedpasswords.com database for breached passwords from your local terminal
#!/bin/bash
read -s -p "Enter password to check: " password
echo ""
echo "Checking that password..."
hash=$(echo -n "$password" | openssl sha1 | tr '[:lower:]' '[:upper:]')
curl -s "https://api.pwnedpasswords.com/range/$(echo $hash | head -c5)"|\
grep $(echo $hash | cut -c 6-) |\
awk '{split($0,a,":"); print "Your password has been found in the breach database"} END { if (!NR) print "Password not found in database"}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment