Summary
Replace the current threading-based port scanning with Python asyncio for significantly faster and more scalable network scanning.
Motivation
- Threading in Python is limited by the GIL and has high overhead per-thread
- asyncio with non-blocking sockets can handle thousands of concurrent connections
- Modern Python (3.11+) has significant asyncio performance improvements
- Scan times for large port ranges (1-65535) can drop from minutes to seconds
Proposed Approach
-
Async scanner module:
- Use
asyncio.open_connection() for TCP connect scans
- Semaphore-based concurrency limiting (configurable, default 1000)
- Timeout handling per-connection with
asyncio.wait_for()
-
SYN scan support:
- Raw socket async SYN scanning (requires root/sudo)
- Fallback to connect scan when privileges unavailable
-
Progress reporting:
- Async progress callback for real-time scan updates
- ETA calculation based on scan rate
-
Backward compatibility:
- Keep existing synchronous API as wrapper
- Add
--async flag to CLI for opt-in
Benchmarks to Target
| Scan Type |
Current (threading) |
Target (asyncio) |
| Top 1000 ports |
~30s |
<5s |
| Full 65535 ports |
~10min |
<45s |
Acceptance Criteria
Summary
Replace the current threading-based port scanning with Python asyncio for significantly faster and more scalable network scanning.
Motivation
Proposed Approach
Async scanner module:
asyncio.open_connection()for TCP connect scansasyncio.wait_for()SYN scan support:
Progress reporting:
Backward compatibility:
--asyncflag to CLI for opt-inBenchmarks to Target
Acceptance Criteria