Port scanner using ‘python-nmap’
In this article, we will learn how to program a port scanner using the ‘
nmap‘ module in Python. The program will take a range of port numbers as input and print the state (open or closed) of all the ports in that range.
Nmap: Nmap is a free and open-source network scanning tool. To run the program discussed in this article, you will need to have ‘nmap’ tool installed in your system. If it is not installed, visit Nmap download page.
We will be using the ‘
python-nmap‘ module to achieve this task. Install the package (if not already installed) by the following command –
pip install python-nmap
Note: Doing ‘nmap’ scans on a target without proper permission and authority is illegal. Use localhost (127.0.0.1) as your target
port 75 is closed. port 76 is closed. port 77 is closed. port 78 is closed. port 79 is closed. port 80 is open.
Note: The output can vary depending on the present status of the ports.