├── .gitignore ├── LICENSE ├── README.md ├── extension-examples ├── example-chromium.png ├── example-firefox.png ├── playwright_chrome.py ├── selenium_chrome.py ├── selenium_firefox.py └── undetected_chrome.py ├── nodejs-examples ├── balance_api.js ├── recognition_api.js └── token_api.js └── python-examples ├── balance_api.py ├── recognition_api.py └── token_api.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | 131 | *.crx 132 | *.xpi 133 | *.zip 134 | geckodriver.log 135 | extension-examples/nopecha/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 NopeCHA 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sample scripts for NopeCHA 2 | 3 | This repository contains example code using official tools published by NopeCHA 4 | to bypass CAPTCHA challenges. These tools that leverage the NopeCHA API include: 5 | 6 | - [NopeCHA Browser Extension](https://github.com/NopeCHALLC/nopecha-extension) 7 | - [NopeCHA Python Library](https://github.com/NopeCHALLC/nopecha-python) 8 | - [NopeCHA Node.js Library](https://github.com/NopeCHALLC/nopecha-nodejs) 9 | 10 | Two core features of the NopeCHA API are Recognition and Token endpoints. 11 | The Recognition endpoint solves image and audio challenges and returns any of 12 | click locations, text contained in the image, and transcription of the audio. 13 | The Token endpoint returns a solved CAPTCHA token without the need for a browser. 14 | For more information, see the [NopeCHA API docs](https://developers.nopecha.com). 15 | 16 | reCAPTCHA | hCaptcha 17 | :---:|:---: 18 | ![reCAPTCHA](https://nopecha.com/image/demo/recaptcha.gif) | ![hCaptcha](https://nopecha.com/image/demo/hcaptcha.gif) 19 | 20 | 21 | ## Supported CAPTCHA types: 22 | - reCAPTCHA v2 23 | - reCAPTCHA v3 24 | - hCaptcha 25 | - FunCAPTCHA 26 | - AWS WAF CAPTCHA 27 | - Text-based CAPTCHA 28 | - Cloudflare Turnstile 29 | - PerimeterX 30 | 31 | 32 | ## Documentation 33 | 34 | See the [NopeCHA API docs](https://developers.nopecha.com). 35 | -------------------------------------------------------------------------------- /extension-examples/example-chromium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NopeCHALLC/nopecha-scripts/430bcd72c67e79388940f184e012201e236a05de/extension-examples/example-chromium.png -------------------------------------------------------------------------------- /extension-examples/example-firefox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NopeCHALLC/nopecha-scripts/430bcd72c67e79388940f184e012201e236a05de/extension-examples/example-firefox.png -------------------------------------------------------------------------------- /extension-examples/playwright_chrome.py: -------------------------------------------------------------------------------- 1 | # python -m playwright install 2 | 3 | from playwright.sync_api import sync_playwright 4 | 5 | with sync_playwright() as p: 6 | for browser_type in [p.chromium, p.firefox, p.webkit]: 7 | browser = browser_type.launch() 8 | page = browser.new_page() 9 | page.goto('http://whatsmyuseragent.org/') 10 | page.screenshot(path=f'example-{browser_type.name}.png') 11 | browser.close() -------------------------------------------------------------------------------- /extension-examples/selenium_chrome.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import time 3 | from selenium import webdriver 4 | from selenium.webdriver.chrome.service import Service as ChromeService 5 | 6 | try: 7 | from webdriver_manager.chrome import ChromeDriverManager 8 | except: 9 | print('webdriver_manager not found. installing...') 10 | os.system('pip install webdriver-manager') 11 | from webdriver_manager.chrome import ChromeDriverManager 12 | 13 | 14 | NOPECHA_KEY = "YOUR KEY HERE" 15 | 16 | options = webdriver.chrome.options.Options() 17 | options.add_argument('--no-sandbox') 18 | options.add_argument('--disable-infobars') 19 | options.add_argument('--disable-dev-shm-usage') 20 | options.add_argument('--disable-blink-features=AutomationControlled') 21 | options.add_experimental_option('excludeSwitches', ['enable-automation']) 22 | options.add_experimental_option('useAutomationExtension', False) 23 | 24 | # Download and load the NopeCHA extension 25 | with open('ext.crx', 'wb') as f: 26 | f.write(requests.get('https://nopecha.com/f/ext.crx').content) 27 | options.add_extension('ext.crx') 28 | 29 | driver = webdriver.Chrome(options=options, service=ChromeService(ChromeDriverManager().install())) 30 | 31 | driver.get(f"https://nopecha.com/setup#{NOPECHA_KEY}") 32 | driver.get('https://accounts.hcaptcha.com/demo') 33 | 34 | try: 35 | print('press CTRL+C to exit') 36 | print('\n') 37 | print(f"if your browser is not solving, check if this is your correct key: {NOPECHA_KEY}") 38 | print('if not, please edit this code to replace "YOUR KEY HERE" with your key') 39 | while True: 40 | time.sleep(1) 41 | except KeyboardInterrupt: 42 | driver.quit() 43 | -------------------------------------------------------------------------------- /extension-examples/selenium_firefox.py: -------------------------------------------------------------------------------- 1 | import os 2 | import requests 3 | import time 4 | from selenium import webdriver 5 | from selenium.webdriver.firefox.service import Service as FirefoxService 6 | 7 | try: 8 | from webdriver_manager.firefox import GeckoDriverManager 9 | except: 10 | print('webdriver manager not found. installing...') 11 | os.system('pip install webdriver-manager') 12 | from webdriver_manager.firefox import GeckoDriverManager 13 | 14 | 15 | NOPECHA_KEY = "YOUR KEY HERE" 16 | 17 | # Download and load the NopeCHA extension 18 | with open('ext.xpi', 'wb') as f: 19 | f.write(requests.get('https://nopecha.com/f/ext.xpi').content) 20 | 21 | driver = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install())) 22 | 23 | driver.install_addon(f"{os.getcwd()}/ext.xpi") 24 | driver.get(f"https://nopecha.com/setup#{NOPECHA_KEY}") 25 | driver.get('https://accounts.hcaptcha.com/demo') 26 | 27 | try: 28 | print('press CTRL+C to exit') 29 | print('\n') 30 | print(f"if your browser is not solving, check if this is your correct key: {NOPECHA_KEY}") 31 | print('if not, please edit this code to replace "YOUR KEY HERE" with your key') 32 | while True: 33 | time.sleep(1) 34 | except KeyboardInterrupt: 35 | driver.quit() 36 | -------------------------------------------------------------------------------- /extension-examples/undetected_chrome.py: -------------------------------------------------------------------------------- 1 | import os 2 | import requests 3 | import time 4 | import zipfile 5 | import undetected_chromedriver.v2 as uc 6 | from selenium.webdriver.chrome.service import Service as ChromeService 7 | 8 | try: 9 | from webdriver_manager.chrome import ChromeDriverManager 10 | except: 11 | print('webdriver_manager not found. installing...') 12 | os.system('pip install webdriver-manager') 13 | from webdriver_manager.chrome import ChromeDriverManager 14 | 15 | 16 | NOPECHA_KEY = "YOUR KEY HERE" 17 | 18 | options = uc.ChromeOptions() 19 | options.add_argument('--no-sandbox') 20 | options.add_argument('--disable-infobars') 21 | options.add_argument('--disable-dev-shm-usage') 22 | options.add_argument('--disable-blink-features=AutomationControlled') 23 | options.add_argument('--no-first-run --no-service-autorun --password-store=basic') 24 | 25 | with open('chrome.zip', 'wb') as f: 26 | f.write(requests.get('https://github.com/NopeCHA/NopeCHA/releases/latest/download/chrome.zip').content) 27 | with zipfile.ZipFile('chrome.zip', 'r') as f: 28 | f.extractall('nopecha') 29 | options.add_argument(f"--load-extension={os.getcwd()}/nopecha") 30 | 31 | driver = uc.Chrome(options=options, service=ChromeService(ChromeDriverManager().install())) 32 | driver.get(f"https://nopecha.com/setup#{NOPECHA_KEY}") 33 | driver.get('https://accounts.hcaptcha.com/demo') 34 | 35 | try: 36 | print('press CTRL+C to exit') 37 | print('\n') 38 | print(f"if your browser is not solving, check if this is your correct key: {NOPECHA_KEY}") 39 | print('if not, please edit this code to replace "YOUR KEY HERE" with your key') 40 | while True: 41 | time.sleep(1) 42 | except KeyboardInterrupt: 43 | driver.quit() 44 | -------------------------------------------------------------------------------- /nodejs-examples/balance_api.js: -------------------------------------------------------------------------------- 1 | try { 2 | console.log(require.resolve('nopecha')); 3 | } catch(e) { 4 | console.log('\n'); 5 | console.log('The Nopecha library is not installed.'); 6 | console.log('Please install using the following command:'); 7 | console.log('npm i nopecha'); 8 | console.log('\n'); 9 | process.exit(e.code); 10 | } 11 | 12 | 13 | const NOPECHA_API_KEY = "YOUR KEY HERE"; 14 | 15 | const { Configuration, NopeCHAApi, AuthenticationError } = require('nopecha'); 16 | const configuration = new Configuration({ 17 | apiKey: NOPECHA_API_KEY, 18 | }); 19 | const nopecha = new NopeCHAApi(configuration); 20 | 21 | (async () => { 22 | try { 23 | // get the current balance 24 | const balance = await nopecha.getBalance(); 25 | 26 | // print the current balance 27 | console.log(balance); 28 | 29 | } catch (e) { 30 | if (e instanceof AuthenticationError) { 31 | console.log('\n') 32 | console.log(`You have provided an invalid key: ${NOPECHA_API_KEY}`, '\n') 33 | console.log('Please set NOPECHA_API_KEY with your NopeCHA key.') 34 | console.log('Visit https://nopecha.com/manage to view your keys.') 35 | console.log('Or join our official Discord for instructions on acquiring test keys.') 36 | console.log('https://nopecha.com/discord') 37 | console.log('\n') 38 | } 39 | else { 40 | throw e; 41 | } 42 | } 43 | })(); 44 | -------------------------------------------------------------------------------- /nodejs-examples/recognition_api.js: -------------------------------------------------------------------------------- 1 | try { 2 | console.log(require.resolve('nopecha')); 3 | } catch(e) { 4 | console.log('\n'); 5 | console.log('The Nopecha library is not installed.'); 6 | console.log('Please install using the following command:'); 7 | console.log('npm i nopecha'); 8 | console.log('\n'); 9 | process.exit(e.code); 10 | } 11 | 12 | 13 | const NOPECHA_API_KEY = "YOUR KEY HERE"; 14 | 15 | const { Configuration, NopeCHAApi, AuthenticationError } = require('nopecha'); 16 | const configuration = new Configuration({ 17 | apiKey: NOPECHA_API_KEY, 18 | }); 19 | const nopecha = new NopeCHAApi(configuration); 20 | 21 | (async () => { 22 | try { 23 | // solve an hcaptcha recognition challenge 24 | const clicks = await nopecha.solveRecognition({ 25 | type: 'hcaptcha', 26 | task: 'Please click each image containing a cat-shaped cookie.', 27 | image_urls: Array.from({length: 9}, (_, i) => `https://nopecha.com/image/demo/hcaptcha/${i}.png`), 28 | }); 29 | 30 | // print the grids to click 31 | console.log(clicks); 32 | } catch (e) { 33 | if (e instanceof AuthenticationError) { 34 | console.log('\n') 35 | console.log(`You have provided an invalid key: ${NOPECHA_API_KEY}`, '\n') 36 | console.log('Please set NOPECHA_API_KEY with your NopeCHA key.') 37 | console.log('Visit https://nopecha.com/manage to view your keys.') 38 | console.log('Or join our official Discord for instructions on acquiring test keys.') 39 | console.log('https://nopecha.com/discord') 40 | console.log('\n') 41 | } 42 | else { 43 | throw e; 44 | } 45 | } 46 | })(); 47 | -------------------------------------------------------------------------------- /nodejs-examples/token_api.js: -------------------------------------------------------------------------------- 1 | try { 2 | console.log(require.resolve('nopecha')); 3 | } catch(e) { 4 | console.log('\n'); 5 | console.log('The Nopecha library is not installed.'); 6 | console.log('Please install using the following command:'); 7 | console.log('npm i nopecha'); 8 | console.log('\n'); 9 | process.exit(e.code); 10 | } 11 | 12 | 13 | const NOPECHA_API_KEY = "YOUR KEY HERE"; 14 | 15 | const { Configuration, NopeCHAApi, AuthenticationError } = require('nopecha'); 16 | const configuration = new Configuration({ 17 | apiKey: NOPECHA_API_KEY, 18 | }); 19 | const nopecha = new NopeCHAApi(configuration); 20 | 21 | (async () => { 22 | try { 23 | // solve an hcaptcha token 24 | const token = await nopecha.solveToken({ 25 | type: 'hcaptcha', 26 | sitekey: 'ab803303-ac41-41aa-9be1-7b4e01b91e2c', 27 | url: 'https://nopecha.com/demo/hcaptcha', 28 | }); 29 | 30 | // print the hcaptcha token 31 | console.log(token); 32 | 33 | } catch (e) { 34 | if (e instanceof AuthenticationError) { 35 | console.log('\n') 36 | console.log(`You have provided an invalid key: ${NOPECHA_API_KEY}`, '\n') 37 | console.log('Please set NOPECHA_API_KEY with your NopeCHA key.') 38 | console.log('Visit https://nopecha.com/manage to view your keys.') 39 | console.log('Or join our official Discord for instructions on acquiring test keys.') 40 | console.log('https://nopecha.com/discord') 41 | console.log('\n') 42 | } 43 | else { 44 | throw e; 45 | } 46 | } 47 | })(); 48 | -------------------------------------------------------------------------------- /python-examples/balance_api.py: -------------------------------------------------------------------------------- 1 | import sys 2 | try: 3 | import nopecha 4 | except ModuleNotFoundError: 5 | print('\n') 6 | print('The Nopecha library is not installed.') 7 | print('Please install using the following command:') 8 | print('pip install --upgrade nopecha') 9 | print('\n') 10 | sys.exit(0) 11 | 12 | 13 | nopecha.api_key = "YOUR KEY HERE" 14 | 15 | try: 16 | # get the current balance 17 | balance = nopecha.Balance.get() 18 | 19 | # print the current balance 20 | print(balance) 21 | 22 | except nopecha.error.AuthenticationError: 23 | print('\n') 24 | print(f"You have provided an invalid key: {nopecha.api_key}", '\n') 25 | print('Please set nopecha.api_key with your NopeCHA key.') 26 | print('Visit https://nopecha.com/manage to view your keys.') 27 | print('Or join our official Discord for instructions on acquiring test keys.') 28 | print('https://nopecha.com/discord') 29 | print('\n') 30 | -------------------------------------------------------------------------------- /python-examples/recognition_api.py: -------------------------------------------------------------------------------- 1 | import sys 2 | try: 3 | import nopecha 4 | except ModuleNotFoundError: 5 | print('\n') 6 | print('The Nopecha library is not installed.') 7 | print('Please install using the following command:') 8 | print('pip install --upgrade nopecha') 9 | print('\n') 10 | sys.exit(0) 11 | 12 | 13 | nopecha.api_key = "YOUR KEY HERE" 14 | 15 | try: 16 | # solve ah hcaptcha recognition challenge 17 | clicks = nopecha.Recognition.solve( 18 | type='hcaptcha', 19 | task='Please click each image containing a cat-shaped cookie.', 20 | image_urls=[f"https://nopecha.com/image/demo/hcaptcha/{i}.png" for i in range(9)], 21 | ) 22 | 23 | # print the grids to click 24 | print(clicks) 25 | 26 | except nopecha.error.AuthenticationError: 27 | print('\n') 28 | print(f"You have provided an invalid key: {nopecha.api_key}", '\n') 29 | print('Please set nopecha.api_key with your NopeCHA key.') 30 | print('Visit https://nopecha.com/manage to view your keys.') 31 | print('Or join our official Discord for instructions on acquiring test keys.') 32 | print('https://nopecha.com/discord') 33 | print('\n') 34 | -------------------------------------------------------------------------------- /python-examples/token_api.py: -------------------------------------------------------------------------------- 1 | import sys 2 | try: 3 | import nopecha 4 | except ModuleNotFoundError: 5 | print('\n') 6 | print('The Nopecha library is not installed.') 7 | print('Please install using the following command:') 8 | print('pip install --upgrade nopecha') 9 | print('\n') 10 | sys.exit(0) 11 | 12 | 13 | nopecha.api_key = "YOUR KEY HERE" 14 | 15 | try: 16 | # solve an hcaptcha token 17 | token = nopecha.Token.solve( 18 | type='hcaptcha', 19 | sitekey='ab803303-ac41-41aa-9be1-7b4e01b91e2c', 20 | url='https://nopecha.com/demo/hcaptcha', 21 | ) 22 | 23 | # print the hcaptcha token 24 | print(token) 25 | 26 | except nopecha.error.AuthenticationError: 27 | print('\n') 28 | print(f"You have provided an invalid key: {nopecha.api_key}", '\n') 29 | print('Please set nopecha.api_key with your NopeCHA key.') 30 | print('Visit https://nopecha.com/manage to view your keys.') 31 | print('Or join our official Discord for instructions on acquiring test keys.') 32 | print('https://nopecha.com/discord') 33 | print('\n') 34 | --------------------------------------------------------------------------------