Guest User

Untitled

a guest
Mar 23rd, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. #This script was made with OpenVPN via-file in mind
  4.  
  5. #Location of the Approved Username/Password File
  6. USERS="/somefolder/users"
  7.  
  8. #Check to see if username and password in the OpenVPN file has any special characters line by line
  9. #Terminate script if special characters are used
  10. while IFS= read -r line
  11. do
  12. case "$line" in *[!-_a-zA-Z0-9]*) exit 1 ;; esac
  13. done < "$1"
  14.  
  15. Username=`awk 'NR==1' "$1"`
  16. Password=`awk 'NR==2' "$1"`
  17.  
  18. HASHPASS=`echo -n "$Username$Password" | md5sum | sed s'/ -//'`
  19. i=0
  20. while [ $i -lt 10 ]; do
  21. HASHPASS=`echo -n $HASHPASS$HASHPASS | md5sum | sed s'/ -//'`
  22. i=`expr $i + 1`
  23. done
  24.  
  25. if grep -q "$Username:$HASHPASS" $USERS; then
  26. echo "User Authenticated."
  27. exit 0
  28. fi
  29.  
  30. echo "Login credentials failed."
  31. exit 1
Add Comment
Please, Sign In to add comment