mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-09-14 05:56:46 +08:00

- 修改MSSQL插件,在testCredential和identifyService中添加发包控制 - 修改Oracle插件,虽然是占位代码,但为一致性添加发包检查 - 统一包计数逻辑,确保TCP连接成功和失败都正确计数 - 完成数据库插件系列的发包控制统一改造
76 lines
1.6 KiB
Go
76 lines
1.6 KiB
Go
package services
|
||
|
||
import (
|
||
"context"
|
||
"fmt"
|
||
|
||
"github.com/shadow1ng/fscan/common"
|
||
"github.com/shadow1ng/fscan/plugins"
|
||
)
|
||
|
||
type OraclePlugin struct {
|
||
plugins.BasePlugin
|
||
}
|
||
|
||
func NewOraclePlugin() *OraclePlugin {
|
||
return &OraclePlugin{
|
||
BasePlugin: plugins.NewBasePlugin("oracle"),
|
||
}
|
||
}
|
||
|
||
|
||
|
||
func (p *OraclePlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {
|
||
if common.DisableBrute {
|
||
return p.identifyService(ctx, info)
|
||
}
|
||
|
||
// Oracle驱动未安装,但保持与其他插件一致的发包检查
|
||
if canSend, reason := common.CanSendPacket(); !canSend {
|
||
common.LogError(fmt.Sprintf("Oracle连接 %s:%s 受限: %s", info.Host, info.Ports, reason))
|
||
return &ScanResult{
|
||
Success: false,
|
||
Service: "oracle",
|
||
Error: fmt.Errorf("发包受限: %s", reason),
|
||
}
|
||
}
|
||
|
||
return &ScanResult{
|
||
Success: false,
|
||
Service: "oracle",
|
||
Error: fmt.Errorf("Oracle驱动未安装"),
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
func (p *OraclePlugin) identifyService(ctx context.Context, info *common.HostInfo) *ScanResult {
|
||
// 保持与其他插件一致的发包检查
|
||
if canSend, reason := common.CanSendPacket(); !canSend {
|
||
common.LogError(fmt.Sprintf("Oracle识别 %s:%s 受限: %s", info.Host, info.Ports, reason))
|
||
return &ScanResult{
|
||
Success: false,
|
||
Service: "oracle",
|
||
Error: fmt.Errorf("发包受限: %s", reason),
|
||
}
|
||
}
|
||
|
||
return &ScanResult{
|
||
Success: false,
|
||
Service: "oracle",
|
||
Error: fmt.Errorf("Oracle驱动未安装"),
|
||
}
|
||
}
|
||
|
||
func init() {
|
||
// 使用高效注册方式:直接传递端口信息,避免实例创建
|
||
RegisterPluginWithPorts("oracle", func() Plugin {
|
||
return NewOraclePlugin()
|
||
}, []int{1521, 1522, 1525})
|
||
} |