Overview

4 Passive reconnaissance agents

This text introduces reconnaissance as the foundation of offensive security work and argues that repeatable pipelines are safer and more useful than scattered manual commands or one-off scripts. Instead of relying on ad hoc notes, screenshots, and terminal output, an AI-assisted reconnaissance workflow breaks the process into explicit stages: planning what to examine, acting through low-impact collection steps, observing results, and recording evidence. The key idea is that AI should augment human analysts rather than replace them, helping propose actions, interpret observations, and summarize findings while humans enforce boundaries, approve execution, and remain accountable.

The chapter walks through building a minimal Python-based reconnaissance pipeline that generates candidate hostnames, resolves DNS, sends lightweight HTTP HEAD requests, optionally inspects TLS metadata, checks for simple WAF or CDN hints, and records each observation as a structured JSONL artifact. The design emphasizes composability: each function performs a small stateless task, and each result is appended to a durable recon.jsonl file with fields such as host, IP addresses, headers, TLS details, notes, and timestamps. These artifacts become persistent memory for both humans and future AI agents, making it possible to replay, audit, search, cluster, and reason over reconnaissance activity as a chronological story rather than a pile of unstructured logs.

The text also stresses that automation must be constrained by scope, safety gates, and responsible data handling. Reconnaissance pipelines should enforce approved targets, time windows, and human approval before actions occur, and they should log blocked or rejected actions as carefully as successful ones. Because artifacts may contain sensitive intelligence such as internal hostnames, headers, or API-related details, they must be sanitized, protected, and eventually archived or deleted. Overall, the chapter frames passive or low-impact reconnaissance as a disciplined first step toward more advanced agentic security systems, preparing the reader for deeper enumeration, scoring, and active testing while keeping accountability and ethics central.

Our passive reconnaissance pipeline. The pipeline gathers information about a target domain and its subdomains. For each discovered subdomain, the pipeline queries DNS servers to retrieve the IP addresses to which the subdomain points. The pipeline then sends an HTTP HEAD request to each live subdomain. If the subdomain uses HTTPS, the pipeline examines the TLS/SSL certificate, checks for Application Layer Protocol Negotiation (ALPN), and inspects the Subject Alternative Name (SAN). All this information gets written to JSONL.
The architecture of a minimal AI recon pipeline. We’ll create a passive recon agent that performs safe actions, collects and interprets the results from these safe actions, and records them to an artifact file.
Each artifact records one cycle of the recon loop. At the Plan stage, the AI agent reads in the seed list and generates candidate subdomains. During the Action stage, it issues DNS queries and HTTPS HEAD requests to each candidate. The Observation stage collects the evidence, which includes resolved Ips, response headers, TLS certificate fields, and WAF hints. Finally, the Record stage persists everything into a JSONL file. Together, these four stages form a complete account of discovery in recon.

Summary

  • Non-intrusive reconnaissance gathers intelligence about a target through standard, low-impact interactions (DNS lookups, HEAD requests, TLS handshakes) that any browser or crawler might perform. Truly passive techniques such as certificate transparency, Shodan, WHOIS, and archived DNS rely entirely on third-party data and never touch the target at all.
  • A pipeline differs from a script in that it connects multiple stages, with each stage's output feeding the next, producing structured artifacts with timestamps and context rather than ad hoc notes.
  • The ReAct pattern (Plan, Act, Observe, Record) organizes a recon agent into four reusable stages: generating candidate hostnames, gathering data through DNS and HTTP probes, interpreting the results, and persisting findings as structured artifacts.
  • JSONL artifacts serve as persistent, machine-readable memory for the agent, capturing what was done and what was found, forming an audit trail that AI agents can later query, filter, and reason over.
  • DNS resolution, HTTPS HEAD requests, WAF/CDN header heuristics, TLS certificate inspection (ALPN and SAN), and robots.txt/sitemap retrieval are the core non-intrusive techniques the pipeline uses to map a target's attack surface.
  • Response headers should be sanitized before writing to disk to prevent sensitive data such as session cookies, authorization tokens, and API keys from persisting in log files.
  • Safety gates, including time-window checks and approval confirmations, enforce operational boundaries and keep humans in the loop before the agent takes network actions.
  • Scope enforcement must be a configured system constraint, not an assumption. Every out-of-scope request should be blocked and logged as an artifact.
  • Structured artifacts enable emergent inferences that were never explicitly programmed, because AI agents excel at interpreting consistent, well-formatted data with context rather than unstructured logs.
  • The human operator remains accountable for every action the AI system performs; AI suggestions must be explainable, operate under the principle of least privilege, and be fully auditable, whether accepted or rejected.

