Skip to content

Instantly share code, notes, and snippets.

@click0
Created January 18, 2019 16:25
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 click0/b0deabfc167d655b63d8c94041aa4782 to your computer and use it in GitHub Desktop.
Save click0/b0deabfc167d655b63d8c94041aa4782 to your computer and use it in GitHub Desktop.
#!/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