theHarvester is the tool almost every red-team engagement and OSINT investigation opens with. Point it at a domain and it queries dozens of third-party datasets — certificate transparency logs, search engines, threat-intel feeds, breach corpora — and hands you back emails, subdomains, hostnames, IPs, ASNs and employee names, without sending a single packet at the target itself. That "passive by default" posture is exactly why it is the safest first pass, and exactly why defenders should run it against their own estate before an attacker does.
This guide installs theHarvester three ways (the modern uv workflow from source, Docker Compose, and the Kali/pipx route), walks every core recon workflow with copy-pasteable commands, wires up the API keys that unlock the high-value sources, and covers the newer HarvestView web UI and REST API for automation. Then it does the part most tutorials skip: shows you how to detect this reconnaissance against your own environment with KQL and SPL.
Everything here is written for authorized use — your own domains, a client with a signed scope, or a lab. Passive does not mean permissionless.
◈ Table of Contents
01 — What theHarvester Is & Why Defenders Care
Phase 1 / 11theHarvester, maintained by Christian Martorella (laramies) since 2011, is an open-source reconnaissance collector written in Python. It has one job: take a target organisation and enumerate its externally visible footprint by asking other people's databases what they already know. It is a staple of the OSINT phase in the OSSTMM and PTES methodologies and ships pre-installed in Kali and Parrot.
Recent releases classify every data source into a capability tier so you always know whether a run touches the target. Understanding these three tiers is the single most important concept for using the tool safely on an engagement.
| Tier | Behaviour | Examples | Touches target? |
|---|---|---|---|
| P0 — Passive | Queries existing third-party datasets only | crtsh, certspotter, bing, duckduckgo, otx, urlscan, hunter, shodan | No |
| P1 — DNS | Resolves / brute-forces DNS records | -r resolution, -c brute force, -n reverse DNS | DNS only |
| P2 — Active | Makes direct HTTP(S) contact with target hosts | -t takeover checks, --screenshot | Yes |
Default runs (a bare -d with P0 sources) send zero traffic to the target's own infrastructure — the result is stitched together entirely from Google, Bing, Certificate Transparency logs and threat-intel APIs. Keep to P0 until your scope explicitly authorises active checks.
A single run against a mid-size organisation typically returns hundreds of artifacts. Each is deduplicated and tagged with the source that produced it, so you can weight confidence.
- 1Emails — harvested from search engines, PGP key servers and breach/OSINT feeds; the seed list for password spraying tests and phishing-resistance reviews.
- 2Subdomains & hosts — the backbone of external attack-surface mapping, largely from Certificate Transparency (crt.sh, certspotter).
- 3IP addresses & ASNs — netblocks that anchor further scanning scope.
- 4Employee names — feed username-convention guessing (e.g.
first.last@). - 5Open ports & banners — when Shodan/Censys keys are configured, without you scanning anything.
theHarvester is not just an attacker tool. The same output is a defender's external-exposure inventory — the shadow subdomains, forgotten dev hosts and leaked mailboxes an attacker would build their target package from.
Attack Surface Discovery
Enumerate every subdomain in Certificate Transparency to find the staging box nobody decommissioned.
Phishing Exposure
See which employee mailboxes are already public before an attacker builds a target list from them.
Recon Pipelines
Feed JSON output straight into amass, httpx and nmap for a full external-assessment chain.
Continuous Monitoring
Schedule runs and diff results to catch new exposed hosts the moment they appear.
02 — Prerequisites & Requirements
Phase 2 / 11theHarvester is cross-platform and light on resources — it is an I/O-bound HTTP client, not a scanner. The one modern requirement worth flagging up front: current releases target a recent Python and are built around the uv package manager.
| Requirement | Minimum | Recommended |
|---|---|---|
| Python | 3.12 min | 3.14 rec (matches repo .python-version) |
| Package manager | pip | uv (used by the project for lockfile installs) |
| OS | Windows 10 / macOS 12 / any modern Linux | Kali or a Linux VM for the full toolchain |
| RAM | 1 GB | 2 GB+ (many concurrent source workers) |
| Network | Outbound HTTPS (443) | Unfiltered egress — proxies break some sources |
| Accounts | None (P0 free sources) | Free API keys: Hunter, Shodan, Censys, VirusTotal |
AUTHORIZATION: theHarvester is passive, but running recon against an organisation you have no permission to assess can still breach computer-misuse law and terms of service on the queried APIs. Only target domains you own or that fall inside a signed engagement scope. "It's just Google results" is not a legal defence.
uv is a fast Rust-based Python package/venv manager. It creates an isolated environment from the project lockfile so you get the exact dependency set the maintainers tested — the most reliable way to avoid the dependency-hell issues older pip installs were famous for.
uv also manages Python itself — uv python install 3.14 pulls the exact interpreter the project pins, so you don't have to touch your system Python at all.
03 — Method 1: uv Install from Source (Recommended)
Phase 3 / 11This is the maintainers' recommended path and always gives you the newest sources and fixes. It clones the repository, resolves the locked dependency tree, and runs the tool inside its own environment.
Three commands take you from nothing to a working install. uv sync reads pyproject.toml / uv.lock, provisions the pinned Python, creates a .venv, and installs every dependency.
Every subsequent invocation is prefixed with uv run, which activates the project environment for that command only. No source .venv/bin/activate needed.
Run a tiny passive query against a domain you control. If Certificate Transparency subdomains come back, the toolchain is healthy.
- The banner prints the version and "Starting harvesting process"
- A list of hosts/subdomains prints under [*] Hosts found
- No ModuleNotFoundError / SSL errors appear
Source modules break constantly as upstream sites change their markup or rate limits. Update often — a subdomain source that worked last month may silently return nothing today.
04 — Method 2: Docker Compose
Phase 4 / 11Docker is the cleanest option for CI pipelines, shared team boxes, or when you want the REST API running as a service. The project ships a Compose definition that runs the tool as an unprivileged user and persists runs in a named volume.
Clone the repo and build from the bundled Dockerfile. This bakes the pinned dependency set into an image so every teammate runs identical code.
Mount a host directory for output and pass CLI arguments straight through. The container is disposable; only the mounted results survive.
Mount your API-key file into the container or the paid sources return nothing: add -v $HOME/.theHarvester:/root/.theHarvester to the docker run line, or bake keys in via an env/secret in Compose.
To run theHarvester as a persistent service — the REST API and HarvestView UI — use a Compose file. This runs as a non-root user, persists the run database in a named volume, and reads provider keys from a mounted secret file so credentials never live in the image.
Binding the port to 127.0.0.1 is deliberate — the REST API and UI have no business being reachable from the network. Front them with an SSH tunnel or reverse proxy with auth if remote access is genuinely required.
05 — Method 3: Kali Linux & pipx
Phase 5 / 11On Kali and Parrot, theHarvester is already installed. That is the fastest way to a working tool, but the packaged version can lag the GitHub master by weeks — worth knowing when a source suddenly breaks.
Confirm it's present and current. If missing, the metapackage pulls it in.
If you don't want the uv workflow but still want an isolated, PATH-linked binary, install straight from the Git repository with pipx. This is ideal on a non-Kali analyst workstation.
Do NOT sudo pip install into system Python. It clobbers OS-managed packages and is the number-one cause of a broken theHarvester and a broken Python at the same time. Use uv, pipx or a venv — never global pip as root.
| Method | Best for | Freshness | Effort |
|---|---|---|---|
| uv from source | Analysts who want latest sources | Newest | Low |
| Docker Compose | API/UI service, CI, teams | Newest (you build) | Medium |
| Kali apt | Quick one-off on Kali | Can lag weeks | None |
| pipx from git | Isolated binary on any distro | Newest | Low |
06 — First Run & Reading the Output
Phase 6 / 11The command grammar is always the same: a target with -d, one or more sources with -b, and optional flags for resolution, output and limits. Learn the flags once and every workflow below is a variation on them.
| Flag | Purpose |
|---|---|
| -d | Target domain or company name |
| -b | Source(s): names (crtsh,bing) or capabilities (subdomains, emails, all) |
| -l | Result limit per source (-l 0 removes the cap) |
| -f | Output filename stem — writes .json / .xml / .jsonl |
| -r | Resolve discovered hostnames to IPs (P1 / DNS) |
| -c | DNS brute force against the domain (P1) |
| -n | Reverse DNS on resolved ranges (P1) |
| -t | Subdomain takeover checks (P2 / active) |
| --screenshot | Screenshot discovered hosts to a directory (P2) |
Run three free P0 sources against a domain and cap results generously. This is the safe "hello world" of external recon.
New to the tool? Run theHarvester -b with no value, or read the help, to print the current list of source names — they change between releases and a stale source name just errors out.
Results stream to the terminal grouped by artifact type. A typical tail looks like this (values illustrative):
- Hosts with
dev,staging,test,uat= forgotten pre-prod exposure - A hostname resolving to an unexpected IP = shadow / third-party hosting
- Role mailboxes = phishing and spray target seeds
The -f flag writes structured output for later parsing. Modern builds emit JSON (grouped by type) and a JSONL stream where the first line is run metadata and each following line is a deduplicated finding with provenance. Runs are also retained in a local SQLite stash.
07 — Data Sources & API Keys
Phase 7 / 11theHarvester supports roughly 60 sources. Many of the best ones — Shodan, Hunter, Censys — require a free or paid API key. Configuring keys is what separates a thin free run from a genuinely deep one.
Keys are read from a YAML file in your home directory. Copy the template from the repo, then fill in the providers you have. System-wide paths (/etc/theHarvester/) also work for shared installs.
Never commit api-keys.yaml to a repo or bake it into a Docker image layer. Add it to .gitignore, mount it read-only at runtime, and rotate any key that has ever touched a shared box.
You do not need all 60. These are the high-value sources per artifact type; the free tiers are enough for most assessments.
| Source | Best for | Key? | Free tier |
|---|---|---|---|
| crtsh | Subdomains (CT logs) | No | Unlimited |
| certspotter | Subdomains (CT logs) | No | Yes |
| otx (AlienVault) | Hosts, passive DNS | Optional | Yes |
| hunter | Corporate emails | Yes | ~25/mo |
| shodan | Open ports, banners | Yes | Limited |
| censys | Hosts, certs, services | Yes | Limited |
| virustotal | Subdomains, passive DNS | Yes | 4 req/min |
| urlscan | Hosts, URLs | No | Yes |
| intelx | Emails, leaks, docs | Yes | Trial |
Once keys are set, chain the sources that complement each other — CT logs for subdomains, Hunter for emails, Shodan for exposed services — in a single command.
Use the capability keyword -b subdomains or -b all to let theHarvester pick every configured source in that category, instead of naming them one by one. all is noisy but exhaustive for a first pass on your own estate.
08 — Core Recon Workflows
Phase 8 / 11These are the recipes you will actually run on an engagement, ordered from safest (pure passive) to most active (direct target contact). Escalate down this list only as your scope allows.
Combine search-engine and email-specialist sources. The output seeds username-convention analysis and phishing-resistance reviews.
CT logs are the single richest passive subdomain source — every TLS certificate ever issued for the domain is public record. crt.sh and certspotter mine exactly that.
CT never forgets. A cert issued for old-intranet.yourcompany.com in 2019 still shows up today — which is precisely how attackers find hosts you decommissioned but forgot to remove from DNS.
Add -r to resolve every discovered hostname. Now you have host-to-IP mappings — the input to netblock scoping and Shodan/Censys pivots.
-c brute-forces subdomains from a wordlist; -n runs reverse DNS across the resolved ranges to catch hosts that share a netblock. These touch DNS (not the target's web tier), so confirm scope covers active DNS queries.
DNS brute force generates a burst of queries against the authoritative name servers and your resolver. On a monitored network this is one of the first things a DNS-anomaly rule flags — expect it to show up in the blue-team queries in Phase 10.
-t checks discovered subdomains for dangling CNAMEs pointing at deprovisioned cloud services — the classic subdomain-takeover condition. This makes direct HTTP contact, so it is a P2 active check.
The --screenshot flag captures every reachable host to an output directory — a fast visual triage of what's exposed, from forgotten admin panels to default install pages.
Big estates need higher limits and more concurrency. Raise the per-source cap and the worker count, but back off if sources start rate-limiting you (HTTP 429).
-b all with -l 0 (uncapped) can run for a long time and will hammer rate-limited APIs. Reserve it for your own estate or an authorised long-run; for time-boxed engagements name the three or four sources that matter.
09 — HarvestView, REST API & Automation
Phase 9 / 11Recent versions ship far more than a CLI: a local web UI (HarvestView), a REST API for programmatic runs, scheduling, and hostname-change tracking. This is what turns theHarvester from a point-in-time command into a continuous exposure monitor.
HarvestView is a local browser interface for running, scheduling and reviewing harvests, and for tracking when a target's hostnames change between runs. It binds to localhost.
The API authenticates with an operator key sent in the X-API-Key header. Submit a run, poll for completion, then export JSONL — the pattern for wiring theHarvester into any orchestrator.
theHarvester is the front of the funnel. Extract its hostnames with jq, then feed live-host probing (httpx) and port scanning (nmap) — the standard external-assessment pipeline.
For continuous monitoring, schedule the JSONL export nightly and diff against yesterday's host list. A brand-new subdomain appearing at 2am is exactly the signal a defender wants — often a shadow-IT deployment nobody told security about.
Scheduled Harvests
HarvestView schedules recurring runs so exposure data is never stale.
Hostname Diffing
Change-tracking flags new or removed hosts between runs automatically.
Pipeline Front-End
JSONL feeds amass, httpx, nuclei and nmap for a full assessment chain.
10 — Blue-Team Use, Maintenance & Troubleshooting
Phase 10 / 11Passive P0 recon is invisible to you by design — you cannot detect someone querying crt.sh. What you can do is (1) monitor your own Certificate Transparency footprint to shrink what recon returns, and (2) detect the active P1/P2 stages (DNS brute force, host probing) when an attacker escalates against your estate.
Run theHarvester against yourself on a schedule and treat the output as a to-do list. You cannot stop CT logging, but you can control what it reveals.
- 1Decommission dangling DNS records for hosts that no longer exist — kills both stale CT hits and takeover risk.
- 2Use wildcard certs sparingly on internal names so pre-prod hostnames don't leak into CT.
- 3Replace public role mailboxes with contact forms where practical to cut harvested emails.
- 4Enforce phishing-resistant MFA so a harvested-email spray has nowhere to land.
The -c brute-force stage produces a spike of failed DNS lookups (NXDOMAIN) for non-existent subdomains from a single source in a short window. Both queries below alert on that burst.
Tune the 50 threshold to your baseline — busy resolvers on large networks generate NXDOMAIN legitimately. Group by an authoritative-zone field if you have one, so you alert on brute force against your domains specifically.
The P2 stages (-t, --screenshot, or a downstream httpx sweep) touch many of your hosts from one source in a short window. Web/WAF logs show one client hitting a large number of distinct hostnames.
Most theHarvester problems are source-side (rate limits, markup changes, missing keys), not bugs in the tool. This table covers the ones you will hit.
| Symptom | Cause | Fix |
|---|---|---|
| A source returns 0 results | Source markup/API changed or is rate-limited | git pull && uv sync; try another source; wait out the limit |
| HTTP 429 / "read timed out" | API rate limit hit | Lower --source-workers, add a paid key, or reduce -l |
| "No API key found for..." | Key missing or wrong YAML path | Check ~/.theHarvester/api-keys.yaml and indentation |
| ModuleNotFoundError | Ran outside the project env | Prefix with uv run, or reinstall via pipx |
| SSL: CERTIFICATE_VERIFY_FAILED | Corporate TLS-inspection proxy | Trust the proxy CA, or run from an unfiltered network |
| Unknown source name error | Source renamed/removed in this release | Print the current source list; update the -b value |
If one specific source consistently fails while others work, it is almost always an upstream change — check the project's GitHub issues before assuming your install is broken.
11 — Sources & References
Phase 11 / 11Primary documentation and reference material used in this guide. Always verify source names and flags against the current release, which changes frequently.
Know your external footprint before an attacker maps it for you.
Run theHarvester against your own domains this week, then paste the resolved host list into CyberHawk's IOC Scanner and browse our blog for the rest of the external-assessment toolchain — Nmap, Shodan, BloodHound and more. Turn recon on yourself before someone else does.
◈ Stay Connected
Follow CyberHawk Threat Intel for threat intelligence, deployment guides and hands-on SOC tooling content.
"They can't exploit you if you are the Exploit."