Skip to content

Censys Search Executor

Category: Attack Surface Management Script: censys.py Integration: REST API Faraday Plugin: Raw JSON Website: https://search.censys.io

Description

Runs a Censys Search v2 query and imports the matching hosts, exposed services and certificates into Faraday as attack-surface discoveries.

Prerequisites

  • A Censys account with Search API access
  • A Censys API ID and secret, from the console under Account > API
  • requests available in the agent's Python environment

Configuration

Environment Variables (Setup)

Variable Required Description
CENSYS_HOST Yes Censys Search API host (default: https://search.censys.io). Change only for a federated or on-prem deployment.
CENSYS_API_ID Yes Censys API ID, from the console under Account > API
CENSYS_API_SECRET Yes Censys API secret paired with the API ID

These variables are also accepted as execution arguments, so a single run can override them.

Execution Arguments

Parameter Type Mandatory Description
CENSYS_QUERY string Yes Censys query language filter (e.g., services.service_name: HTTP and location.country_code: AR)
CENSYS_VIRTUAL_HOSTS string No How to handle virtual hosts on the hosts search: INCLUDE, EXCLUDE or ONLY (default: EXCLUDE). Boolean-style values (true/false) also work. Ignored on the certificates search.
CENSYS_PAGES string No Maximum number of pages of 100 hits to read for hosts and, separately, for certificates (default: 5, maximum: 50)

YAML Configuration Example

executors:
  censys:
    repo_executor: censys.py
    max_size: 65536
    varenvs:
      CENSYS_HOST: "https://search.censys.io"
      CENSYS_API_ID: "<censys_api_id>"
      CENSYS_API_SECRET: "<censys_api_secret>"
    params:
      CENSYS_QUERY:
        mandatory: true
        type: string
        base: string
      CENSYS_VIRTUAL_HOSTS:
        mandatory: false
        type: string
        base: string
      CENSYS_PAGES:
        mandatory: false
        type: string
        base: string

How It Works

  1. Authenticates every request with HTTP Basic (CENSYS_API_ID as the username, CENSYS_API_SECRET as the password)
  2. Runs CENSYS_QUERY against GET /api/v2/hosts/search and separately against GET /api/v2/certificates/search, 100 hits per page (cursor-based pagination)
  3. Creates one host per matching IP (or per virtual host name), with its ASN, location and OS fingerprint in the description, and one Faraday service per exposed port
  4. Creates one vulnerability per exposed service, named [EASM] Censys exposed <service> on <port>/<proto>. Severity is info by default, low for historically risky unauthenticated services (Telnet, FTP, SMB, RDP, database ports, Docker/Kubernetes APIs, etc.), and medium when the TLS certificate is self-signed, expired or untrusted.
  5. Creates one host per matching certificate, on the synthetic IP 0.0.0.0 with the certificate's SANs as hostnames, and one info vulnerability with the certificate details

Notes

  • CENSYS_QUERY is mandatory; Censys rejects an empty query.
  • The virtual-hosts setting only affects the hosts search. Set CENSYS_VIRTUAL_HOSTS=ONLY to search virtual hosts exclusively.
  • By default the executor reads at most 500 host hits and 500 certificate hits per run. Raise CENSYS_PAGES for larger result sets.
  • CENSYS_HOST can be given with or without https://. Without it, https:// is assumed. The default is the public Censys cloud.
  • The run stops if the credentials are rejected (HTTP 401). If Censys rate-limits or denies a later request, the executor keeps what it has already read.
  • The shared agent parameters (AGENT_CONFIG_* tags and severity filters) are not applied by this executor.