NTOK SCAN — Local-First Recon Engine in Rust
An open-source, nmap-fluent port scanner and reconnaissance engine written in pure Rust — same flags, same XML output — extended into a full cockpit: live web console, website intelligence, a Shodan-style local search index, one-click scan diffing, and a scope-gated MCP tool surface for AI agents. No cloud account, no telemetry.
- Year
- 2026
- Focus
- Rust
- Reading
- 7 min· 8 sections
- Published
- Web


"nmap stays the reference — the goal was never to replace it. The goal was a cockpit over the whole ecosystem: speak its flag vocabulary natively, orchestrate the tools operators already trust, and keep every target and every byte of recon data on the machine that produced it."
Project Overview
The Challenge
Reconnaissance tooling is fragmented across four decades of assumptions — the design had to unify them without breaking what already works.
nmap Fluency Without the Dependency
Operators think in -sT/-sS, top:100 ports, and T4 timing. A new engine that invents its own vocabulary loses them immediately — but shelling out to nmap makes the tool a wrapper, not an engine. The challenge was byte-level nmap compatibility (flags, XML schema, report import) implemented natively in Rust.
Cloud-Locked Recon Data
Shodan-style pivots — "find every nginx on my net with an expired cert" — live behind SaaS accounts that see your infrastructure queries. Red-team and lab work needed the same query power over local scan history, with zero telemetry and zero data leaving the host.
Drift Detection as an Afterthought
Point-in-time scans answer "what is open" but not "what changed." Security teams rescan networks constantly and diff results by hand or with awk pipelines. Drift needed to be a first-class loop: rescan, compare, explain — in one click.
Safe AI Agent Access
AI agents are powerful recon assistants but a scanner is a loaded weapon — unrestricted tool access means an agent can send packets anywhere. The MCP surface needed read tools ungated but scanning behind an explicit scope allowlist checked before a packet is built.
Solution Architecture
A cargo workspace of eight crates — one engine library, five frontends, one index, one agent surface.
01. ntok-core — The Scanning Engine
The library crate, laid out like nmap itself: each -s* technique is a module under scan/ behind the PortProber trait. Connect and UDP probes are always available; the raw flag-scan family and ICMP echo discovery compile only with the `privileged` feature (Npcap on Windows, CAP_NET_RAW on Unix). Target parsing handles IPs, CIDRs, ranges, hostnames and full URLs; the port planner supports literals, ranges, top:N and all. Timing templates T0–T5 map to concrete concurrency, timeout and delay budgets. Adding a technique = one module + one enum variant.
02. ntok-cli — The nmap-Fluent Frontend
A clap binary speaking the operator vocabulary verbatim: -p port specs, -T timing, --syn/--ack/--fin/--null/--xmas/--udp techniques, --Pn to skip discovery, --sV service detection, -v verbosity. Reports emit in six formats — --oJ JSON, --oX nmap-XML (round-trips through import), --oN text, --oG greppable, --oC CSV, --oH HTML, or --oA to write all six at once.
03. ntok-store — The Local Shodan
Every finished scan and import feeds reports/ntok.db: a SQLite + FTS5 index holding one row per open service ever seen, joined with TLS/web/tech enrichment. An edges table records cert SANs, redirect targets, third-party asset hosts and DNS names — the graph substrate. It also stores web-UI accounts, sessions and API tokens with argon2id hashes. Index failures never fail a scan; delete the DB and it rebuilds from the reports you feed it next.
04. ntok-web — The Live Console
A server-rendered UI (Topcoat + htmx polling) over the same engine: start scans in the browser and watch a dense port-state grid light up cell by cell, alongside a throughput waveform and terminal-style log. Finished reports persist as files and reload at startup, so history survives restarts. One-click Rescan replays a stored form; /compare/A/B renders the ndiff drift view — the rescan→compare loop is two clicks total.
05. ntok-mcp — The Gated Agent Surface
An MCP server (stdio, or Streamable HTTP with Bearer auth) exposing the engine and index as tools for Claude Desktop, Cursor, Devin and other MCP clients. Read tools — stats, search, graph, subs, lookup, scans, report, diff, import — are always on. The scan tool exists only behind --allow-scan, and every target is checked against a --scope allowlist (CIDRs, hostname globs, or `private` for RFC1918+loopback) before a packet is built.
06. Shells — Desktop, Extension, Mobile
ntok-desktop wraps ntok-web in a Tauri v2 window on a private port with an OS-profile data dir, falling back to the browser when no webview exists. The MV3 browser extension adds "Scan this host" popup and context-menu actions against the same Bearer-token API. Android and iOS shells are thin WebView viewers over a hosted ntok-web — one UI serves every form factor.
Workspace Topology
Eight crates, one engine — every frontend drives the same ntok-core, and every scan feeds the same index.
Scan Pipeline
From flag parse to indexed report — every stage bounded, every failure degradable.
Technical Implementation
The engineering decisions that make the cockpit work.
Technique Modules Behind One Trait
Every scan technique implements PortProber — connect and UDP unconditionally, the raw flag-scan family behind the `privileged` cargo feature so the default build needs no Npcap, no root and no Packet.lib. OS hints from TTL/window analysis ride the same gate. New techniques cost one module, one enum variant, one dispatch entry.
Wappalyzer-Scale Fingerprinting
The full community fingerprint DB — ~7,700 technology fingerprints vendored into ntok-core/data/web-tech.json — matched over headers, cookies, meta, script URLs, DOM selectors, JS globals, page URL, DNS, robots.txt, TLS issuer, first-party JS bundles and body text. Every hit reports confidence, version and an evidence trail; implies/excludes inference adds dependent techs (PHP under WordPress). --crawl N merges inner pages into detection.
Shodan Pivots, Local Math
favicon.ico is hashed with mmh3 and matched against a 700+ product table — the http.favicon.hash pivot Shodan users know, catching infra the page never mentions. The search DSL supports 25+ fields (service:, net:, has:tls, expired:, finding:cve-…, after:/before:). risk is a deterministic 0–100 exposure score — risky-port table plus expired/self-signed certs and missing hardening headers; anomaly inverts it: 100 − % of indexed hosts where that port is open.
Relationship Graph Over Edges
Cert SANs, redirect targets, third-party asset hosts, DNS names and crt.sh CT subdomains ingest into one edges table. ntok graph pivots any IP or domain in both directions — a wildcard SAN on one cert surfaces sibling hostnames on different machines — with --depth walks capped at 3 hops / 500 edges and --oT turning discoveries straight into target files.
External Tools as Subprocesses, Never Libraries
--tools masscan,nmap,nuclei,naabu,rustscan run as bounded subprocesses (NTOK_TOOL_TIMEOUT_MS, default 300s). masscan/naabu/rustscan replace host discovery; nmap merges -sV service detail and NSE findings; nuclei attaches severity-tagged vulnerabilities. A missing binary degrades to a log warning — scans never depend on tools being installed. --tool-prefix routes Kali binaries through WSL from the Windows build.
Bounded AI, Everywhere It Touches
The advisor is a ScanAdvisor trait with NullAdvisor as default — any OpenAI-compatible endpoint (DeepSeek default, keyless Ollama for full locality). The recon agent runs a tool-calling loop capped at 8 turns and 8KB per tool result; it can propose a scan plan for operator approval but cannot launch probes. API keys are never rendered back, logged, or written into reports.
Wappalyzer community signatures vendored and matched across 12 evidence channels per web profile.
One engine library, five frontends (CLI, web, MCP, desktop, extension), the index, and mobile shells.
JSON, nmap-XML, text, greppable, CSV and HTML — --oA writes all six in one run; -oX round-trips through import.
mmh3 favicon hash table resolving Shodan-style http.favicon.hash pivots locally.
field:value operators over the FTS5 index — service, net, risk, anomaly, favicon, finding, date ranges and more.
Hard caps on the recon agent — turns and per-tool result bytes — plus scope-checked targets before any packet is built.
Web console dashboard — scans, index stats and drift at a glance
Live port map — every probe lights a cell as it lands, not after
Website intelligence — tech fingerprint, TLS posture, company attribution, asset inventory
Index search — the full field:value DSL over every service ever seen
Drift view — appeared/disappeared hosts, port flips and finding deltas between any two scans
Recon agent — plain-language answers over the local index, read-only and bounded