cachex

module
v1.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2025 License: MIT

README ΒΆ

cachex

A high-accuracy, behavioral cache poisoning scanner for modern Web APIs

🌟 Why CacheX?

Most cache poisoning scanners only check:

  • whether a response changes with certain headers
  • or whether cache-related headers exist

This produces tons of false positives and rarely confirms a real exploit.

CacheX is different.

It performs behavioral diffing, multi-threaded poisoning, and persistence verification, confirming only real, weaponizable cache poisoning.

demo

πŸ”₯ Features

  • ⚑ High-speed multi-threaded scanning
  • 🎯 Zero-FP design with behavioral diffing
  • πŸ” Real-time cache poisoning attempts
  • πŸ§ͺ Persistence confirmation for true vulnerabilities
  • πŸ” Single and multi-header scan modes
  • 🧩 YAML-based payload configuration
  • πŸ“€ JSON or pretty output formats
  • πŸ“ Optional file-based export
  • 🏷 Tentative vs confirmed vuln tagging

πŸ”§ Installation

go install github.com/ayuxsec/cachex/cmd/cachex@latest

Or build manually:

git clone --depth=1 https://github.com/ayuxsec/cachex
cd cachex
go build -o cachex "cmd/cachex/main.go"
./cachex -h

πŸš€ Usage

▢️ Scan a single URL

cachex -u https://example.com

▢️ Scan multiple targets

cachex -l urls.txt

▢️ Scan URLs via pipeline

echo "https://example.com" | cachex

or:

cat urls.txt | cachex

πŸ“Œ All CLI Flags

Category Flag Description
Input -u, --url URL to scan
-l, --list File with list of URLs
Concurrency -t, --threads Number of scanning threads
-m, --scan-mode single or multi
HTTP Client --timeout Total request timeout
--proxy Proxy URL
Persistence Check --no-chk-prst Disable persistence checker
--prst-requests Poisoning requests
--prst-threads Threads for poisoning
Output -o, --output Output file
-j, --json JSON output
Payloads --pcf Custom payload config file

πŸ’‘ Example

cachex -l targets.txt -t 50 --pcf payloads.yaml --json -o results.json

βš™οΈ Configuration

CacheX automatically loads:

~/.config/cachex/config.yaml
~/.config/cachex/payloads.yaml

You can configure:

  • Payload headers
  • Default request headers
  • Timeouts & concurrency
  • Logging mode
  • Proxy settings
  • Persistence checker behavior

πŸ“ Output Formats

Pretty Output

