censys-search
Use when the user wants to run a censys search, censys search for hosts or certificates, search censys for hosts/certs/web properties, find censys hosts with a given condition, run a censys query for hosts, or search for certificates on censys using CenQL. Wraps the `censys search` CLI subcommand. Trigger phrases include "censys search," "search censys for," "find censys hosts with," "censys query for hosts," and "search for certificates on censys." Do not use for viewing a single known host/cert/domain by identifier (see censys-view) or for aggregating/counting by field (see censys-aggregate).
- License 许可
- Apache-2.0
- 最近更新
- 2026-10-30
- Stars
- ★ 14
- Forks
- 0
01 前言 Front Matter
- name
- censys-search
- version
- 0.1.0
- description
- Use when the user wants to run a censys search, censys search for hosts or certificates, search censys for hosts/certs/web properties, find censys hosts with a given condition, run a censys query for hosts, or search for certificates on censys using CenQL. Wraps the `censys search` CLI subcommand. Trigger phrases include "censys search," "search censys for," "find censys hosts with," "censys query for hosts," and "search for certificates on censys." Do not use for viewing a single known host/cert/domain by identifier (see censys-view) or for aggregating/counting by field (see censys-aggregate).
02 资源文件 1
- 参考文档references/cli-globals.md1.9 KB
03 SKILL.md 正文
Censys Search
When to use
Use this skill whenever the user wants to run a full-text or structured Censys Query Language (CenQL) query against Censys host, certificate, or web-property data via the censys search CLI command. This covers requests like:
- "censys search for SSH hosts not on port 22"
- "search censys for certificates matching censys.com"
- "find censys hosts with port 443 open in Germany"
- "censys query for hosts running HTTP"
If the user already has a specific IP, cert SHA-256, or FQDN and wants a single-record lookup (not a query), that's censys-view, not this skill. If the user wants counts/breakdowns by field value rather than raw matching records, that's censys-aggregate. If the user needs help writing or debugging the CenQL query itself, defer to censys-cenql.
Invocation
Base form:
censys search "<CenQL query>" [flags]
Search-specific flags
| Flag | Alias | Description |
|---|---|---|
--fields |
-f |
Comma-separated list of fields to return (reduces payload size and speeds up parsing) |
--page-size |
-n |
Results per page (default: 100) |
--max-pages |
-p |
Max pages to fetch (default: 1; use -1 for exhaustive/all pages) |
--collection-id |
-c |
Restrict the search to a specific collection (UUID) |
Output format
Pass --output-format/-O with one of: json (default), yaml, tree, short, template. For streaming/pipeline use, pass --streaming/-S to emit NDJSON (one JSON object per line) instead of a single JSON array — this is required for piping into jq over exhaustive result sets without buffering the whole array in memory.
Global CLI flags
See ${CLAUDE_SKILL_DIR}/references/cli-globals.md for the full global flags reference (output
format, streaming, diagnostics, org-id, and PAT vs OAuth notes).
Common patterns
# Find SSH hosts not on port 22
censys search 'host.services: (protocol=SSH and not port: 22)' -O short
# Search with specific fields returned
censys search --fields host.ip,host.location.country "host.services.protocol=HTTP"
# Exhaustive export to NDJSON, extract IPs with jq
censys search "host.services.port: 443 and host.location.country: Germany" \
--max-pages -1 --streaming | jq -r '.host.ip'
# Search within a specific collection
censys search -c <collection-uuid> "host.services.protocol=SSH"
# Paginated results (5 pages of 50 each = up to 250 results)
censys search --page-size 50 --max-pages 5 "cert.names=censys.com"
Post-retrieval filtering
Once results are retrieved, use jq for filtering, projecting, and counting rather than trying to encode every condition in CenQL:
# Extract specific fields from JSON output
censys search "host.services.port=22" | jq '.[].host.ip'
# Filter results by condition
censys search "host.services.port=443" -O json | \
jq '[.[] | select(.host.location.country_code == "US")]'
# Count results matching a sub-condition
censys search "host.services.protocol=SSH" --max-pages 3 -O json | \
jq '[.[] | select(.host.services[]? | .port == 22)] | length'
Output guidance
- Default to
-O shortfor quick human review of a handful of results in the terminal. - Use the default
json(or-O jsonexplicitly) when the output will be piped intojqor another tool for filtering/analysis. - Use
--streaming(NDJSON) whenever--max-pages -1(exhaustive) is combined with a pipeline — this avoids holding the full result set in memory as one JSON array and letsjqprocess records incrementally. -O treeis useful for visually inspecting the full nested structure of a single result during ad-hoc exploration.-O templatesupports custom output formatting when the user needs a specific text layout (e.g., for a report or script).
Export workflow
For bulk exports, always aggregate first to check population size before spending credits on a full pull:
# Step 1: Check distribution before committing to a full pull
censys aggregate "<query>" "host.location.country"
# Step 2: Export using the plugin's export script
"${CLAUDE_PLUGIN_ROOT}/scripts/censys-export.sh" "<query>" ips data/hosts.txt
"${CLAUDE_PLUGIN_ROOT}/scripts/censys-export.sh" "<query>" ndjson data/hosts.ndjson
"${CLAUDE_PLUGIN_ROOT}/scripts/censys-export.sh" "<query>" csv data/hosts.csv
The export script uses streaming (-S) by default to avoid buffering large
result sets. Formats:
ips— plain text, one IP per linendjson— one JSON object per line (ip, asn, country, services)csv— spreadsheet-ready with header row
Without an output file, the script writes to stdout for piping into jq or
other tools.
Export caveats
software.productvalues are lowercase —software.product="AnyDesk"silently returns nothing; usesoftware.product: "AnyDesk"(:is case-insensitive) orsoftware.product="anydesk". Seecensys-cenqlfor=vs:guidance.2>/dev/nullsuppresses the status line (e.g.200 (OK) - 1.2s) that the CLI writes to stderr — without it, the status text can pollute piped output.
Error handling
- Invalid CenQL syntax: the CLI returns an error message that includes the malformed part of the query. Check
censys-cenqlfor field paths, operators, and syntax reference before retrying. - Auth expired / unauthorized: run
censys auth loginto re-authenticate (OAuth), or verify the PAT is still valid viacensys config auth addif using a token. - Rate limited: back off and retry after a delay. Check remaining credits with
censys creditsbefore issuing another large/exhaustive query. - Empty results with a PAT and multi-org access: pass
--org-id/-oexplicitly — the query may be scoping to the wrong (or no) organization.
Parsing CLI output programmatically
When redirecting censys search -O json to a file and parsing it later:
- stdout is valid JSON. The output (when using
-O json) is a single JSON array[...]starting on the first line. Parse it directly — no line-skipping needed. The status line (e.g.,200 (OK) - 347ms) goes to stderr. - Empty results may be
null. Some queries returnnullinstead of[]for zero results. Defensive parsing:data = json.load(f) or []. - Suppress stderr in pipelines. Use
2>/dev/nullwhen piping intojqto suppress the status line and any diagnostic output. Use-qto suppress response metadata at the source.
Caveats
-
--max-pages -1fetches up to the API maximum of 100 pages (10,000 results at the default page size) (per CLI config docs) — this can consume significant API credits on broad queries, and returns no warning when capped. Confirm scope with the user (or add tightening conditions) before running an unbounded exhaustive search on a broad query. -
--page-sizeabove the platform's per-page maximum will be clamped by the API; there is no benefit to setting it above that ceiling. -
--fieldsonly trims the returned payload — it does not change which records match the query. Filtering must still happen in the CenQL query itself or via post-retrievaljqfiltering. -
Results are subject to Censys data freshness/indexing lag; a very recent scan may not yet appear in search results.
-
--collection-idrequires a valid collection UUID that the authenticated identity has access to; an unrecognized or unauthorized UUID returns an error rather than an empty result set. -
Run
censyscommands one at a time (cencli < 1.1.3). On versions before 1.1.3, the CLI's local cache database can producefailed to set journal_mode WAL: database is locked (261)when two or more concurrentcensysprocesses run. The command exits 0 and writes an empty output file, so the failure is easy to miss. Check that each output file is not empty before you use it. The fix in cencli 1.1.3 (#82) serializes concurrent database initialization. On 1.1.3+, parallel invocations have been observed to succeed (verified on cencli 1.1.3, 2026-08), though a race cannot be fully excluded. -
To count matching hosts, use the plugin's count script:
"${CLAUDE_PLUGIN_ROOT}/scripts/censys-count.sh" '<query>'The script pages the full result set and prints the count. It exits 2 with a warning if the count hits the 10,000-result API ceiling (100 pages × 100 per page) — treat that number as a floor, not a total.
Do not add
censys aggregatebuckets to get a total —-nlimits the bucket list (default 25) and the sum can be far below the true total. Seecensys-aggregate.
Managing collections (no CLI support)
censys search and censys aggregate can read a collection with -c, but the CLI cannot create, update, list, or delete one. Use the Platform API for that. Authenticate with CENSYS_PLATFORM_TOKEN and CENSYS_PLATFORM_ORGID. These are Platform API variables — they are not used by the censys CLI itself, which stores credentials in its own database.
Base URL: https://api.platform.censys.io/v3/collections. Every request needs ?organization_id=$CENSYS_PLATFORM_ORGID.
| Action | Method | Path |
|---|---|---|
| List | GET |
/v3/collections |
| Read one | GET |
/v3/collections/<id> |
| Create | POST |
/v3/collections |
| Update | PUT |
/v3/collections/<id> |
Create and update take the same JSON body: {"name": ..., "description": ..., "query": ...}.
# create
jq -n --arg n "My collection" --arg d "What it tracks" --arg q '<CenQL>' \
'{name:$n, description:$d, query:$q}' > /tmp/c.json
curl -sS -X POST -H "Authorization: Bearer $CENSYS_PLATFORM_TOKEN" \
-H "Content-Type: application/json" --data @/tmp/c.json \
"https://api.platform.censys.io/v3/collections?organization_id=$CENSYS_PLATFORM_ORGID"
Notes:
PUTis the update verb.PATCHandPOSTagainst/v3/collections/<id>both return HTTP 405.- Build the JSON body with
jq -n --arg, not a shell heredoc. CenQL queries contain double quotes and backslash escapes that break under manual shell quoting. - The list endpoint paginates. It returns 100 collections per page plus
result.next_page_token. Loop on that token until it is empty. A new collection does not always appear on page 1, so do not conclude that creation failed after checking one page. - After a create or an update,
statusispopulatingandtotal_assetsis0. The status becomesactiveand the count settles after a short delay. An update setsstatus_reasontoquery_changed. - Verify membership with a collection-scoped search:
censys search -c <id> '<broad query>' --max-pages -1 -O json | jq 'length'. - Collections are visible to the whole organization. Write a description that explains what the collection tracks, which known-benign members it contains and why, and which indicators were deliberately left out.
Cross-references
- censys-cenql — CenQL syntax, field paths, operators, and query cookbook. Defer here for help constructing or debugging the query string itself.
- censys-view — single-record lookup by IP/SHA-256/FQDN (not a query).
- censys-aggregate — aggregate/count results by field instead of returning raw records.
- censys-analyze — deeper post-retrieval analysis: jq recipes, SQLite, batch cert analysis, cross-referencing.
04 同仓库更多 Skills
censys-view
Use when the user wants detailed point-lookup data on a single asset via the Censys CLI — e.g. "censys view," "censys look up this IP," "censys host details for," "view this cert on censys," "censys what services does X run," "censys view this cert," "look this host up on censys," "censys pull the record for," "what does censys show for this hostname," "what's running on this IP," "profile this host," or "show me this host's services." Wraps `censys view` for hosts, certificates, and web properties. This is the right skill for any single-asset lookup — use censys-investigate only when the user explicitly asks for a multi-step investigation. Not for search-by-criteria (see censys-search) or time-series history (see censys-timeline).
censys-timeline
Use when the user wants temporal analysis of how a Censys-tracked asset changed over time — e.g. "censys timeline," "censys host history," "censys what changed on this host," "censys when did this service appear," "censys change detection," "censys temporal analysis," "censys track cert rotations," or "censys did this host change hands." Wraps `censys history` for hosts, web properties, and certificates. Not for current-state lookups (see censys-view) or criteria search (see censys-search).
censys-investigate
Use when the user explicitly requests a multi-step Censys investigation — e.g. "censys investigate," "censys deep dive into," "trace this infrastructure with censys," "censys pivot chain," "full censys investigation," "hunt for related infrastructure," or "/censys-investigate." This is a heavyweight methodology skill (typically 20–50+ API calls) — do NOT fire on simple lookups like "what's running on this IP" or "profile this host" (use censys-view for those). Structured as a baseline collection phase followed by decision trees that branch on what the baseline reveals. Prescribes a findings template and data preservation convention. Always confirms scope and estimated cost with the user before starting.
censys-enrich
Use when the user wants fast, credit-free IP context for SOC/triage work via the Censys CLI — e.g. "censys enrich," "censys enrich this IP," "censys bulk enrich," "censys triage IP," "censys SOC lookup," "is this IP interesting per censys," "censys check this IP for scanning activity," or "censys reputation on this address." Wraps `censys enrich` for single/bulk IP enrichment (location, AS, WHOIS, DNS, labels, GreyNoise, reputation, network/privacy classification, third-party verdicts). Not for full host records with all services and raw banners (see censys-view) or criteria-based search (see censys-search).
censys-censeye
Use when the user wants to run censys censeye, censys pivot analysis, censys rarity analysis, censys find related infrastructure, or run censeye on a host. Wraps the `censys censeye` CLI subcommand to analyze a single host and generate pivotable threat-hunting queries bounded by rarity (how many other hosts share each attribute). Trigger phrases include "censys censeye," "censys pivot analysis," "censys rarity analysis," "censys find related infrastructure," and "run censeye on." Requires Threat Hunting feature access on the organization. Not for criteria-based search (see censys-search) or single-record point lookups (see censys-view).
censys-cenql
Use when the user needs help with CenQL syntax, censys query syntax, how to write a censys query, what censys fields are available, or censys query help — field paths, operators, quoting/escaping rules, or example queries for hosts, certificates, and web properties. Trigger phrases include "CenQL syntax," "censys query syntax," "how do I write a censys query," "what censys fields are available," and "censys query help." Also fires when the user writes "CQL," a frequent misspelling of CenQL. This is a reference skill, not a CLI wrapper — defer to censys-search, censys-aggregate, or censys-view to actually execute the query once it's constructed.