diff --git a/adapters/README.md b/adapters/README.md new file mode 100644 index 0000000..9a47498 --- /dev/null +++ b/adapters/README.md @@ -0,0 +1,77 @@ +# Adapters Directory + +这个目录包含了各种适配器实现,用于将不同架构的代码无缝集成到新的插件系统中。 + +## 目录结构 + +``` +adapters/ +├── README.md # 本文档 +├── legacy_plugin.go # 老版本插件适配器框架 +└── legacy_plugins/ # 老版本插件适配器实现 + ├── README.md # 老版本插件适配器说明 + ├── ms17010/ # MS17010漏洞检测适配器 + ├── smbghost/ # SMBGhost漏洞检测适配器 + ├── smb/ # SMB服务检测适配器 + ├── smb2/ # SMB2服务检测适配器 + ├── rdp/ # RDP服务检测适配器 + ├── netbios/ # NetBIOS信息收集适配器 + └── elasticsearch/ # Elasticsearch服务检测适配器 +``` + +## 设计原则 + +### 1. 分离关注点 +- **plugins/**: 存放原始的老版本插件代码,保持不变 +- **plugins/services/**: 存放新架构的服务插件 +- **adapters/**: 存放各种适配器,实现不同架构间的桥接 + +### 2. 零侵入性 +- 老版本插件代码完全不需要修改 +- 通过适配器模式实现无缝集成 +- 保持原有功能和行为不变 + +### 3. 统一管理 +- 所有插件(新架构 + 适配器)通过统一的插件注册表管理 +- 提供一致的调用接口和结果格式 +- 支持统一的配置和控制机制 + +## 适配器类型 + +### LegacyPlugin适配器 +将老版本插件函数适配为新架构的Plugin接口: + +```go +// 老版本插件函数 +func PluginFunc(*common.HostInfo) error + +// 通过适配器转换为 +type Plugin interface { + Scanner + Exploiter + // ...其他接口方法 +} +``` + +## 扩展方式 + +如需添加新的适配器类型: + +1. 在此目录创建对应的适配器框架文件 +2. 在子目录中实现具体的适配器插件 +3. 在 core/Registry.go 中注册适配器插件 +4. 更新相关文档 + +## 使用示例 + +适配器插件会自动注册,使用方式与标准插件相同: + +```bash +# 使用老版本插件(通过适配器) +fscan -h target -m ms17010,smb2 + +# 混合使用新旧插件 +fscan -h target -m mysql,redis,ms17010 +``` + +适配器确保了新旧插件的完全兼容性和统一体验。 \ No newline at end of file diff --git a/adapters/legacy_plugin.go b/adapters/legacy_plugin.go new file mode 100644 index 0000000..1b2910f --- /dev/null +++ b/adapters/legacy_plugin.go @@ -0,0 +1,181 @@ +package adapters + +import ( + "context" + "fmt" + + "github.com/shadow1ng/fscan/common" + "github.com/shadow1ng/fscan/plugins/base" +) + +// LegacyPluginFunc 老版本插件的函数签名 +type LegacyPluginFunc func(*common.HostInfo) error + +// LegacyPlugin 老版本插件适配器 +type LegacyPlugin struct { + metadata *base.PluginMetadata + legacyFunc LegacyPluginFunc + options *LegacyPluginOptions +} + +// LegacyPluginOptions 老版本插件选项 +type LegacyPluginOptions struct { + // 是否需要检查暴力破解开关 + CheckBruteFlag bool + // 是否为漏洞检测类插件 + IsVulnPlugin bool + // 是否为信息收集类插件 + IsInfoPlugin bool + // 自定义端口(如果不使用metadata中的端口) + CustomPorts []int +} + +// NewLegacyPlugin 创建老版本插件适配器 +func NewLegacyPlugin(metadata *base.PluginMetadata, legacyFunc LegacyPluginFunc, options *LegacyPluginOptions) *LegacyPlugin { + if options == nil { + options = &LegacyPluginOptions{ + CheckBruteFlag: true, + IsVulnPlugin: true, + } + } + + return &LegacyPlugin{ + metadata: metadata, + legacyFunc: legacyFunc, + options: options, + } +} + +// GetMetadata 实现Plugin接口 +func (p *LegacyPlugin) GetMetadata() *base.PluginMetadata { + return p.metadata +} + +// GetName 实现Scanner接口 +func (p *LegacyPlugin) GetName() string { + return p.metadata.Name +} + +// Initialize 实现Plugin接口 +func (p *LegacyPlugin) Initialize() error { + return nil +} + +// Scan 实现Plugin接口 - 适配老版本插件调用 +func (p *LegacyPlugin) Scan(ctx context.Context, info *common.HostInfo) (*base.ScanResult, error) { + // 检查上下文是否取消 + select { + case <-ctx.Done(): + return nil, ctx.Err() + default: + } + + // 如果需要检查暴力破解标志且已禁用暴力破解 + if p.options.CheckBruteFlag && common.DisableBrute { + if p.options.IsVulnPlugin { + // 漏洞检测类插件在禁用暴力破解时仍然运行 + // 这里不返回,继续执行 + } else { + // 非漏洞检测类插件在禁用暴力破解时跳过 + return &base.ScanResult{ + Success: false, + Service: p.metadata.Name, + Error: fmt.Errorf("brute force disabled"), + }, nil + } + } + + // 调用老版本插件函数 + err := p.legacyFunc(info) + + if err != nil { + // 插件执行失败 + return &base.ScanResult{ + Success: false, + Service: p.metadata.Name, + Error: err, + }, nil + } + + // 插件执行成功 + // 老版本插件通常自己处理日志和结果输出,所以这里返回基本成功信息 + return &base.ScanResult{ + Success: true, + Service: p.metadata.Name, + Banner: fmt.Sprintf("%s scan completed", p.metadata.Name), + Extra: map[string]interface{}{ + "plugin_type": "legacy", + "category": p.metadata.Category, + }, + }, nil +} + +// ScanCredential 实现Plugin接口 - 老版本插件不支持单独的凭据测试 +func (p *LegacyPlugin) ScanCredential(ctx context.Context, info *common.HostInfo, cred *base.Credential) (*base.ScanResult, error) { + // 老版本插件通常内部处理凭据,所以这里直接调用Scan + return p.Scan(ctx, info) +} + +// ============================================================================= +// Exploiter接口实现 - 老版本插件通常不支持独立的利用功能 +// ============================================================================= + +// Exploit 实现Exploiter接口 - 老版本插件通常不支持单独利用 +func (p *LegacyPlugin) Exploit(ctx context.Context, info *common.HostInfo, creds *base.Credential) (*base.ExploitResult, error) { + // 老版本插件通常在Scan中完成所有操作,不支持独立利用 + return nil, fmt.Errorf("legacy plugin does not support separate exploitation") +} + +// GetExploitMethods 实现Exploiter接口 - 返回空的利用方法列表 +func (p *LegacyPlugin) GetExploitMethods() []base.ExploitMethod { + // 老版本插件不支持独立的利用方法 + return []base.ExploitMethod{} +} + +// IsExploitSupported 实现Exploiter接口 - 老版本插件不支持独立利用 +func (p *LegacyPlugin) IsExploitSupported(method base.ExploitType) bool { + // 老版本插件不支持独立的利用方法 + return false +} + +// GetCapabilities 实现Plugin接口 +func (p *LegacyPlugin) GetCapabilities() []base.Capability { + capabilities := []base.Capability{} + + // 根据插件类型分配合适的能力 + if p.options.IsVulnPlugin { + // 漏洞检测插件通常涉及信息泄露检测 + capabilities = append(capabilities, base.CapInformationLeak) + } + + if p.options.IsInfoPlugin { + // 信息收集插件 + capabilities = append(capabilities, base.CapInformationLeak) + } + + // 大多数老版本插件都支持弱密码检测 + if p.options.CheckBruteFlag { + capabilities = append(capabilities, base.CapWeakPassword) + } + + return capabilities +} + +// SetCapabilities 实现Plugin接口 - 老版本插件不支持动态设置能力 +func (p *LegacyPlugin) SetCapabilities(capabilities []base.Capability) { + // 老版本插件的能力是固定的,这里不做任何操作 +} + +// GetDefaultPorts 获取默认端口 +func (p *LegacyPlugin) GetDefaultPorts() []int { + if len(p.options.CustomPorts) > 0 { + return p.options.CustomPorts + } + return p.metadata.Ports +} + +// Cleanup 清理资源 +func (p *LegacyPlugin) Cleanup() error { + // 老版本插件通常没有需要清理的资源 + return nil +} \ No newline at end of file diff --git a/adapters/legacy_plugins/README.md b/adapters/legacy_plugins/README.md new file mode 100644 index 0000000..5503770 --- /dev/null +++ b/adapters/legacy_plugins/README.md @@ -0,0 +1,90 @@ +# Legacy Plugin Adapters + +这个目录包含了老版本插件的适配器实现,使用适配器模式将老版本插件无缝接入新的插件架构。 + +## 架构设计 + +``` +老版本插件函数 (plugins/*.go) + ↓ +LegacyPlugin适配器 (adapter/legacy_plugin.go) + ↓ +新插件系统 (base/*.go) +``` + +## 已适配插件列表 + +### 漏洞检测类插件 +- **ms17010** - SMB远程代码执行漏洞检测 (EternalBlue) + - 端口: 445 + - 功能: MS17010漏洞检测 + - 原函数: `Plugins.MS17010` + +- **smbghost** - CVE-2020-0796 远程代码执行漏洞检测 + - 端口: 445 + - 功能: SMBGhost漏洞检测 + - 原函数: `Plugins.SmbGhost` + +### 服务检测类插件 +- **smb** - SMB服务弱密码检测和共享枚举 + - 端口: 445, 139 + - 功能: SMB弱密码检测、共享枚举 + - 原函数: `Plugins.SmbScan` + +- **smb2** - SMB2服务弱密码检测 (支持NTLM哈希) + - 端口: 445 + - 功能: SMB2弱密码检测、NTLM哈希支持 + - 原函数: `Plugins.SmbScan2` + +- **rdp** - RDP远程桌面服务弱密码检测 + - 端口: 3389 + - 功能: RDP弱密码检测 + - 原函数: `Plugins.RdpScan` + +- **elasticsearch** - Elasticsearch弱密码检测和未授权访问检测 + - 端口: 9200, 9201, 9300 + - 功能: 弱密码检测、未授权访问检测 + - 原函数: `Plugins.ElasticScan` + +### 信息收集类插件 +- **netbios** - NetBIOS信息收集和主机名解析 + - 端口: 139, 445 + - 功能: NetBIOS信息收集、主机名解析 + - 原函数: `Plugins.NetBIOS` + +## 适配器特点 + +1. **零侵入性** - 老版本插件代码完全不需要修改 +2. **完整兼容** - 实现完整的Plugin接口 (Scanner + Exploiter) +3. **类型感知** - 根据插件类型自动配置能力和行为 +4. **统一管理** - 与新架构插件一起统一调度和管理 + +## 配置选项 + +每个适配器支持以下配置选项: + +- `CheckBruteFlag` - 是否检查暴力破解开关 +- `IsVulnPlugin` - 是否为漏洞检测插件 +- `IsInfoPlugin` - 是否为信息收集插件 +- `CustomPorts` - 自定义端口列表 + +## 使用方式 + +适配器插件会自动注册到全局插件注册表,无需额外配置。通过标准的插件系统调用即可: + +```bash +# 扫描特定端口 +fscan -h target -p 445 + +# 使用特定插件 +fscan -h target -m ms17010,smb2 +``` + +## 未来扩展 + +如需添加更多老版本插件适配器,按以下步骤操作: + +1. 在此目录下创建新的插件目录 +2. 实现plugin.go文件,参考现有适配器 +3. 在core/Registry.go中添加import语句 +4. 更新此README文档 \ No newline at end of file diff --git a/adapters/legacy_plugins/elasticsearch/plugin.go b/adapters/legacy_plugins/elasticsearch/plugin.go new file mode 100644 index 0000000..868a28d --- /dev/null +++ b/adapters/legacy_plugins/elasticsearch/plugin.go @@ -0,0 +1,54 @@ +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) +} \ No newline at end of file diff --git a/adapters/legacy_plugins/ms17010/plugin.go b/adapters/legacy_plugins/ms17010/plugin.go new file mode 100644 index 0000000..ff35ced --- /dev/null +++ b/adapters/legacy_plugins/ms17010/plugin.go @@ -0,0 +1,54 @@ +package ms17010 + +import ( + "github.com/shadow1ng/fscan/adapters" + "github.com/shadow1ng/fscan/plugins/base" + Plugins "github.com/shadow1ng/fscan/plugins" +) + +// NewMS17010Plugin 创建MS17010漏洞检测插件 +func NewMS17010Plugin() base.Plugin { + // 插件元数据 + metadata := &base.PluginMetadata{ + Name: "ms17010", + Version: "1.0.0", + Author: "fscan-team", + Description: "MS17010 SMB远程代码执行漏洞检测 (EternalBlue)", + Category: "vulnerability", + Ports: []int{445}, // SMB端口 + Protocols: []string{"tcp"}, + Tags: []string{"smb", "ms17010", "eternalblue", "vulnerability"}, + } + + // 适配器选项 + options := &adapters.LegacyPluginOptions{ + CheckBruteFlag: false, // MS17010不依赖暴力破解标志 + IsVulnPlugin: true, // 这是漏洞检测插件 + IsInfoPlugin: false, + CustomPorts: []int{445}, // 固定使用SMB端口 + } + + // 创建适配器,直接使用老版本的MS17010函数 + return adapters.NewLegacyPlugin(metadata, Plugins.MS17010, options) +} + +// init 自动注册MS17010插件 +func init() { + // 创建插件工厂 + metadata := &base.PluginMetadata{ + Name: "ms17010", + Version: "1.0.0", + Author: "fscan-team", + Description: "MS17010 SMB远程代码执行漏洞检测 (EternalBlue)", + Category: "vulnerability", + Ports: []int{445}, + Protocols: []string{"tcp"}, + Tags: []string{"smb", "ms17010", "eternalblue", "vulnerability"}, + } + + factory := base.NewSimplePluginFactory(metadata, func() base.Plugin { + return NewMS17010Plugin() + }) + + base.GlobalPluginRegistry.Register("ms17010", factory) +} \ No newline at end of file diff --git a/adapters/legacy_plugins/netbios/plugin.go b/adapters/legacy_plugins/netbios/plugin.go new file mode 100644 index 0000000..9227eca --- /dev/null +++ b/adapters/legacy_plugins/netbios/plugin.go @@ -0,0 +1,54 @@ +package netbios + +import ( + "github.com/shadow1ng/fscan/adapters" + "github.com/shadow1ng/fscan/plugins/base" + Plugins "github.com/shadow1ng/fscan/plugins" +) + +// NewNetBiosPlugin 创建NetBIOS信息收集插件 +func NewNetBiosPlugin() base.Plugin { + // 插件元数据 + metadata := &base.PluginMetadata{ + Name: "netbios", + Version: "1.0.0", + Author: "fscan-team", + Description: "NetBIOS信息收集和主机名解析", + Category: "information", + Ports: []int{139, 445}, // NetBIOS端口 + Protocols: []string{"tcp", "udp"}, + Tags: []string{"netbios", "information-gathering", "hostname", "smb"}, + } + + // 适配器选项 + options := &adapters.LegacyPluginOptions{ + CheckBruteFlag: false, // NetBIOS信息收集不依赖暴力破解标志 + IsVulnPlugin: false, // 这不是漏洞检测插件 + IsInfoPlugin: true, // 这是信息收集插件 + CustomPorts: []int{139, 445}, // NetBIOS/SMB端口 + } + + // 创建适配器,直接使用老版本的NetBIOS函数 + return adapters.NewLegacyPlugin(metadata, Plugins.NetBIOS, options) +} + +// init 自动注册NetBIOS插件 +func init() { + // 创建插件工厂 + metadata := &base.PluginMetadata{ + Name: "netbios", + Version: "1.0.0", + Author: "fscan-team", + Description: "NetBIOS信息收集和主机名解析", + Category: "information", + Ports: []int{139, 445}, + Protocols: []string{"tcp", "udp"}, + Tags: []string{"netbios", "information-gathering", "hostname", "smb"}, + } + + factory := base.NewSimplePluginFactory(metadata, func() base.Plugin { + return NewNetBiosPlugin() + }) + + base.GlobalPluginRegistry.Register("netbios", factory) +} \ No newline at end of file diff --git a/adapters/legacy_plugins/rdp/plugin.go b/adapters/legacy_plugins/rdp/plugin.go new file mode 100644 index 0000000..433d2c4 --- /dev/null +++ b/adapters/legacy_plugins/rdp/plugin.go @@ -0,0 +1,54 @@ +package rdp + +import ( + "github.com/shadow1ng/fscan/adapters" + "github.com/shadow1ng/fscan/plugins/base" + Plugins "github.com/shadow1ng/fscan/plugins" +) + +// NewRdpPlugin 创建RDP弱密码检测插件 +func NewRdpPlugin() base.Plugin { + // 插件元数据 + metadata := &base.PluginMetadata{ + Name: "rdp", + Version: "1.0.0", + Author: "fscan-team", + Description: "RDP远程桌面服务弱密码检测", + Category: "service", + Ports: []int{3389}, // RDP端口 + Protocols: []string{"tcp"}, + Tags: []string{"rdp", "remote-desktop", "weak-password", "service", "brute-force"}, + } + + // 适配器选项 + options := &adapters.LegacyPluginOptions{ + CheckBruteFlag: true, // RDP依赖暴力破解标志 + IsVulnPlugin: false, // 这是服务检测插件,不是漏洞检测 + IsInfoPlugin: false, // 主要是弱密码检测 + CustomPorts: []int{3389}, // RDP端口 + } + + // 创建适配器,直接使用老版本的RdpScan函数 + return adapters.NewLegacyPlugin(metadata, Plugins.RdpScan, options) +} + +// init 自动注册RDP插件 +func init() { + // 创建插件工厂 + metadata := &base.PluginMetadata{ + Name: "rdp", + Version: "1.0.0", + Author: "fscan-team", + Description: "RDP远程桌面服务弱密码检测", + Category: "service", + Ports: []int{3389}, + Protocols: []string{"tcp"}, + Tags: []string{"rdp", "remote-desktop", "weak-password", "service", "brute-force"}, + } + + factory := base.NewSimplePluginFactory(metadata, func() base.Plugin { + return NewRdpPlugin() + }) + + base.GlobalPluginRegistry.Register("rdp", factory) +} \ No newline at end of file diff --git a/adapters/legacy_plugins/smb/plugin.go b/adapters/legacy_plugins/smb/plugin.go new file mode 100644 index 0000000..769075d --- /dev/null +++ b/adapters/legacy_plugins/smb/plugin.go @@ -0,0 +1,54 @@ +package smb + +import ( + "github.com/shadow1ng/fscan/adapters" + "github.com/shadow1ng/fscan/plugins/base" + Plugins "github.com/shadow1ng/fscan/plugins" +) + +// NewSmbPlugin 创建SMB弱密码检测插件 +func NewSmbPlugin() base.Plugin { + // 插件元数据 + metadata := &base.PluginMetadata{ + Name: "smb", + Version: "1.0.0", + Author: "fscan-team", + Description: "SMB服务弱密码检测和共享枚举", + Category: "service", + Ports: []int{445, 139}, // SMB端口 + Protocols: []string{"tcp"}, + Tags: []string{"smb", "weak-password", "service", "brute-force"}, + } + + // 适配器选项 + options := &adapters.LegacyPluginOptions{ + CheckBruteFlag: true, // SMB依赖暴力破解标志 + IsVulnPlugin: false, // 这是服务检测插件,不是漏洞检测 + IsInfoPlugin: true, // 包含信息收集功能 + CustomPorts: []int{445, 139}, // SMB端口 + } + + // 创建适配器,直接使用老版本的SmbScan函数 + return adapters.NewLegacyPlugin(metadata, Plugins.SmbScan, options) +} + +// init 自动注册SMB插件 +func init() { + // 创建插件工厂 + metadata := &base.PluginMetadata{ + Name: "smb", + Version: "1.0.0", + Author: "fscan-team", + Description: "SMB服务弱密码检测和共享枚举", + Category: "service", + Ports: []int{445, 139}, + Protocols: []string{"tcp"}, + Tags: []string{"smb", "weak-password", "service", "brute-force"}, + } + + factory := base.NewSimplePluginFactory(metadata, func() base.Plugin { + return NewSmbPlugin() + }) + + base.GlobalPluginRegistry.Register("smb", factory) +} \ No newline at end of file diff --git a/adapters/legacy_plugins/smb2/plugin.go b/adapters/legacy_plugins/smb2/plugin.go new file mode 100644 index 0000000..d7b0168 --- /dev/null +++ b/adapters/legacy_plugins/smb2/plugin.go @@ -0,0 +1,54 @@ +package smb2 + +import ( + "github.com/shadow1ng/fscan/adapters" + "github.com/shadow1ng/fscan/plugins/base" + Plugins "github.com/shadow1ng/fscan/plugins" +) + +// NewSmb2Plugin 创建SMB2弱密码检测插件 +func NewSmb2Plugin() base.Plugin { + // 插件元数据 + metadata := &base.PluginMetadata{ + Name: "smb2", + Version: "1.0.0", + Author: "fscan-team", + Description: "SMB2服务弱密码检测和共享枚举 (支持NTLM哈希)", + Category: "service", + Ports: []int{445}, // SMB2端口 + Protocols: []string{"tcp"}, + Tags: []string{"smb2", "weak-password", "service", "brute-force", "ntlm"}, + } + + // 适配器选项 + options := &adapters.LegacyPluginOptions{ + CheckBruteFlag: true, // SMB2依赖暴力破解标志 + IsVulnPlugin: false, // 这是服务检测插件,不是漏洞检测 + IsInfoPlugin: true, // 包含信息收集功能 + CustomPorts: []int{445}, // SMB2端口 + } + + // 创建适配器,直接使用老版本的SmbScan2函数 + return adapters.NewLegacyPlugin(metadata, Plugins.SmbScan2, options) +} + +// init 自动注册SMB2插件 +func init() { + // 创建插件工厂 + metadata := &base.PluginMetadata{ + Name: "smb2", + Version: "1.0.0", + Author: "fscan-team", + Description: "SMB2服务弱密码检测和共享枚举 (支持NTLM哈希)", + Category: "service", + Ports: []int{445}, + Protocols: []string{"tcp"}, + Tags: []string{"smb2", "weak-password", "service", "brute-force", "ntlm"}, + } + + factory := base.NewSimplePluginFactory(metadata, func() base.Plugin { + return NewSmb2Plugin() + }) + + base.GlobalPluginRegistry.Register("smb2", factory) +} \ No newline at end of file diff --git a/adapters/legacy_plugins/smbghost/plugin.go b/adapters/legacy_plugins/smbghost/plugin.go new file mode 100644 index 0000000..37315e5 --- /dev/null +++ b/adapters/legacy_plugins/smbghost/plugin.go @@ -0,0 +1,54 @@ +package smbghost + +import ( + "github.com/shadow1ng/fscan/adapters" + "github.com/shadow1ng/fscan/plugins/base" + Plugins "github.com/shadow1ng/fscan/plugins" +) + +// NewSmbGhostPlugin 创建SMBGhost漏洞检测插件 +func NewSmbGhostPlugin() base.Plugin { + // 插件元数据 + metadata := &base.PluginMetadata{ + Name: "smbghost", + Version: "1.0.0", + Author: "fscan-team", + Description: "SMBGhost (CVE-2020-0796) 远程代码执行漏洞检测", + Category: "vulnerability", + Ports: []int{445}, // SMB端口 + Protocols: []string{"tcp"}, + Tags: []string{"smb", "smbghost", "cve-2020-0796", "vulnerability"}, + } + + // 适配器选项 + options := &adapters.LegacyPluginOptions{ + CheckBruteFlag: false, // SMBGhost不依赖暴力破解标志 + IsVulnPlugin: true, // 这是漏洞检测插件 + IsInfoPlugin: false, + CustomPorts: []int{445}, // 固定使用SMB端口 + } + + // 创建适配器,直接使用老版本的SmbGhost函数 + return adapters.NewLegacyPlugin(metadata, Plugins.SmbGhost, options) +} + +// init 自动注册SmbGhost插件 +func init() { + // 创建插件工厂 + metadata := &base.PluginMetadata{ + Name: "smbghost", + Version: "1.0.0", + Author: "fscan-team", + Description: "SMBGhost (CVE-2020-0796) 远程代码执行漏洞检测", + Category: "vulnerability", + Ports: []int{445}, + Protocols: []string{"tcp"}, + Tags: []string{"smb", "smbghost", "cve-2020-0796", "vulnerability"}, + } + + factory := base.NewSimplePluginFactory(metadata, func() base.Plugin { + return NewSmbGhostPlugin() + }) + + base.GlobalPluginRegistry.Register("smbghost", factory) +} \ No newline at end of file