scut_padavan

curl认证scut-student

2018-12-05  本文已影响110人  libgcc

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&para=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:"
*/1 * * * * /root/auth.sh >/dev/null 2>&1
上一篇 下一篇

猜你喜欢

热点阅读