FAQ

Why does the chapter recommend a reconnaissance pipeline instead of one-off scripts?

A pipeline is more repeatable, auditable, and safer than scattered one-off scripts. Instead of running isolated commands and manually copying results into notes, a pipeline breaks reconnaissance into explicit stages—plan, act, observe, and record. Each stage produces structured artifacts with timestamps, context, and results, making it possible to replay, review, pause, or extend the operation later.

What is the main purpose of the passive reconnaissance agent built in Chapter 4?

The chapter builds a minimal, auditable reconnaissance pipeline that behaves like a junior analyst. It generates candidate hostnames, resolves them, sends a lightweight HEAD request, optionally captures TLS metadata, and writes each observation to a structured recon.jsonl artifact. The goal is to gather evidence safely while preserving a clear audit trail.

What is the difference between passive reconnaissance and active reconnaissance?

Passive reconnaissance gathers information without directly interacting with the target system, such as reviewing public records, WHOIS data, breach databases, or certificate transparency logs. Active reconnaissance directly interacts with target systems, such as sending requests, scanning ports, or crawling applications. The chapter’s pipeline is low-impact and non-intrusive, but because it sends DNS lookups, HTTPS HEAD requests, and optional content requests, it sits at the low-impact end of active recon rather than being purely passive.

What are the four ReAct-style building blocks used by the recon agent?

The chapter maps the reconnaissance agent to four reusable ReAct-style stages:

  • Plan: Generate a small list of likely subdomains for the target.
  • Act: Resolve DNS and send safe requests such as a single HEAD /.
  • Observe: Extract response headers, TLS hints, status codes, and WAF/CDN indicators.
  • Record: Append a structured JSONL artifact with timestamps and notes.
Why does the pipeline use JSONL artifacts such as recon.jsonl?

JSONL, or JSON Lines, stores one JSON object per line. This makes it append-friendly, easy to parse with tools like jq, grep, and Python, and friendly for later AI reasoning. Each artifact acts as persistent memory for the agent, recording what host was examined, what evidence was collected, when it happened, and what conclusions or notes were produced.

What information does an Artifact record contain?

A typical reconnaissance artifact includes fields such as schema, host, DNS addresses in a, a best-effort cname, sanitized HTTP headers, a waf_hint, optional tls metadata, free-form notes, and a UTC timestamp in ts. Together, these fields create a structured record of the pipeline’s observation for one host.

Why does the pipeline use a HEAD request instead of a GET request by default?

The pipeline uses HEAD because it only needs response headers, not the full response body. This keeps traffic lightweight and minimizes the footprint of the reconnaissance activity. The collected headers can still reveal useful metadata, including server technology, CDN indicators, and possible WAF-related headers.

What does the WAF/CDN heuristic detection do?

The infer_waf() function checks response headers for broad signature fragments such as cloudflare, cf-ray, x-waf, akamai-, fastly, or x-amzn. If a match appears in a header name or value, the pipeline marks waf_hint as true. This is only a lightweight hint, not a definitive WAF fingerprint; deeper active WAF fingerprinting is deferred to Chapter 5.

What safety gates does the chapter recommend for reconnaissance automation?

The chapter emphasizes safety gates that keep automation accountable. Two core gates are introduced: a time-window gate, which ensures the pipeline only runs during approved hours, and an approval or automation gate, which confirms intent before execution. The chapter also recommends scope filters, ethical boundary checks, quality-control gates, and logging both allowed and blocked actions as artifacts.

How should recon artifacts be handled safely and ethically?

Recon artifacts should be treated as confidential evidence because they may contain sensitive hostnames, headers, endpoints, or infrastructure details. The chapter recommends storing artifacts locally, never committing them to public repositories, sanitizing secrets before writing to disk, and archiving or deleting data after the assessment ends. It also stresses that AI should remain advisory, humans remain accountable, and every action must respect documented scope and authorization.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • AI Agents for Offensive Security ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • AI Agents for Offensive Security ebook for free