fix(proxy): 修复透明代理导致输出全端口的问题

在代理初始化时主动探测代理行为,通过连接 RFC 5737 保留的
测试地址来检测是否存在"全回显"问题。如果探测到代理不可靠,
则在端口扫描时跳过所有端口,避免误报。

- 新增 proxyReliable 标志位标记代理可靠性
- 新增 ProbeProxyBehavior 函数探测代理行为
- 端口扫描前检查代理可靠性并输出警告

Fixes #495
This commit is contained in:
ZacharyZcR
2026-01-18 03:07:02 +08:00
parent 334159d3d7
commit e65211e777
4 changed files with 83 additions and 3 deletions
+11
View File
@@ -148,6 +148,11 @@ func EnhancedPortScan(hosts []string, ports string, timeout int64, config *commo
exclude[p] = struct{}{}
}
// 检查代理可靠性,如果存在全回显问题则警告
if common.IsProxyEnabled() && !common.IsProxyReliable() {
common.LogBase("[!] 检测到代理存在全回显问题,端口扫描结果可能不准确")
}
// 创建流式迭代器(O(1) 内存,端口喷洒策略)
iter := NewSocketIterator(hosts, portList, exclude)
totalTasks := iter.Total()
@@ -375,6 +380,12 @@ func verifyProxyConnection(conn net.Conn, addr string) bool {
return true
}
// 如果代理不可靠(存在全回显问题),直接返回 false
if !common.IsProxyReliable() {
common.LogDebug(fmt.Sprintf("代理不可靠,跳过端口 %s", addr))
return false
}
// 设置短超时进行连接验证(100ms)
// 如果目标端口真的开放,不会在这么短时间内收到错误
// 如果目标不可达,非标准代理可能会立即返回错误