mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-09-14 14:06:44 +08:00

- 删除整个legacy插件系统(7794行代码) - 完成所有插件向单文件架构迁移 - 移除19个插件的虚假Exploit功能,只保留真实利用: * Redis: 文件写入、SSH密钥注入、计划任务 * SSH: 命令执行 * MS17010: EternalBlue漏洞利用 - 统一插件接口,简化架构复杂度 - 清理临时文件和备份文件 重构效果: - 代码行数: -7794行 - 插件文件数: 从3文件架构→单文件架构 - 真实利用插件: 从22个→3个 - 架构复杂度: 大幅简化
82 lines
2.2 KiB
Go
82 lines
2.2 KiB
Go
package core
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/shadow1ng/fscan/common"
|
|
"github.com/shadow1ng/fscan/plugins/services"
|
|
)
|
|
|
|
// PluginAdapter 插件适配器
|
|
// 提供从新插件系统到旧扫描接口的适配
|
|
type PluginAdapter struct{}
|
|
|
|
// NewPluginAdapter 创建插件适配器
|
|
func NewPluginAdapter() *PluginAdapter {
|
|
return &PluginAdapter{}
|
|
}
|
|
|
|
// 全局插件适配器实例
|
|
var GlobalPluginAdapter = NewPluginAdapter()
|
|
|
|
// GetAllPluginNames 获取所有插件名称
|
|
func (pa *PluginAdapter) GetAllPluginNames() []string {
|
|
return services.GetAllPlugins()
|
|
}
|
|
|
|
// PluginExists 检查插件是否存在
|
|
func (pa *PluginAdapter) PluginExists(name string) bool {
|
|
plugin := services.GetPlugin(name)
|
|
return plugin != nil
|
|
}
|
|
|
|
// 已移除未使用的 GetPluginPorts 方法
|
|
|
|
// 已移除未使用的 GetPluginsByPort 方法
|
|
|
|
// 已移除未使用的 GetPluginsByType 方法
|
|
|
|
// ScanWithPlugin 使用插件进行扫描
|
|
func (pa *PluginAdapter) ScanWithPlugin(pluginName string, info *common.HostInfo) error {
|
|
common.LogDebug(fmt.Sprintf("使用新插件架构扫描: %s", pluginName))
|
|
|
|
// 获取插件实例
|
|
plugin := services.GetPlugin(pluginName)
|
|
if plugin == nil {
|
|
return fmt.Errorf("插件 %s 不存在", pluginName)
|
|
}
|
|
|
|
// 执行扫描
|
|
result := plugin.Scan(context.Background(), info)
|
|
|
|
// 处理扫描结果
|
|
if result == nil {
|
|
common.LogDebug(fmt.Sprintf("插件 %s 返回了空结果", pluginName))
|
|
} else if result.Success {
|
|
common.LogDebug(fmt.Sprintf("插件 %s 扫描成功", pluginName))
|
|
|
|
// 如果插件支持利用功能且发现了弱密码,执行利用
|
|
if exploiter, ok := plugin.(services.Exploiter); ok && result.Username != "" {
|
|
creds := services.Credential{
|
|
Username: result.Username,
|
|
Password: result.Password,
|
|
}
|
|
exploitResult := exploiter.Exploit(context.Background(), info, creds)
|
|
if exploitResult != nil && exploitResult.Success {
|
|
common.LogDebug(fmt.Sprintf("插件 %s 利用成功", pluginName))
|
|
}
|
|
}
|
|
} else {
|
|
common.LogDebug(fmt.Sprintf("插件 %s 扫描失败: %v", pluginName, result.Error))
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// 已移除未使用的 FilterPluginsByType 方法
|
|
|
|
// 已移除未使用的 GetServicePlugins 方法
|
|
|
|
// 已移除未使用的 GetWebPlugins 方法
|
|
|
|
// 已移除未使用的 GetLocalPlugins 方法
|