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

- 新增SNMP服务插件,支持UDP协议和community字符串认证 - 实现SNMP连接器、利用器和主插件的完整架构 - 添加UDP端口161的特殊处理机制,解决UDP端口扫描问题 - 支持默认community字符串爆破(public, private, cisco, community) - 集成SNMP系统信息获取和服务识别功能 - 完善国际化消息支持和Docker测试环境配置
110 lines
3.6 KiB
Go
110 lines
3.6 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/ldap"
|
|
_ "github.com/shadow1ng/fscan/plugins/services/memcached"
|
|
_ "github.com/shadow1ng/fscan/plugins/services/modbus"
|
|
_ "github.com/shadow1ng/fscan/plugins/services/mongodb"
|
|
_ "github.com/shadow1ng/fscan/plugins/services/mssql"
|
|
_ "github.com/shadow1ng/fscan/plugins/services/mysql"
|
|
_ "github.com/shadow1ng/fscan/plugins/services/neo4j"
|
|
_ "github.com/shadow1ng/fscan/plugins/services/oracle"
|
|
_ "github.com/shadow1ng/fscan/plugins/services/pop3"
|
|
_ "github.com/shadow1ng/fscan/plugins/services/postgresql"
|
|
_ "github.com/shadow1ng/fscan/plugins/services/rabbitmq"
|
|
_ "github.com/shadow1ng/fscan/plugins/services/redis"
|
|
_ "github.com/shadow1ng/fscan/plugins/services/rsync"
|
|
_ "github.com/shadow1ng/fscan/plugins/services/smtp"
|
|
_ "github.com/shadow1ng/fscan/plugins/services/snmp"
|
|
_ "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())
|
|
}
|
|
} |