Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@zhullyb
Last active April 9, 2024 12:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhullyb/4c8708df5724c42f913d3d86ed49d929 to your computer and use it in GitHub Desktop.
Save zhullyb/4c8708df5724c42f913d3d86ed49d929 to your computer and use it in GitHub Desktop.
浙江工业大学的校园网网页认证脚本
#!/bin/bash
# 浙江工业大学校园网网页认证
# 此处需要填写网页认证时使用的账号和密码
user_account=
user_password=
# 针对路由器,用于设置路由表以方便访问学校内网
# 可能需要将路由器 DNS 设置为 172.16.7.10 和 172.16.7.30 以获取正确的内网服务器 ip
if `ip route | grep -q 10.129.0.1`; then
gateway=10.129.0.1
elif `ip route | grep -q 10.136.0.1`; then
gateway=10.136.0.1
fi
if whoami | grep -q "admin\|root" && [ -n "$gateway" ]; then
route add -net 192.168.210.111 netmask 255.255.255.255 gw ${gateway}
route add -net 192.168.210.112 netmask 255.255.255.255 gw ${gateway}
route add -net 192.168.210.100 netmask 255.255.255.255 gw ${gateway}
route add -net 172.16.0.0 netmask 255.255.0.0 gw ${gateway}
fi
# 尝试访问内网服务器,如果未通过网页认证则会获得 url 跳转信息,用于判断用户为朝晖校区或屏峰校区,并获取用户 ip
test_curl=$(curl -s http://172.16.19.160)
wlan_user_ip=$(echo ${test_curl} | grep -oE 'wlanuserip=[0-9\.]+' | grep -oE '[0-9\.]+')
wlan_ac_ip=$(echo ${test_curl} | grep -oE 'wlanacip=[0-9\.]+' | grep -oE '[0-9\.]+')
wlan_user_mac=$(echo ${test_curl} | grep -oE 'usermac=[[:xdigit:]-]+' | cut -d'=' -f2 | tr -d '-')
wlan_ac_name=$(echo ${test_curl} | grep -o "wlanacname=[^&]*" | cut -d'=' -f2)
# 朝晖校区宿舍楼内的移动宽带的认证请求
if echo "${test_curl}" | grep -q "192.168.210.112"; then \
curl "http://192.168.210.112:801/eportal/portal/login?callback=dr1003&login_method=1&user_account=%2C0%2C${user_account}%40cmcczhyx&user_password=${user_password}&wlan_user_ip=${wlan_user_ip}&wlan_user_ipv6=&wlan_user_mac=${wlan_user_mac}&wlan_ac_ip=${wlan_ac_ip}&wlan_ac_name=${wlan_ac_name}&jsVersion=4.2.1&terminal_type=1&lang=zh-cn&v=5099&lang=zh"
# 屏峰校区宿舍楼内的移动宽带的认证请求
elif echo "${test_curl}" | grep -q "192.168.210.111"; then \
curl "http://192.168.210.111:801/eportal/portal/login?callback=dr1003&login_method=1&user_account=%2C0%2C${user_account}%40cmccpfyx&user_password=${user_password}&wlan_user_ip=${wlan_user_ip}&wlan_user_ipv6=&wlan_user_mac=${wlan_user_mac}&wlan_ac_ip=${wlan_ac_ip}&wlan_ac_name=${wlan_ac_name}&jsVersion=4.2.1&terminal_type=1&lang=zh-cn&v=5099&lang=zh"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment