Advertisement
Guest User

Untitled

a guest
Nov 7th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # This script is for generating a random password, setting it for a specified
  4. # user, and sending that password to a remote listener.
  5. WHO=$(whoami)
  6. # target user for password change
  7. USER=jsumners
  8. RECVR="10.0.0.10"
  9. PORT=8000
  10. if [ $WHO != "root" ]; then
  11. echo 'need to be root'
  12. exit 1
  13. fi
  14. PASS=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-16};echo;)
  15. echo "$USER:$PASS" | chpasswd
  16. if [ $? -eq 0 ]; then
  17. echo "$(hostname): $PASS" | nc $RECVR $PORT
  18. else
  19. echo "$(hostname): FAILED" | nc $RECVR $PORT
  20. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement