From a0fc7881f2b3debe70b2ea1eccaa9787defc0ac7 Mon Sep 17 00:00:00 2001 From: ZacharyZcR Date: Fri, 15 May 2026 22:40:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20-m=20=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E6=9C=AC=E5=9C=B0=E6=8F=92=E4=BB=B6=E6=97=B6=E8=AF=AF?= =?UTF-8?q?=E8=B5=B0=E6=9C=8D=E5=8A=A1=E6=89=AB=E6=8F=8F=E7=AD=96=E7=95=A5?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当通过 -m 参数指定本地插件(如 systeminfo)时,由于 LocalMode 未被设置, 会错误地进入服务扫描流程,导致不必要的端口扫描和插件重复执行。 现在 determineScanMode 会自动检测 -m 指定的插件类型, 全部为 local 类型时自动切换到本地扫描模式。 --- core/scanner.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/core/scanner.go b/core/scanner.go index 7703b25..1813cfa 100644 --- a/core/scanner.go +++ b/core/scanner.go @@ -6,6 +6,7 @@ import ( "net/url" "os" "os/signal" + "strings" "sync" "syscall" "time" @@ -54,6 +55,10 @@ func determineScanMode(config *common.Config, state *common.State) ScanMode { return ScanModeAlive case config.LocalMode: return ScanModeLocal + case isAllLocalPlugins(config.Mode): + config.LocalMode = true + config.LocalPlugin = config.Mode + return ScanModeLocal case len(state.GetURLs()) > 0: return ScanModeWeb default: @@ -61,6 +66,23 @@ func determineScanMode(config *common.Config, state *common.State) ScanMode { } } +// isAllLocalPlugins 检查 -m 指定的插件是否全部为 local 类型 +func isAllLocalPlugins(mode string) bool { + if mode == "" || mode == "all" { + return false + } + for _, name := range strings.Split(mode, ",") { + name = strings.TrimSpace(name) + if name == "" { + continue + } + if !plugins.HasType(name, plugins.PluginTypeLocal) { + return false + } + } + return true +} + // selectStrategy 根据扫描模式选择策略 func selectStrategy(config *common.Config, state *common.State, info common.HostInfo) ScanStrategy { mode := determineScanMode(config, state)