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

- 新增Kafka插件支持9092等端口扫描 - 实现SASL PLAIN认证机制支持 - 支持弱密码暴力破解和服务识别功能 - 延迟连接设计避免SASL握手错误 - 支持Consumer和Client双重连接验证 - 完善Kafka相关国际化消息支持 - 兼容新插件架构设计模式
97 lines
2.9 KiB
Go
97 lines
2.9 KiB
Go
package core
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/shadow1ng/fscan/common"
|
|
"github.com/shadow1ng/fscan/plugins/base"
|
|
|
|
// 导入新架构插件,触发自动注册
|
|
_ "github.com/shadow1ng/fscan/plugins/services/activemq"
|
|
_ "github.com/shadow1ng/fscan/plugins/services/cassandra"
|
|
_ "github.com/shadow1ng/fscan/plugins/services/ftp"
|
|
_ "github.com/shadow1ng/fscan/plugins/services/imap"
|
|
_ "github.com/shadow1ng/fscan/plugins/services/kafka"
|
|
_ "github.com/shadow1ng/fscan/plugins/services/mysql"
|
|
_ "github.com/shadow1ng/fscan/plugins/services/redis"
|
|
_ "github.com/shadow1ng/fscan/plugins/services/ssh"
|
|
)
|
|
|
|
// =============================================================================
|
|
// 新一代插件注册系统 (New Architecture)
|
|
// 完全基于工厂模式和自动发现的现代化插件架构
|
|
// =============================================================================
|
|
|
|
// InitializePluginSystem 初始化插件系统
|
|
func InitializePluginSystem() error {
|
|
common.LogInfo("初始化新一代插件系统...")
|
|
|
|
// 统计已注册的插件
|
|
registeredPlugins := base.GlobalPluginRegistry.GetAll()
|
|
common.LogInfo(fmt.Sprintf("已注册插件数量: %d", len(registeredPlugins)))
|
|
|
|
// 显示已注册的插件列表
|
|
if len(registeredPlugins) > 0 {
|
|
common.LogInfo("已注册插件:")
|
|
for _, name := range registeredPlugins {
|
|
metadata := base.GlobalPluginRegistry.GetMetadata(name)
|
|
if metadata != nil {
|
|
common.LogInfo(fmt.Sprintf(" - %s v%s (%s)",
|
|
metadata.Name, metadata.Version, metadata.Category))
|
|
}
|
|
}
|
|
}
|
|
|
|
common.LogInfo("插件系统初始化完成")
|
|
return nil
|
|
}
|
|
|
|
// GetAllPlugins 获取所有已注册插件名称
|
|
func GetAllPlugins() []string {
|
|
return base.GlobalPluginRegistry.GetAll()
|
|
}
|
|
|
|
// GetPluginMetadata 获取插件元数据
|
|
func GetPluginMetadata(name string) *base.PluginMetadata {
|
|
return base.GlobalPluginRegistry.GetMetadata(name)
|
|
}
|
|
|
|
// CreatePlugin 创建插件实例
|
|
func CreatePlugin(name string) (base.Plugin, error) {
|
|
return base.GlobalPluginRegistry.Create(name)
|
|
}
|
|
|
|
// GetPluginsByCategory 按类别获取插件
|
|
func GetPluginsByCategory(category string) []string {
|
|
var plugins []string
|
|
for _, name := range base.GlobalPluginRegistry.GetAll() {
|
|
if metadata := base.GlobalPluginRegistry.GetMetadata(name); metadata != nil {
|
|
if metadata.Category == category {
|
|
plugins = append(plugins, name)
|
|
}
|
|
}
|
|
}
|
|
return plugins
|
|
}
|
|
|
|
// GetPluginsByPort 按端口获取插件
|
|
func GetPluginsByPort(port int) []string {
|
|
var plugins []string
|
|
for _, name := range base.GlobalPluginRegistry.GetAll() {
|
|
if metadata := base.GlobalPluginRegistry.GetMetadata(name); metadata != nil {
|
|
for _, p := range metadata.Ports {
|
|
if p == port {
|
|
plugins = append(plugins, name)
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return plugins
|
|
}
|
|
|
|
// init 自动初始化插件系统
|
|
func init() {
|
|
if err := InitializePluginSystem(); err != nil {
|
|
common.LogError("插件系统初始化失败: " + err.Error())
|
|
}
|
|
} |