A fast, threaded command-line port scanner written in Python.
This tool is for educational purposes only. Only use it on networks and systems you own or have explicit written permission to scan. Unauthorized port scanning may be illegal in your jurisdiction and can violate terms of service. The author accepts no responsibility for any misuse of this tool.
- Python 3.10 or higher
- Clone or download this repository.
- Navigate into the
port_scannerdirectory:
cd port_scanner- (Recommended) Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txtRun the scanner with:
python scanner.pyYou will be prompted to enter:
| Prompt | Example |
|---|---|
| Target IP address | 192.168.1.1 |
| Number of threads | 100 |
| Port range | 1-1024 |
After the scan completes, a clean table of all open ports and their associated services is printed.
==================================================
PortScan
==================================================
Enter target IP address: 192.168.1.1
Enter number of threads (1-500): 100
Enter port range (e.g. 1-1024): 1-1024
Scanning 192.168.1.1 ports 1-1024 (1024 ports) threads: 100
--------------------------------------------------
Found 3 open port(s):
PORT SERVICE
---------- --------------------
22 ssh
80 http
443 https
Scan complete.
- More threads = faster scan, but very high counts can flood the target or trigger firewalls. 100–200 is a good balance for most local networks.
- The scan uses a 0.5 second connection timeout per port. Decrease it in
scanner.py(timeoutvariable inmain()) for faster scans on reliable networks, or increase it for slow or remote targets. - To scan all ports, use the range
1-65535.