mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-24 12:11:52 +08:00
feat: v2.1.0 核心重构与功能增强
## 架构重构
- 全局变量消除,迁移至 Config/State 对象
- SMB 插件融合(smb/smb2/smbghost/smbinfo)
- 服务探测重构,实现 Nmap 风格 fallback 机制
- 输出系统重构,TXT 实时刷盘 + 双写机制
- i18n 框架升级至 go-i18n
## 性能优化
- 正则表达式预编译
- 内存优化 map[string]struct{}
- 并发指纹匹配
- SOCKS5 连接复用
- 滑动窗口调度 + 自适应线程池
## 新功能
- Web 管理界面
- 多格式 POC 适配(xray/afrog)
- 增强指纹库(3139条)
- Favicon hash 指纹识别
- 插件选择性编译(Build Tags)
- fscan-lab 靶场环境
- 默认端口扩展(62→133)
## 构建系统
- 添加 no_local tag 支持排除本地插件
- 多版本构建:fscan/fscan-nolocal/fscan-web
- CI 添加 snapshot 模式支持仅测试构建
## Bug 修复
- 修复 120+ 个问题,包括 RDP panic、批量扫描漏报、
JSON 输出格式、Redis 检测、Context 超时等
## 测试增强
- 单元测试覆盖率 74-100%
- 并发安全测试
- 集成测试(Web/端口/服务/SSH/ICMP)
This commit is contained in:
@@ -1,31 +1,69 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/shadow1ng/fscan/Common"
|
||||
"github.com/shadow1ng/fscan/Core"
|
||||
"github.com/shadow1ng/fscan/common"
|
||||
"github.com/shadow1ng/fscan/common/i18n"
|
||||
"github.com/shadow1ng/fscan/core"
|
||||
"github.com/shadow1ng/fscan/web"
|
||||
|
||||
// 导入统一插件系统
|
||||
_ "github.com/shadow1ng/fscan/plugins/local"
|
||||
_ "github.com/shadow1ng/fscan/plugins/services"
|
||||
_ "github.com/shadow1ng/fscan/plugins/web"
|
||||
)
|
||||
|
||||
func main() {
|
||||
Common.InitLogger()
|
||||
// 启动 pprof(仅调试版本)
|
||||
startPprof()
|
||||
defer stopPprof() // 程序退出时保存性能分析数据
|
||||
|
||||
var Info Common.HostInfo
|
||||
Common.Flag(&Info)
|
||||
|
||||
// 解析 CLI 参数
|
||||
if err := Common.Parse(&Info); err != nil {
|
||||
// 解析命令行参数
|
||||
var info common.HostInfo
|
||||
if err := common.Flag(&info); err != nil {
|
||||
if err == common.ErrShowHelp {
|
||||
os.Exit(0) // 显示帮助是正常退出
|
||||
}
|
||||
common.LogError(i18n.Tr("param_error", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// 初始化输出系统,如果失败则直接退出
|
||||
if err := Common.InitOutput(); err != nil {
|
||||
Common.LogError(fmt.Sprintf("初始化输出系统失败: %v", err))
|
||||
// Web模式:启动Web服务器
|
||||
if common.WebMode {
|
||||
if err := web.StartServer(common.WebPort); err != nil {
|
||||
common.LogError(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 检查参数互斥性
|
||||
if err := common.ValidateExclusiveParams(&info); err != nil {
|
||||
common.LogError(i18n.Tr("error_generic", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
defer Common.CloseOutput()
|
||||
|
||||
// 执行 CLI 扫描逻辑
|
||||
Core.Scan(Info)
|
||||
// 统一初始化:解析 → 配置 → 输出
|
||||
result, err := common.Initialize(&info)
|
||||
if err != nil {
|
||||
common.LogError(i18n.Tr("init_failed", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// 设置信号处理,确保 Ctrl+C 时能正确保存结果
|
||||
sigChan := make(chan os.Signal, 1)
|
||||
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-sigChan
|
||||
common.LogBase(i18n.GetText("received_exit_signal"))
|
||||
_ = common.Cleanup() // 确保结果写入磁盘
|
||||
os.Exit(130) // 128 + SIGINT(2) = 130,标准的中断退出码
|
||||
}()
|
||||
defer func() { _ = common.Cleanup() }()
|
||||
|
||||
// 执行扫描
|
||||
core.RunScan(*result.Info, result.Config, result.State)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user