fscan/plugins/services/oracle.go
ZacharyZcR f8c8f3d1eb refactor: 重构MSSQL和Oracle插件使用统一发包控制
- 修改MSSQL插件,在testCredential和identifyService中添加发包控制
- 修改Oracle插件,虽然是占位代码,但为一致性添加发包检查
- 统一包计数逻辑,确保TCP连接成功和失败都正确计数
- 完成数据库插件系列的发包控制统一改造
2025-09-02 11:46:42 +00:00

76 lines
1.6 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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})
}