From 8e3cac303d0198ef8bb4f2305709e4884e88053e Mon Sep 17 00:00:00 2001 From: ZacharyZcR Date: Fri, 12 Jun 2026 12:23:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20webtitle=20HTTP=20=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E6=97=B6=E9=87=8D=E8=AF=95=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=89=B9=E9=87=8F=E6=89=AB=E6=8F=8F=20POC=20=E7=BC=BA?= =?UTF-8?q?=E5=A4=B1=20#587?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 批量扫描(-hf)时并发压力导致 HTTP 请求瞬时失败,getWebTitle 直接返回 error,跳过指纹识别和 POC 触发。 加入指数退避重试(200ms→400ms),最多 3 次,复用 config.MaxRetries。 --- plugins/web/webtitle.go | 43 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/plugins/web/webtitle.go b/plugins/web/webtitle.go index 4a4ab0a..214b400 100644 --- a/plugins/web/webtitle.go +++ b/plugins/web/webtitle.go @@ -10,6 +10,7 @@ import ( "net/url" "regexp" "strings" + "time" "unicode/utf8" "github.com/shadow1ng/fscan/common" @@ -42,7 +43,47 @@ func NewWebTitlePlugin() *WebTitlePlugin { // Scan 执行WebTitle扫描 func (p *WebTitlePlugin) Scan(ctx context.Context, info *common.HostInfo, session *common.ScanSession) *WebScanResult { config := session.Config - title, status, length, server, fingerprints, url, err := p.getWebTitle(ctx, info, config, session) + + // 带重试的 HTTP 请求:批量扫描时并发压力可能导致瞬时失败 + maxRetries := config.MaxRetries + if maxRetries <= 0 { + maxRetries = 1 + } + if maxRetries > 3 { + maxRetries = 3 + } + + var title string + var status, length int + var server string + var fingerprints []string + var url string + var err error + + for attempt := 0; attempt < maxRetries; attempt++ { + select { + case <-ctx.Done(): + return &WebScanResult{Success: false, Error: ctx.Err()} + default: + } + + title, status, length, server, fingerprints, url, err = p.getWebTitle(ctx, info, config, session) + if err == nil { + break + } + + if attempt < maxRetries-1 { + wait := time.Duration(200*(1<