Created
February 19, 2025 21:27
-
-
Save joshfinley/6c87fe00cdb82b9a1468f9c1efbda701 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define the target host | |
$target = "192.168.1.1" # Change this to your target IP or hostname | |
# 100 most common ports | |
$ports = @(21, 22, 23, 25, 26, 37, 53, 67, 68, 69, 80, 81, 88, 110, 111, 123, 135, 137, 138, 139, 143, 161, 162, 179, 199, 389, 427, 443, 445, 465, 500, 514, 515, 520, 523, 524, 548, 554, 587, 623, 636, 873, 902, 989, 990, 993, 995, 1025, 1080, 1194, 1433, 1723, 2049, 2082, 2083, 2181, 2195, 3128, 3268, 3306, 3389, 3690, 4000, 4045, 4369, 4500, 4664, 4899, 5000, 5060, 5190, 5222, 5432, 5500, 5631, 5900, 6000, 6379, 6665, 6666, 6667, 7001, 7002, 8000, 8008, 8080, 8081, 8443, 8888, 9000, 9090, 9100, 9418, 9999, 10000, 32768, 49152, 49153, 49154, 49155, 49156, 49157) | |
# Function to check open ports | |
function Check-Port { | |
param ( | |
[string]$ip, | |
[int]$port | |
) | |
$tcp = New-Object System.Net.Sockets.TcpClient | |
if ($tcp.ConnectAsync($ip, $port).Wait(100)) { | |
Write-Output "Port $port is OPEN on $ip" | |
} | |
$tcp.Close() | |
} | |
# Scan ports and only print open ones | |
foreach ($port in $ports) { | |
Check-Port -ip $target -port $port | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment