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)