diff --git a/plugins/services/smbghost.go b/plugins/services/smbghost.go index c0b7f69..e102ebf 100644 --- a/plugins/services/smbghost.go +++ b/plugins/services/smbghost.go @@ -156,11 +156,18 @@ func (p *SmbGhostPlugin) detectVulnerability(ctx context.Context, info *common.H addr := fmt.Sprintf("%s:445", info.Host) timeout := time.Duration(common.Timeout) * time.Second + // 检查发包限制 + if canSend, reason := common.CanSendPacket(); !canSend { + return false, fmt.Errorf("发包受限: %s", reason) + } + // 建立TCP连接 conn, err := common.WrapperTcpWithTimeout("tcp", addr, timeout) if err != nil { + common.IncrementTCPFailedPacketCount() return false, fmt.Errorf("连接失败: %v", err) } + common.IncrementTCPSuccessPacketCount() defer conn.Close() // 设置连接超时 @@ -200,10 +207,17 @@ func (p *SmbGhostPlugin) gatherSystemInfo(ctx context.Context, info *common.Host addr := fmt.Sprintf("%s:445", info.Host) timeout := time.Duration(common.Timeout) * time.Second - conn, err := common.WrapperTcpWithTimeout("tcp", addr, timeout) - if err != nil { + // 检查发包限制 + if canSend, _ := common.CanSendPacket(); !canSend { return "" } + + conn, err := common.WrapperTcpWithTimeout("tcp", addr, timeout) + if err != nil { + common.IncrementTCPFailedPacketCount() + return "" + } + common.IncrementTCPSuccessPacketCount() defer conn.Close() // 发送标准SMB协商请求获取系统信息