mirror of https://github.com/nirenjan/dotfiles.git
Add script to query pwned password database
parent
63656f9fc2
commit
6f89117689
|
@ -0,0 +1,31 @@
|
|||
#!/bin/bash
|
||||
# Script to query the pwned passwords database to see if the user
|
||||
# specified password has been leaked
|
||||
|
||||
echo "Query Pwned Passwords Database"
|
||||
echo "Enter your password, press Ctrl-D to exit"
|
||||
|
||||
while read -s -p 'Password: '
|
||||
do
|
||||
HASH=$(echo -n "$REPLY" | sha1sum | awk '{ print $1 }')
|
||||
|
||||
PREFIX=${HASH:0:5}
|
||||
SUFFIX=${HASH:5}
|
||||
|
||||
RESULT=$(curl -s -XGET https://api.pwnedpasswords.com/range/$PREFIX |
|
||||
grep -i $SUFFIX)
|
||||
|
||||
# Print a newline
|
||||
echo
|
||||
|
||||
if [[ -n "$RESULT" ]]
|
||||
then
|
||||
COUNT=${RESULT##*:}
|
||||
COUNT=${COUNT%
}
|
||||
echo "Password has been found $COUNT times"
|
||||
else
|
||||
echo "Password appears to be safe to use"
|
||||
fi
|
||||
|
||||
echo
|
||||
done
|
Loading…
Reference in New Issue