mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-09-14 05:56:46 +08:00

- 实现本地插件严格单个指定控制,拒绝多插件分隔符 - 修复本地插件自动调用问题,避免不必要的插件实例创建 - 添加-local与-h/-u参数的互斥性检查 - 优化插件存在性检查,使用pluginExists()替代plugins.Get() - 完善统一插件系统的端口信息管理 - 增强Web插件的协议智能检测功能 主要变更: * 本地插件现在只能通过-local参数明确指定单个插件运行 * 插件适用性检查不再创建不必要的插件实例,提升性能 * 本地扫描与网络扫描参数完全隔离,避免配置冲突
67 lines
1.7 KiB
Go
67 lines
1.7 KiB
Go
package core
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/shadow1ng/fscan/common"
|
|
"github.com/shadow1ng/fscan/common/i18n"
|
|
"sync"
|
|
)
|
|
|
|
// LocalScanStrategy 本地扫描策略
|
|
type LocalScanStrategy struct {
|
|
*BaseScanStrategy
|
|
}
|
|
|
|
// NewLocalScanStrategy 创建新的本地扫描策略
|
|
func NewLocalScanStrategy() *LocalScanStrategy {
|
|
return &LocalScanStrategy{
|
|
BaseScanStrategy: NewBaseScanStrategy("本地扫描", FilterLocal),
|
|
}
|
|
}
|
|
|
|
// LogPluginInfo 重写以只显示通过-local指定的插件
|
|
func (s *LocalScanStrategy) LogPluginInfo() {
|
|
if common.LocalPlugin != "" {
|
|
common.LogBase(fmt.Sprintf("本地插件: %s", common.LocalPlugin))
|
|
} else {
|
|
common.LogBase("本地插件: 未指定")
|
|
}
|
|
}
|
|
|
|
// Name 返回策略名称
|
|
func (s *LocalScanStrategy) Name() string {
|
|
return i18n.GetText("scan_strategy_local_name")
|
|
}
|
|
|
|
// Description 返回策略描述
|
|
func (s *LocalScanStrategy) Description() string {
|
|
return i18n.GetText("scan_strategy_local_desc")
|
|
}
|
|
|
|
// Execute 执行本地扫描策略
|
|
func (s *LocalScanStrategy) Execute(info common.HostInfo, ch *chan struct{}, wg *sync.WaitGroup) {
|
|
// 输出扫描开始信息
|
|
s.LogScanStart()
|
|
|
|
// 验证插件配置
|
|
if err := s.ValidateConfiguration(); err != nil {
|
|
common.LogError(err.Error())
|
|
return
|
|
}
|
|
|
|
// 输出插件信息
|
|
s.LogPluginInfo()
|
|
|
|
// 准备目标(本地扫描通常只有一个目标,即本机)
|
|
targets := s.PrepareTargets(info)
|
|
|
|
// 执行扫描任务
|
|
ExecuteScanTasks(targets, s, ch, wg)
|
|
}
|
|
|
|
// PrepareTargets 准备本地扫描目标
|
|
func (s *LocalScanStrategy) PrepareTargets(info common.HostInfo) []common.HostInfo {
|
|
// 本地扫描只使用传入的目标信息,不做额外处理
|
|
return []common.HostInfo{info}
|
|
}
|