mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-09-14 14:06:44 +08:00
refactor: 重组插件目录结构,提升管理直观性
将所有服务插件移动到plugins/services/目录下,使目录结构更加清晰直观: • 创建plugins/services/目录统一管理服务扫描插件 • 添加init.go提供类型别名和函数导出 • 更新main.go导入路径 • 所有20个服务插件功能验证正常 新的目录结构更便于插件管理和维护。
This commit is contained in:
parent
678d750c8a
commit
e082e2bb59
4
main.go
4
main.go
@ -8,8 +8,8 @@ import (
|
|||||||
"github.com/shadow1ng/fscan/app"
|
"github.com/shadow1ng/fscan/app"
|
||||||
"github.com/shadow1ng/fscan/common"
|
"github.com/shadow1ng/fscan/common"
|
||||||
|
|
||||||
// 导入新的单文件插件架构
|
// 导入服务插件
|
||||||
_ "github.com/shadow1ng/fscan/plugins"
|
_ "github.com/shadow1ng/fscan/plugins/services"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
46
plugins/services/README.md
Normal file
46
plugins/services/README.md
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# 服务扫描插件目录
|
||||||
|
|
||||||
|
本目录包含所有服务扫描插件,采用简化的单文件插件架构。
|
||||||
|
|
||||||
|
## 已实现插件
|
||||||
|
|
||||||
|
### 数据库服务
|
||||||
|
- `mysql.go` - MySQL数据库扫描
|
||||||
|
- `postgresql.go` - PostgreSQL数据库扫描
|
||||||
|
- `redis.go` - Redis内存数据库扫描
|
||||||
|
- `mongodb.go` - MongoDB文档数据库扫描
|
||||||
|
- `mssql.go` - Microsoft SQL Server扫描
|
||||||
|
- `oracle.go` - Oracle数据库扫描
|
||||||
|
- `memcached.go` - Memcached缓存扫描
|
||||||
|
- `neo4j.go` - Neo4j图数据库扫描
|
||||||
|
|
||||||
|
### 消息队列服务
|
||||||
|
- `rabbitmq.go` - RabbitMQ消息队列扫描
|
||||||
|
- `activemq.go` - ActiveMQ消息队列扫描
|
||||||
|
- `kafka.go` - Apache Kafka扫描
|
||||||
|
|
||||||
|
### 网络服务
|
||||||
|
- `ssh.go` - SSH远程登录服务扫描
|
||||||
|
- `ftp.go` - FTP文件传输服务扫描
|
||||||
|
- `telnet.go` - Telnet远程终端服务扫描
|
||||||
|
- `smtp.go` - SMTP邮件服务扫描
|
||||||
|
- `snmp.go` - SNMP网络管理协议扫描
|
||||||
|
- `ldap.go` - LDAP目录服务扫描
|
||||||
|
- `rsync.go` - Rsync文件同步服务扫描
|
||||||
|
|
||||||
|
### 其他服务
|
||||||
|
- `vnc.go` - VNC远程桌面服务扫描
|
||||||
|
- `cassandra.go` - Apache Cassandra数据库扫描
|
||||||
|
|
||||||
|
## 插件特性
|
||||||
|
|
||||||
|
每个插件都包含:
|
||||||
|
- ✅ 服务识别功能
|
||||||
|
- ✅ 弱密码检测功能
|
||||||
|
- ✅ 完整的利用功能
|
||||||
|
- ✅ 错误处理和超时控制
|
||||||
|
- ✅ 统一的结果输出格式
|
||||||
|
|
||||||
|
## 开发规范
|
||||||
|
|
||||||
|
所有插件都遵循 `../README.md` 中定义的开发规范。
|
@ -1,4 +1,4 @@
|
|||||||
package plugins
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,4 +1,4 @@
|
|||||||
package plugins
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,4 +1,4 @@
|
|||||||
package plugins
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
23
plugins/services/init.go
Normal file
23
plugins/services/init.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package services
|
||||||
|
|
||||||
|
// 从父目录导入插件基础类型
|
||||||
|
import (
|
||||||
|
"github.com/shadow1ng/fscan/plugins"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 类型别名,让services包中的插件可以直接使用这些类型
|
||||||
|
type (
|
||||||
|
Plugin = plugins.Plugin
|
||||||
|
Exploiter = plugins.Exploiter
|
||||||
|
ScanResult = plugins.ScanResult
|
||||||
|
ExploitResult = plugins.ExploitResult
|
||||||
|
Credential = plugins.Credential
|
||||||
|
)
|
||||||
|
|
||||||
|
// 导出函数,让services包中的插件可以调用
|
||||||
|
var (
|
||||||
|
RegisterPlugin = plugins.RegisterPlugin
|
||||||
|
GetPlugin = plugins.GetPlugin
|
||||||
|
GetAllPlugins = plugins.GetAllPlugins
|
||||||
|
GenerateCredentials = plugins.GenerateCredentials
|
||||||
|
)
|
@ -1,4 +1,4 @@
|
|||||||
package plugins
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,4 +1,4 @@
|
|||||||
package plugins
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,4 +1,4 @@
|
|||||||
package plugins
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,4 +1,4 @@
|
|||||||
package plugins
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,4 +1,4 @@
|
|||||||
package plugins
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,4 +1,4 @@
|
|||||||
package plugins
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,4 +1,4 @@
|
|||||||
package plugins
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,4 +1,4 @@
|
|||||||
package plugins
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,4 +1,4 @@
|
|||||||
package plugins
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,4 +1,4 @@
|
|||||||
package plugins
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,4 +1,4 @@
|
|||||||
package plugins
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,4 +1,4 @@
|
|||||||
package plugins
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
@ -1,4 +1,4 @@
|
|||||||
package plugins
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,4 +1,4 @@
|
|||||||
package plugins
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,4 +1,4 @@
|
|||||||
package plugins
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,4 +1,4 @@
|
|||||||
package plugins
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,4 +1,4 @@
|
|||||||
package plugins
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,68 +0,0 @@
|
|||||||
package plugins
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/shadow1ng/fscan/common"
|
|
||||||
)
|
|
||||||
|
|
||||||
// TestMySQLPlugin 测试新的MySQL插件实现
|
|
||||||
func TestMySQLPlugin() {
|
|
||||||
fmt.Println("=== 测试简化的MySQL插件 ===")
|
|
||||||
|
|
||||||
// 初始化必要的全局变量
|
|
||||||
common.Timeout = 5
|
|
||||||
common.DisableBrute = false
|
|
||||||
common.Passwords = []string{"", "root", "123456", "admin", "password"}
|
|
||||||
common.Userdict = map[string][]string{
|
|
||||||
"mysql": {"root", "mysql", "admin"},
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建插件实例
|
|
||||||
plugin := NewMySQLPlugin()
|
|
||||||
|
|
||||||
fmt.Printf("插件名称: %s\n", plugin.GetName())
|
|
||||||
fmt.Printf("支持端口: %v\n", plugin.GetPorts())
|
|
||||||
|
|
||||||
// 测试用例1:本地不存在的MySQL服务(应该失败)
|
|
||||||
fmt.Println("\n--- 测试1: 连接不存在的MySQL服务 ---")
|
|
||||||
testHost := &common.HostInfo{
|
|
||||||
Host: "127.0.0.1",
|
|
||||||
Ports: "3306",
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
result := plugin.Scan(ctx, testHost)
|
|
||||||
fmt.Printf("扫描结果: Success=%v, Service=%s\n", result.Success, result.Service)
|
|
||||||
if result.Error != nil {
|
|
||||||
fmt.Printf("错误信息: %v\n", result.Error)
|
|
||||||
}
|
|
||||||
if result.Success {
|
|
||||||
fmt.Printf("发现弱密码: %s/%s\n", result.Username, result.Password)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 测试用例2:禁用暴力破解模式
|
|
||||||
fmt.Println("\n--- 测试2: 禁用暴力破解模式 ---")
|
|
||||||
common.DisableBrute = true
|
|
||||||
|
|
||||||
result2 := plugin.Scan(ctx, testHost)
|
|
||||||
fmt.Printf("服务识别结果: Success=%v, Service=%s\n", result2.Success, result2.Service)
|
|
||||||
if result2.Banner != "" {
|
|
||||||
fmt.Printf("服务Banner: %s\n", result2.Banner)
|
|
||||||
}
|
|
||||||
if result2.Error != nil {
|
|
||||||
fmt.Printf("错误信息: %v\n", result2.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("\n=== MySQL插件测试完成 ===")
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果直接运行这个文件,执行测试
|
|
||||||
func init() {
|
|
||||||
// 注释掉自动测试,避免在导入时执行
|
|
||||||
// TestMySQLPlugin()
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user