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

- 为所有平台特定插件添加正确的编译标签 - Linux插件添加 //go:build linux 标签 - Windows插件添加 //go:build windows 标签 - 重构本地插件注册方式 - 从main.go移至core包统一管理 - 创建平台特定的注册文件实现条件编译 - 修正参数文档中minidump平台支持描述 - 优化插件注册架构,提升代码组织性
136 lines
5.0 KiB
Go
136 lines
5.0 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"
|
|
_ "github.com/shadow1ng/fscan/plugins/services/telnet"
|
|
|
|
// 导入Legacy插件适配器
|
|
_ "github.com/shadow1ng/fscan/plugins/legacy/netbios"
|
|
_ "github.com/shadow1ng/fscan/plugins/legacy/ms17010"
|
|
_ "github.com/shadow1ng/fscan/plugins/legacy/smb"
|
|
_ "github.com/shadow1ng/fscan/plugins/legacy/smb2"
|
|
_ "github.com/shadow1ng/fscan/plugins/legacy/smbghost"
|
|
_ "github.com/shadow1ng/fscan/plugins/legacy/rdp"
|
|
_ "github.com/shadow1ng/fscan/plugins/legacy/elasticsearch"
|
|
_ "github.com/shadow1ng/fscan/plugins/legacy/findnet"
|
|
|
|
// 导入Web插件适配器
|
|
_ "github.com/shadow1ng/fscan/plugins/legacy/webtitle"
|
|
_ "github.com/shadow1ng/fscan/plugins/legacy/webpoc"
|
|
|
|
// 导入跨平台本地插件
|
|
_ "github.com/shadow1ng/fscan/plugins/local/fileinfo" // 文件信息收集
|
|
_ "github.com/shadow1ng/fscan/plugins/local/dcinfo" // 域控信息收集
|
|
_ "github.com/shadow1ng/fscan/plugins/local/reverseshell" // 反弹Shell
|
|
_ "github.com/shadow1ng/fscan/plugins/local/socks5proxy" // SOCKS5代理
|
|
_ "github.com/shadow1ng/fscan/plugins/local/avdetect" // 杀毒软件检测
|
|
_ "github.com/shadow1ng/fscan/plugins/local/forwardshell" // 正向Shell
|
|
_ "github.com/shadow1ng/fscan/plugins/local/keylogger" // 跨平台键盘记录
|
|
_ "github.com/shadow1ng/fscan/plugins/local/downloader" // 跨平台文件下载
|
|
_ "github.com/shadow1ng/fscan/plugins/local/cleaner" // 跨平台系统痕迹清理
|
|
)
|
|
|
|
// =============================================================================
|
|
// 新一代插件注册系统 (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())
|
|
}
|
|
} |