mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-22 19:21:52 +08:00
## 架构重构
- 全局变量消除,迁移至 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)
140 lines
5.0 KiB
Go
140 lines
5.0 KiB
Go
//go:build web
|
|
|
|
package api
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
// ScanPreset 扫描预设
|
|
type ScanPreset struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
NameEn string `json:"name_en"`
|
|
Description string `json:"description"`
|
|
DescEn string `json:"description_en"`
|
|
Ports string `json:"ports"`
|
|
ScanMode string `json:"scan_mode"`
|
|
ThreadNum int `json:"thread_num"`
|
|
Timeout int `json:"timeout"`
|
|
}
|
|
|
|
// PluginInfo 插件信息
|
|
type PluginInfo struct {
|
|
Name string `json:"name"`
|
|
Type string `json:"type"` // service, web, local
|
|
Description string `json:"description"`
|
|
DescEn string `json:"description_en"`
|
|
Enabled bool `json:"enabled"`
|
|
}
|
|
|
|
// ConfigHandler 配置处理器
|
|
type ConfigHandler struct{}
|
|
|
|
// NewConfigHandler 创建配置处理器
|
|
func NewConfigHandler() *ConfigHandler {
|
|
return &ConfigHandler{}
|
|
}
|
|
|
|
// 预设配置
|
|
var presets = []ScanPreset{
|
|
{
|
|
ID: "quick",
|
|
Name: "快速扫描",
|
|
NameEn: "Quick Scan",
|
|
Description: "仅扫描常用端口,速度最快",
|
|
DescEn: "Scan common ports only, fastest speed",
|
|
Ports: "21,22,23,80,443,445,1433,3306,3389,6379,8080",
|
|
ScanMode: "all",
|
|
ThreadNum: 1000,
|
|
Timeout: 2,
|
|
},
|
|
{
|
|
ID: "standard",
|
|
Name: "标准扫描",
|
|
NameEn: "Standard Scan",
|
|
Description: "扫描主要端口,平衡速度和覆盖",
|
|
DescEn: "Scan main ports, balance between speed and coverage",
|
|
Ports: "21,22,23,25,80,110,135,139,143,443,445,465,587,993,995,1433,1521,3306,3389,5432,5900,6379,8080,8443,9000,27017",
|
|
ScanMode: "all",
|
|
ThreadNum: 600,
|
|
Timeout: 3,
|
|
},
|
|
{
|
|
ID: "full",
|
|
Name: "完整扫描",
|
|
NameEn: "Full Scan",
|
|
Description: "扫描所有常用端口,最完整",
|
|
DescEn: "Scan all common ports, most comprehensive",
|
|
Ports: "1-1000,1433,1521,3306,3389,5432,5900,6379,8000-9000,27017",
|
|
ScanMode: "all",
|
|
ThreadNum: 400,
|
|
Timeout: 5,
|
|
},
|
|
{
|
|
ID: "stealth",
|
|
Name: "隐蔽扫描",
|
|
NameEn: "Stealth Scan",
|
|
Description: "低速扫描,减少被检测风险",
|
|
DescEn: "Low-speed scan, reduce detection risk",
|
|
Ports: "21,22,23,80,443,445,3389,8080",
|
|
ScanMode: "all",
|
|
ThreadNum: 50,
|
|
Timeout: 10,
|
|
},
|
|
{
|
|
ID: "web",
|
|
Name: "Web专项",
|
|
NameEn: "Web Focus",
|
|
Description: "专注Web服务和漏洞检测",
|
|
DescEn: "Focus on web services and vulnerability detection",
|
|
Ports: "80,443,8080,8443,8000,8888,9000,9090,9999",
|
|
ScanMode: "all",
|
|
ThreadNum: 200,
|
|
Timeout: 5,
|
|
},
|
|
}
|
|
|
|
// 插件列表
|
|
var plugins = []PluginInfo{
|
|
// 服务类
|
|
{Name: "ssh", Type: "service", Description: "SSH服务检测与爆破", DescEn: "SSH service detection and brute force", Enabled: true},
|
|
{Name: "smb", Type: "service", Description: "SMB服务检测与爆破", DescEn: "SMB service detection and brute force", Enabled: true},
|
|
{Name: "rdp", Type: "service", Description: "RDP服务检测", DescEn: "RDP service detection", Enabled: true},
|
|
{Name: "mysql", Type: "service", Description: "MySQL数据库检测与爆破", DescEn: "MySQL database detection and brute force", Enabled: true},
|
|
{Name: "mssql", Type: "service", Description: "MSSQL数据库检测与爆破", DescEn: "MSSQL database detection and brute force", Enabled: true},
|
|
{Name: "postgresql", Type: "service", Description: "PostgreSQL数据库检测与爆破", DescEn: "PostgreSQL database detection and brute force", Enabled: true},
|
|
{Name: "redis", Type: "service", Description: "Redis服务检测与未授权访问", DescEn: "Redis service detection and unauthorized access", Enabled: true},
|
|
{Name: "mongodb", Type: "service", Description: "MongoDB数据库检测", DescEn: "MongoDB database detection", Enabled: true},
|
|
{Name: "ftp", Type: "service", Description: "FTP服务检测与爆破", DescEn: "FTP service detection and brute force", Enabled: true},
|
|
{Name: "telnet", Type: "service", Description: "Telnet服务检测", DescEn: "Telnet service detection", Enabled: true},
|
|
|
|
// Web类
|
|
{Name: "webinfo", Type: "web", Description: "Web指纹识别", DescEn: "Web fingerprinting", Enabled: true},
|
|
{Name: "poc", Type: "web", Description: "POC漏洞检测", DescEn: "POC vulnerability detection", Enabled: true},
|
|
|
|
// 本地类
|
|
{Name: "avdetect", Type: "local", Description: "杀软检测", DescEn: "Antivirus detection", Enabled: false},
|
|
{Name: "cleaner", Type: "local", Description: "痕迹清理", DescEn: "Trace cleaning", Enabled: false},
|
|
}
|
|
|
|
// Presets 获取扫描预设
|
|
func (h *ConfigHandler) Presets(w http.ResponseWriter, r *http.Request) {
|
|
if r.Method != http.MethodGet {
|
|
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
|
return
|
|
}
|
|
|
|
writeJSON(w, http.StatusOK, presets)
|
|
}
|
|
|
|
// Plugins 获取插件列表
|
|
func (h *ConfigHandler) Plugins(w http.ResponseWriter, r *http.Request) {
|
|
if r.Method != http.MethodGet {
|
|
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
|
return
|
|
}
|
|
|
|
writeJSON(w, http.StatusOK, plugins)
|
|
}
|