<# .SYNOPSIS Lab 09.3 — Agentless Schannel Event ID 36880 PQC Handshake Audit (255-bit vs 1216-bit) .DESCRIPTION Reads Windows System Event Log for Schannel handshake telemetry (Event ID 36880) and TLS failure events (36874, 36888, 36871) to separate hybrid PQC handshakes (>= 1000 bits, e.g., 1216 bits for X25519_MLKEM768) from classical handshakes (255/256 bits). Optionally toggles Schannel EventLogging temporarily for pilot verification. Classification : Read-only audit (default) / temporary audit config (-EnableTempLogging) Required Roles : Local Administrator or Event Log Readers .NOTES Author : Caner Cetinkaya (canercetinkaya.com/labs/09-post-quantum-cryptography/) #> [CmdletBinding()] param( [int]$HoursBack = 24, [switch]$EnableTempLogging, [switch]$RestoreDefaultLogging ) Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' $regPath = 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL' if ($EnableTempLogging) { Set-ItemProperty -Path $regPath -Name EventLogging -Value 7 -Type DWord Write-Host 'Schannel EventLogging temporarily set to 7 (Verbose). Remember to restore to 1 after pilot capture.' -ForegroundColor Yellow } if ($RestoreDefaultLogging) { Set-ItemProperty -Path $regPath -Name EventLogging -Value 1 -Type DWord Write-Host 'Schannel EventLogging restored to default value 1.' -ForegroundColor Green return } $events = Get-WinEvent -FilterHashtable @{ LogName = 'System' ProviderName = 'Schannel' Id = @(36880, 36874, 36888, 36871) StartTime = (Get-Date).AddHours(-$HoursBack) } -ErrorAction SilentlyContinue if (-not $events) { Write-Warning "No Schannel 36880/36874/36888/36871 events found in the last $HoursBack hours." return } $events | ForEach-Object { $msg = $_.Message $proto = if ($msg -match 'Protocol version:\s*(.+)') { $Matches[1].Trim() } else { '-' } $suite = if ($msg -match 'CipherSuite:\s*(\S+)') { $Matches[1].Trim() } else { '-' } $bits = if ($msg -match 'Exchange strength:\s*(\d+)') { [int]$Matches[1] } else { 0 } $sni = if ($msg -match 'Target name:\s*(.+)') { $Matches[1].Trim() } else { '-' } [PSCustomObject]@{ TimeCreated = $_.TimeCreated EventId = $_.Id Protocol = $proto CipherSuite = $suite ExchangeBit = $bits PqcHybrid = ($bits -ge 1000) Target = $sni } } | Format-Table -AutoSize