test

mail@pastecode.io avatar
unknown
powershell
a month ago
996 B
2
Indexable
Never
# Function to check if a port is open
function Check-Port {
    param (
        [int]$port
    )
    $result = netstat -ano | find $port | find "LISTENING"
    return $result.TcpTestSucceeded
}

# Arrays to store blocked ports
$blockedPorts = @()

# Check STUN/TURN Servers
$stunPorts = @(3478)
foreach ($port in $stunPorts) {
    if (-not (Check-Port -port $port)) {
        $blockedPorts += $port
    }
}

# Check Signaling Ports
$signalingPorts = @(80, 443)
foreach ($port in $signalingPorts) {
    if (-not (Check-Port -port $port)) {
        $blockedPorts += $port
    }
}

# Check Media Ports (Dynamic Range)
$mediaPorts = 1024..65535
foreach ($port in $mediaPorts) {
    if (-not (Check-Port -port $port)) {
        $blockedPorts += $port
    }
}

# Report
$totalPorts = $stunPorts.Count + $signalingPorts.Count + $mediaPorts.Count
$blockedCount = $blockedPorts.Count
Write-Host "$blockedCount out of $totalPorts ports are blocked."
Write-Host "Blocked ports: $($blockedPorts -join ', ')"
Leave a Comment