Serve a local replica of a reCAPTCHA widget and capture the token.
Project description
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
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
• 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,
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
• --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-rulesto map the target domain to127.0.0.1inside 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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file recaptcha_domain_replicator-1.0.5.tar.gz.
File metadata
- Download URL: recaptcha_domain_replicator-1.0.5.tar.gz
- Upload date:
- Size: 38.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4496eb3c7d1e77d3c67b670354972e572b7e37b024e413d3102753b869f031f
|
|
| MD5 |
35e13ccc2c1eb989ea60e6859116306c
|
|
| BLAKE2b-256 |
bd32f713e72ecfb2c273ce8ee58f86e252db0a8d59d792238295d5d4b0d861e1
|
Provenance
The following attestation bundles were made for recaptcha_domain_replicator-1.0.5.tar.gz:
Publisher:
publish.yml on DannyLuna17/RecaptchaDomainReplicator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
recaptcha_domain_replicator-1.0.5.tar.gz -
Subject digest:
e4496eb3c7d1e77d3c67b670354972e572b7e37b024e413d3102753b869f031f - Sigstore transparency entry: 787509502
- Sigstore integration time:
-
Permalink:
DannyLuna17/RecaptchaDomainReplicator@9d8d3ec5424bfdfaad4f59cc2f1f0520716dc5a0 -
Branch / Tag:
refs/tags/v1.0.5 - Owner: https://github.com/DannyLuna17
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9d8d3ec5424bfdfaad4f59cc2f1f0520716dc5a0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file recaptcha_domain_replicator-1.0.5-py3-none-any.whl.
File metadata
- Download URL: recaptcha_domain_replicator-1.0.5-py3-none-any.whl
- Upload date:
- Size: 37.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3794a31e0038f6912e391fa407dcb54719044c3f0aa411c04b365c1b3e2917f3
|
|
| MD5 |
0dbac8ee054cad0bdf3574a717e781c2
|
|
| BLAKE2b-256 |
4cde5722077910a88e6709a7e744e94e63fda2a12cc38fc29a846083fb2e73d8
|
Provenance
The following attestation bundles were made for recaptcha_domain_replicator-1.0.5-py3-none-any.whl:
Publisher:
publish.yml on DannyLuna17/RecaptchaDomainReplicator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
recaptcha_domain_replicator-1.0.5-py3-none-any.whl -
Subject digest:
3794a31e0038f6912e391fa407dcb54719044c3f0aa411c04b365c1b3e2917f3 - Sigstore transparency entry: 787509510
- Sigstore integration time:
-
Permalink:
DannyLuna17/RecaptchaDomainReplicator@9d8d3ec5424bfdfaad4f59cc2f1f0520716dc5a0 -
Branch / Tag:
refs/tags/v1.0.5 - Owner: https://github.com/DannyLuna17
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9d8d3ec5424bfdfaad4f59cc2f1f0520716dc5a0 -
Trigger Event:
release
-
Statement type: