修复 IPv6 over IPv4 的 bug , IPv4 没有校验的问题 和 反馈 *.check.place 在部分机器上会被 waf 拦阻#70
Open
修复 IPv6 over IPv4 的 bug , IPv4 没有校验的问题 和 反馈 *.check.place 在部分机器上会被 waf 拦阻#70
Conversation
修改了 ipv4 获取的逻辑 -ipv4 的情况下,优先获取 ipinfo.io/json 的数据,ipv6 保持原样 -添加了对 ipv4 的校验
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

BUG 1
IPv6 over IPv4 的问题
原版 bug 的实际表现是,在 ipv4 over ipv6 的情况下,明明有 IPv4,但因为 API 返回了 IPv6 被误存,最终 is_valid_ipv4 兜底拦截,脚本静默退出,用户完全看不到检测结果。原因是,脚本内,内置的 ip 查询都是支持 ipv4 和 ipv6 双栈的
效果

在这种情况下,就算脚本手动强制设置解析成 ipv4 来请求,也没有帮助,因为实际上所有的请求会被二次代理,使用 ipv6 来请求。
效果

解决办法
已知 ipinfo.io 是没有任何的 ipv6 支持

因此可以在请求 ipv4 的时候,优先使用 ipinfo.io/ip 的 api 来请求,解决 ipv4 over ipv6 的问题,避免强制走 ipv6 的问题

然后,又已知 ipinfo 不支持 ipv6 的环境,因此在 ipv6 的检测中,不使用此 api 来检测
复现方法
在手机开代理,并且开启 fake-ip 等模式,并且开启 ipv6 的情况下,执行脚本,脚本将会静默退出
BUG 2
IPv4 没有校验的问题
部分网络环境下,可能阻断部分的 api 检查站点,并且效果可能不是无法访问,而是返回一个自定义页面
原版的 IPv4 的校验逻辑是
这就会导致,网站被劫持,脚本因为没有正确的判断,而直接写入不是 IPv4 的值,而不是切换下一个 API
解决办法
使用 regex 来判断是否是正确的 ipv4 格式,而不是用简单的 error 来判断
*.check.place 可能会被 waf 拦
这个目前我没有解决方案,因为需要来自作者的配合检查一下 waf 的规则。
问题截图

这会导致无法上传报告,IP 类型少掉来自 IP2Location 和 AbuseIPDB 和 “风险因子” 的结果少掉一大堆
希作者能够解决这个问题
谨此,感谢