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
+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
}