fix: 非标准端口的服务无法匹配对应插件 #588

端口扫描识别到 8881 上运行 SSH,但 SSH 插件只注册了 [22,2222,2200,22222],
端口不匹配导致插件不执行。

新增服务名称缓存:端口扫描阶段记录 host:port → serviceName,
插件匹配时端口不命中则回退到服务名称匹配。
This commit is contained in:
ZacharyZcR
2026-06-14 22:23:46 +08:00
parent 5c251b123d
commit 2ab7c4d9b2
3 changed files with 59 additions and 2 deletions
+11
View File
@@ -115,6 +115,7 @@ func (b *BaseScanStrategy) isLocalPluginExplicitlySpecified(pluginName string, c
}
// isPluginApplicableToPortWithHost 检查插件是否适用于指定端口
// 匹配策略:端口匹配 → 服务名称匹配(解决非标准端口问题)
func (b *BaseScanStrategy) isPluginApplicableToPortWithHost(pluginName string, targetHost string, targetPort int) bool {
if b.isWebPlugin(pluginName) {
return IsMarkedWebService(targetHost, targetPort)
@@ -136,6 +137,16 @@ func (b *BaseScanStrategy) isPluginApplicableToPortWithHost(pluginName string, t
}
}
// 端口不匹配时,按服务识别结果匹配
// 例:8881 端口上识别到 ssh 服务 → ssh 插件应该执行
if targetHost != "" && targetPort > 0 {
if svcName, ok := GetServiceName(targetHost, targetPort); ok {
if strings.EqualFold(svcName, pluginName) {
return true
}
}
}
return false
}