Google indexes web pages. Shodan indexes devices. It continuously scans the public IPv4 (and increasingly IPv6) internet, connects to open ports, grabs the service banner each host returns, and stores it — the software, version, TLS certificate, geolocation, owning organisation, and any CVEs that banner is known to carry. The result is a search engine for everything plugged into the internet: databases with no password, industrial controllers, exposed RDP, forgotten dev servers, printers, cameras, and your own shadow IT.
This guide is written for the two people who get the most out of Shodan: the defender mapping their organisation's real external attack surface, and the penetration tester doing passive reconnaissance before ever sending a packet at the target. You will install the CLI three different ways, learn the filter language that turns noise into precision, automate everything with the official Python API, and stand up Shodan Monitor so you get an alert the moment a new port opens on your network.
Everything below is passive OSINT against banners Shodan already collected — but the on-demand scan and monitor features do touch hosts directly, so the legal and OPSEC rules in the final phase are not optional reading.
◈ Table of Contents
01 — WHAT SHODAN IS & WHY DEFENDERS USE IT
CONCEPTSShodan runs a fleet of crawlers that pick random public IP addresses around the clock, connect to a large set of common ports, and record the raw response — the "banner" — that each service sends back. It never follows links like a web crawler; it talks directly to services. A single result therefore describes one service on one host: its IP, port, transport, detected product and version, TLS certificate details, hostnames, ASN/organisation, country and city, and any CVEs historically tied to that product version.
Because Shodan indexes the banner, your searches match on what a service advertises about itself — not on live behaviour. A device may have been patched hours ago but still show a vulnerable version until Shodan re-crawls it (typically every few days to a couple of weeks). Always treat results as a lead to verify, never as ground truth.
The same dataset serves opposite missions. Defenders use Shodan to see themselves the way an attacker does — an external, unauthenticated view of every service they have accidentally left exposed. Offensive testers use it to build a target's footprint without sending a single probe, keeping the reconnaissance phase completely off the target's radar.
External Attack Surface Mgmt
Enumerate every port, service and certificate exposed on your org or net ranges, then close what should not be public.
Passive Recon
Map a target's IP ranges, subdomains and tech stack from Shodan's cache — zero packets to the target, zero logs on their side.
Exposure Hunting
Find unauthenticated databases, exposed admin panels and known-CVE services across an ASN before an adversary does.
Continuous Monitoring
Shodan Monitor watches your ranges and alerts on new open ports, new vulns, or newly exposed services in near real time.
Shodan is powerful precisely because it lowers the barrier to finding exposed systems. Searching is legal; connecting to, logging into, or exploiting anything you find is not, unless you own it or hold written authorisation. This guide is for defending your own assets and for authorised testing only.
02 — ACCOUNT, API KEY & CREDIT MODEL
SETUPAlmost every useful Shodan feature — the CLI, the API, monitoring — authenticates with a single API key. Register a free account first, then copy the key from your account page. Keep it secret: your key is tied to your credit balance and can be abused if leaked.
- 1Register at
account.shodan.io/registerand confirm your email. - 2Sign in and open
account.shodan.io— your API Key is shown at the top of the page. - 3Treat it like a password. You will feed it to the CLI once with
shodan init, and reference it from scripts via an environment variable.
A free account lets you log in and run basic searches, but the filter language, bulk export and monitoring are gated behind a paid tier. The most cost-effective option for individuals has long been the one-time Membership unlock (a lifetime upgrade, not a subscription); ongoing high-volume automation uses metered API subscription plans.
| Tier | Search filters | Monitoring | Best for |
|---|---|---|---|
| Free | Very limited; most filters blocked | 1 IP | Trying it out |
| Membership (one-time) | Full filter language, screenshots, export | 16 IPs | Individuals, learners, CTF |
| API subscription | Full + high query/scan volume | Large ranges | Automation, ASM at scale |
Shodan frequently discounts the lifetime Membership around Black Friday. If you only need it for study or occasional recon, wait for that window — it is dramatically cheaper than any subscription and never expires.
Shodan meters usage with three separate credit pools. Understanding them is the difference between a productive month and hitting a wall on day three. Credits from a Membership refresh monthly and do not roll over; the first page of any web search is free, and the count command never costs a credit.
| Credit type | Spent when | Free alternative |
|---|---|---|
| Query credits | Paginating past page 1 of results, or API search() beyond the first 100 results | Use count / facets for totals |
| Scan credits | You request an on-demand scan of a host with shodan scan | Query existing cached data instead |
| Export credits | You bulk-download results with shodan download | Stream/parse smaller result sets |
The classic beginner mistake: running broad shodan download or deep pagination and draining a whole month of query credits in minutes. Always prototype a query with shodan count (free) to see how many results exist before you spend a credit pulling them.
03 — METHOD 1: INSTALL THE CLI NATIVELY
INSTALLThe Shodan CLI is a Python package published on PyPI. On any Linux system with Python 3 and pip you can install it in one line. On modern Kali and Debian releases, the system Python is "externally managed", so prefer a per-user or pipx install to avoid clobbering distro packages.
If you see error: externally-managed-environment, do not force it with --break-system-packages on your main box. Use pipx (above) or a virtualenv (Method 2). Breaking system packages is how you brick a Kali install.
The same pip package works everywhere Python runs. On macOS use Homebrew's Python or pipx; on Windows install from python.org (tick "Add Python to PATH") and use pip from PowerShell.
On Windows, if shodan isn't found after install, your user Scripts directory isn't on PATH. Either add %APPDATA%\Python\Python3x\Scripts to PATH, or just invoke everything as py -m shodan ... — the subcommands are identical.
Before any command works you must bind your API key to the CLI. This is a one-time step; the key is written to a small config file in your home directory (~/.config/shodan/api_key on Linux) and reused by every subsequent command.
- shodan version prints a version number
- shodan init returns "Successfully initialized"
- shodan info shows your plan and credit balances
04 — METHOD 2 & 3: VIRTUALENV & DOCKER
INSTALLA virtualenv keeps Shodan and its dependencies out of your system Python entirely — the right choice on "externally managed" distros and when you script against the API library. Everything lives in one folder you can delete to uninstall.
Inside a venv, the shodan Python library and the shodan CLI are the same install — so import shodan in your scripts and the command-line tool always agree on version. That consistency matters when you automate (Phase 07).
If you want a throwaway, dependency-free environment — or you run Shodan inside CI — a container is ideal. There is no need for a heavyweight image: the official python:slim base plus a one-line pip install gives you a working CLI. Pass the API key as an environment variable so it never bakes into the image.
Never COPY your API key into a Dockerfile or commit it to a compose file. Anyone who pulls the image or reads your git history gets your key and your credits. Always inject it at runtime via -e / environment, as shown.
05 — WEB INTERFACE & SEARCH FILTERS
CORE SKILLAt shodan.io, the search bar accepts free-text and filter:value syntax. Every result shows the IP, hostnames, owning org/ISP, location, and a set of facet sidebars — top ports, top countries, top organisations, top products — that let you pivot instantly. Click any host to see its full banner set and a "Vulnerabilities" panel listing CVEs mapped to the detected versions.
- 1Type a query, e.g.
product:MongoDB, and read the left facet rail to understand the population before drilling in. - 2Use the map and "Images" tabs (screenshots) to triage exposed panels visually.
- 3Open a single host page to see all services, the TLS cert chain, and the CVE list Shodan attaches.
Without filters, a keyword search is noise. Filters are how you slice the internet down to exactly the population you care about. These are the filters you will use daily; combine them freely, and remember most require a paid tier.
| Filter | Matches | Example |
|---|---|---|
| port: | Open port / service | port:3389 |
| product: | Detected software | product:nginx |
| version: | Software version | product:OpenSSH version:8.9p1 |
| org: | Owning organisation | org:"Contoso Ltd" |
| net: | CIDR / IP range | net:203.0.113.0/24 |
| hostname: | Hostname substring | hostname:.example.com |
| asn: | Autonomous System | asn:AS13335 |
| country: / city: | Geolocation | country:US city:"New York" |
| http.title: | HTML <title> | http.title:"Citrix Gateway" |
| http.html: | Body content | http.html:"wp-login" |
| http.status: | HTTP status code | http.status:200 |
| ssl.cert.subject.cn: | TLS cert common name | ssl.cert.subject.cn:example.com |
| ssl.jarm: | JARM TLS fingerprint | ssl.jarm:2ad... |
| vuln: | Mapped CVE (paid) | vuln:CVE-2021-44228 |
| tag: | Shodan tag (paid) | tag:database |
| has_screenshot: | Has a screenshot | has_screenshot:true |
| before: / after: | Banner date (d/m/Y) | after:01/01/2026 |
The vuln: filter is the sharpest and the most restricted — it typically requires an academic or enterprise-grade API plan, not just Membership. If vuln: returns "requires membership" errors, pivot to product: + version: and cross-reference CVEs yourself.
Precision comes from stacking filters and negating noise with a leading minus. The queries below are the kind you run during an authorised engagement or a self-audit — each narrows the internet to one specific exposure class. Point org:/net: at ranges you own or are authorised to test.
Quote multi-word values (org:"Palo Alto Networks"), separate OR-values with commas (port:80,443,8080), and prefix a term with - to exclude it (-http.status:401 drops auth-protected hits). These three tricks cover 90% of real query building.
06 — COMMAND-LINE RECONNAISSANCE
CLI DEEP DIVEThe shodan host command is the fastest way to profile a single address: open ports, detected products, hostnames, org, and mapped vulnerabilities — all from cache, so it costs no query credit. Add --history to see how the host changed over time, or --details for the raw banners.
Always size a query with count (free) before spending credits with search. search prints matching results and accepts --fields to control columns and --limit to cap output — critical for not burning query credits on a huge result set.
Omitting --limit lets search paginate deep and quietly consume one query credit per page beyond the first. On broad queries that is your whole monthly allowance. Cap it, always.
Facets are aggregate breakdowns and they are the analyst's best friend: instead of listing hosts, they summarise a population by any field — top ports, top products, top ASNs, top vulns. This is how you understand an org's exposure at a glance, cheaply.
Facets read from the search index, so a facet query is far cheaper than pulling every host. When you onboard a new range for monitoring, run a stats --facets pass first to map the shape of the exposure before drilling into individual hosts.
For a snapshot you can diff over time, download writes results to a compressed JSON lines file (costs export credits, one per result set page), and parse extracts fields from that file locally — free, repeatable, and perfect for feeding a spreadsheet or SIEM.
Three small commands earn their keep constantly. myip returns your current public IP (handy in scripts and VPN checks), domain dumps DNS + subdomain intel for a domain, and honeyscore estimates the probability that an IP is a honeypot — useful before you trust an "easy" target during authorised testing.
Run shodan domain yourcompany.com against your own domains regularly — it surfaces subdomains and DNS records that Shodan has seen, which is a cheap way to catch forgotten staging., vpn-old. and test. hosts before an attacker enumerates them.
07 — AUTOMATE WITH THE PYTHON API
AUTOMATIONThe same shodan package exposes a clean Python client. Read the key from an environment variable — never hard-code it — and you have programmatic access to search, host lookups, counts, facets and alerts.
Set the key in your shell (export SHODAN_API_KEY=...) or a .env that is git-ignored. A hard-coded key committed to a public repo is the single most common way Shodan users get their credits drained by scrapers.
Use count() first (free), then iterate results deliberately. The search_cursor() helper pages through large result sets one item at a time — but every page past the first costs a query credit, so gate it with a hard cap.
Here is something you can actually run weekly against ranges you own: it walks your networks, flags any service on a "should-never-be-public" port list, and prints a report you can email or push to a ticket queue. It uses only cached data and cheap host lookups.
- Any RDP, database, VNC or Telnet service reachable from the internet
- The product/version banner for each exposed service
- CVEs Shodan has already mapped to those banners
- A diff-able text report you can schedule via cron
08 — ATTACK SURFACE MONITORING
DEFENSIVEShodan Monitor (monitor.shodan.io) lets you register the IP ranges you are responsible for and get notified whenever the exposure changes — a new port opens, a new service appears, or a known CVE is detected. It is the single highest-value defensive feature Shodan offers, and Membership includes a modest IP quota.
- 1Open
monitor.shodan.ioand click Add IP / Network. - 2Enter your CIDR ranges — only ranges you own or are authorised to watch.
- 3Configure notifications (email, and via API a webhook) for the trigger types you care about.
Only add networks you are authorised to monitor. Registering someone else's range doesn't scan it for you — Shodan already has the data — but building alerting workflows around third-party assets you don't own is out of bounds.
Everything Monitor does in the browser is scriptable through shodan alert. Create an alert bound to a range, list your alerts, and wire triggers so changes generate notifications — perfect for baking attack-surface monitoring into infrastructure-as-code.
The shodan stream command opens a live feed. Restricted to your own alerts with --alerts, it prints banner events as Shodan observes changes on your monitored ranges — pipe it to a script and you have a home-grown SOC feed.
Point shodan stream --alerts at a small handler that forwards new-service and vulnerable-service events into your ticketing or chat system. You now get external-exposure detection with a latency measured in Shodan's crawl interval — for free with an account you already pay for once.
09 — INTEGRATIONS: NMAP, METASPLOIT, NUCLEI
TOOLINGNmap ships a shodan-api NSE script that queries Shodan's cache for each target's host data — so you learn open ports and CVEs without sending scan packets. That is invaluable when you want an initial picture but must stay quiet on the wire.
Pair this with our full Nmap tutorial: use the Shodan NSE script to build a cheap, silent host list first, then switch to active Nmap scanning only on the handful of hosts that actually warrant packets.
Metasploit's auxiliary/gather/shodan_search module runs a Shodan query from inside the console and drops results into the workspace database, so hosts you discover flow straight into the rest of your (authorised) engagement.
Feeding Shodan results into Metasploit blurs recon and exploitation fast. Keep the scope document open: a host appearing in Shodan does not put it in your authorised target list. Only act on assets explicitly in scope.
Shodan's InternetDB API (internetdb.shodan.io) returns open ports, hostnames, tags and CVEs for a single IP with no key and no credits — ideal for lightweight enrichment in a pipeline. Pipe those IPs into a scanner like Nuclei to validate exposures on assets you are authorised to test.
InternetDB has no rate-limit gate on a key, so it is the right choice for enriching large IP lists in CI or dashboards. Reserve your credit-bearing Shodan queries for the filter-rich searches InternetDB can't do.
10 — ADVANCED, OPSEC & TROUBLESHOOTING
PROMost Shodan work is passive, reading cached banners. But shodan scan asks Shodan to actively re-scan an IP or range now and costs scan credits. This does send packets at the target, so it is only appropriate against assets you own or are explicitly authorised to test.
shodan scan generates real traffic to the target from Shodan's infrastructure. Running it against systems you don't own or have written permission to test can constitute unauthorised scanning. Passive search does not carry this risk; active scan does.
Shodan makes exposure trivial to find, which makes discipline essential. Searching the index is passive and legal in most jurisdictions; the moment you interact with a discovered host — logging in, downloading data, exploiting a CVE — you leave OSINT and enter conduct that requires authorisation.
Always fine
Searching banners, running facets, profiling your own ranges, monitoring assets you own.
Authorisation required
Active scan submit, InternetDB→Nuclei chains, or Metasploit against a target — only within a signed scope.
Never
Logging into an "open" database, screenshotting private panels, or touching third-party systems you don't own.
Most Shodan CLI and API problems come down to four causes: PATH, key binding, plan limits, or credit exhaustion. This table maps the message you see to the fix.
| Symptom | Cause | Fix |
|---|---|---|
| shodan: command not found | User scripts dir not on PATH | Re-open shell; pipx ensurepath; or run python3 -m shodan |
| Invalid API key | Never ran init / wrong key | shodan init <key>; re-copy from account.shodan.io |
| Requires membership | Filter (vuln/tag) needs paid tier | Upgrade, or pivot to product:+version: |
| 403 / Access denied | Query credits exhausted | Use count/facets; wait for monthly refresh |
| externally-managed-environment | PEP 668 on Kali/Debian | Install with pipx or in a venv |
| No information available | Host not yet crawled | Try scan submit (own IPs) or wait for re-crawl |
When automating, always wrap API calls in a handler for shodan.APIError and back off on rate-limit messages. The free/Membership API is rate-limited to roughly one request per second — respect it and your long-running jobs won't get throttled or blocked.
11 — SOURCES & REFERENCES
DOCSPrimary documentation used to verify every command, filter and credit rule in this guide:
Everything in this tutorial is for defending assets you own and for authorised security testing only. Passive Shodan searches are OSINT; the scan, monitor and integration features touch live hosts and must be limited to systems you own or hold written permission to test. Unauthorised scanning or access violates computer-misuse law in most jurisdictions. CyberHawk Threat Intel and the author accept no responsibility for misuse of these techniques.
- Nmap Complete Tutorial — turn Shodan leads into verified, active scans
- theHarvester & Recon-ng — round out passive OSINT and subdomain enumeration
- Nuclei & OpenVAS — validate the exposures Shodan surfaces on in-scope hosts
- CyberHawk SOPs — structured response for when an exposure turns into an incident
◈ 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."