Created
November 7, 2016 14:58
-
-
Save jsumners/3d639712a7dda2ba1e43ca5fe89dedbe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment