auth.sh
#!/bin/sh
# curl script for scut-student
LOGGER=0
AUTO_WLANACIP=0
username="201688888888"
password="88888888"
ifname="apcli0"
wlanacip_default="172.28.255.250"
det_ips="114.114.114.114 119.29.29.29"
get_wlanacip() {
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36"
curl -k -s --interface $ifname http://www.scut.edu.cn/ --user-agent "$user_agent" -w "%{redirect_url}" -o /dev/null |sed 's/\(.*\)wlanacip=\(.*\)&\(.*\)/\2/g'
}
for n in $det_ips; do
/bin/ping -I "$ifname" -c 1 -W 2 "$n" >/dev/null 2>&1
if [ "$?" = "0" ]; then
exit 0
fi
done
[ $LOGGER -eq 0 ] || logger -t "scut_auth" "Connection failed, restart auth"
[ $AUTO_WLANACIP -eq 0 ] && wlanacip=$wlanacip_default || wlanacip="$(get_wlanacip)"
curl -k -s -o /dev/null --interface $ifname \
-d "DDDDD=$username&upass=$password&R1=0&R2=&R6=0¶=00&0MKKey=123456" \
--url "https://s.scut.edu.cn:801/eportal/?c=ACSetting&a=Login&wlanuserip=&wlanacip=$wlanacip&wlanacname=&redirect=&session=&vlanid=scut-student&port=&iTermType=1&protocol=https:"
- 将
AUTO_WLANACIP
赋值为1即可自动识别wlanacip,否则使用默认值
- 将
LOGGER
赋值为1则在认证时使用logger
打印系统日志
- ifname可能需要视情况更改
- curl需要启用ssl支持
- crontab中加入该脚本,每分钟检测网络连通性后执行认证
*/1 * * * * /root/auth.sh >/dev/null 2>&1
网友评论