Saturday, May 18, 2024
HomePowershellExterior Port Scan utilizing PowerShell

Exterior Port Scan utilizing PowerShell


I need to scan my web site and see which ports are opened, and the scan supply must be exterior. There are some web sites and companies which give a port scan, however with some limitations. So I wrote a PowerShell script to carry out an exterior port scanning via considered one of these port scanning suppliers.

Stipulations

You want Home windows PowerShell 5.1 or 7 and an web connection. The service used on this tutorial is IP Finger Print, so ensure you can entry this web site and isn’t blocked.

This service is easy and free with no limitation “until the date of writing this publish” possibly issues will change sooner or later. Let me know.

Downloading PowerShell Port Scan Script

Be at liberty and obtain the script from my Github repo or by working the next PowerShell line

Set up-Script -Identify PortScan

Utilizing PowerShell Port Scan Script

The script accepts the next parameters:

[String]HostToScan: The Identify or IP handle of the host to scan e.g. “www.powershellcenter.com” or 8.8.8.8

[ParameterSet=Range][Int]StartingPort: The primary IP to scan on a variety e.g 25

[ParameterSet=Range][Int]EndingPort: The final IP to scan on a variety e.g 80

[ParameterSet=SelectivePort][Int]SelectivePort: A set of customized ports to scan e.g 25,80,443

For instance, to scan www.powershellcenter.com for all open ports ranging from port 25 until 80, use the next code

PortScan.ps1 -HostToScan 'www.powershellcenter.com' -StartingPort 25 -EndingPort 80

The output seems like

open ports
Open ports

Dont use the PowerShell port scan script to scan a hug vary as it’d delay the outcome and trigger surprising outcomes. And dont overlook that the script rely on an exterior service to do the scan so one thing issues go creepy there 🙂

To scan customized ports for instance 25,80,443,555,888 run the next code

PortScan.ps1 -HostToScan 'www.powershellcenter.com' -SelectivePort 25,80,443,555,888

The outcomes seem like the next

Host                     Port Outcome
----                     ---- ------
www.powershellcenter.com 25   Open
www.powershellcenter.com 80   Open
www.powershellcenter.com 443  Open
www.powershellcenter.com 555  Filtered
www.powershellcenter.com 888  Filtered

This script is just for private use and I’m not chargeable for any miss-use

Extra options will likely be added within the quickly future. Be at liberty and remark under on which function you want to incorporate, or get a Github fork and replace what you would like.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments