How robertdavidgraham/masscan works
MASSCAN is an Internet-scale asynchronous IP/port scanner. The principal workflow is: a user supplies targets, ports, rate, and output options; configuration builds address/port ranges; the scan engine generates and throttles probes through the raw adapter; received packets are processed by the ad hoc IP/TCP stack and protocol/banner parsers; results are dispatched to selectable output formats. The tree and excerpts confirm orchestration, packet construction, TCP handling, configuration, parsing, and output components; some receive-side wiring is inferred only from documented responsibilities.
Main entry points: main.c Scan Orchestrator · stack-tcp-core.c Ad Hoc Stack · proto-banner1.c Banner Engine · rawsock.c Raw Adapter
Components 19
Control & Configuration
- Scan Orchestrator
src/main.c - Config Parser
src/main-conf.c - Target Ranges
src/massip-rangesv4.c
Scan & Networking
- Rate Throttler
src/main-throttle.c - Packet Templates
src/templ-pkt.c - Ad Hoc Stack
src/stack-tcp-core.c - Raw Adapter
src/rawsock.c - Packet Queues
src/rte-ring.c
Protocol Inspection
- Service Probes
src/read-service-probes.c - Banner Engine
src/proto-banner1.c - Protocol Parsers
src/proto-http.c - Service Naming
src/out-tcp-services.c - Vulnerability Checks
src/vulncheck.c
Results & Extensions
- Output Dispatcher
src/output.c - Output Formats
src/out-json.c - Banner Scripting
src/scripting.c
Other components
- Scanner User
- Scan Result Sink
- Probed Network
Connections 22
- Scanner User → Scan Orchestrator: starts scan
- Scan Orchestrator → Config Parser: parses options
- Config Parser → Target Ranges: builds ranges
- Scan Orchestrator → Rate Throttler: starts rate
- Scan Orchestrator → Packet Templates: creates probes
- Scan Orchestrator → Ad Hoc Stack: flushes packets
- Packet Templates → Ad Hoc Stack: formats packets
- Rate Throttler → Ad Hoc Stack: limits transmission
- Ad Hoc Stack → Packet Queues: queues packets
- Packet Queues → Raw Adapter: delivers packets
- Raw Adapter → Probed Network: sends probes
- Probed Network → Raw Adapter: returns packets
- Raw Adapter → Ad Hoc Stack: feeds responses
- Ad Hoc Stack → Banner Engine: delivers streams
- Banner Engine → Protocol Parsers: dispatches protocols
- Service Probes → Banner Engine: configures probes
- Protocol Parsers → Service Naming: names services
- Banner Engine → Vulnerability Checks: runs checks
- Banner Engine → Banner Scripting: runs scripts
- Scan Orchestrator → Output Dispatcher: dispatches results
- Output Dispatcher → Output Formats: formats records
- Output Formats → Scan Result Sink: writes results