Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # This script is for generating a random password, setting it for a specified
- # user, and sending that password to a remote listener.
- WHO=$(whoami)
- # target user for password change
- USER=jsumners
- RECVR="10.0.0.10"
- PORT=8000
- if [ $WHO != "root" ]; then
- echo 'need to be root'
- exit 1
- fi
- PASS=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-16};echo;)
- echo "$USER:$PASS" | chpasswd
- if [ $? -eq 0 ]; then
- echo "$(hostname): $PASS" | nc $RECVR $PORT
- else
- echo "$(hostname): FAILED" | nc $RECVR $PORT
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement