A fast, multi-threaded TCP port scanning tool built for reconnaissance, network enumeration, and OSCP-style labs. This scanner supports custom port ranges, banner grabbing, randomized scan order (IDS evasion), and JSON/TXT reporting.
This version replaces the simplistic beginner script with a professional-grade scanning utility suitable for security portfolios and real-world assessments.
basic-port-scanner/
│── src/
│ └── port_scanner.py
│── reports/
│ └── .gitkeep
│── wordlists/
│ └── .gitkeep
│── README.md
│── LICENSE
Uses 100 concurrent threads to accelerate scanning, handling large port ranges efficiently.
Supports:
-p 1-1024 # range
-p 80,443,3306 # comma-separated
-p 22 # single port
Identifies running services by capturing application banners:
SSH-2.0-OpenSSH_8.2
Apache/2.4.54
MySQL Protocol 10
Ports are shuffled before scanning to avoid linear port sweep signatures.
Reports stored under /reports/:
- JSON structured report
- TXT list of open ports
Handles:
- Host resolution errors
- Network timeouts
- Connection failures
- Interrupted scans
python3 src/port_scanner.py 192.168.1.10 -p 1-1024python3 src/port_scanner.py scanme.nmap.org -p 80,443,22,3306python3 src/port_scanner.py example.com -p 443========== Port Scan Started ==========
Target: 192.168.1.10
Ports: 1-1024
Threads: 100
----------------------------------------
[OPEN] 22/tcp → SSH-2.0-OpenSSH_8.2
[OPEN] 80/tcp
========== Scan Complete ==========
Open Ports Found: 2
Scan Duration: 3.24 seconds
====================================
Inside /reports/:
portscan-20251114-160420.json
portscan-20251114-160420.txt
{
"target": "192.168.1.10",
"open_ports": [
{"port": 22, "banner": "SSH-2.0-OpenSSH_8.2"},
{"port": 80, "banner": null}
],
"scan_duration": 3.24
}Resolves domain → IPv4:
socket.gethostbyname(target)
Each worker pulls a port from a queue and attempts:
s.connect_ex((ip, port))
If result == 0 → port open.
If port is open, tool attempts:
s.recv(1024)
to capture service fingerprints.
Shuffles ports for basic stealth against sequential-scan detection.
Results compiled into:
- TXT output
- JSON structured file
Testing on local VM:
| Ports Scanned | Threads | Duration |
|---|---|---|
| 1–1024 | 100 | ~3s |
| 1–65535 | 300 | ~40–60s |
(Depends heavily on latency and host responsiveness.)
- Asyncio-based ultra-fast scanning
- SYN-scan mode (requires raw sockets)
- UDP scanning mode
- OS fingerprinting (TTL analysis)
- NSE-style script hooks
- Banner signature matching
This tool is intended ONLY for:
- Authorized penetration testing
- Lab environments
- Educational use
Scanning systems you do not own or have permission to test is illegal and unethical.
Vignesh Mani Offensive Security Researcher GitHub: https://github.com/vigneshoffsec LinkedIn: https://linkedin.com/in/vignesh-m17
