How amitheffect/port-scanner-tool works
Project type and purpose
• Type: Single-file CLI network utility (open‑source tool) — a Python-based TCP port scanner intended for authorized security testing and network discovery.
• Purpose: Given a target (IP/hostname or CIDR) the tool concurrently probes TCP ports, identifies open ports and known services, optionally grabs banners, and prints/saves a human-readable report.
File-structure analysis
• Top level: LICENSE, README.md, port_scanner.py — the entire implementation lives in one script.
• No frontend/backend split, no external services or containers.
• Implicit modules / functional areas (from README): argument parsing, target resolution (CIDR expansion / DNS), thread pool scanning, socket connect probes, service mapping, optional banner grabbing, reporting/output.
• Runtime & deployment: Python 3.10+, no external dependencies; runs locally (CLI). Possible runtime resources: network stack, system resolver (DNS), file system for output.
README insights to capture
• Concurrency model: ThreadPoolExecutor (configurable --threads, default 100).
• Scanning method: TCP connect (socket.connect_ex), timeout parameter.
• Inputs and modes: single IP/hostname, CIDR range, port ranges/list, --top-ports mode.
• Outputs: terminal (colorized), optional file output.
• Service detection: built-in mappings + socket.getservbyport fallback.
• Banner grabbing flow: reconnect to open port to read greeting.
• Limitations: TCP-only, IPv4-only, no raw sockets.