SHARE
TWEET

Passcheck.sh

a guest Apr 26th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. ###
  4. # Checks provided password against breach database
  5. ###
  6.  
  7. function pc() {
  8.  if [[ -z $@ ]]; then
  9.    echo -n Password:
  10.    read -s password
  11.  else
  12.    password="$@"
  13.  fi
  14.  hash="$(echo -n $password | openssl sha1 | awk '{print $2}')"
  15.  upperCase="$(echo $hash | tr '[a-z]' '[A-Z]')"
  16.  prefix="${upperCase:0:5}"
  17.  response=$(curl -s https://api.pwnedpasswords.com/range/$prefix)
  18.  while read -r line; do
  19.    lineOriginal="$prefix$line"
  20.    if [ "${lineOriginal:0:40}" == "$upperCase" ]; then
  21.      echo -e "\nPassword breached."
  22.      return 1;
  23.    fi
  24.  done <<< "$response"
  25.  echo -e "\nPassword not found in breached database."
  26. }
  27.  
  28. pc "$@"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top