How to build a simple Port Scanner? Lets get started!
A port scanner is the process of running through a list of ports to see if they are open or not.
Using, sockets to provide the basic functionality of a port scanner. This is a form of "reconnaissance" for hackers and penetration testers.
- Run CMD as administrator.
- Once in the command prompt window, execute the command below.
netstat -ab
- After, you run the command you will see the port number right next to the ip address for e.g. 192.168.1.198:50412.
Nirsoft Utilities has a pretty neat and lightweight tool called CurrPorts which lists all the ports that are in use by Windows and other programs. In case you don’t, Nirsoft has a lot of small and portable apps that are quite useful in day to day life. If you’ve never used Nirsoft Utilities, go browse the developer site and you will find interesting little tools.
-
First, download CurrPorts from the official website. Being a portable application, you don’t have to install it. After downloading, extract the exe file from the zip file and double-click on it to open.
-
As soon as you open the window, the application will list all the connections and their ports. You can find the port number under the Local Port section.
TCPview(2021). https://docs.microsoft.com/en-us/sysinternals/downloads/tcpview . Date Accessed: 11/12/21 Currports(2021). https://www.nirsoft.net/utils/cports.html#DownloadLinks . Date Accessed: 11/12/21
Git clone repo from my github page.
python Simpleportscanner.py
Enter a remote host to scan: x.x.x.x
Please wait, scanning remote host x.x.x.x:
In this example output, the ports that are open are '135' and '149' for the given REMOTE host x.x.x.x.