Skip to main content

RecaptchaDomainReplicator

License: MIT PyPI version CI CodeFactor Colombia Flag

Serve a local replica of a reCAPTCHA widget and capture the token.

RecaptchaDomainReplicator generates a local HTML page that renders a reCAPTCHA widget, serves it via a local Flask server, opens it in Chromium, and monitors the DOM to capture the resulting token.

https://github.com/user-attachments/assets/9a464e30-fae7-461e-ab84-37d6c4bec078


Features

• Generate local page for any sitekey and domain
• Serve via local Flask server (in-memory by default, optional disk persistence)
• Open in Chromium or reuse an existing browser/tab
• Monitor page in separated thread and expose token via TokenHandle • Proxy support (HTTP, HTTPS, SOCKS4, SOCKS5 with optional credentials)
• Domain bypass modes (VPN-friendly browser rules & hosts file fallback)
• HTTPS with temporary self-signed certificates
• Support for invisible reCAPTCHA, enterprise, custom actions, and data-s values
• Invisible reCAPTCHA (v3) is executed automatically


How It Works

Pipeline

The library follows a simple four-step pipeline:

• Generate: Build a single HTML page that renders reCAPTCHA for a given sitekey and domain (with optional params like action, data-s, enterprise).
• Serve: Host it on a local Flask server (in-memory by default; can persist to disk).
• Open: Launch (or reuse) a Chromium tab to load that page.
• Observe: Poll the DOM to extract the token once it appears.


Requirements

• Python: 3.9+
• Browser: Chromium-based browser (Chrome, Chrome for Testing, Edge)
• For credential proxies: Use Chrome for Testing or Microsoft Edge (Newer versions of Google Chrome doesn't support this) • Admin privileges (optional): Required only for hosts file changes and port forwarding


Installation

pip install recaptcha-domain-replicator

From source (with dev dependencies):

pip install -e ".[dev]"

Usage

Library Usage

from recaptcha_domain_replicator import RecaptchaDomainReplicator

with RecaptchaDomainReplicator(
    download_dir="tmp",
    server_port=8080,
    proxy=None,  # "http://user:pass@host:port"
    browser_path=None,  # r"C:\path\to\chrome.exe"
) as replicator:
    browser, token_handle = replicator.replicate_captcha(
        website_key="YOUR_SITE_KEY",
        website_url="https://example.com/path",
        is_invisible=True,
        action="submit",
        data_s_value=None,
        api_domain="google.com",  # or "recaptcha.net"
        is_enterprise=False,
        bypass_domain_check=True,
        use_ssl=True,
        headless=False,
        user_agent=None,
        cookies=None,
        browser=None, # already instanciated browser
        tab=None,
    )

    # replicate_captcha() returns immediately, wait with the async token monitor
    token = token_handle.wait(timeout=120) if token_handle else None # 0 to wait until token is received
    print("Token:", token)

CLI Usage

After installation, a console script is available:

recaptcha-domain-replicator --help

Run the built-in demo:

recaptcha-domain-replicator demo

Replicate a captcha:

recaptcha-domain-replicator replicate \
  --website-key "YOUR_SITE_KEY" \
  --website-url "https://example.com/path" \
  --persist-html \
  --invisible \
  --action "submit" \
  --bypass-domain-check \
  --proxy "socks5://user:pass@host:port" \
  --browser-path "C:\path\to\chrome.exe" \
  --observation-time 0

CLI behavior notes:

• Prints the token (if obtained) as plain text
• logging: Disabled by default, enable with --log-level INFO or DEBUG
• --headless: Launch the browser in headless mode (default: headful)
• --observation-time: Set to 0 to run until a token is captured or browser closes


Domain Bypass Modes

When bypass_domain_check=True is enabled with a website_url, the tool makes the replica page appear to load from the original domain.

• Preferred (VPN-friendly) mode: Let the replicator create the browser

  • Uses Chromium --host-resolver-rules to map the target domain to 127.0.0.1 inside that browser only
  • Does not modify your system hosts file

• Fallback mode: You provide an existing browser/tab

  • The browser is already running, so host-resolver-rules can't be applied, it falls back to modifying the Windows hosts file
  • Requires an elevated (Administrator) shell

HTTPS, Ports & System Changes

• HTTPS by default: use_ssl=True serves the replica over HTTPS using a temporary self-signed certificate. Use --no-ssl for plain HTTP.

• Port forwarding (admin only): When elevated, the tool may create a Windows netsh interface portproxy rule to forward 80/443 -> the chosen high port. Port forwarding is removed during shutdown, firewall rules may remain.


Limitations

Even if you successfully capture a token, it may not be accepted by server-side verification.

Common rejection reasons: • Action mismatch: Backend expects a specific action value • Risk scoring: reCAPTCHA considers IP reputation, browser state, and interaction signals • Session mismatch: Server might expect the token from the same browser session • IP mismatch: Tokens might be evaluated relative to the client IP that solved the challenge • Token freshness: Tokens are short-lived • Enterprise vs non-enterprise: Using the wrong API variant changes behavior

  • google.com vs recaptcha.net: Using the wrong scripts domain

Troubleshooting

• reCAPTCHA iframe never loads / shows an error

  • The sitekey may be domain-restricted. Try --bypass-domain-check
  • If relying on hosts-file bypass, run your terminal as Administrator

Repository Layout

recaptcha_domain_replicator/
├── recaptcha_domain_replicator/ # Package
│   ├── __init__.py
│   ├── __main__.py # CLI entry
│   ├── captcha_replicator.py # Replicator class
│   ├── html_builder.py # HTML generation
│   ├── server_manager.py # Flask server
│   ├── token_monitor.py # Token polling
│   ├── browser_config.py # Chromium options
│   ├── hosts_manager.py # Windows hosts file
│   ├── certificates.py # SSL certificate generation
│   ├── proxy_utils.py # Proxy parsing
│   ├── proxy_auth_extension.py # Chrome extension for proxy auth
│   └── logging_utils.py # Logging configuration
├── tests/ # Tests
├── assets/  # Images and diagrams
├── pyproject.toml # Project configuration
└── README.md

Development

To run the tests just run:

pytest

Should I star this repository?

You don't have to, but giving it a star would mean a lot. It helps more people discover the project. Your support helps grow an open and accessible community. Thank you!


Contributing

We welcome issues, feature requests, and pull requests! Please read the contribution guidelines before you begin.

If you discovered a typo or small documentation bug, feel free to open a quick PR straight away. For anything larger, open an issue first.


Code of Conduct

Be kind. We follow the Contributor Covenant. By participating in this project you agree to uphold those guidelines.


Donate

If you find this project helpful, please consider supporting the developer with a donation. Thank you! :)

  • BTC: 1EXLMgvU1pNaXNwuaRSMRQ69Vqp2UTjTSZ
  • ETH (ERC-20): 0xebb810aa4258d97f98157c32ac49b6be9dda4433
  • LTC: LUqdVjS9cJFby5Mj5c7wkvyNM3zaJxzhTc
  • USDT (TRC-20): TN5LEgpa1xu5EecC9LobzVN8KAgyi5kwgZ
  • BNB (BEP-20): 0xebb810aa4258d97f98157c32ac49b6be9dda4433
  • SOL: GGWSzrdftR4aivxxWZCEqJspfcqtzmLso9AkVXBkDfEK

Acknowledgements

• DrissionPage - Browser automation library
• Flask - Web framework for serving the replica
• pyOpenSSL - SSL certificate generation


License

This project is licensed under the MIT License.


Legal & Responsible Use

RecaptchaDomainReplicator is provided for educational and research purposes. Use responsibly and comply with all applicable laws and terms of service.

Metadata

Release files for recaptcha-domain-replicator 1.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for recaptcha-domain-replicator 1.0.6
File Size Uploaded
recaptcha_domain_replicator-1.0.6.tar.gz 38.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for recaptcha-domain-replicator 1.0.6
File Interpreter ABI Platform
recaptcha_domain_replicator-1.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 76.0 kB

Release files / recaptcha_domain_replicator-1.0.6.tar.gz

Download URL recaptcha_domain_replicator-1.0.6.tar.gz
Size 38.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5e66926acc97957ddcbeeb13b72caafed8f83f85337ce11274906a6e338a50cf
BLAKE2b-256 checksum
How to use checksums
7e62bdd8c74e830ab1beecce7c11449cc24c337ec27864f59ce21eb9983daf3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 24, 2026.

Transparency log

Release files / recaptcha_domain_replicator-1.0.6-py3-none-any.whl

Download URL recaptcha_domain_replicator-1.0.6-py3-none-any.whl
Size 37.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dd754512db59fdd11a2c04b4dd455efe085774f299c9c0a2b4d0d90bc579af44
BLAKE2b-256 checksum
How to use checksums
7afd9138cb938aba7cfe9a5312b028e2ccf57941391337325cd150bddc57d362
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 24, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.6 This release

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page