A high-performance network port scanner written in Python that scans multiple IP addresses and port ranges concurrently using multiprocessing.
- Parallel Scanning: Uses multiprocessing for fast concurrent port scanning
- Network Support: Supports individual IPs and CIDR notation for network ranges
- Port Ranges: Accepts single ports or port ranges (e.g., 80-443)
- Network Grouping: Automatically groups results by /24 networks
- Dual Reports: Generates both detailed and summary reports
- Type Safety: Full type hints for better code maintainability
- Python 3.10 or higher
- uv package manager (recommended) or pip
Using uv (recommended):
uv syncUsing pip:
pip install -r requirements.txt-
Prepare your target file (
ips_formatados.txt) with IP addresses and ports:192.168.1.1 80 192.168.1.1 443 10.0.0.0/24 22-25 192.168.2.100 3306 -
Run the scanner:
python port_scan.py
Or with uv:
uv run python port_scan.py
The input file should contain lines with IP addresses/networks and ports, separated by spaces:
- Individual IPs:
192.168.1.1 80 - Network ranges:
10.0.0.0/24 22(scans all hosts in the network) - Port ranges:
192.168.1.1 80-443(scans ports 80 through 443) - Comments: Lines starting with
#are ignored - Empty lines: Ignored
The scanner generates two report files:
Shows all IPs with open ports, grouped by /24 network:
=== Rede 192.168.1.0/24 ===
Porta 80 aberta em 3 IPs:
- 192.168.1.10
- 192.168.1.15
- 192.168.1.20
Porta 443 aberta em 2 IPs:
- 192.168.1.10
- 192.168.1.15
Shows counts of accessible IPs per port per network:
Resumo por rede:
Rede 192.168.1.0/24:
- Porta 80: 3 IPs acessíveis
- Porta 443: 2 IPs acessíveis
- Workers: Default 20 concurrent processes (configurable in
scan_targets()) - Timeout: Default 3 seconds per port connection attempt
- Input file:
ips_formatados.txt(hardcoded in main)
loguru: Structured loggingipaddress: IP network manipulation (stdlib)socket: Network connections (stdlib)multiprocessing: Parallel processing (stdlib)
mypy .Consider adding:
rufffor lintingblackfor code formattingpytestfor testing
This project is open source. Please check the license file for details.