mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-24 12:11:52 +08:00
feat: 统一服务缓存 + 指纹驱动插件匹配
将 webServiceCache 扩展为通用 serviceCache,所有指纹识别结果 统一缓存,插件匹配时端口不命中则回退到服务名称匹配。 删除多余的 service_cache.go,复用已有的 ServiceInfo 体系。 补充 nil 防御、Explicit 标记、大量单元/集成/回归测试。
This commit is contained in:
+33
-4
@@ -145,6 +145,35 @@ type LocalExploitConfig struct {
|
||||
DownloadSavePath string // 下载保存路径
|
||||
}
|
||||
|
||||
func cloneStringSlice(values []string) []string {
|
||||
if values == nil {
|
||||
return nil
|
||||
}
|
||||
return append([]string(nil), values...)
|
||||
}
|
||||
|
||||
func cloneStringSliceMap(values map[string][]string) map[string][]string {
|
||||
if values == nil {
|
||||
return nil
|
||||
}
|
||||
cloned := make(map[string][]string, len(values))
|
||||
for key, value := range values {
|
||||
cloned[key] = cloneStringSlice(value)
|
||||
}
|
||||
return cloned
|
||||
}
|
||||
|
||||
func clonePortMap(values map[int][]string) map[int][]string {
|
||||
if values == nil {
|
||||
return nil
|
||||
}
|
||||
cloned := make(map[int][]string, len(values))
|
||||
for key, value := range values {
|
||||
cloned[key] = cloneStringSlice(value)
|
||||
}
|
||||
return cloned
|
||||
}
|
||||
|
||||
// NewConfig 创建带默认值的Config(后备用,正常流程使用BuildConfigFromFlags)
|
||||
func NewConfig() *Config {
|
||||
return &Config{
|
||||
@@ -163,13 +192,13 @@ func NewConfig() *Config {
|
||||
MaxRetries: 3,
|
||||
|
||||
// 高级功能 - 使用默认配置
|
||||
PortMap: config.DefaultPortMap,
|
||||
DefaultMap: config.DefaultProbeMap,
|
||||
PortMap: clonePortMap(config.DefaultPortMap),
|
||||
DefaultMap: cloneStringSlice(config.DefaultProbeMap),
|
||||
|
||||
// 分组配置 - 使用默认字典
|
||||
Credentials: CredentialConfig{
|
||||
Userdict: config.DefaultUserDict,
|
||||
Passwords: config.DefaultPasswords,
|
||||
Userdict: cloneStringSliceMap(config.DefaultUserDict),
|
||||
Passwords: cloneStringSlice(config.DefaultPasswords),
|
||||
UserPassPairs: nil,
|
||||
},
|
||||
Network: NetworkConfig{
|
||||
|
||||
Reference in New Issue
Block a user