无锡学院校园网自动登陆教程

Insider Lv1

原理

一个简单的GET请求,使用Curl配合Cron定时任务来实现自动登陆校园网

教程

浏览器标签–手动登陆

运营商标识

  • 移动 @cmcc
  • 联通 @unicom
  • 电信 @telecom
  • 无锡学院 空

按照以下格式修改链接

1
http://10.1.99.100:801/eportal/portal/login?callback=dr1003&login_method=1&user_account=,1,学号+运营商标识&user_password=密码

例子

1
http://10.1.99.100:801/eportal/portal/login?callback=dr1003&login_method=1&user_account=,1,20212321033@cmcc&user_password=111111

将该链接保存为浏览器书签,登陆时只需要点开书签即可登陆
退出登陆链接

1
http://10.1.99.100:801/eportal/portal/logout?callback=dr1003&login_method=1&user_account=drcom&user_password=123&ac_logout=1&register_mode=1

Linux(Openwrt)/Macos

此代码用于有校园卡的同学,使用运营商的网络,保证网络通畅

推荐cron命令:*/20 6-23 * * * sh AutoCheckSchoolNetWork.sh

每天6点到23点每隔20分钟执行一次

按照下面提示填入即可

  • AutoCheckSchoolNetWork.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash

#运营商
#移动 @cmcc
#联通 @unicom
#电信 @telecom
operator=''
#学号
username=''
#密码
password=''
#www.pushplus.plus 用于推送登陆消息
pushplus_token=''
# 执行 curl 命令并使用 grep 和 sed 处理输出
output=$(curl 'http://10.1.99.100/' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7' \
-H 'Accept-Language: zh-CN,zh;q=0.9,en;q=0.8' \
-H 'Cache-Control: max-age=0' \
-H 'Connection: keep-alive' \
-H 'Upgrade-Insecure-Requests: 1' \
-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36' \
--insecure 2>/dev/null | grep uid | sed -n "s/.*'\([^']*@[^']*\)'.*/\1/p")

# 检查输出是否为空
if [ -z "$output" ]; then
echo "输出为空,执行 curl 语句"
exit_output=$(curl "http://10.1.99.100:801/eportal/portal/logout?callback=dr1003&login_method=1&user_account=drcom&user_password=123&ac_logout=1&register_mode=1")
echo "尝试退出原有登陆"
echo "输出:$exit_output"
login_output=$(curl "http://10.1.99.100:801/eportal/portal/login?callback=dr1003&login_method=1&user_account=,1,${username}${operator}&user_password=${password}")
echo "尝试登陆新账号"
echo "输出:$login_output"
# push_log=$(curl --location --request GET "https://www.pushplus.plus/send?token=${pushplus_token}&title=校园网重新登陆成功&content=${login_output}&template=html&topic=&channel=wechat&webhook =&callbackUrl=&timestamp=&to=")
# echo "通过pushplus推送登陆消息"
# echo "输出:$push_log"
else
echo "已经登陆正常"
echo "输出内容: $output"
fi

# 尝试 ping 百度
ping -c 1 www.baidu.com > /dev/null 2>&1

# 检查 ping 命令的退出状态
if [ $? -eq 0 ]; then
echo "Ping Baidu.com Success"
else
error_push_log=$(curl --location --request GET "https://www.pushplus.plus/send?token=${pushplus_token}&title=网络错误,请自行检查网络状态&content=网络错误,请自行检查网络状态&template=html&topic=&channel=wechat&webhook =&callbackUrl=&timestamp=&to=")
echo "通过pushplus推送网络错误消息"
echo "输出:$error_push_log"
fi

如果你是学校的网络或者你并不希望进行网络检查请使用以下脚本

推荐cron命令: * * * * * sh AutoLogin.sh

每分钟执行一次,防止掉线后无法自动恢复

  • AutoLogin.sh
1
2
3
4
5
6
7
8
9
10
11
12
#在单引号中填入对应参数
#学号
user=''
#运营商
#移动 @cmcc
#联通 @unicom
#电信 @telecom
#无锡学院 为空
operator=''
#密码
password=''
curl "http://10.1.99.100:801/eportal/portal/login?callback=dr1003&login_method=1&user_account=,1,${user}${operator}&user_password=${password}&wlan_user_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=6727&lang=zh"

Windows

方案1:开机自动执行脚本

脚本文件放入该目录下

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp

方案2:设置定时任务

https://www.cnblogs.com/sui776265233/p/13602893.html

  • AutoCheckSchoolNetWork.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
@echo off
setlocal

:: 运营商
:: 移动 @cmcc
:: 联通 @unicom
:: 电信 @telecom
set "operator="
:: 学号
set "username="
:: 密码
set "password="
:: www.pushplus.plus 用于推送登陆消息
set "pushplus_token="

:: 执行 curl 命令并使用 findstr 和 for 处理输出
for /f "tokens=2 delims=', " %%a in ('curl "http://10.1.99.100/" ^
-H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7" ^
-H "Accept-Language: zh-CN,zh;q=0.9,en;q=0.8" ^
-H "Cache-Control: max-age=0" ^
-H "Connection: keep-alive" ^
-H "Upgrade-Insecure-Requests: 1" ^
-H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36" ^
--insecure 2^>nul ^| findstr /r /c:"uid='[^']*@[^']*'"') do (
set "output=%%a"
)

:: 检查输出是否为空
if "%output%"=="" (
echo 输出为空,执行 curl 语句
set "exit_output="
set "login_output="
echo 尝试退出原有登陆
echo 输出:%exit_output%
echo 尝试登陆新账号
echo 输出:%login_output%
:: push_log=
:: echo 通过pushplus推送登陆消息
:: echo 输出:%push_log%
) else (
echo 已经登陆正常
echo 输出内容: %output%
)

:: 尝试 ping 百度
ping -n 1 www.baidu.com >nul

:: 检查 ping 命令的退出状态
if errorlevel 1 (
echo 网络错误,请自行检查网络状态
set "error_push_log="
echo 通过pushplus推送网络错误消息
echo 输出:%error_push_log%
) else (
echo Ping Baidu.com Success
)

endlocal
  • AutoLogin.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
@echo off
setlocal

:: 学号
set "user="
:: 运营商
:: 移动 @cmcc
:: 联通 @unicom
:: 电信 @telecom
:: 无锡学院 为空
set "operator="
:: 密码
set "password="

:: 使用 curl 执行登录请求
curl "http://10.1.99.100:801/eportal/portal/login?callback=dr1003&login_method=1&user_account=,1,%user%%operator%&user_password=%password%&wlan_user_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=6727&lang=zh"

endlocal
  • Title: 无锡学院校园网自动登陆教程
  • Author: Insider
  • Created at : 2024-06-21 05:39:06
  • Updated at : 2024-07-01 08:10:21
  • Link: https://blog.katetseng.icu/2024/06/21/无锡学院校园网自动登陆教程/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments
On this page
无锡学院校园网自动登陆教程