Ping - RDP Check & Port Scanning
Ping - RDP Check & Port Scanning
Some of the feedback on the articles I wrote presented a concern of not being able to use or download Nmap on the
network:
Port scanning and reconnaissance via NMAP By: Larry Brasher | LinkedIn
Stealth Port Scanning. Stealth, Decoy or Zombie. By: Larry Brasher | LinkedIn
Well, all is not lost as you can create your own port scanner with the Windows inbox Powershell, at least to some degree.
While not as robust or feature rich as NMAP, the script I wrote does allow you to scan servers in a text file list via
whatever range you want to specify for TCP.
Disclaimer: The script in question was created and tested in my own home lab, on my own time, at my own expense and
resources. There is no proprietary code from any source listed other than what is native to powershell and\or publicly
listed. Any and all resources used or referenced are fully open to the public, such as TechNet for example.
Disclaimer: The script in question was created and tested in my own home lab, on my own time, at my own expense and
resources. There is no proprietary code from any source listed other than what is native to powershell and\or publicly
listed. Any and all resources used or referenced are fully open to the public, such as TechNet for example.
Warning: The port scanning script should be used with caution. While simple to use and simple in its scripting, if used on
your network without consent, it could be detected by security monitoring tools as an exploit or reconnaissance attempt.
A test-netconnection for “A” port, singular, is of no consequence but against a range of ports can be prone to a different
interpretation of intent. I personally will NOT be doing such a thing at work against a range of ports. If you are part of
the security team and you have management approval then you are covered as management is aware. Never assume
you are not violating any company policy but rather err on the side of caution and find out first. All of this is up to YOU
to find out as each company is different.
And of course the notice given should you give a response for something other than “P” or “R”.
Script
*************************
function Test-Connectivity {
$date= Get-date
$choice = Read-Host "Do you want to ping (P) or test RDP port 3389 (R) on $server?"
# Ping option
if ($result. TcpTestSucceeded) {
} else {
} else {
Write-Host "Invalid choice. Please select 'P' for ping or 'T' for RDP port testing." -ForegroundColor Red
Test-Connectivity
This script scans against a list of servers for a range of ports. The range of course can be altered to whatever you want.
Note that this is for TCP and not UDP.
Port Scan against a list of computers. Output is only for listening ports. You can alter the port range as you see fit in red
below:
********************
Function PortScanv2 {
if ($result.TcpTestSucceeded) {
PortScanv2
#END
Output