fscan/main.go
ZacharyZcR 43ddb3630d feat: 完善本地插件控制机制和参数验证
- 实现本地插件严格单个指定控制,拒绝多插件分隔符
- 修复本地插件自动调用问题,避免不必要的插件实例创建
- 添加-local与-h/-u参数的互斥性检查
- 优化插件存在性检查,使用pluginExists()替代plugins.Get()
- 完善统一插件系统的端口信息管理
- 增强Web插件的协议智能检测功能

主要变更:
* 本地插件现在只能通过-local参数明确指定单个插件运行
* 插件适用性检查不再创建不必要的插件实例,提升性能
* 本地扫描与网络扫描参数完全隔离,避免配置冲突
2025-08-26 19:34:14 +08:00

53 lines
1.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
"fmt"
"os"
"github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/core"
// 导入统一插件系统
_ "github.com/shadow1ng/fscan/plugins/services"
_ "github.com/shadow1ng/fscan/plugins/web"
_ "github.com/shadow1ng/fscan/plugins/local"
)
func main() {
// Linus式简化直接执行删除过度工程
var info common.HostInfo
common.Flag(&info)
// 检查-local与-h -u的互斥性
if common.LocalPlugin != "" && info.Host != "" {
fmt.Printf("错误: -local参数与-h参数互斥本地插件只能在本机运行\n")
os.Exit(1)
}
if common.LocalPlugin != "" && common.TargetURL != "" {
fmt.Printf("错误: -local参数与-u参数互斥本地插件不需要URL目标\n")
os.Exit(1)
}
// 初始化日志
common.InitLogger()
// 解析和验证参数
if err := common.Parse(&info); err != nil {
handleError("参数解析失败", err)
}
// 初始化输出系统
if err := common.InitOutput(); err != nil {
handleError("输出初始化失败", err)
}
defer common.CloseOutput()
// 执行扫描
core.RunScan(info)
}
func handleError(msg string, err error) {
common.LogError(fmt.Sprintf("%s: %v", msg, err))
os.Exit(1)
}