60 Mins

Milestone 4: Multi-Threaded Port Scanner

Mission Briefing: Threat Intelligence Reconnaissance

Your mission in the VoidX Incident Room is to automate network reconnaissance for an ongoing penetration test. You are tasked with creating a high-speed, multi-threaded port scanner in Python.

Your scanner must target a specific subnet, identify open TCP ports, perform service banner grabbing for common services (like SSH, HTTP, FTP), and aggregate findings into a structured JSON log for post-incident analysis.

Precision and efficiency are paramount. You must manage thread contention and handle socket timeouts to ensure the scanner does not crash during high-volume operations.

Security Operator Note: Use a ThreadPoolExecutor from the concurrent.futures library for better thread lifecycle management and resource control.
Text
# Target Input Ports: [21, 22, 80, 443]
# Expected Output: '[{"port": 22, "status": "open"}, {"port": 80, "status": "open"}]'

Mission Requirements & Delivery

To successfully complete this milestone, your code must adhere to the following strict operational requirements.

1. Implementation: You must use the threading library to launch concurrent threads for scanning.

2. Banner Handling: Implement a try-except block for socket.recv() to ensure a service timeout does not terminate your entire scan process.

3. Output Format: The final data structure must be exported as a list of dictionaries, converted to a JSON string using json.dumps().

4. Network Integrity: The scanner must explicitly close all sockets after the banner read or timeout to prevent File Descriptor exhaustion on the host machine.

Security Operator Note: Validate your JSON output using the jq command-line utility to ensure it complies with the required VoidX reporting standards.
Text
# Verification Command: Run this to check if your script produces valid JSON
python3 scanner.py > results.json
cat results.json | jq .
Lab Overview

Objectives & Tasks

Review the tasks below and follow the interactive instructions to complete this module.

Knowledge Check

Ready to test your understanding of Milestone 4: Multi-Threaded Port Scanner?

Back