refactor: 精简化输出,移除冗余启动信息

- 移除showParseSummary开局配置输出
- 移除LogPluginInfo/LogPluginInfoWithPort插件信息输出
- 移除alive_scanner冗余统计输出
- 移除port_scan_start扫描开始提示
- 移除handleUDPPorts SNMP死代码
- 移除相关i18n条目
This commit is contained in:
ZacharyZcR
2026-01-17 13:31:24 +08:00
parent 5ebdbd3aa2
commit b17061c98c
7 changed files with 14 additions and 191 deletions
-2
View File
@@ -155,8 +155,6 @@ scan_vulnerability_start:
other: "Starting vulnerability scan"
scan_no_service_plugins:
other: "No available service plugins found"
scan_snmp_udp_ports_added:
other: "Detected SNMP port 161, adding UDP ports to scan targets"
# ========================= Scan Strategy Messages =========================
scan_strategy_alive_name:
-2
View File
@@ -155,8 +155,6 @@ scan_vulnerability_start:
other: "开始漏洞扫描"
scan_no_service_plugins:
other: "未找到可用的服务插件"
scan_snmp_udp_ports_added:
other: "检测到SNMP端口161,添加UDP端口到扫描目标"
# ========================= 扫描策略消息 =========================
scan_strategy_alive_name:
+2 -95
View File
@@ -396,102 +396,9 @@ func joinInts(slice []int, sep string) string {
return strings.Join(strs, sep)
}
// showParseSummary 显示解析结果摘要(精简
// showParseSummary 显示解析结果摘要(精简,不再输出冗余信息
func showParseSummary(config *parsers.ParsedConfig) {
if config == nil {
return
}
fv := GetFlagVars()
// 1. 目标信息(合并为一行)
if config.Targets != nil {
var targetParts []string
// 主机信息
if len(config.Targets.Hosts) > 0 {
if len(config.Targets.Hosts) == 1 {
targetParts = append(targetParts, config.Targets.Hosts[0])
} else {
targetParts = append(targetParts, fmt.Sprintf("%d主机", len(config.Targets.Hosts)))
}
}
// URL信息
if len(config.Targets.URLs) > 0 {
if len(config.Targets.URLs) == 1 {
targetParts = append(targetParts, config.Targets.URLs[0])
} else {
targetParts = append(targetParts, fmt.Sprintf("%dURL", len(config.Targets.URLs)))
}
}
// 端口信息
if len(config.Targets.Ports) > 0 {
targetParts = append(targetParts, fmt.Sprintf("%d端口", len(config.Targets.Ports)))
}
// 本地模式
if config.Targets.LocalMode {
targetParts = append(targetParts, "本地模式")
}
if len(targetParts) > 0 {
LogBase(fmt.Sprintf("目标: %s", strings.Join(targetParts, " x ")))
}
// 排除端口单独显示(如果有)
if len(config.Targets.ExcludePorts) > 0 {
LogBase(fmt.Sprintf("排除: %d端口", len(config.Targets.ExcludePorts)))
}
}
// 2. 非默认配置(只显示用户修改过的)
var customConfigs []string
if fv.ThreadNum != 600 {
customConfigs = append(customConfigs, fmt.Sprintf("线程%d", fv.ThreadNum))
}
if fv.TimeoutSec != 3 {
customConfigs = append(customConfigs, fmt.Sprintf("超时%ds", fv.TimeoutSec))
}
if fv.ModuleThreadNum != 20 {
customConfigs = append(customConfigs, fmt.Sprintf("模块线程%d", fv.ModuleThreadNum))
}
if fv.GlobalTimeout != 180 {
customConfigs = append(customConfigs, fmt.Sprintf("全局超时%ds", fv.GlobalTimeout))
}
// 代理配置
if config.Network != nil {
if config.Network.HTTPProxy != "" {
customConfigs = append(customConfigs, fmt.Sprintf("HTTP代理:%s", config.Network.HTTPProxy))
}
if config.Network.Socks5Proxy != "" {
customConfigs = append(customConfigs, fmt.Sprintf("SOCKS5:%s", config.Network.Socks5Proxy))
}
}
if len(customConfigs) > 0 {
LogBase(fmt.Sprintf("配置: %s", strings.Join(customConfigs, " ")))
}
// 3. 凭据信息(合并为一行)
if config.Credentials != nil {
var credParts []string
if len(config.Credentials.Usernames) > 0 {
credParts = append(credParts, fmt.Sprintf("%d用户", len(config.Credentials.Usernames)))
}
if len(config.Credentials.Passwords) > 0 {
credParts = append(credParts, fmt.Sprintf("%d密码", len(config.Credentials.Passwords)))
}
if len(config.Credentials.HashValues) > 0 {
credParts = append(credParts, fmt.Sprintf("%d哈希", len(config.Credentials.HashValues)))
}
if len(credParts) > 0 {
LogBase(fmt.Sprintf("凭据: %s", strings.Join(credParts, " ")))
}
}
// 不再输出开局配置信息,减少干扰
}
// logLevelMap 日志级别字符串到级别的映射(支持新旧格式)
+4 -34
View File
@@ -2,7 +2,6 @@ package core
import (
"fmt"
"strings"
"sync"
"time"
@@ -61,8 +60,6 @@ func (s *AliveScanStrategy) Execute(config *common.Config, state *common.State,
return
}
// 输出存活探测开始信息
common.LogBase(i18n.GetText("scan_alive_start"))
// 执行存活探测
s.performAliveScan(info, config, state)
@@ -91,12 +88,6 @@ func (s *AliveScanStrategy) performAliveScan(info common.HostInfo, config *commo
s.stats.AliveHosts = 0
s.stats.DeadHosts = 0
// 显示扫描信息
if len(hosts) == 1 {
common.LogBase(i18n.Tr("alive_scan_start_single", hosts[0]))
} else {
common.LogBase(i18n.Tr("alive_scan_start_multi", len(hosts), hosts[0]))
}
// 执行存活检测
aliveList := CheckLive(hosts, false, config, state) // 使用ICMP探测
@@ -112,33 +103,12 @@ func (s *AliveScanStrategy) performAliveScan(info common.HostInfo, config *commo
}
}
// outputStats 输出详细统计信息
// outputStats 输出统计信息(精简版)
func (s *AliveScanStrategy) outputStats() {
// 输出分隔线
common.LogBase("=" + strings.Repeat("=", 60))
// 输出扫描结果摘要
common.LogBase(i18n.GetText("scan_alive_summary_title"))
// 基础统计
common.LogBase(i18n.Tr("alive_total_hosts", s.stats.TotalHosts))
common.LogBase(i18n.Tr("alive_hosts_count", s.stats.AliveHosts))
common.LogBase(i18n.Tr("alive_dead_hosts", s.stats.DeadHosts))
common.LogBase(i18n.Tr("alive_success_rate", fmt.Sprintf("%.2f%%", s.stats.SuccessRate)))
common.LogBase(i18n.Tr("alive_scan_duration", s.stats.ScanDuration.Round(time.Millisecond)))
// 如果有存活主机,显示详细列表
if s.stats.AliveHosts > 0 {
common.LogBase("")
common.LogBase(i18n.GetText("scan_alive_hosts_list"))
for i, host := range s.stats.AliveHostList {
common.LogSuccess(i18n.Tr("alive_host_item", i+1, host))
}
// 输出存活主机列表,不输出冗余统计
for _, host := range s.stats.AliveHostList {
common.LogSuccess(fmt.Sprintf("alive %s", host))
}
// 输出分隔线
common.LogBase("=" + strings.Repeat("=", 60))
}
// PrepareTargets 存活探测不需要准备扫描目标
+8 -20
View File
@@ -180,16 +180,10 @@ func (b *BaseScanStrategy) LogPluginInfo(config *common.Config) {
prefix = i18n.GetText("concurrency_plugin")
}
if len(allPlugins) > 0 {
pluginStr := formatPluginList(allPlugins)
if isCustomMode {
common.LogBase(i18n.Tr("plugins_custom_specified", prefix, pluginStr))
} else {
common.LogBase(i18n.Tr("plugins_info", prefix, pluginStr))
}
} else {
common.LogBase(i18n.Tr("plugins_none", prefix))
}
// 插件信息不再输出,减少干扰
_ = allPlugins
_ = isCustomMode
_ = prefix
}
// formatPluginList 格式化插件列表(超过5个时精简显示)
@@ -226,16 +220,10 @@ func (b *BaseScanStrategy) LogPluginInfoWithPort(targetHost string, targetPort i
}
}
if len(applicablePlugins) > 0 {
pluginStr := formatPluginList(applicablePlugins)
if isCustomMode {
common.LogBase(i18n.Tr("plugins_custom_specified", prefix, pluginStr))
} else {
common.LogBase(i18n.Tr("plugins_info", prefix, pluginStr))
}
} else {
common.LogBase(i18n.Tr("plugins_none", prefix))
}
// 插件信息不再输出,减少干扰
_ = applicablePlugins
_ = isCustomMode
_ = prefix
}
// ValidateConfiguration 验证扫描配置
-5
View File
@@ -155,11 +155,6 @@ func EnhancedPortScan(hosts []string, ports string, timeout int64, config *commo
// 使用传入的配置
threadNum := config.ThreadNum
// 估算并显示扫描时间
if totalTasks > 0 {
estimatedTime := estimateScanTime(totalTasks, threadNum, timeout)
common.LogBase(i18n.Tr("port_scan_start", totalTasks, estimatedTime, estimatedTime/60))
}
// 初始化端口扫描进度条
if totalTasks > 0 && config.Output.ShowProgress {
-33
View File
@@ -264,13 +264,6 @@ func (s *ServiceScanStrategy) discoverAlivePorts(hosts []string, config *common.
common.LogBase(i18n.Tr("alive_ports_count", len(alivePorts)))
}
// UDP端口特殊处理(当前仅支持SNMP的161端口)
udpPorts := s.handleUDPPorts(hosts)
if len(udpPorts) > 0 {
alivePorts = append(alivePorts, udpPorts...)
common.LogBase(i18n.Tr("alive_ports_count", len(alivePorts)))
}
return alivePorts
}
@@ -317,29 +310,3 @@ func (s *ServiceScanStrategy) convertToTargetInfos(ports []string, baseInfo comm
return infos
}
// handleUDPPorts 处理UDP端口的特殊逻辑
func (s *ServiceScanStrategy) handleUDPPorts(hosts []string) []string {
var udpPorts []string
// 检查是否包含SNMP端口161
portList := parsers.ParsePort(common.GetFlagVars().Ports)
hasPort161 := false
for _, port := range portList {
if port == 161 {
hasPort161 = true
break
}
}
// 如果端口列表包含161,则为每个主机添加UDP 161端口
if hasPort161 {
for _, host := range hosts {
udpPorts = append(udpPorts, fmt.Sprintf("%s:161", host))
}
if len(udpPorts) > 0 {
common.LogBase(i18n.GetText("scan_snmp_udp_ports_added"))
}
}
return udpPorts
}