mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-22 03:10:42 +08:00
fix: 移除误导性的"无可用插件"日志 #588
扫描开始前的插件预检基于端口列表静态匹配,不代表实际扫描中插件 不会执行。移除"无可用插件"提示,避免用户误以为插件未工作。
This commit is contained in:
@@ -4,7 +4,9 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
@@ -132,13 +134,19 @@ func toInt(v interface{}) (int, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func splitHostPort(target string) (string, int, bool) {
|
func splitHostPort(target string) (string, int, bool) {
|
||||||
idx := strings.LastIndex(target, ":")
|
host, portText, err := net.SplitHostPort(target)
|
||||||
if idx < 0 {
|
if err != nil {
|
||||||
|
if strings.Count(target, ":") != 1 {
|
||||||
return "", 0, false
|
return "", 0, false
|
||||||
}
|
}
|
||||||
host := target[:idx]
|
parts := strings.SplitN(target, ":", 2)
|
||||||
var port int
|
host, portText = parts[0], parts[1]
|
||||||
if _, err := fmt.Sscanf(target[idx+1:], "%d", &port); err != nil {
|
}
|
||||||
|
port, err := strconv.Atoi(portText)
|
||||||
|
if err != nil {
|
||||||
|
return "", 0, false
|
||||||
|
}
|
||||||
|
if host == "" || port < 1 || port > 65535 {
|
||||||
return "", 0, false
|
return "", 0, false
|
||||||
}
|
}
|
||||||
return host, port, true
|
return host, port, true
|
||||||
|
|||||||
+4
-18
@@ -69,7 +69,7 @@ func (s *ServiceScanStrategy) showPluginsForSpecifiedPorts(config *common.Config
|
|||||||
applicablePlugins = append(applicablePlugins, pluginName)
|
applicablePlugins = append(applicablePlugins, pluginName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 输出结果
|
// 输出结果(仅在有匹配插件时显示,避免因预检端口不完整而输出误导性的"无可用插件")
|
||||||
if len(applicablePlugins) > 0 {
|
if len(applicablePlugins) > 0 {
|
||||||
pluginStr := formatPluginList(applicablePlugins)
|
pluginStr := formatPluginList(applicablePlugins)
|
||||||
if isCustomMode {
|
if isCustomMode {
|
||||||
@@ -77,8 +77,6 @@ func (s *ServiceScanStrategy) showPluginsForSpecifiedPorts(config *common.Config
|
|||||||
} else {
|
} else {
|
||||||
session.LogInfo(i18n.Tr("service_plugin_info", pluginStr))
|
session.LogInfo(i18n.Tr("service_plugin_info", pluginStr))
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
session.LogInfo(i18n.GetText("service_plugin_none"))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,18 +86,9 @@ func (s *ServiceScanStrategy) parsePortList(portStr string) []int {
|
|||||||
return []int{}
|
return []int{}
|
||||||
}
|
}
|
||||||
|
|
||||||
ports := []int{} // 初始化为空切片而非nil
|
ports := parsers.ParsePort(portStr)
|
||||||
parts := strings.Split(portStr, ",")
|
if ports == nil {
|
||||||
for _, part := range parts {
|
return []int{}
|
||||||
part = strings.TrimSpace(part)
|
|
||||||
if port, err := strconv.Atoi(part); err == nil {
|
|
||||||
// 验证端口范围 1-65535(与 scanner.go 的 parsePort 保持一致)
|
|
||||||
if port >= 1 && port <= 65535 {
|
|
||||||
ports = append(ports, port)
|
|
||||||
} else {
|
|
||||||
common.LogError(i18n.Tr("port_out_of_range", port))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ports
|
return ports
|
||||||
}
|
}
|
||||||
@@ -340,11 +329,8 @@ func (s *ServiceScanStrategy) LogVulnerabilityPluginInfo(targets []common.HostIn
|
|||||||
servicePlugins = append(servicePlugins, pluginName)
|
servicePlugins = append(servicePlugins, pluginName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 输出插件信息
|
|
||||||
if len(servicePlugins) > 0 {
|
if len(servicePlugins) > 0 {
|
||||||
common.LogInfo(i18n.Tr("service_plugin_info", strings.Join(servicePlugins, ", ")))
|
common.LogInfo(i18n.Tr("service_plugin_info", strings.Join(servicePlugins, ", ")))
|
||||||
} else {
|
|
||||||
common.LogInfo(i18n.GetText("scan_no_service_plugins"))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user