Evaluation:
$enabledProtocolList = @("TLS 1.2","TLS 1.3")
$disabledProtocolList = @("SSL 2.0","SSL 3.0","TLS 1.0", "TLS 1.1")
$ProtocolSubKeyList = @("Client", "Server")
$Enabled = "Enabled"
$registryPath = "HKLM:\\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\"
$evalCount = 0
foreach($Protocol in $enabledProtocolList)
{
foreach($key in $ProtocolSubKeyList)
{
$currentRegPath = $registryPath + $Protocol + "\" + $key
Write-Host "Checking" $currentRegPath
$currentEnableValue = Get-ItemProperty -Path $currentRegPath -name $Enabled
if($currentEnableValue.Enabled -ne 1)
{
$errorMsg = ""error]" + $protocol + "\" + $key + " is set to disabled. Not compliant."
Write-Host $errorMsg
$evalCount ++
}
}
}
foreach($Protocol in $disabledProtocolList)
{
foreach($key in $ProtocolSubKeyList)
{
$currentRegPath = $registryPath + $Protocol + "\" + $key
Write-Host "Checking" $currentRegPath
$currentEnableValue = Get-ItemProperty -Path $currentRegPath -name $Enabled
if($currentEnableValue -eq 1)
{
$errorMsg = ""error]" + $protocol + "\" + $key + " is set to enabled. Not compliant."
Write-Host $errorMsg
$evalCount ++
}
}
}
if($evalCount > 0)
{
exit 1
}
else
{
exit 0
}
Remediation:
$ProtocolList = @("SSL 2.0","SSL 3.0","TLS 1.0", "TLS 1.1", "TLS 1.2", "TLS 1.3")
$ProtocolSubKeyList = @("Client", "Server")
$DisabledByDefault = "DisabledByDefault"
$Enabled = "Enabled"
$registryPath = "HKLM:\\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\"
foreach($Protocol in $ProtocolList)
{
Write-Host " In 1st For loop"
foreach($key in $ProtocolSubKeyList)
{
$currentRegPath = $registryPath + $Protocol + "\" + $key
Write-Host " Current Registry Path $currentRegPath"
if(!(Test-Path $currentRegPath))
{
Write-Host "creating the registry"
New-Item -Path $currentRegPath -Force | out-Null
}
if($Protocol -eq "TLS 1.2")
{
Write-Host "Working for TLS 1.2"
New-ItemProperty -Path $currentRegPath -Name $DisabledByDefault -Value "0" -PropertyType DWORD -Force | Out-Null
New-ItemProperty -Path $currentRegPath -Name $Enabled -Value "1" -PropertyType DWORD -Force | Out-Null
}
if($Protocol -eq "TLS 1.3")
{
Write-Host "Working for TLS 1.3"
New-ItemProperty -Path $currentRegPath -Name $DisabledByDefault -Value "0" -PropertyType DWORD -Force | Out-Null
New-ItemProperty -Path $currentRegPath -Name $Enabled -Value "1" -PropertyType DWORD -Force | Out-Null
else
{
Write-Host "Working for other protocol"
New-ItemProperty -Path $currentRegPath -Name $DisabledByDefault -Value "1" -PropertyType DWORD -Force | Out-Null
New-ItemProperty -Path $currentRegPath -Name $Enabled -Value "0" -PropertyType DWORD -Force | Out-Null
}
}
}