本文最后更新于 374 天前,其中的信息可能已经有所发展或是发生改变。
年末,宣传大半年的校园网提速终于是提了,可以先看一下这代的拨号形式:
这里用了GET的方式提交了user_account和user_password两个参数,来代替了上一代的POST参数。不过据说drcom的拨号方式依然是上一代的POST。
Crontab + Curl
适合路由器(或者unix真机写),在Crontabs目录下写入
* * * * * sh脚本路径
为每分钟执行一次sh脚本,当然也可以改时间间隔,例如每隔两天的上午8点到11点的第3和第15分钟执行,这部分可以参考Crontab文档修改。
3,15 8-11 */2 * * myCommand
接下来写sh,做了一个是否已经拨号的判断,如果没有拨号则自动拨号。
#!/bin/sh
res=$(curl -s "http://captive.apple.com/hotspot-detect.html")
case $res in
*Success*)
logger -t "drcom.szu" "Online"
;;
*)
logger -t "drcom.szu" "Offline"
curl -s "http://{校园网拨号IP,格式为xxx.xx.xxx.xx}:801/eportal/portal/login?user_account=%2C0%2C{你的校园卡号}&user_password={你的密码}" > /dev/null
;;
esac
exit 0
当然,如果你不做判断直接反复请求,甚至直接写Crontab也行,就是比较粗暴,权威大佬Domain声称会闪断。
* * * * * curl -s "http://{校园网拨号IP,格式为xxx.xx.xxx.xx}:801/eportal/portal/login?user_account=%2C0%2C{你的校园卡号}&user_password={你的密码}" > /dev/null
Docker
来自信安学弟@正汰 ,相对来说比较复杂,但我觉得这个思路还挺有意思.jpg。
run.sh
#!/bin/bash
export PATH=$PATH:/bin:/sbin:/usr/bin
while true
do
if ping -c 1 -w 60 baidu.com >/dev/null; then
echo "ping success"
else
echo "ping failed"
ifconfig | grep -A1 'wan' | grep inet | awk '{print $2}' | awk -F : '{print $2}' | while read ip
do
curl "http://{校园网拨号IP,格式为xxx.xx.xxx.xx}:801/eportal/portal/login?callback=dr1003&login_method=1&user_account=%2C0%2CP{你的账号}&user_password={你的密码}&wlan_user_ip=$ip&wlan_user_ipv6=&wlan_user_mac=000000000000&wlan_ac_ip=&wlan_ac_name=&jsVersion=4.1.3&terminal_type=1&lang=zh-cn&v=8040&lang=zh" \
-H 'Connection: keep-alive' \
-H 'Pragma: no-cache' \
-H 'Cache-Control: no-cache' \
-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36' \
-H 'DNT: 1' \
-H 'Accept: */*' \
-H 'Accept-Language: zh-CN,zh;q=0.9' \
--insecure
done
fi
sleep 60s
done
把run.sh传入docker(当然不写自循环也能传入crontab)
docker pull bash
docker run --name bash 你的脚本路径:/etc/runsh/ bash:latest sh /etc/runsh/run.sh
always restart
docker update --restart=always id
其他
关于其他有关的方法,虽然也有看见py进程循环的,但我感觉相对来说还是用crontab更干净一些,当然,如果能挂在路由器上就更好了。
有关{}内的内容,请填入你的账号和密码,同时出于对学校网络安全的考虑,将不泄露具体拨号的IP等信息。
文中所提方法在2022年1月1日有效,关于拨号可能的安全问题已经上报给校方,因此不保证日后任然有效。如登录方法发生变化,将会对文章的部分内容进行更新。
ddw