破解Web校园网
putty用来登陆路由器后台 下方百度云链接打开可以下载
WinSCP可以上传脚本到路由器 下方百度云链接打开可以下载
百度云资源里的OpenWrt固件是适用于K2的 (官方版本,英文界面)
百度云链接: 密码: h38h
1.准备一个已经刷好不死鸟的路由器
K2 ,K2P ,小米, 新三路由等等 都可以
2.去OpenWrt官网下载对应自己路由版本的固件
3.将固件刷好
前面3个步骤不会的,可以自行度娘
4.通过SSH登陆路由器
1.ssh root@192.168.1.1
登陆路由器后台
2.opkg update
更新软件包
3.opkg install privoxy
安装privoxy代理软件
4.opkg install luci-app-privoxy
安装这个后,路由里才会有Service(服务) 显示privoxy 插件
5.opkg install curl
安装curl,为脚本自动认证做准备
5.在路由器里添加自动认证脚本
1.cd /etc
2.vim web.sh
不会vim操作的,该步骤可以通过WinSCP软件代替实现
内容:
#!/bin/sh
studentid='' # 用户名
password='' # 密码
IP=$(ubus call network.interface.wan status | grep \"address\" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')
function login() {
#IP="10.73.11.167"
echo "DDDDD=${studentid}&upass=${password}&R1=0&R2=&R6=0¶=00&0MKKey=123456&buttonClicked=&redirect_url=&err_flag=&username=&password=&user=&cmd=&Login=&R7=0"
statusfull=$(curl 'http://192.168.167.46/a70.htm' \
-X POST \
-H "Cookie: program=ip; vlan=0; md5_login2=${studentid}%7C${password}; ip=${IP}" \
--data-raw "DDDDD=${studentid}&upass=${password}&R1=0&R2=&R6=0¶=00&0MKKey=123456&buttonClicked=&redirect_url=&err_flag=&username=&password=&user=&cmd=&Login=&R7=0")
echo "${statusfull}"
status=$(echo "${statusfull}" | grep -a -oE '<!--Dr.COMWebLoginID_[0-9]\.htm-->')
echo ${status}
if [ $status == '<!--Dr.COMWebLoginID_2.htm-->' ]; then
errormsg=$(echo "${statusfull}" | grep 'msga' | grep -oE "msga='.*'")
logger -t "校园网认证" "Login Failed:${errormsg}"
echo "Log Failed:${errormsg}"
sleep 1
login
else
lasturl=$(echo "${statusfull}" | grep 'UL' | grep -oE "UL='.*'")
logger -t "校园网认证" "Login Success:${lasturl}"
fi
}
function checkstatus() {
status=$(curl 'http://192.168.167.46/' \
-H "Cookie: program=ip; vlan=0; md5_login2=${studentid}%7C${password}; ip=${IP}" | grep 'Dr.COMWebLoginID')
}
# 3成功2失败
function oneloop() {
checkstatus
echo ${status}
if [ $status == '<!--Dr.COMWebLoginID_1.htm-->' ]; then
echo 'Normal'
logger 'Normal'
sleep 1
else
logger -t "校园网认证" "Disconnected"
sleep 13 # 虽然报错是3s,但是实际上应该是13s,猜测是检测10s+冷却3s
logger -t "校园网认证" "Try to Connect"
login
echo 'Logged'
fi
}
while true; do
oneloop
done
3. chmod 777 web.sh
修改文件权限 这里我直接给了最高
4.cd /etc
5.vim rc.local
设置配置路由器启动后,自动执行自己添加的脚本
增加代码
/etc/web.sh >dev/null 2&1 &
exit 0
5.配置Privoxy
打开http://config.privoxy.org/edit-actions-list?f=0
在Action 那一列中,hide-user-agent 改选为 Enable(绿色)
6.配置防火墙规则
iptables -t nat -N ntp_force_local
iptables -t nat -I PREROUTING -p udp --dport 123 -j ntp_force_local
iptables -t nat -A ntp_force_local -d 0.0.0.0/8 -j RETURN
iptables -t nat -A ntp_force_local -d 127.0.0.0/8 -j RETURN
iptables -t nat -A ntp_force_local -d 192.168.0.0/16 -j RETURN
iptables -t nat -A ntp_force_local -s 192.168.0.0/16 -j DNAT --to-destination 192.168.1.1
iptables -t nat -N http_ua_drop
iptables -t nat -I PREROUTING -p tcp --dport 80 -j http_ua_drop
iptables -t nat -A http_ua_drop -d 0.0.0.0/8 -j RETURN
iptables -t nat -A http_ua_drop -d 127.0.0.0/8 -j RETURN
iptables -t nat -A http_ua_drop -d 192.168.0.0/16 -j RETURN
iptables -t nat -I http_ua_drop -m mac --mac-source **:**:**:**:**:** -j RETURN
iptables -t nat -A http_ua_drop -p tcp -j REDIRECT --to-port 8118
iptables -t nat -I http_ua_drop -m mac --mac-source **:**:**:**:**:** -j RETURN
这条规则的意思是让该mac地址设备流量不走代理
7.同步时间
参考来自https://www.cnblogs.com/cloudbird/archive/2019/02/20/10406936.html