A simple Python tool that scans a target IP or domain for common open ports, then runs Nmap service detection on any ports found open.
This is a learning project built while studying networking and cybersecurity fundamentals (first-year CS student).
- Performs a fast raw-socket scan on a set of common ports (21, 22, 80, 443, 8080).
- For any ports found open, runs
nmap -sVto detect the running service and its version. - Prints a clean summary of the results.
- Python 3
- nmap installed on your system
python-nmaplibrary
Install the Python dependency:
pip install python-nmappython3 portscan-nmap.pyYou'll be prompted to enter a target IP address or domain name.
Note: The Nmap service-detection phase (
-sV) may require root privileges:sudo python3 portscan-nmap.py
Enter target IP or domain: scanme.nmap.org
Scanning scanme.nmap.org ...
[CLOSED] Port 21
[OPEN] Port 22
[OPEN] Port 80
[CLOSED] Port 443
[CLOSED] Port 8080
Running Nmap on open ports...
Host: 45.33.32.156
State: up
Port 22 | ssh | OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.13
Port 80 | http | Apache httpd 2.4.7
Scan Complete.
Only scan systems you own or have explicit permission to test. scanme.nmap.org is Nmap's official target for practicing scans.
Mohammad Alsarawi