fscan/adapters/legacy_plugins/elasticsearch/plugin.go
ZacharyZcR 32223db6e3 refactor: 重新组织插件架构,分离老版本插件和适配器
目录结构优化:
- 保留 plugins/ 目录下的老版本插件代码不变
- 新增 adapters/ 目录专门存放适配器相关代码
- adapters/legacy_plugin.go - 老版本插件适配器框架
- adapters/legacy_plugins/ - 老版本插件适配器实现

架构分离:
- plugins/ - 原始老版本插件代码,保持不变
- plugins/services/ - 新架构服务插件
- adapters/ - 各种适配器,实现架构间桥接

设计原则:
- 零侵入性:老版本插件完全不需要修改
- 分离关注点:不同类型的代码放在合适的目录
- 统一管理:通过注册表统一管理所有插件

测试验证:✓ 重组后所有插件功能正常
2025-08-09 16:24:26 +08:00

54 lines
1.8 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package elasticsearch
import (
"github.com/shadow1ng/fscan/adapters"
"github.com/shadow1ng/fscan/plugins/base"
Plugins "github.com/shadow1ng/fscan/plugins"
)
// NewElasticsearchPlugin 创建Elasticsearch弱密码检测插件
func NewElasticsearchPlugin() base.Plugin {
// 插件元数据
metadata := &base.PluginMetadata{
Name: "elasticsearch",
Version: "1.0.0",
Author: "fscan-team",
Description: "Elasticsearch搜索引擎弱密码检测和未授权访问检测",
Category: "service",
Ports: []int{9200, 9201, 9300}, // Elasticsearch端口包含测试端口9201
Protocols: []string{"tcp"},
Tags: []string{"elasticsearch", "weak-password", "unauthorized", "service"},
}
// 适配器选项
options := &adapters.LegacyPluginOptions{
CheckBruteFlag: true, // Elasticsearch依赖暴力破解标志
IsVulnPlugin: false, // 这是服务检测插件,虽然包含安全检查
IsInfoPlugin: true, // 包含信息收集功能
CustomPorts: []int{9200, 9201, 9300}, // Elasticsearch端口包含测试端口9201
}
// 创建适配器直接使用老版本的ElasticScan函数
return adapters.NewLegacyPlugin(metadata, Plugins.ElasticScan, options)
}
// init 自动注册Elasticsearch插件
func init() {
// 创建插件工厂
metadata := &base.PluginMetadata{
Name: "elasticsearch",
Version: "1.0.0",
Author: "fscan-team",
Description: "Elasticsearch搜索引擎弱密码检测和未授权访问检测",
Category: "service",
Ports: []int{9200, 9201, 9300},
Protocols: []string{"tcp"},
Tags: []string{"elasticsearch", "weak-password", "unauthorized", "service"},
}
factory := base.NewSimplePluginFactory(metadata, func() base.Plugin {
return NewElasticsearchPlugin()
})
base.GlobalPluginRegistry.Register("elasticsearch", factory)
}