-
-
Save danny-source/f745d641a8fa2a1001ad689518e8b1cd to your computer and use it in GitHub Desktop.
Auto login cht-wifi for dd-wrt
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/sh | |
# description: check cht-wifi login status, and auto login if no login. | |
# default script path: /mnt/sda1/mnt/scripts/login-cht-wifi.sh | |
# author: JustinTWD <[email protected]> | |
# date: 2016/03/12 | |
USERNAME=YOUR_CHT_ACCOUNT | |
PASSWD=YOUR_CHT_PASSWORD | |
LOGFILE=/mnt/sda1/log/cht-wifi.log | |
TMPSESSION=/tmp/cht_session.tmp | |
login_v1(){ | |
/opt/bin/curl -d cht_user=$USERNAME -d passwd=$PASSWD -d username=$USERNAME%40hinet.net -d password=$PASSWD -d custom=cht -d session=$(/opt/bin/curl -I www.google.com.tw | grep Location | cut -d "&" -f 1 | cut -d "=" -f 2) https://wlanac.hinet.net/loginpages/userlogin.shtml | |
} | |
login_v2(){ | |
rm -f $TMPSESSION | |
R1=$(/opt/bin/curl -c $TMPSESSION -k \ | |
$(/opt/bin/curl -Ls -o /dev/null -w %{url_effective} http://google.com) 2>&1 \ | |
| grep redirect_url= \ | |
| awk -F"'" '{print $2}') | |
R2=$(/opt/bin/curl -b $TMPSESSION -c $TMPSESSION -k -i $R1 2>&1 \ | |
| grep Location \ | |
| awk '{print $2}') | |
/opt/bin/curl -b $TMPSESSION -c $TMPSESSION -k \ | |
-H "Referer: $R2" \ | |
-d cht_user=$USERNAME -d passwd=$PASSWD -d username=$USERNAME%40hinet.net -d password=$PASSWD -d custom=cht \ | |
https://wlangw.hinet.net/v2_0/cht_auth/auth_page.php | |
} | |
main(){ | |
testing=$(/opt/bin/curl -I www.google.com.tw | grep "200 OK") | |
echo "=============================================" | |
if [ "$testing" != "" ]; then | |
echo "wifi logined." | |
elif [ "$1" == "" ]; then | |
echo "`date` You need login CHT Wi-Fi PWLAN." | tee $LOGFILE | |
login_v2; | |
fi | |
} | |
main; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment