mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-09-14 14:06:44 +08:00

主要修复: 1. 修复时间显示Bug - StartTime初始化问题 2. 修复Web智能探测错误检测预定义端口而非用户指定端口 3. 修复本地插件被错误调用到端口扫描中的问题 4. 修复host:port格式双重处理导致的多余端口扫描 5. 统一插件过滤逻辑,消除接口不一致性 6. 优化Web检测缓存机制,减少重复HTTP请求 技术改进: - 重构插件适用性检查逻辑,确保策略过滤器正确工作 - 区分Web检测的自动发现模式和用户指定端口模式 - 在解析阶段正确处理host:port格式,避免与默认端口冲突 - 完善缓存机制,提升性能 测试验证: - ./fscan -h 127.0.0.1:3306 现在只检测3306端口 - 本地插件不再参与端口扫描 - Web检测只对指定端口进行协议检测 - 时间显示正确
57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
package main
|
||
|
||
import (
|
||
"fmt"
|
||
"os"
|
||
"time"
|
||
|
||
"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式简化:直接执行,删除过度工程
|
||
// 首先设置开始时间
|
||
common.StartTime = time.Now()
|
||
|
||
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)
|
||
}
|