[vuln] [https://target.com] [Location Poisoning] [header: X-Forwarded-Host: evil.com] [poc: https://target.com?cache=XYZ]

JSON Output

{
  "URL": "https://target.com/",
  "IsVulnerable": true,
  "IsResponseManipulable": true,
  "ManipulationType": "ChangedBody",
  "RequestHeaders": {
    "Accept": "*/*",
    "User-Agent": "Mozilla/5.0"
  },
  "PayloadHeaders": {
    "X-Forwarded-Host": "evil.com"
  },
  "OriginalResponse": {
    "StatusCode": 200,
    "Headers": {
      "...": "..."
    },
    "Body": "...",
    "Location": ""
  },
  "ModifiedResponse": {
    "StatusCode": 200,
    "Headers": {
      "...": "..."
    },
    "Body": "...",
    "Location": ""
  },
  "PersistenceCheckResult": {
    "IsPersistent": true,
    "PoCLink": "https://target.example.com/?cache=XYZ",
    "FinalResponse": {
      "StatusCode": 200,
      "Headers": {
        "...": "..."
      },
      "Body": "...",
      "Location": ""
    }
  }
}

πŸŽ› Scan Modes

  • single: precise, tests each header independently
  • multi: fast, tests all payload headers together

🧩 Payload Headers

Defined in:

~/.config/cachex/payloads.yaml

Example:

payload_headers:
    X-Forwarded-Host: evil.com
    X-Forwarded-For: 127.0.0.1
    X-Original-URL: /evilpath
    X-Client-IP: 127.0.0.1

πŸ“ Configuration File Example (config.yaml)

scan_mode: single
threads: 25

request_headers:
  Accept: '*/*'
  User-Agent: Mozilla/5.0 (...)

client:
  dial_timeout: 5
  handshake_timeout: 5
  response_timeout: 10
  proxy_url: ""

persistence_checker:
  enabled: true
  num_requests_to_send: 10
  threads: 5

logger:
  log_error: false
  log_mode: pretty
  debug: false
  output_file: ""
  skip_tentative: true

🧠 How CacheX Works

  1. Fetches baseline response
  2. Injects payload headers
  3. Detects response manipulation (body, code, redirect)
  4. If changed β†’ launches concurrent poisoning attempts
  5. Fetches clean requests
  6. If poisoned response persists β†’ confirmed vulnerability
  7. Outputs PoC link

πŸ“ Project Structure

cachex/
β”œβ”€β”€ cmd/
β”‚   └── cachex/
β”‚       └── main.go                # CLI entrypoint
β”‚
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   └── cachex/
β”‚   β”‚       └── cmd/
β”‚   β”‚           β”œβ”€β”€ banner.go      # ASCII banner
β”‚   β”‚           β”œβ”€β”€ flags.go       # CLI flags + config binding
β”‚   β”‚           β”œβ”€β”€ helper.go      # Help message builder
β”‚           β”œβ”€β”€ root.go        # Main CLI logic & runner
β”‚           └── utils.go           # File helpers
β”‚
β”‚   β”œβ”€β”€ pkg/
β”‚   β”‚   β”œβ”€β”€ client/
β”‚   β”‚   β”‚   β”œβ”€β”€ client.go          # Custom HTTP client & transport
β”‚   β”‚   β”‚   └── request.go         # Fetch + send raw requests
β”‚   β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”‚   └── config.go          # Legacy internal config
β”‚   β”‚   └── logger/
β”‚   β”‚       β”œβ”€β”€ colors.go          # Color themes
β”‚   β”‚       └── logger.go          # Pretty logger (info/warn/debug/vuln)
β”‚
β”‚   └── scanner/
β”‚       β”œβ”€β”€ core.go                # Core poisoning test logic
β”‚       β”œβ”€β”€ detector.go            # Behavioral response diffing
β”‚       β”œβ”€β”€ logger.go              # Pretty + JSON output formatter
β”‚       β”œβ”€β”€ output.go              # JSON serialization helpers
β”‚       β”œβ”€β”€ persistchk.go          # Persistence checker (real-time poisoning)
β”‚       β”œβ”€β”€ scanner.go             # Scan controller (single/multi mode)
β”‚       β”œβ”€β”€ types.go               # All scanner structs & enums
β”‚       └── utils.go               # Cache buster, merging maps, helpers
β”‚
β”œβ”€β”€ pkg/
β”‚   └── cachex/
β”‚       β”œβ”€β”€ scanner.go             # Public API wrapper for internal scanner
β”‚       β”œβ”€β”€ utils.go               # Config mappers (log mode, scan mode)
β”‚       └── validate.go            # Config validation
β”‚
β”‚   └── config/
β”‚       β”œβ”€β”€ config.go              # YAML config schema
β”‚       β”œβ”€β”€ default.go             # Default paths + default config
β”‚       └── payloads.go            # Default payload headers
β”‚
β”œβ”€β”€ .github/workflows/
β”‚   └── release.yml                # Automated builds via GoReleaser
β”‚
β”œβ”€β”€ images/
β”‚   β”œβ”€β”€ cachex-logo.png            # Logo
β”‚   └── cachex-demo.gif            # Showcase GIF
β”‚
β”œβ”€β”€ .goreleaser.yaml               # Multi-platform binary releases
β”œβ”€β”€ .gitignore
β”œβ”€β”€ go.mod
β”œβ”€β”€ go.sum
β”œβ”€β”€ LICENSE
└── Makefile                       # Build / install helpers

🀝 Contribute

Sure, PRs are welcome!

πŸ“œ License

MIT Β© @ayuxsec

Directories ΒΆ

Path Synopsis
cmd
cachex command
internal
pkg/client
Description: This file contains the client package which is responsible for creating a new HTTP client with custom transport settings.
Description: This file contains the client package which is responsible for creating a new HTTP client with custom transport settings.
scanner
Description: This file contains the core logic for the cache poisoning scanner.
Description: This file contains the core logic for the cache poisoning scanner.
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL