From ed2f9477225c050f2cac24ba512bf5afbedb0e11 Mon Sep 17 00:00:00 2001 From: ZacharyZcR Date: Sat, 27 Jun 2026 15:36:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20POC=20=E6=89=AB=E6=8F=8F=E9=81=87?= =?UTF-8?q?=E5=88=B0=E9=9D=9E=20HTTP=20=E6=9C=8D=E5=8A=A1=E6=97=B6?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E8=BE=93=E5=87=BA=E9=94=99=E8=AF=AF=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 扫描非 HTTP 端口时 Go net/http 返回 malformed HTTP status code 等 transport 级错误,属于正常现象,不应作为 error 输出。 在 executeRule 和 clustersend 两个调用点统一过滤 transport 错误, 返回 false, nil 表示"目标不可达 = 无漏洞"。 --- webscan/lib/poc_executor.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/webscan/lib/poc_executor.go b/webscan/lib/poc_executor.go index a11a3e1..0f25879 100644 --- a/webscan/lib/poc_executor.go +++ b/webscan/lib/poc_executor.go @@ -2,9 +2,11 @@ package lib import ( "crypto/md5" //nolint:gosec // G501: MD5用于POC规则去重,非加密用途 + "errors" "fmt" "io" "math/rand" //nolint:gosec // G404: math/rand用于生成测试数据,非加密用途 + "net" "net/http" "net/url" "os" @@ -236,6 +238,9 @@ func executeRules(oReq *http.Request, p *Poc, variableMap map[string]interface{} resp, err := DoRequest(newRequest, rule.FollowRedirects, session) newRequest = nil if err != nil { + if isTransportError(err) { + return false, nil + } return false, err } @@ -793,6 +798,9 @@ func clustersend(oReq *http.Request, variableMap map[string]interface{}, req *Re // 发送请求 resp, err := DoRequest(newRequest, rule.FollowRedirects, session) if err != nil { + if isTransportError(err) { + return false, nil + } return false, fmt.Errorf("%s: %w", i18n.GetText("webscan_request_send_error"), err) } @@ -936,3 +944,20 @@ func GetHeader(header map[string]string) string { builder.WriteString("\r\n") return builder.String() } + +func isTransportError(err error) bool { + if err == nil { + return false + } + var netErr *net.OpError + if errors.As(err, &netErr) { + return true + } + s := err.Error() + return strings.Contains(s, "malformed HTTP") || + strings.Contains(s, "transport connection broken") || + strings.Contains(s, "connection reset") || + strings.Contains(s, "connection refused") || + strings.Contains(s, "i/o timeout") || + strings.Contains(s, "EOF") +}