From 8f54702c0210c0aec1d8b5d109b4347c0a58cb9f Mon Sep 17 00:00:00 2001 From: ZacharyZcR Date: Tue, 26 Aug 2025 20:38:39 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=B2=BE=E5=87=86=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=8F=92=E4=BB=B6=E7=B3=BB=E7=BB=9F=E4=B8=89=E4=B8=AA?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 经Linus式架构审计,发现并修复插件系统中的具体问题: ## 核心修复 ### 1. 消除local插件GetPorts()方法冗余 - 删除21个local插件中无意义的GetPorts()方法 - 简化local.Plugin接口:移除端口概念 - 理由:本地插件不涉及网络,端口概念完全多余 ### 2. 消除web插件GetPorts()方法冗余 - 删除2个web插件中无用的GetPorts()方法 - 简化web.WebPlugin接口:专注智能HTTP检测 - 理由:Web插件使用动态HTTP检测,预定义端口无价值 ### 3. 统一插件命名规范 - 统一所有插件接口使用Name()方法(符合Go惯例) - 消除GetName()与Name()不一致问题 - 简化适配器:不再需要方法名转换 ## 技术改进 接口精简: - local插件:GetName() + GetPorts() → Name() - web插件:GetName() + GetPorts() → Name() - services插件:GetName() → Name()(保留GetPorts(),业务必需) 代码减少: - 删除23个无用GetPorts()方法 - 重命名52个Name()方法 - 简化3个插件接口定义 ## 影响范围 修改文件:55个插件文件 代码变更:-155行 +61行(净减少94行) 功能影响:零破坏性,保持所有业务逻辑不变 这是基于业务需求分析的精准重构,消除真正多余的部分, 保持系统架构合理性和向后兼容性。 --- plugins/local/avdetect.go | 6 +----- plugins/local/cleaner.go | 6 +----- plugins/local/crontask.go | 6 +----- plugins/local/dcinfo.go | 6 +----- plugins/local/downloader.go | 6 +----- plugins/local/envinfo.go | 6 +----- plugins/local/fileinfo.go | 6 +----- plugins/local/forwardshell.go | 6 +----- plugins/local/keylogger.go | 6 +----- plugins/local/ldpreload.go | 6 +----- plugins/local/minidump.go | 6 +----- plugins/local/reverseshell.go | 6 +----- plugins/local/shellenv.go | 6 +----- plugins/local/socks5proxy.go | 6 +----- plugins/local/systemdservice.go | 6 +----- plugins/local/systeminfo.go | 6 +----- plugins/local/types.go | 7 +++---- plugins/local/winregistry.go | 6 +----- plugins/local/winschtask.go | 6 +----- plugins/local/winservice.go | 6 +----- plugins/local/winstartup.go | 6 +----- plugins/local/winwmi.go | 6 +----- plugins/services/activemq.go | 2 +- plugins/services/cassandra.go | 2 +- plugins/services/elasticsearch.go | 2 +- plugins/services/findnet.go | 2 +- plugins/services/ftp.go | 2 +- plugins/services/kafka.go | 2 +- plugins/services/ldap.go | 2 +- plugins/services/memcached.go | 2 +- plugins/services/mongodb.go | 2 +- plugins/services/ms17010.go | 2 +- plugins/services/mssql.go | 2 +- plugins/services/mysql.go | 2 +- plugins/services/neo4j.go | 2 +- plugins/services/netbios.go | 2 +- plugins/services/oracle.go | 2 +- plugins/services/postgresql.go | 2 +- plugins/services/rabbitmq.go | 2 +- plugins/services/rdp.go | 2 +- plugins/services/redis.go | 2 +- plugins/services/rsync.go | 2 +- plugins/services/smb.go | 2 +- plugins/services/smb2.go | 2 +- plugins/services/smbghost.go | 2 +- plugins/services/smbinfo.go | 2 +- plugins/services/smtp.go | 2 +- plugins/services/snmp.go | 2 +- plugins/services/ssh.go | 2 +- plugins/services/telnet.go | 2 +- plugins/services/types.go | 6 +++--- plugins/services/vnc.go | 2 +- plugins/web/types.go | 7 +++---- plugins/web/webpoc.go | 6 +----- plugins/web/webtitle.go | 6 +----- 55 files changed, 61 insertions(+), 155 deletions(-) diff --git a/plugins/local/avdetect.go b/plugins/local/avdetect.go index bd6d2c8..a7af5fc 100644 --- a/plugins/local/avdetect.go +++ b/plugins/local/avdetect.go @@ -50,14 +50,10 @@ func NewAVDetectPlugin() *AVDetectPlugin { } // GetName 实现Plugin接口 -func (p *AVDetectPlugin) GetName() string { +func (p *AVDetectPlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - local插件不需要端口 -func (p *AVDetectPlugin) GetPorts() []int { - return []int{} -} // Scan 执行AV/EDR检测 - 直接、有效 func (p *AVDetectPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { diff --git a/plugins/local/cleaner.go b/plugins/local/cleaner.go index dcbeaa0..badde1c 100644 --- a/plugins/local/cleaner.go +++ b/plugins/local/cleaner.go @@ -29,14 +29,10 @@ func NewCleanerPlugin() *CleanerPlugin { } // GetName 实现Plugin接口 -func (p *CleanerPlugin) GetName() string { +func (p *CleanerPlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - local插件不需要端口 -func (p *CleanerPlugin) GetPorts() []int { - return []int{} -} // Scan 执行系统痕迹清理 - 直接、简单 func (p *CleanerPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { diff --git a/plugins/local/crontask.go b/plugins/local/crontask.go index ab9796d..e73a457 100644 --- a/plugins/local/crontask.go +++ b/plugins/local/crontask.go @@ -40,14 +40,10 @@ func NewCronTaskPlugin() *CronTaskPlugin { } // GetName 实现Plugin接口 -func (p *CronTaskPlugin) GetName() string { +func (p *CronTaskPlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - local插件不需要端口 -func (p *CronTaskPlugin) GetPorts() []int { - return []int{} -} // Scan 执行计划任务持久化 - 直接实现 func (p *CronTaskPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { diff --git a/plugins/local/dcinfo.go b/plugins/local/dcinfo.go index 0f1cd51..4396f1a 100644 --- a/plugins/local/dcinfo.go +++ b/plugins/local/dcinfo.go @@ -39,14 +39,10 @@ func NewDCInfoPlugin() *DCInfoPlugin { } // GetName 实现Plugin接口 -func (p *DCInfoPlugin) GetName() string { +func (p *DCInfoPlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - local插件不需要端口 -func (p *DCInfoPlugin) GetPorts() []int { - return []int{} -} // Scan 执行域控信息收集 - 直接实现 func (p *DCInfoPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { diff --git a/plugins/local/downloader.go b/plugins/local/downloader.go index ec0d0f4..379c09a 100644 --- a/plugins/local/downloader.go +++ b/plugins/local/downloader.go @@ -40,14 +40,10 @@ func NewDownloaderPlugin() *DownloaderPlugin { } // GetName 实现Plugin接口 -func (p *DownloaderPlugin) GetName() string { +func (p *DownloaderPlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - local插件不需要端口 -func (p *DownloaderPlugin) GetPorts() []int { - return []int{} -} // Scan 执行文件下载任务 - 直接实现 func (p *DownloaderPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { diff --git a/plugins/local/envinfo.go b/plugins/local/envinfo.go index fd73e96..142e6be 100644 --- a/plugins/local/envinfo.go +++ b/plugins/local/envinfo.go @@ -28,14 +28,10 @@ func NewEnvInfoPlugin() *EnvInfoPlugin { } // GetName 实现Plugin接口 -func (p *EnvInfoPlugin) GetName() string { +func (p *EnvInfoPlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - local插件不需要端口 -func (p *EnvInfoPlugin) GetPorts() []int { - return []int{} -} // Scan 执行环境变量收集 - 直接、有效 func (p *EnvInfoPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { diff --git a/plugins/local/fileinfo.go b/plugins/local/fileinfo.go index fdd10f8..4ce05e4 100644 --- a/plugins/local/fileinfo.go +++ b/plugins/local/fileinfo.go @@ -30,14 +30,10 @@ func NewFileInfoPlugin() *FileInfoPlugin { } // GetName 实现Plugin接口 -func (p *FileInfoPlugin) GetName() string { +func (p *FileInfoPlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - local插件不需要端口 -func (p *FileInfoPlugin) GetPorts() []int { - return []int{} -} // Scan 执行本地文件扫描 - 直接、简单、有效 func (p *FileInfoPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { diff --git a/plugins/local/forwardshell.go b/plugins/local/forwardshell.go index e5e98fd..f655e20 100644 --- a/plugins/local/forwardshell.go +++ b/plugins/local/forwardshell.go @@ -40,14 +40,10 @@ func NewForwardShellPlugin() *ForwardShellPlugin { } // GetName 实现Plugin接口 -func (p *ForwardShellPlugin) GetName() string { +func (p *ForwardShellPlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - local插件不需要端口 -func (p *ForwardShellPlugin) GetPorts() []int { - return []int{} -} // Scan 执行正向Shell服务 - 直接实现 func (p *ForwardShellPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { diff --git a/plugins/local/keylogger.go b/plugins/local/keylogger.go index af52944..27ac7c3 100644 --- a/plugins/local/keylogger.go +++ b/plugins/local/keylogger.go @@ -43,14 +43,10 @@ func NewKeyloggerPlugin() *KeyloggerPlugin { } // GetName 实现Plugin接口 -func (p *KeyloggerPlugin) GetName() string { +func (p *KeyloggerPlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - local插件不需要端口 -func (p *KeyloggerPlugin) GetPorts() []int { - return []int{} -} // Scan 执行键盘记录 - 直接实现 func (p *KeyloggerPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { diff --git a/plugins/local/ldpreload.go b/plugins/local/ldpreload.go index e5bcbbb..126d7e2 100644 --- a/plugins/local/ldpreload.go +++ b/plugins/local/ldpreload.go @@ -39,14 +39,10 @@ func NewLDPreloadPlugin() *LDPreloadPlugin { } // GetName 实现Plugin接口 -func (p *LDPreloadPlugin) GetName() string { +func (p *LDPreloadPlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - local插件不需要端口 -func (p *LDPreloadPlugin) GetPorts() []int { - return []int{} -} // Scan 执行LD_PRELOAD持久化 - 直接实现 func (p *LDPreloadPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { diff --git a/plugins/local/minidump.go b/plugins/local/minidump.go index 555fd1c..6df78dc 100644 --- a/plugins/local/minidump.go +++ b/plugins/local/minidump.go @@ -82,14 +82,10 @@ func NewMiniDumpPlugin() *MiniDumpPlugin { } // GetName 实现Plugin接口 -func (p *MiniDumpPlugin) GetName() string { +func (p *MiniDumpPlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - local插件不需要端口 -func (p *MiniDumpPlugin) GetPorts() []int { - return []int{} -} // Scan 执行内存转储 - 直接实现 func (p *MiniDumpPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { diff --git a/plugins/local/reverseshell.go b/plugins/local/reverseshell.go index cfc6ddc..6ebd8d9 100644 --- a/plugins/local/reverseshell.go +++ b/plugins/local/reverseshell.go @@ -56,14 +56,10 @@ func NewReverseShellPlugin() *ReverseShellPlugin { } // GetName 实现Plugin接口 -func (p *ReverseShellPlugin) GetName() string { +func (p *ReverseShellPlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - local插件不需要端口 -func (p *ReverseShellPlugin) GetPorts() []int { - return []int{} -} // Scan 执行反弹Shell - 直接实现 func (p *ReverseShellPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { diff --git a/plugins/local/shellenv.go b/plugins/local/shellenv.go index 7c44762..2dc6340 100644 --- a/plugins/local/shellenv.go +++ b/plugins/local/shellenv.go @@ -39,14 +39,10 @@ func NewShellEnvPlugin() *ShellEnvPlugin { } // GetName 实现Plugin接口 -func (p *ShellEnvPlugin) GetName() string { +func (p *ShellEnvPlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - local插件不需要端口 -func (p *ShellEnvPlugin) GetPorts() []int { - return []int{} -} // Scan 执行Shell环境变量持久化 - 直接实现 func (p *ShellEnvPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { diff --git a/plugins/local/socks5proxy.go b/plugins/local/socks5proxy.go index 7e189d9..dfa409b 100644 --- a/plugins/local/socks5proxy.go +++ b/plugins/local/socks5proxy.go @@ -39,14 +39,10 @@ func NewSocks5ProxyPlugin() *Socks5ProxyPlugin { } // GetName 实现Plugin接口 -func (p *Socks5ProxyPlugin) GetName() string { +func (p *Socks5ProxyPlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - local插件不需要端口 -func (p *Socks5ProxyPlugin) GetPorts() []int { - return []int{} -} // Scan 执行SOCKS5代理扫描 - 直接实现 func (p *Socks5ProxyPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { diff --git a/plugins/local/systemdservice.go b/plugins/local/systemdservice.go index fed5a01..8e7d195 100644 --- a/plugins/local/systemdservice.go +++ b/plugins/local/systemdservice.go @@ -39,14 +39,10 @@ func NewSystemdServicePlugin() *SystemdServicePlugin { } // GetName 实现Plugin接口 -func (p *SystemdServicePlugin) GetName() string { +func (p *SystemdServicePlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - local插件不需要端口 -func (p *SystemdServicePlugin) GetPorts() []int { - return []int{} -} // Scan 执行系统服务持久化 - 直接实现 func (p *SystemdServicePlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { diff --git a/plugins/local/systeminfo.go b/plugins/local/systeminfo.go index 43365f4..1fc3ce6 100644 --- a/plugins/local/systeminfo.go +++ b/plugins/local/systeminfo.go @@ -30,14 +30,10 @@ func NewSystemInfoPlugin() *SystemInfoPlugin { } // GetName 实现Plugin接口 -func (p *SystemInfoPlugin) GetName() string { +func (p *SystemInfoPlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - local插件不需要端口 -func (p *SystemInfoPlugin) GetPorts() []int { - return []int{} -} // Scan 执行系统信息收集 - 直接、简单、有效 func (p *SystemInfoPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { diff --git a/plugins/local/types.go b/plugins/local/types.go index 5539966..e5afbb3 100644 --- a/plugins/local/types.go +++ b/plugins/local/types.go @@ -9,10 +9,9 @@ import ( "github.com/shadow1ng/fscan/plugins" ) -// 向后兼容的类型别名 +// 本地插件接口 - 不需要端口概念 type Plugin interface { - GetName() string - GetPorts() []int + Name() string Scan(ctx context.Context, info *common.HostInfo) *ScanResult } @@ -40,7 +39,7 @@ type localPluginAdapter struct { } func (a *localPluginAdapter) Name() string { - return a.localPlugin.GetName() + return a.localPlugin.Name() } func (a *localPluginAdapter) Scan(ctx context.Context, info *common.HostInfo) *plugins.Result { diff --git a/plugins/local/winregistry.go b/plugins/local/winregistry.go index 4edf44d..e909ce0 100644 --- a/plugins/local/winregistry.go +++ b/plugins/local/winregistry.go @@ -38,14 +38,10 @@ func NewWinRegistryPlugin() *WinRegistryPlugin { } // GetName 实现Plugin接口 -func (p *WinRegistryPlugin) GetName() string { +func (p *WinRegistryPlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - local插件不需要端口 -func (p *WinRegistryPlugin) GetPorts() []int { - return []int{} -} // Scan 执行Windows注册表持久化 - 直接实现 func (p *WinRegistryPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { diff --git a/plugins/local/winschtask.go b/plugins/local/winschtask.go index ee1bc5d..49bd5af 100644 --- a/plugins/local/winschtask.go +++ b/plugins/local/winschtask.go @@ -38,14 +38,10 @@ func NewWinSchTaskPlugin() *WinSchTaskPlugin { } // GetName 实现Plugin接口 -func (p *WinSchTaskPlugin) GetName() string { +func (p *WinSchTaskPlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - local插件不需要端口 -func (p *WinSchTaskPlugin) GetPorts() []int { - return []int{} -} // Scan 执行Windows计划任务持久化 - 直接实现 func (p *WinSchTaskPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { diff --git a/plugins/local/winservice.go b/plugins/local/winservice.go index 06ae283..c70066c 100644 --- a/plugins/local/winservice.go +++ b/plugins/local/winservice.go @@ -38,14 +38,10 @@ func NewWinServicePlugin() *WinServicePlugin { } // GetName 实现Plugin接口 -func (p *WinServicePlugin) GetName() string { +func (p *WinServicePlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - local插件不需要端口 -func (p *WinServicePlugin) GetPorts() []int { - return []int{} -} // Scan 执行Windows服务持久化 - 直接实现 func (p *WinServicePlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { diff --git a/plugins/local/winstartup.go b/plugins/local/winstartup.go index 44d2321..7ae6da8 100644 --- a/plugins/local/winstartup.go +++ b/plugins/local/winstartup.go @@ -38,14 +38,10 @@ func NewWinStartupPlugin() *WinStartupPlugin { } // GetName 实现Plugin接口 -func (p *WinStartupPlugin) GetName() string { +func (p *WinStartupPlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - local插件不需要端口 -func (p *WinStartupPlugin) GetPorts() []int { - return []int{} -} // Scan 执行Windows启动文件夹持久化 - 直接实现 func (p *WinStartupPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { diff --git a/plugins/local/winwmi.go b/plugins/local/winwmi.go index e7a863b..6e24b84 100644 --- a/plugins/local/winwmi.go +++ b/plugins/local/winwmi.go @@ -38,14 +38,10 @@ func NewWinWMIPlugin() *WinWMIPlugin { } // GetName 实现Plugin接口 -func (p *WinWMIPlugin) GetName() string { +func (p *WinWMIPlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - local插件不需要端口 -func (p *WinWMIPlugin) GetPorts() []int { - return []int{} -} // Scan 执行Windows WMI事件订阅持久化 - 直接实现 func (p *WinWMIPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { diff --git a/plugins/services/activemq.go b/plugins/services/activemq.go index cf71f84..849c51e 100644 --- a/plugins/services/activemq.go +++ b/plugins/services/activemq.go @@ -22,7 +22,7 @@ func NewActiveMQPlugin() *ActiveMQPlugin { } } -func (p *ActiveMQPlugin) GetName() string { +func (p *ActiveMQPlugin) Name() string { return p.name } diff --git a/plugins/services/cassandra.go b/plugins/services/cassandra.go index 982ef89..f289c0c 100644 --- a/plugins/services/cassandra.go +++ b/plugins/services/cassandra.go @@ -23,7 +23,7 @@ func NewCassandraPlugin() *CassandraPlugin { } } -func (p *CassandraPlugin) GetName() string { +func (p *CassandraPlugin) Name() string { return p.name } diff --git a/plugins/services/elasticsearch.go b/plugins/services/elasticsearch.go index 4942e33..5c7aaf1 100644 --- a/plugins/services/elasticsearch.go +++ b/plugins/services/elasticsearch.go @@ -25,7 +25,7 @@ func NewElasticsearchPlugin() *ElasticsearchPlugin { } } -func (p *ElasticsearchPlugin) GetName() string { +func (p *ElasticsearchPlugin) Name() string { return p.name } diff --git a/plugins/services/findnet.go b/plugins/services/findnet.go index 40442e0..d0c017d 100644 --- a/plugins/services/findnet.go +++ b/plugins/services/findnet.go @@ -30,7 +30,7 @@ func NewFindNetPlugin() *FindNetPlugin { } // GetName 实现Plugin接口 -func (p *FindNetPlugin) GetName() string { +func (p *FindNetPlugin) Name() string { return p.name } diff --git a/plugins/services/ftp.go b/plugins/services/ftp.go index f1abfba..243a97c 100644 --- a/plugins/services/ftp.go +++ b/plugins/services/ftp.go @@ -21,7 +21,7 @@ func NewFTPPlugin() *FTPPlugin { } } -func (p *FTPPlugin) GetName() string { +func (p *FTPPlugin) Name() string { return p.name } diff --git a/plugins/services/kafka.go b/plugins/services/kafka.go index 749e6b4..e7b4107 100644 --- a/plugins/services/kafka.go +++ b/plugins/services/kafka.go @@ -21,7 +21,7 @@ func NewKafkaPlugin() *KafkaPlugin { } } -func (p *KafkaPlugin) GetName() string { +func (p *KafkaPlugin) Name() string { return p.name } diff --git a/plugins/services/ldap.go b/plugins/services/ldap.go index 63bc1af..7d0d203 100644 --- a/plugins/services/ldap.go +++ b/plugins/services/ldap.go @@ -20,7 +20,7 @@ func NewLDAPPlugin() *LDAPPlugin { } } -func (p *LDAPPlugin) GetName() string { +func (p *LDAPPlugin) Name() string { return p.name } diff --git a/plugins/services/memcached.go b/plugins/services/memcached.go index d8377bc..6bdc215 100644 --- a/plugins/services/memcached.go +++ b/plugins/services/memcached.go @@ -22,7 +22,7 @@ func NewMemcachedPlugin() *MemcachedPlugin { } } -func (p *MemcachedPlugin) GetName() string { +func (p *MemcachedPlugin) Name() string { return p.name } diff --git a/plugins/services/mongodb.go b/plugins/services/mongodb.go index d835cbf..3d91d2a 100644 --- a/plugins/services/mongodb.go +++ b/plugins/services/mongodb.go @@ -22,7 +22,7 @@ func NewMongoDBPlugin() *MongoDBPlugin { } } -func (p *MongoDBPlugin) GetName() string { +func (p *MongoDBPlugin) Name() string { return p.name } diff --git a/plugins/services/ms17010.go b/plugins/services/ms17010.go index f14051a..7eab284 100644 --- a/plugins/services/ms17010.go +++ b/plugins/services/ms17010.go @@ -31,7 +31,7 @@ func NewMS17010Plugin() *MS17010Plugin { } // GetName 实现Plugin接口 -func (p *MS17010Plugin) GetName() string { +func (p *MS17010Plugin) Name() string { return p.name } diff --git a/plugins/services/mssql.go b/plugins/services/mssql.go index bad19bf..8561dc3 100644 --- a/plugins/services/mssql.go +++ b/plugins/services/mssql.go @@ -23,7 +23,7 @@ func NewMSSQLPlugin() *MSSQLPlugin { } } -func (p *MSSQLPlugin) GetName() string { +func (p *MSSQLPlugin) Name() string { return p.name } diff --git a/plugins/services/mysql.go b/plugins/services/mysql.go index 04c0f37..48d4e84 100644 --- a/plugins/services/mysql.go +++ b/plugins/services/mysql.go @@ -23,7 +23,7 @@ func NewMySQLPlugin() *MySQLPlugin { } } -func (p *MySQLPlugin) GetName() string { +func (p *MySQLPlugin) Name() string { return p.name } diff --git a/plugins/services/neo4j.go b/plugins/services/neo4j.go index f64bea6..49462c7 100644 --- a/plugins/services/neo4j.go +++ b/plugins/services/neo4j.go @@ -23,7 +23,7 @@ func NewNeo4jPlugin() *Neo4jPlugin { } } -func (p *Neo4jPlugin) GetName() string { +func (p *Neo4jPlugin) Name() string { return p.name } diff --git a/plugins/services/netbios.go b/plugins/services/netbios.go index 2753563..3d59ddf 100644 --- a/plugins/services/netbios.go +++ b/plugins/services/netbios.go @@ -26,7 +26,7 @@ func NewNetBIOSPlugin() *NetBIOSPlugin { } // GetName 实现Plugin接口 -func (p *NetBIOSPlugin) GetName() string { +func (p *NetBIOSPlugin) Name() string { return p.name } diff --git a/plugins/services/oracle.go b/plugins/services/oracle.go index ad52c25..5b41dbc 100644 --- a/plugins/services/oracle.go +++ b/plugins/services/oracle.go @@ -19,7 +19,7 @@ func NewOraclePlugin() *OraclePlugin { } } -func (p *OraclePlugin) GetName() string { +func (p *OraclePlugin) Name() string { return p.name } diff --git a/plugins/services/postgresql.go b/plugins/services/postgresql.go index 2443c3b..71d6cc8 100644 --- a/plugins/services/postgresql.go +++ b/plugins/services/postgresql.go @@ -23,7 +23,7 @@ func NewPostgreSQLPlugin() *PostgreSQLPlugin { } } -func (p *PostgreSQLPlugin) GetName() string { +func (p *PostgreSQLPlugin) Name() string { return p.name } diff --git a/plugins/services/rabbitmq.go b/plugins/services/rabbitmq.go index 48c2833..39253ae 100644 --- a/plugins/services/rabbitmq.go +++ b/plugins/services/rabbitmq.go @@ -23,7 +23,7 @@ func NewRabbitMQPlugin() *RabbitMQPlugin { } } -func (p *RabbitMQPlugin) GetName() string { +func (p *RabbitMQPlugin) Name() string { return p.name } diff --git a/plugins/services/rdp.go b/plugins/services/rdp.go index 75fbd26..06c9c1b 100644 --- a/plugins/services/rdp.go +++ b/plugins/services/rdp.go @@ -25,7 +25,7 @@ func NewRDPPlugin() *RDPPlugin { } // GetName 实现Plugin接口 -func (p *RDPPlugin) GetName() string { +func (p *RDPPlugin) Name() string { return p.name } diff --git a/plugins/services/redis.go b/plugins/services/redis.go index 3705c11..b84422f 100644 --- a/plugins/services/redis.go +++ b/plugins/services/redis.go @@ -27,7 +27,7 @@ func NewRedisPlugin() *RedisPlugin { } // GetName 实现Plugin接口 -func (p *RedisPlugin) GetName() string { +func (p *RedisPlugin) Name() string { return p.name } diff --git a/plugins/services/rsync.go b/plugins/services/rsync.go index 9dc0f47..908bb04 100644 --- a/plugins/services/rsync.go +++ b/plugins/services/rsync.go @@ -23,7 +23,7 @@ func NewRsyncPlugin() *RsyncPlugin { } } -func (p *RsyncPlugin) GetName() string { +func (p *RsyncPlugin) Name() string { return p.name } diff --git a/plugins/services/smb.go b/plugins/services/smb.go index a9207fc..8a4ffba 100644 --- a/plugins/services/smb.go +++ b/plugins/services/smb.go @@ -24,7 +24,7 @@ func NewSmbPlugin() *SmbPlugin { } // GetName 实现Plugin接口 -func (p *SmbPlugin) GetName() string { +func (p *SmbPlugin) Name() string { return p.name } diff --git a/plugins/services/smb2.go b/plugins/services/smb2.go index cee46c6..2d722cb 100644 --- a/plugins/services/smb2.go +++ b/plugins/services/smb2.go @@ -24,7 +24,7 @@ func NewSmb2Plugin() *Smb2Plugin { } // GetName 实现Plugin接口 -func (p *Smb2Plugin) GetName() string { +func (p *Smb2Plugin) Name() string { return p.name } diff --git a/plugins/services/smbghost.go b/plugins/services/smbghost.go index 3056dba..163c448 100644 --- a/plugins/services/smbghost.go +++ b/plugins/services/smbghost.go @@ -110,7 +110,7 @@ func NewSmbGhostPlugin() *SmbGhostPlugin { } // GetName 实现Plugin接口 -func (p *SmbGhostPlugin) GetName() string { +func (p *SmbGhostPlugin) Name() string { return p.name } diff --git a/plugins/services/smbinfo.go b/plugins/services/smbinfo.go index de9103b..1fcde04 100644 --- a/plugins/services/smbinfo.go +++ b/plugins/services/smbinfo.go @@ -27,7 +27,7 @@ func NewSMBInfoPlugin() *SMBInfoPlugin { } // GetName 实现Plugin接口 -func (p *SMBInfoPlugin) GetName() string { +func (p *SMBInfoPlugin) Name() string { return p.name } diff --git a/plugins/services/smtp.go b/plugins/services/smtp.go index 6b84139..dc2a21d 100644 --- a/plugins/services/smtp.go +++ b/plugins/services/smtp.go @@ -24,7 +24,7 @@ func NewSMTPPlugin() *SMTPPlugin { } } -func (p *SMTPPlugin) GetName() string { +func (p *SMTPPlugin) Name() string { return p.name } diff --git a/plugins/services/snmp.go b/plugins/services/snmp.go index 4339918..b17b1a7 100644 --- a/plugins/services/snmp.go +++ b/plugins/services/snmp.go @@ -22,7 +22,7 @@ func NewSNMPPlugin() *SNMPPlugin { } } -func (p *SNMPPlugin) GetName() string { +func (p *SNMPPlugin) Name() string { return p.name } diff --git a/plugins/services/ssh.go b/plugins/services/ssh.go index 6039cc6..74d4db1 100644 --- a/plugins/services/ssh.go +++ b/plugins/services/ssh.go @@ -29,7 +29,7 @@ func NewSSHPlugin() *SSHPlugin { } // GetName 实现Plugin接口 -func (p *SSHPlugin) GetName() string { +func (p *SSHPlugin) Name() string { return p.name } diff --git a/plugins/services/telnet.go b/plugins/services/telnet.go index 98e7bf1..edc6c45 100644 --- a/plugins/services/telnet.go +++ b/plugins/services/telnet.go @@ -22,7 +22,7 @@ func NewTelnetPlugin() *TelnetPlugin { } } -func (p *TelnetPlugin) GetName() string { +func (p *TelnetPlugin) Name() string { return p.name } diff --git a/plugins/services/types.go b/plugins/services/types.go index 67ac187..aff029b 100644 --- a/plugins/services/types.go +++ b/plugins/services/types.go @@ -7,9 +7,9 @@ import ( "github.com/shadow1ng/fscan/plugins" ) -// 插件接口定义 +// 插件接口定义 - 统一命名风格 type Plugin interface { - GetName() string + Name() string GetPorts() []int Scan(ctx context.Context, info *common.HostInfo) *ScanResult } @@ -43,7 +43,7 @@ type servicePluginAdapter struct { } func (a *servicePluginAdapter) Name() string { - return a.servicePlugin.GetName() + return a.servicePlugin.Name() } func (a *servicePluginAdapter) Scan(ctx context.Context, info *common.HostInfo) *plugins.Result { diff --git a/plugins/services/vnc.go b/plugins/services/vnc.go index 25c734d..9b5a2f2 100644 --- a/plugins/services/vnc.go +++ b/plugins/services/vnc.go @@ -24,7 +24,7 @@ func NewVNCPlugin() *VNCPlugin { } } -func (p *VNCPlugin) GetName() string { +func (p *VNCPlugin) Name() string { return p.name } diff --git a/plugins/web/types.go b/plugins/web/types.go index d5c0146..02d8378 100644 --- a/plugins/web/types.go +++ b/plugins/web/types.go @@ -7,10 +7,9 @@ import ( "github.com/shadow1ng/fscan/plugins" ) -// 向后兼容的类型别名 +// Web插件接口 - 使用智能HTTP检测,不需要预定义端口 type WebPlugin interface { - GetName() string - GetPorts() []int + Name() string Scan(ctx context.Context, info *common.HostInfo) *WebScanResult } @@ -33,7 +32,7 @@ type webPluginAdapter struct { } func (a *webPluginAdapter) Name() string { - return a.webPlugin.GetName() + return a.webPlugin.Name() } func (a *webPluginAdapter) Scan(ctx context.Context, info *common.HostInfo) *plugins.Result { diff --git a/plugins/web/webpoc.go b/plugins/web/webpoc.go index bcd28b6..115806b 100644 --- a/plugins/web/webpoc.go +++ b/plugins/web/webpoc.go @@ -21,14 +21,10 @@ func NewWebPocPlugin() *WebPocPlugin { } // GetName 实现Plugin接口 -func (p *WebPocPlugin) GetName() string { +func (p *WebPocPlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - Web插件不需要预定义端口,依赖全局检测器 -func (p *WebPocPlugin) GetPorts() []int { - return []int{} -} // Scan 执行Web POC扫描 func (p *WebPocPlugin) Scan(ctx context.Context, info *common.HostInfo) *WebScanResult { diff --git a/plugins/web/webtitle.go b/plugins/web/webtitle.go index abc0c31..1fa00c0 100644 --- a/plugins/web/webtitle.go +++ b/plugins/web/webtitle.go @@ -27,14 +27,10 @@ func NewWebTitlePlugin() *WebTitlePlugin { } // GetName 实现Plugin接口 -func (p *WebTitlePlugin) GetName() string { +func (p *WebTitlePlugin) Name() string { return p.name } -// GetPorts 实现Plugin接口 - Web插件不需要预定义端口 -func (p *WebTitlePlugin) GetPorts() []int { - return []int{} -} // Scan 执行WebTitle扫描 func (p *WebTitlePlugin) Scan(ctx context.Context, info *common.HostInfo) *WebScanResult {