From f30a153b67db20aac8c22c3c6dca16fd56a8c780 Mon Sep 17 00:00:00 2001 From: ZacharyZcR Date: Wed, 13 May 2026 01:55:27 +0800 Subject: [PATCH] fix: credential TCP precheck bypass proxy and pipeline goroutine leak - Skip TCP precheck when proxy is enabled, net.DialTimeout cannot reach targets behind SOCKS5/HTTP proxy - Drain stream channel on ctx cancellation to prevent EnhancedPortScan goroutine from blocking on a full channel --- core/service_scanner.go | 7 ++++++- plugins/services/credential_tester.go | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/service_scanner.go b/core/service_scanner.go index 35ca412..8924d0a 100644 --- a/core/service_scanner.go +++ b/core/service_scanner.go @@ -175,10 +175,15 @@ func (s *ServiceScanStrategy) performHostScan(ctx context.Context, session *comm // pipeline 消费:边收开放端口边执行插件 pluginsToRun, isCustomMode := s.GetPlugins(config) + cancelled := false for addr := range stream { + if cancelled { + continue // ctx 已取消,排空 stream 防止写端阻塞 + } select { case <-ctx.Done(): - return + cancelled = true + continue default: } diff --git a/plugins/services/credential_tester.go b/plugins/services/credential_tester.go index ebe8d93..da4f2ae 100644 --- a/plugins/services/credential_tester.go +++ b/plugins/services/credential_tester.go @@ -152,7 +152,8 @@ func TestCredentialsConcurrently( } // TCP 预检:快速验证目标可达,避免对不可达目标浪费全部凭据尝试 - if testConfig.TargetAddr != "" { + // 代理模式下跳过:net.DialTimeout 直连无法到达代理后的内网目标 + if testConfig.TargetAddr != "" && !common.IsProxyEnabled() { preConn, err := net.DialTimeout("tcp", testConfig.TargetAddr, 3*time.Second) if err != nil { return &ScanResult{