← All Tweaks
Firewall & Security
Block SMB Port 445
Block incoming SMB traffic on port 445 to prevent ransomware attacks
Benefit
Significantly improves security by blocking major attack vector for ransomware and worms
Impact
highCommands (1)
$ErrorActionPreference='Continue'; $name = 'CodeWinOpt-Block-SMB-445'; $r = Get-NetFirewallRule -DisplayName $name -ErrorAction SilentlyContinue; if ($r) { Write-Host "[OK] Rule '$name' already exists" } else { try { New-NetFirewallRule -DisplayName $name -Direction Inbound -Action Block -Protocol TCP -LocalPort 445 -Profile Any -Description 'Block inbound SMB on port 445 (CodeWinOptimizer)' -ErrorAction Stop | Out-Null; Write-Host "[OK] Created firewall rule '$name' blocking inbound TCP 445" } catch { Write-Host "[ERR] $($_.Exception.Message)" } }Warnings
- Port 445 is the primary vector for ransomware propagation on Windows networks. Blocking is highly recommended unless you require SMB shares.