4-电脑一连接上自动弹框到路由器web配置页面

很多路由器在还没有配置路由信息的时候,只要一连接wifi/有线,就会自动弹出路由器web配置页面,强制用户配置一次基本信息才可以进行上网

这也其实也是portal认证的一种应用,原本的portal是跳转到后台认证服务器页面,目前是跳转到路由器本地管理页面。

所以我们只需要根据应用策略进行区分,然后修改跳转的页面url即可。

为啥有时候会自动弹出,有时候不会自动弹出呢?

portal的原理是捕获80端口和443端口的流量,转到2060端口,然后做重定向。所以只要设备没有这两个80的数据访问就没有办法跳转。

我们抓取电脑网络刚通时的数据包,可以发现比如window就会自动访问类似www.microsoft.com、www.msftconnecttest.com这些域名。

但是访问的这些域名不一定是通过80/443来访问,而是其他私有协议交互,所以为了加快跳转,我们不通过portal的端口捕获原理,而直接使用dnsmasq的域名劫持原理,只要访问这个域名就直接跳转到路由器本地配置页面。

dnsmasq启动代码添加:

复制代码
local target_ip="1.127.127.254"

#windows
uci add_list dhcp.@dnsmasq[0].address='/www.msftconnecttest.com/'$target_ip
uci add_list dhcp.@dnsmasq[0].address='/dns.msftncsi.com/'$target_ip
uci add_list dhcp.@dnsmasq[0].address='/geo.prod.do.dsp.mp.microsoft.com/'$target_ip
uci add_list dhcp.@dnsmasq[0].address='/www.microsoft.com/'$target_ip

#ubuntu
uci add_list dhcp.@dnsmasq[0].address='/connectivity-check.ubuntu.com/'$target_ip

#google
uci add_list dhcp.@dnsmasq[0].address='/connectivitycheck.gstatic.com/'$target_ip

#apple
uci add_list dhcp.@dnsmasq[0].address='/www.apple.com/'$target_ip

#Samsung
uci add_list dhcp.@dnsmasq[0].address='/connectivitycheck.android.com/'$target_ip
uci add_list dhcp.@dnsmasq[0].address='/clients3.google.com/'$target_ip

#xiaomi
uci add_list dhcp.@dnsmasq[0].address='/connect.rom.miui.com/'$target_ip
uci add_list dhcp.@dnsmasq[0].address='/connect.miui.com/'$target_ip
uci add_list dhcp.@dnsmasq[0].address='/s1.miui.com/'$target_ip
uci add_list dhcp.@dnsmasq[0].address='/captive.v2ex.co/'$target_ip

#vivo
uci add_list dhcp.@dnsmasq[0].address='/www.googleapis.cn/'$target_ip
uci add_list dhcp.@dnsmasq[0].address='/connectivitycheck.vivo.com.cn/'$target_ip
uci add_list dhcp.@dnsmasq[0].address='/connect.vivo.com.cn/'$target_ip

#oppo
uci add_list dhcp.@dnsmasq[0].address='/connectivity.oppo.com/'$target_ip
uci add_list dhcp.@dnsmasq[0].address='/connect.oppo.com/'$target_ip
uci add_list dhcp.@dnsmasq[0].address='/connect.oppomobile.com/'$target_ip
uci add_list dhcp.@dnsmasq[0].address='/www.oppo.com/'$target_ip

#huawei
uci add_list dhcp.@dnsmasq[0].address='/www.huawei.com/'$target_ip
uci add_list dhcp.@dnsmasq[0].address='/connect.cloud.huawei.com/'$target_ip
uci add_list dhcp.@dnsmasq[0].address='/www.hwcdn.net/'$target_ip
uci add_list dhcp.@dnsmasq[0].address='/connect.vmall.com/'$target_ip
uci add_list dhcp.@dnsmasq[0].address='/hispace.dbankcloud.com/'$target_ip

#huawei harmonyOs
uci add_list dhcp.@dnsmasq[0].address='/connectivitycheck.platform.hicloud.com/'$target_ip
uci add_list dhcp.@dnsmasq[0].address='/connectivitycheck.cbg-app.huawei.com/'$target_ip

#Google Chrome
uci add_list dhcp.@dnsmasq[0].address='/connectivitycheck.gstatic.com/'$target_ip

#Mozilla Firefox
uci add_list dhcp.@dnsmasq[0].address='/detectportal.firefox.com/'$target_ip

#Apple Safari or Opera
uci add_list dhcp.@dnsmasq[0].address='/captive.apple.com/'$target_ip

#Microsoft Edge
uci add_list dhcp.@dnsmasq[0].address='/msftconnecttest.com/'$target_ip

uci commit dhcp
/etc/init.d/dnsmasq restart

dnsmasq停止代码添加:

复制代码
uci -q delete dhcp.@dnsmasq[0].address

local ret=$?
if [ "$ret" == "0" ]; then
        logger -t portal "del dnsmasq url address success, restart dnsmasq"
        uci commit dhcp
        /etc/init.d/dnsmasq restart
fi
相关推荐
翻滚吧键盘27 分钟前
Spring Boot 中的 Web 应用与 Reactive Web 应用
前端·spring boot·后端
老K(郭云开)41 分钟前
allWebPlugin中间件VLC专用版之录像功能介绍
前端·javascript·chrome·中间件·edge
_CodePencil_1 小时前
CSS专题之水平垂直居中
前端·css·html·css3·html5
石小石Orz1 小时前
用dayjs解析时间戳,我被提了bug
前端
小小小小宇1 小时前
前端html文件的缓存如何处理
前端
小小小小宇1 小时前
H5软键盘笔记
前端
风风吹不到1 小时前
JavaScript入门基础篇-day04
开发语言·前端·javascript
前端snow1 小时前
你的cursor还在帮你胡乱添加功能代码吗?
前端·后端
小小小小宇1 小时前
一个小小的webpack插件
前端
小小小小宇1 小时前
前端Webpack中`compilation` 和 `compiler`
前端