Skip to content

Instantly share code, notes, and snippets.

@JonasAlfredsson
Created August 15, 2019 07:56
Show Gist options
  • Save JonasAlfredsson/eaba99f48b1e6cdfd23ebf113f1119ce to your computer and use it in GitHub Desktop.
Save JonasAlfredsson/eaba99f48b1e6cdfd23ebf113f1119ce to your computer and use it in GitHub Desktop.
Have I Been Pwned
#!/bin/bash
# A small script for querying the https://haveibeenpwned.com/ API to see if your
# password has been leaked, and how many have the same passphrase.
# It is only the first 5 characters of the hash of your password that is sent to
# the server, and what will be printed is something like this:
# 018E42F7FF3A3AD8DFD5A4EB6C78AFFA87C:16173
# which is the whole hash of the password, and how many occurences that was found.
while true; do
read -s -p "enter password> " N
hash=$(echo -n $N | tr -d '\n' | sha1sum)
curl https://api.pwnedpasswords.com/range/${hash:0:5} 2>/dev/null \
| grep $(echo ${hash:5:35} | tr '[:lower:]' '[:upper:]')
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment