HyperCaptcha is an open-source Rust and Python research harness for tuning and running multimodal decision models to solve Google reCAPTCHA and hCaptcha challenges with high accuracy, live in Camoufox or offline on saved grids with hypercaptcha-eval.
Research use only: HyperCaptcha is built for research and should not be used on third-party sites without permission. See SECURITY.md · Apache-2.0.
Image CAPTCHAs ask you to select every square in a 3×3 or 4×4 grid containing a target object (like traffic lights or motorcycles). Instead of asking a vision model once on the raw screenshot, HyperCaptcha runs a short multi-step pipeline on each grid:
- Multi-view scoring (whole grid + close-ups): Each square is scored on the full grid for scene context and again on zoomed-in close-up crops (averaged in log-odds across two scales at
high/max) so details at tile edges are not missed. - Neighbor-aware logistic scoring: On 4×4 grids, a fitted logistic model combines each square's whole-grid and close-up log-odds with its strongest adjacent neighbors, capturing objects that span touching tiles.
- Skip-grid presence gate: On skippable challenges ("If there are none, click skip"), a parallel presence check asks whether the target appears anywhere before clicking tiles.
- Bounding-box veto: At
--effort mediumand above, the model draws bounding boxes around target objects and vetoes lower-confidence clicks that no box supports.
(See docs/ARCHITECTURE.md for pipeline details, dynamic 3×3 early-tile inference, and image encoding.)
A 4×4 grid counts as solved only when every target square is selected and no empty square is clicked. You can tune how much work HyperCaptcha asks a model to do per 4×4 grid with --effort:
low: Whole grid + 1 close-up pass + skip check (6requests)medium: Adds whole-grid bounding-box verification to drop false positives (7requests)high(default): Adds a 2nd close-up pass at capture resolution (11requests)max: Adds 16 zoomed per-tile window box checks (12requests)
- Why
--effort highis the default: Inside HyperCaptcha,vLLM/d3-ultraathighsolves82.9%(281/339) of 4×4 test grids, within 1 grid ofmax(83.2%,282/339), while using4,404fewer input tokens and cutting median provider compute wait roughly in half (282 msvs.556 ms). - Comparing decision models in the harness:
Liquid/d1.2-ultrapeaks at72.3%(high/max), whiletypesafe/Jevreaches53.4%in its single-request default or68.8%with multi-view + box verification on an earlier 311-grid label pass (and68.0%vs.d3-ultra's80.0%in a live 50-attempt reCAPTCHA v2 Enterprise run without box checks). - Offline vs. live scope: The 4×4 box verification,
--efforttiers,Liquid/*, andhCaptchasolve rates have been measured offline or on test keys, not yet on live production verdicts. Full methodology, dataset details, additional models (Liquid/d1.2), and caveats live in docs/RESULTS.md and docs/BENCHMARK_REPORT_2026-11-15.md.
Prerequisites: Rust 1.88+, Python 3.11+, and uv (or pip). Full installation and CAPTCHA key setup instructions live in docs/SETUP.md.
Inspect shipped models, validate TOML configs, and start a local smoke lab using official public test keys:
# List built-in models, required env vars, default decision rules, and effort tiers
cargo run --locked -- models
# Validate one or more model configs offline
cargo run --locked -- validate-config models/recaptcha/vllm/d3-ultra.toml
# Google reCAPTCHA v2 public test key (defaults to --mode v2 -> http://localhost:8765)
cargo run --locked -- serve --google-test-key
# hCaptcha public test key (defaults to --captcha hcaptcha -> http://hypercaptcha.localhost:8765)
cargo run --locked -- serve --hcaptcha-test-keyCopy .env.example to .env, add your localhost CAPTCHA key and model provider key (such as VLLM_SR_API_KEY, LIQUID_API_KEY, or TYPESAFE_API_KEY), and pass --env-file .env explicitly (shell env vars always take precedence):
cp .env.example .env
cargo run --release --locked -- serve \
--env-file .env \
--mode v2-enterprise \
--model vLLM/d3-ultra \
--log reports/vllm-server.jsonl--effort defaults to high (low, medium, high, and max are all supported). In a second terminal, fetch the pinned Camoufox browser once and run automated trials:
uv run --extra browser python -m camoufox fetch
uv run --extra browser python scripts/recaptcha_lab.py --trials 5 --submit --output reports/vllm-live
uv run hypercaptcha-eval summarize reports/vllm-live/trials.jsonlBoth runners use Camoufox (via --extra browser), read GET /config capability flags automatically, and work with vllm, liquid, jev, custom (--model-config), and openai-chat:
| Script | Default --output |
Automated Flags | Special Modes |
|---|---|---|---|
scripts/recaptcha_lab.py |
reports/recaptcha |
--trials, --submit, --max-rounds, --max-stages, --no-early-tiles, --fast, --headed |
--interactive, --smoke, --score (v3/v3-enterprise) |
scripts/hcaptcha_lab.py |
reports/hcaptcha |
--trials, --submit, --max-rounds, --max-stages, --max-refreshes, --headed |
--interactive, --smoke |
hypercaptcha-eval turns captured runs into a fitted, validated TOML config and deterministic parity fixture without touching live CAPTCHA services during tuning:
# 1. Deduplicate captured runs into a portable manifest
uv run hypercaptcha-eval dataset reports/capture-run -o datasets/4x4/dataset.jsonl --layout 4
# 2. Label grids in the local browser UI (127.0.0.1 only)
uv run hypercaptcha-eval label --dataset datasets/4x4/dataset.jsonl --labels datasets/4x4/labels.jsonl
# 3. Record raw two-view scores, skip probabilities, and boxes (auto-discovers target/release/hypercaptcha)
cargo build --release --locked
uv run hypercaptcha-eval record --dataset datasets/4x4/dataset.jsonl -o recordings/my-model.jsonl \
--model-config models/examples/custom-decision-model.toml --passes 3
# 4. Fit logistic weights, sweep effort tiers, and export + validate TOML & parity fixture
uv run hypercaptcha-eval fit --dataset datasets/4x4/dataset.jsonl --labels datasets/4x4/labels.jsonl \
--recordings recordings/my-model.jsonl --layout 4 -o recordings/fit.json
uv run hypercaptcha-eval sweep --dataset datasets/4x4/dataset.jsonl --labels datasets/4x4/labels.jsonl \
--recordings recordings/my-model.jsonl --fit recordings/fit.json -o recordings/sweep.json
uv run hypercaptcha-eval export --base-config models/examples/custom-decision-model.toml \
--sweep recordings/sweep.json --fit recordings/fit.json \
-o my-model.toml --fixture tests/fixtures/my_model_4x4.json.gz --recordings recordings/my-model.jsonl
cargo run --locked -- validate-config my-model.tomlSee docs/ADDING_MODELS.md for the complete schema_version = 1 TOML schema, capability flags, and custom-provider walkthrough.
Challenges flow from the local lab page or Camoufox runner (scripts/, web/) to the localhost Rust server (src/server.rs), which loads declarative models/**/*.toml WireProfile configs (src/captcha/mod.rs, src/plan.rs) and runs parallel multi-view + box-verification fan-out (src/providers.rs, src/boxes.rs). Byte-exact image preprocessing lives in src/pillow.rs, positional-image translation and patch-token billing guards live in src/liquid.rs, and hCaptcha canvas segmentation lives in src/captcha/hcaptcha/grid.rs.
src/
main.rs # CLI entry point (`serve`, `models`, `validate-config`)
envfile.rs # Opt-in `--env-file` parser & precedence overlay
server.rs # Localhost-only HTTP server, Host/Origin guards, JSONL logging
providers.rs # WireProfile-driven parallel fan-out, log-odds scoring, warming & hedging
plan.rs # Owned/deserializable 4x4 effort plans, gap rule, box verification rule
boxes.rs # 9-ordinal, every-instance, and 16-window box requests + incremental Vote
pillow.rs # Byte-exact Pillow bilinear resizer & libjpeg baseline 4:2:0 q90 encoder
liquid.rs # Positional-image dialect rewriter & 1.5 tokens/patch billing guard
captcha/ # Service profiles (recaptcha/, hcaptcha/ + canvas grid segmentation)
models/ # Embedded schema_version=1 TOML configs + custom-decision-model.toml starter
eval/ # Standalone Python toolkit (`hypercaptcha-eval`: dataset/label/record/fit/sweep/export/summarize)
scripts/ # Camoufox browser runners (`recaptcha_lab.py`, `hcaptcha_lab.py`, `_common.py`)
web/ # Embedded local lab UI (`recaptcha/`, `hcaptcha/`, `lab.css`)
tests/ # Rust integration tests, Python eval tests, image-free `.json.gz` parity fixtures
docs/ # Setup, empirical results, adding models, architecture, and historical report
All checks below run completely offline (no API keys or live browsers required) and match .github/workflows/ci.yml:
# Rust formatting, lints, unit/integration tests, and offline fixture parity
cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo test --locked
cargo run --locked -- models >/dev/null
cargo run --locked -- validate-config models/recaptcha/*/*.toml models/hcaptcha/*/*.toml models/examples/custom-decision-model.toml
# Python runner syntax/CLI checks and offline eval + Rust-parity tests (5,288/5,288 exact fixture checks)
uv run --extra browser python -m py_compile scripts/_common.py scripts/recaptcha_lab.py scripts/hcaptcha_lab.py
uv run --extra browser python scripts/recaptcha_lab.py --help >/dev/null
uv run --extra browser python scripts/hcaptcha_lab.py --help >/dev/null
uv run --extra dev pytest -v- Try an unmeasured model on an existing provider: Run
hypercaptcha serve --provider vllm --model <model-id> --decision-rule average(or--recordto log raw views/boxes for offline fitting) without editing code. - Add a custom decision-model API: Copy models/examples/custom-decision-model.toml, configure
[endpoint](systemone-assetsorsystemone-imagesdialect), validate withhypercaptcha validate-config, and pass--model-config <path.toml>toserveorhypercaptcha-eval record. - Ship a built-in model & parity fixture: Place its TOML under
models/<service>/<provider>/<model>.toml, register it viainclude_str!insrc/captcha/<service>/mod.rs, generate an image-free/label-free.json.gzfixture undertests/fixtures/viahypercaptcha-eval export --fixture, and verify bothcargo test --lockedanduv run --extra dev pytest -v. - Add a new wire dialect or CAPTCHA service: Extend
WireDialect/WireProfilein src/providers.rs and src/captcha/mod.rs (see docs/ARCHITECTURE.md and docs/ADDING_MODELS.md). - Data hygiene: Keep raw captures, labels, logs, and
.envfiles in gitignored paths (/reports/,/datasets/,/recordings/); never commit CAPTCHA imagery, human labels, or credentials. See CONTRIBUTING.md.
| Guide | What It Covers |
|---|---|
| docs/SETUP.md | Rust/Python/Camoufox installation, Google reCAPTCHA & hCaptcha key setup, .env / --env-file, localhost security |
| docs/RESULTS.md | Full empirical report (datasets, effort ladders, Liquid/d1.2, negative findings, live runs, unmeasured scope) |
| docs/ADDING_MODELS.md | Unmeasured models, custom schema_version = 1 TOML configs, full hypercaptcha-eval loop, adding wire dialects |
| docs/ARCHITECTURE.md | Server routes, JSONL schemas, decision & box-verification pipeline, pillow.rs, liquid.rs, hCaptcha segmentation |
| docs/BENCHMARK_REPORT_2026-11-15.md | Historical November 15, 2026 live 50-attempt Jev vs. d3-ultra failure review |
| CONTRIBUTING.md · SECURITY.md · LICENSE | Development workflow, parity-fixture rules, responsible-research scope, Apache-2.0 license |



