Skip to content

Creating a Port Scanner with Windows PowerShell

<#
Creating a Port Scanner with Windows PowerShell

Creating a Port Scanner with Windows PowerShell


#>
# Creating a Port Scanner with Windows PowerShell
$port = 80
$net = “192.168.1”
$range = 1..254

foreach ($r in $range)
{
$ip = “{0}.{1}” -F $net,$r

if(Test-Connection -BufferSize 32 -Count 1 -Quiet -ComputerName $ip)
{
$socket = new-object System.Net.Sockets.TcpClient($ip, $port)

If($socket.Connected)
{
“$ip listening to port $port”
$socket.Close() }
}
}

Published inUncategorized

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *