NUIST 校园网自动登录 Shell 脚本

System: Ubuntu 18.04
Requirements: curl


非小白向,写得比较丑,但是能用。

这里写成了两个文件,当然也可以写成一个文件。

1. /etc/NetworkManager/dispatcher.d/al.sh

#!/bin/bash
# nm sets this values
INTERFACE=$1
ACTION=$2

SSID="i-NUIST"
ESSID=`iwconfig $INTERFACE | grep ESSID | cut -d":" -f2 | sed 's/^[^"]*"\|"[^"]*$//g'`

if [ "$INTERFACE" == "wlo1" ]; then
    if [ "$SSID" == "$ESSID" ] && [ "$ACTION" == "up" ]; then
        bash /home/sirius/ws/sstoolbox/autologin.sh
    else
        echo "Ignored (1)."
    fi
else
    echo "Ignored (2)."
fi

2. autologin.sh

这里,可以尝试进行多次登录,如果某一个用户是可以登录并已经完成登录的话,后面会继续执行不会有什么影响。

最后判断是否登录成功就可以了。

-d 的部分,可以抓包,也可以通过 echo -n “yourpassword” | base64 获取,也可以直接chorme抓包。

#!/bin/bash
curl -s -d "username=guest&domain=NUIST&password=***=" http://10.255.255.13/index.php/index/login >/dev/null
curl -s -d "username=177*******&domain=ChinaNet&password=*******" http://10.255.255.13/index.php/index/login >/dev/null
curl -s -d "username=188*******&domain=CMCC&password=*******" http://10.255.255.13/index.php/index/login >/dev/null
echo "All login attempted. Trying to access the web."

res=$(curl -s http://10.255.255.13/index.php/index/login)

if [[ $res == *"\\u7528\\u6237\\u5df2\\u767b\\u5f55"* ]]; then
    echo "It works!"
else
    echo "Something went wrong..."
fi

别忘了chmod +x

CC BY-NC-SA 4.0 本作品使用基于以下许可授权:Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

3 thoughts on “NUIST 校园网自动登录 Shell 脚本

  1. 为了这个刷了一个路由器,结果现在只能等七点的计划任务或者手动打开后台用curl联网了…本来只是想捣鼓一下学习间隙偷个懒,头痛。

回复 saber、 取消回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注