Advertisement
metalx1000

Random Password Changer

Apr 7th, 2023 (edited)
1,509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.48 KB | None | 0 0
  1. #!/bin/bash
  2. ######################################################################
  3. #Copyright (C) 2023  Kris Occhipinti
  4. #https://filmsbykris.com
  5.  
  6. #This program is free software: you can redistribute it and/or modify
  7. #it under the terms of the GNU General Public License as published by
  8. #the Free Software Foundation version 3 of the License.
  9.  
  10. #This program is distributed in the hope that it will be useful,
  11. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. #GNU General Public License for more details.
  14.  
  15. #You should have received a copy of the GNU General Public License
  16. #along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17. ######################################################################
  18. # Resets my kids password to a 4 char word and random number
  19. # for use with crontab
  20. # new passwords are sent to server for retrieval
  21.  
  22. user="kid"
  23. dir="/home/${user}/.fbk"
  24. word_file="${dir}/words"
  25.  
  26. [[ -d $dir ]] || mkdir -p "$dir" || exit 1
  27. if [[ ! -f $word_file ]]
  28. then
  29.         grep -E '^[[:alpha:]]{4}$' /usr/share/dict/words|shuf|tr "[A-Z]" "[a-z]"|head -n25 > "$word_file"
  30.         cat "$word_file" || exit 1
  31. fi
  32.  
  33. password="$(shuf $word_file|head -n1)$RANDOM"
  34. echo "$password"
  35. echo "$password" > /tmp/.p
  36. url="https://filmsbykris.com/passwordUpdate.php?device=${user}&p=${password}"
  37. wget -qO /dev/null "$url"
  38. #chpasswd <<< "$user:$password"
  39. echo -e "$password\n$password" | passwd $user
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement