Created
July 13, 2014 01:04
-
-
Save narendrans/2f15abbaee30e5ec0595 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
# Router restart script | |
# This scrit authenticates itself with the router and then restarts the router | |
# Version 1.0 | |
# Auther - Naren | |
# Tested on a faulty Belkin router :X | |
# To execute: | |
# $ sh restart.sh | |
# Note: You may want to chmod 777 restart.sh to give it permission | |
# Step 0: | |
# Ping a website and check for STATUS 200 | |
# If status is 200 then internet connection is fine, exit the script | |
while true; | |
do | |
STATUS=$(curl --connect-timeout 10 -silent -sL -w "%{http_code}" "http://www.google.com/" -o /dev/null) | |
if [[ STATUS -eq "200" ]]; then | |
echo "Internet Connection appears to be OK" | |
sleep 30 | |
continue | |
fi | |
# Step 1: | |
# Send a post request with the password to http://192.168.2.1/cgi-bin/login.exe | |
# The password must be md5 hashed before we send it to server | |
# Example password is: default | |
# MD5 Hash:c21f969b5f03d33d43e04f8f136e7682 | |
# Tip: You can use the below site to generate MD5 | |
# http://www.md5hashgenerator.com/index.php | |
echo "Authenticating..." | |
curl -silent --data "pws=c21f969b5f03d33d43e04f8f136e7682" http://192.168.2.1/cgi-bin/login.exe | |
# Step 2: | |
# Execute the restart.exe cgi | |
echo "Restarting..." | |
curl -silent http://192.168.2.1/cgi-bin/restart.exe | |
echo "Sleeping for 40 Seconds to perform next check..." | |
sleep 40 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment