Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env sh
set -e
#set -x
# ask user for password
read -p "Input password for check: " -t 30 passwd
# sha1sum replaced openssl sha1 | awk '{ print $2;}'
if [ -n "$passwd" ]; then
echo -n "$passwd" | openssl sha1 | awk '{ print $2;}' | \
awk '{
prefix=substr($1,1,5); reminder=substr($1,6,35);
if(system("curl -sk https://api.pwnedpasswords.com/range/" prefix "> ./pwhashes.txt")){print "Error"; exit}
cmd="cat ./pwhashes.txt | tr [A-Z] [a-z] | grep \"" reminder "\"";
cmd | getline result; close(cmd); split(result,arr,":");
if(!length(arr[2])) print "Password not found"; else print "Password found: " arr[2]
system("rm ./pwhashes.txt");
}'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.