Pentest Methodology & Recon · beginner · ~10 min
**What you will learn** - Define passive and active reconnaissance precisely, using the one test that separates them: *do any of your packets reach the target?* - Classify common recon activities (DNS lookups, Certificate Transparency, Shodan, port scans, banner grabs) into passive or active correctly. - Explain the OPSEC (operational security) trade-off between how much you learn and how much noise you make. - Sequence a real engagement's recon so passive work comes first and active probes are precise and scope-bound. - **From the defender's chair:** describe which logs and signals reveal active recon, and how a blue team detects a scan without producing false alarms. - Apply an authorization checklist so every active probe stays inside a system you own or are explicitly permitted to test.
Security objective. The asset being protected in this lesson is the information about your target and, on the defensive side, the target's ability to notice it is being studied. The threat is an outsider mapping a network's attack surface. As an authorized tester you learn to gather that map responsibly; as a defender you learn to detect the active half of it. By the end you can tell, for any recon action, whether it is silent (passive) or leaves a trace (active), and you can plan work that respects scope and authorization.
Reconnaissance means gathering information about a target before you test it. It is the first real work in an engagement and it comes in two forms:
This lesson builds directly on your prerequisite, The phases of an engagement (methodology-phases). There you saw that a professional test moves through ordered phases — scoping and authorization, reconnaissance, scanning/enumeration, exploitation, and reporting. Recon is that second phase, and the passive-then-active ordering you learn here is what makes the phase disciplined instead of noisy. The general rule is simple: do passive recon first, then active. It leads into your next lesson, DNS, WHOIS, and subdomain discovery (recon-dns-whois), which drills into the specific passive sources named above.
In authorized professional work, the passive/active distinction controls two things at the same time:
Passive recon is stealthy. It reads public data held by third parties, so in most engagements it needs no special authorization to read (though you must still respect the third party's terms of service and never social-engineer real people). It lets you map a large surface for free before spending a single loud packet.
Active recon is detectable by design: your packets arrive at the target and can land in its logs, its IDS, and its SOC's alert queue. That is exactly why it must stay strictly inside your authorized scope and time window. Getting this wrong is not a style problem — unauthorized active scanning of systems you do not own can be a crime in many jurisdictions and will end an engagement (and a career) fast.
There is a second, symmetric reason this matters: defenders get paid to catch the active half. A blue-team analyst who understands what a port scan looks like in the logs can detect an intruder in the recon phase — long before exploitation. Learning both sides makes you a better tester (you know what you are triggering) and a better defender (you know what to watch for).
Each concept below is taught on its own: a definition, a plain explanation, how it works, when it applies and when it does not, and a common pitfall.
Definition. Information gathering in which no packet you generate reaches the target's systems. You query third parties and public sources instead.
Plain explanation. You are reading about the target from records other people already collected — like researching a building from public property records and street-view photos rather than walking up and rattling the doors.
How it works. Typical sources:
When / when not. Use it first, always, to build the widest possible picture cheaply and quietly. It is not enough on its own: public data is often stale or incomplete, so it cannot confirm what is running on a host right now.
Pitfall. People assume passive means "consequence-free." Reading a CT log is passive; but interacting with a real employee to extract information, or hammering a third-party API against its terms of service, is neither harmless nor in-scope. Passive is about not touching the target, not about ignoring ethics or terms of service.
Definition. Information gathering that sends traffic to the target and interacts with it directly.
Plain explanation. Now you are actually knocking on doors and listening for answers: ping sweeps to find live hosts, port scans to find open services, banner grabs to read version strings, and web crawling to map an application.
How it works. You send packets (ICMP echo, TCP SYN, HTTP requests) and interpret the responses. It is far richer than passive recon because it reveals the current state — which ports are open, which service versions answer. That richness is the reward for the risk.
When / when not. Use it after passive recon has mapped the surface, and only within your authorized scope and time window. Do not run active recon against any host you have not confirmed is in scope.
Pitfall. Active recon is logged. A single aggressive scan can trip an IDS and burn your stealth for the rest of the engagement — and against an out-of-scope host it can be illegal.
Definition. Protecting information about your own activity — here, keeping your recon from being noticed.
Plain explanation. Every active probe is a footprint. OPSEC is the discipline of leaving as few footprints as the objective allows, and of understanding what each footprint looks like from the defender's side.
How it works. You minimize and pace active traffic, prefer passive sources when they answer the question, and stay aware that scans generate connection logs, IDS alerts, and rate-based anomalies.
When / when not. OPSEC matters most on stealth-oriented (red-team) engagements. On a cooperative, announced vulnerability assessment, stealth is often not the goal — speed and coverage are — but you still log and time-box your activity.
Pitfall. Treating stealth as always-on. Sometimes the client wants to see if their SOC catches you; then loud is fine — but only because it is agreed in scope.
Definition. A sequencing rule: exhaust passive sources before sending any active probe.
Plain explanation. Map for free and quietly first; then aim your loud probes precisely at what you already found, instead of blindly scanning everything.
How it works. Passive recon yields hostnames, IP ranges, and technologies. You feed those into a small, targeted active scan rather than a broad, noisy sweep — fewer packets, less noise, better data.
Pitfall. Skipping straight to a full-range port scan. It is loud, slow, and often scans hosts a five-minute CT-log read would have told you to ignore.
TRUST BOUNDARY (the target's perimeter)
|
ASSETS being studied: | ENTRY POINTS an active probe hits:
- hostnames / subdomains | - open TCP/UDP ports
- IP ranges | - service banners (versions)
- service versions | - web app endpoints
- employee/tech footprint |
|
PASSIVE recon path (NO packets cross the boundary):
tester ---> [Search / DNS / WHOIS / CT logs / Shodan / Censys] (third parties)
^ reads stored public data; target sees nothing
|
ACTIVE recon path (packets CROSS the boundary and are logged):
tester ============> | firewall | ==> hosts/services ==> [logs, IDS, SOC alerts]
^ trust boundary; every crossing can be recorded
Insecure assumption an attacker exploits: "a scan is just noise, nobody reads the logs."
Defensive reality: connection logs + IDS turn active recon into a detectable event.
Knowledge check.
Recon is a concept, not one command, but a few lab-safe commands make the passive/active line concrete. Everything below targets only hosts you own or are authorized to test (here, localhost / your own lab VM).
# PASSIVE-style: query a THIRD PARTY, not the target.
# whois asks a registry's database; no packet goes to the target's own servers.
whois example.com # 'example.com' is IANA's reserved documentation domain (safe to name)
# PASSIVE-style: a DNS resolver answers from records; you are not probing the host itself.
dig +short example.com A # ask a resolver for the A record
# ACTIVE: nmap sends packets DIRECTLY to the host and reads the responses.
# -sT = full TCP connect scan; run ONLY against your own lab host.
nmap -sT -p 1-1000 127.0.0.1 # scans YOUR loopback interface only
Annotations:
whois / dig reach a registry or resolver — a third party — so they behave as passive-style OSINT lookups; the target's own servers are not contacted.nmap against 127.0.0.1 is active: real packets, real responses, and (on a monitored host) real log entries. 127.0.0.1 is your own machine, so it is always safe and in scope.Reconnaissance is information gathering. There are two types. They differ by one question: do you touch the target or not?
Collect information without sending any traffic to the target's systems. You query third parties and public sources instead:
Because you never touch the target, passive recon is essentially undetectable by them.
Here you interact with the target directly: ping sweeps, port scans, banner grabbing, and web crawling.
This is far richer. You learn what is actually running. But it is noisy and logged. Active recon must stay inside your authorized scope and time window.
Passive first, active second.
On a real engagement, active recon is where you start leaving footprints in the target's logs.
This lesson is on the concept track, so the "code" is a set of lab-safe commands plus the log evidence they create. The shape is noisy (active) vs quiet (passive) → the secure/defensive habit → verify by reading the logs.
A careless tester runs a broad, fast, un-scoped active scan and assumes nobody is watching:
# WARNING: intentionally noisy example. Lab host you OWN only (here: your loopback).
# -T5 = fastest/loudest timing, -p- = ALL 65535 ports. This is maximally detectable.
nmap -sS -T5 -p- 127.0.0.1
Why this is a problem in real work: -T5 and -p- generate a flood of connection attempts in a very short window — the single easiest-to-detect pattern a defender looks for. Aimed at anything you are not authorized to scan, it is also likely unlawful.
Do passive recon first, then a small, paced, scoped active scan aimed only at what you found:
# Step A - PASSIVE: learn names/records from third parties (no packets to the target host).
whois example.com | grep -Ei 'registrar|name server'
dig +short example.com A
# Step B - ACTIVE but disciplined: only the handful of ports that matter, gentle timing,
# and ONLY against a host you own/are authorized to test (your lab loopback here).
nmap -sT -T2 -p 22,80,443 127.0.0.1 -oN /tmp/lab_scan.txt
# | | | |
# | | | +-- save evidence for your report
# | | +-- just the services you expect, not all 65535
# | +-- slow, polite timing = far less like a flood
# +-- plain TCP connect; no raw-socket privileges needed
The point of the exercise is to see that active recon is detectable and passive recon is not. On a lab Linux host, watch a service log while you scan:
# In terminal 1, tail your lab web server's access log:
tail -f /var/log/nginx/access.log # or your lab app's log path
# In terminal 2, run ONLY the passive step (whois/dig): terminal 1 shows NOTHING new.
# Then run the scoped active step against the lab host: terminal 1 now shows probe hits.
Expected result. During the passive commands the access log stays quiet — you contacted third parties, not the host. During the active nmap, connection attempts to ports 80/443 appear in the log (and, if a lab IDS is running, an alert). That contrast is the lesson: passive leaves no trace on the target; active does. It also demonstrates the defender's win — the scan was detected because someone logged and read the traffic.
Lab cleanup / reset. rm -f /tmp/lab_scan.txt, stop any lab containers/VMs you started (docker compose down or shut down the VM), and clear or rotate the test log if you want a clean slate. Never run any of the active commands outside your own lab.
Walking through the disciplined sequence in the code section:
| Step | Command | What happens | Passive or active? | What the target sees |
|---|---|---|---|---|
| A1 | whois example.com |
A registry database answers with registration data | Passive-style | Nothing — a third party replied |
| A2 | dig +short example.com A |
A DNS resolver returns the A record | Passive-style | Nothing — the resolver replied, not the host |
| B | nmap -sT -T2 -p 22,80,443 127.0.0.1 |
Your machine opens TCP connections to three ports on the lab host and records which answer | Active | Connection attempts on 22/80/443 land in its logs |
| V1 | tail -f .../access.log |
You watch the log live | (observation) | — |
| V2 | run passive steps | Log stays quiet | Passive | No new log lines |
| V3 | run active step | New connection lines appear | Active | Probe hits recorded |
How the picture changes as you go: after A1–A2 you hold names and records but have touched nothing — your footprint on the target is zero. At B you convert that map into a few precise probes; because you scoped to three ports with polite -T2 timing, you create a small, explainable burst instead of a flood. At V2 vs V3 the log itself proves the distinction: silence during passive, entries during active. The value the tester gains rises at step B; the noise also rises only at step B — which is exactly why passive comes first.
Real mistakes beginners make, why they are wrong, the fix, and how to prevent them.
1. "Scanning is passive because I'm just looking."
2. Jumping straight to a full-range active scan.
3. Treating passive recon as ethics- and terms-free.
4. Running active recon outside the authorized scope or window.
5. Assuming "it didn't alert" means "nobody noticed."
When recon does not behave as expected, work through these.
nmap shows all ports filtered/closed on your lab host. A local firewall may be dropping probes. Check with sudo ufw status (Linux) or your VM's firewall, and confirm the service is actually running (ss -tlnp). Ask: is the host up, is the service listening, is a firewall in the way?whois/dig return nothing. Your resolver or network may be blocking outbound queries, or the name may not exist. Try a different resolver (dig @1.1.1.1 +short example.com) and re-check spelling. Ask: am I querying the right third party, and can I reach it?-T) or a firewall hiding results?Security & safety — detection, logging, and authorization.
Because active recon is the detectable half, both testers and defenders must handle logs well.
What a defender should log to detect recon (and what a tester should record about their own runs):
What to NEVER log: passwords, session tokens or cookies, API keys or private keys, full payment card numbers (PANs), or unnecessary personal data (PII). Recon logs are about who probed what, when, and with what result — not secrets. Use placeholders like API_KEY=<development-placeholder> in any example.
Which events signal recon abuse: many connections from one source to many ports in a short window (port-scan pattern); sequential requests walking through URL paths or subdomains (enumeration); a spike of DNS or reverse-DNS lookups; requests with scanner-style user agents. Correlate by source + short time window rather than a single line.
How false positives arise: legitimate uptime monitors, vulnerability scanners run by your own team, load balancers health-checking, or search-engine crawlers can all look like recon. Reduce false alarms by allow-listing known scanners and monitors, and by tuning thresholds to the environment. For authorized tests, share the tester's source IP and time window with the SOC if the engagement is not a stealth test — otherwise the whole point is to see whether they catch it.
Authorization is the safety rail. Only run active recon against systems you own or have explicit written permission to test, inside the agreed scope and time window. Everything active in this lesson targets 127.0.0.1 or a lab VM you control.
Authorized real-world use case. A consultancy is hired to assess a client's external footprint. On day one they do passive recon only: pull the client's domains from WHOIS, enumerate subdomains from Certificate Transparency logs, and check Shodan for already-known exposed services — all without sending a packet to the client. They hand the client a surface map. On day two, inside the signed scope and agreed hours, they run targeted active scans against just those in-scope hosts to confirm what is live, then move to enumeration. The passive phase made the active phase small, precise, and defensible.
Professional best-practice habits:
Beginner vs advanced.
| Beginner | Advanced | |
|---|---|---|
| Passive | WHOIS, dig, one CT-log search |
Correlating CT + Shodan + code repos into a full asset inventory |
| Active | A scoped nmap of a few ports on a lab host |
Paced, low-and-slow scans tuned to evade or measure detection, mapped to specific detection rules |
| Mindset | "Did my packet touch the target?" | Modeling exactly which log and IDS rule each probe triggers |
Remember: passing an automated scanner clean does not prove a system is secure, and nothing is ever "completely secure." Recon findings are a starting map, not a verdict.
All tasks are lab-only: use localhost, a container, or an intentionally-vulnerable VM you own. Authorization checklist before any active task: (1) I own or have written permission to test this host; (2) it is in scope; (3) I am within the agreed time window; (4) I have a rollback/cleanup plan. Each task ends by remediating or verifying defensively.
Beginner 1 — Classify the activity.
dig A record, HTTP request to the target). For each, write passive/active and the one-line reason (did a packet reach the target?).Beginner 2 — Passive-only footprint of a name you own.
whois, dig, and one public CT-log search, gather registrar, name servers, A record, and any subdomains for a domain you own or the reserved example.com.dig +short, whois.Intermediate 1 — Scoped active scan + evidence.
nmap -sT -T2 against 3–5 expected ports on 127.0.0.1 or a lab VM; save output with -oN.Intermediate 2 — Detect your own scan.
tail -f in one terminal, scan in another.Challenge — Recon plan with an OPSEC and detection view.
Main concepts. Reconnaissance is information gathering, split by one test: does a packet you generate reach the target? Passive recon reads third-party/public data (DNS, WHOIS, CT logs, Shodan/Censys, OSINT) and touches nothing, so it is essentially undetectable by the target. Active recon (ping sweeps, port scans, banner grabs, crawling) sends packets to the target — richer, current data, but logged. OPSEC is minimizing and understanding those footprints. The ordering rule is passive first, then a small, scoped, paced active scan.
Key commands (lab-safe). whois <domain> and dig +short <domain> A behave as passive-style third-party lookups; nmap -sT -T2 -p <ports> 127.0.0.1 -oN file is a disciplined active scan of a host you own. Verify the distinction by tailing the target's log: silent during passive, populated during active.
Common mistakes. Calling a scan "passive"; jumping to a full-range scan first; treating passive as ethics/terms-free; scanning out of scope; assuming no alert means no log.
What to remember. Passive before active; only ever run active recon on systems you own or are authorized to test; log your own activity (timestamp, source, resource, result, decision, correlation id) and never log secrets; and remember that decoding public data or passing a scanner clean never proves a system is secure — nothing is ever completely secure.