Skip to content

Bagre Threat Intelligence Executor

Category: Discovery and Reconnaissance Script: bagre.py Integration: REST API (Intelligence X) / ClickHouse Faraday Plugin: Raw JSON Website: https://intelx.io/

Description

Searches leaked-credential sources for records that belong to a domain and imports them into Faraday. It can query the Intelligence X API (default) or an on-premise ClickHouse leak database. Matching records are grouped into a Faraday vulnerability whose data lists the exposed URLs, usernames and related details; optionally the matched credentials can also be created as Faraday credential objects linked to that vulnerability.

Prerequisites

  • For the Intelligence X backend: an Intelligence X account and API key
  • For the ClickHouse backend: network access to the ClickHouse server and a username and password with read access to the leak tables
  • At least one search parameter (TARGET_DOMAIN, MAIL_DOMAIN or URI_PATH) per run
  • To create and link Faraday credentials: BAGRE_IMPORT_CREDS=true and the FARADAY_URL, FARADAY_USER, FARADAY_PASSWORD and FARADAY_WORKSPACE variables

Configuration

Environment Variables (Setup)

Variable Required Description
BAGRE_SOURCE Yes Leak-source backend. Valid: 'intelx' (Intelligence X public API), 'intelx_leaks' (IntelX Leaks-only bucket subset), 'clickhouse' (on-prem leak-DB). Default 'intelx'.
INTELX_API_KEY No* Intelligence X API key (register at intelx.io). Required when BAGRE_SOURCE is intelx or intelx_leaks.
INTELX_BASE_URL No Intelligence X API base URL (default: https://2.intelx.io).
INTELX_BUCKETS No Comma-separated Intelligence X bucket names to search (default: leaks.logs,leaks.private,leaks.public,pastes,dumpster).
INTELX_MAX_FILES No Cap on files downloaded per search (default: 50; 0 lifts the cap).
INTELX_MAX_FILE_SIZE No Skip individual files larger than this, in bytes (default: 5242880, 5 MB).
INTELX_TIMEOUT_S No HTTP timeout for Intelligence X API calls, in seconds (default: 15).
CLICKHOUSE_HOST No ClickHouse host for the on-prem leak-DB backend (BAGRE_SOURCE=clickhouse). Bare hostname or IP (default: localhost).
CLICKHOUSE_PORT No ClickHouse TCP port (default: 9000).
CLICKHOUSE_DATABASE No ClickHouse database name for the leak tables (default: credentials_db).
CLICKHOUSE_USER No* ClickHouse username. Required when BAGRE_SOURCE=clickhouse.
CLICKHOUSE_PASSWORD No* ClickHouse password. Required when BAGRE_SOURCE=clickhouse.

* Depends on the selected backend: the Intelligence X backends need INTELX_API_KEY; the ClickHouse backend needs CLICKHOUSE_USER and CLICKHOUSE_PASSWORD. The run fails validation if the selected backend's credentials are missing.

Execution Arguments

Parameter Type Mandatory Description
TARGET_DOMAIN string No Apex domain to search for leaked credentials, e.g. 'faradaysec.com'. At least one of TARGET_DOMAIN / TARGET_SUBDOMAIN / MAIL_DOMAIN / URI_PATH must be set per scan.
TARGET_SUBDOMAIN string No Narrow search to a specific subdomain (LIKE wildcards allowed for the ClickHouse backend, e.g. '%.apps.example.com').
MAIL_DOMAIN string No Narrow to leaks whose email address is on this domain (e.g. 'faradaysec.com' catches john@faradaysec.com).
URI_PATH string No Narrow to leaks referencing a specific URI path (e.g. '/admin').
LIMIT integer No Cap the number of leak records returned (default: 100; 0 or a negative value returns every match found).

YAML Configuration Example

executors:
  bagre:
    repo_executor: bagre.py
    max_size: 65536
    varenvs:
      BAGRE_SOURCE: "<bagre_source>"
      INTELX_API_KEY: "<intelx_api_key>"
      INTELX_BASE_URL: "<intelx_base_url>"
      INTELX_BUCKETS: "<intelx_buckets>"
      INTELX_MAX_FILES: "<intelx_max_files>"
      INTELX_MAX_FILE_SIZE: "<intelx_max_file_size>"
      INTELX_TIMEOUT_S: "<intelx_timeout_s>"
      CLICKHOUSE_HOST: "<clickhouse_host>"
      CLICKHOUSE_PORT: "<clickhouse_port>"
      CLICKHOUSE_DATABASE: "<clickhouse_database>"
      CLICKHOUSE_USER: "<clickhouse_user>"
      CLICKHOUSE_PASSWORD: "<clickhouse_password>"
    params:
      TARGET_DOMAIN:
        mandatory: false
        type: string
        base: string
      TARGET_SUBDOMAIN:
        mandatory: false
        type: string
        base: string
      MAIL_DOMAIN:
        mandatory: false
        type: string
        base: string
      URI_PATH:
        mandatory: false
        type: string
        base: string
      LIMIT:
        mandatory: false
        type: integer
        base: integer

How It Works

  1. Loads its configuration from environment variables and validates that the selected BAGRE_SOURCE backend has its required credentials.
  2. Requires at least one search term (TARGET_DOMAIN, MAIL_DOMAIN or URI_PATH); if none is given, the run ends without results.
  3. Queries the selected backend: for Intelligence X it searches the configured buckets and downloads matching files; for ClickHouse it queries the leak tables. Results are optionally narrowed by TARGET_SUBDOMAIN and capped by LIMIT.
  4. Builds a Faraday bulk_create payload directly (no plugin): the matched records are summarised in a vulnerability whose data field lists each record's URL, username, email and other available fields.
  5. If BAGRE_IMPORT_CREDS=true and the Faraday connection variables are set, also creates Faraday credential objects and links them to the imported vulnerability.

Notes

  • The executor builds Faraday JSON itself instead of using a faraday-plugin.
  • Leaked findings are attached to a host derived from the affected domain; hostname resolution is attempted, and the hostname is used as-is when it cannot be resolved.
  • The Intelligence X and ClickHouse backends are mutually exclusive; the unused backend's variables are ignored.
  • The shared agent parameters (AGENT_CONFIG_* tags and severity filters) are not applied by this executor.
  • The executor depends on a vendored bagre package that is bundled in the published dispatcher image; it fails with an explanatory message if that package is not installed.