├── LICENSE ├── README.md ├── aicaptcha ├── __init__.py ├── api.py └── utils.py ├── examples ├── hcaptcha_example.py └── recaptchav3_example.py └── setup.py /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Mr Abood 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 | # AiCaptcha (Beta) 2 | Python library utilizes AiCaptcha's API to solve captcha challenges with the power of AI. With our advanced technology, you can effortlessly handle various types of captcha challenges without any hassle. 3 | 4 | ## Installation 5 | To install the library, simply run the following command: 6 | ``` 7 | pip install aicaptcha 8 | ``` 9 | 10 | ## Services 11 | - [x] `hCaptcha` 12 | - [x] `ReCaptchaV3` 13 | - [x] `Audio Captcha` 14 | - [x] `Object Recognition Captcha` 15 | 16 | ## Usage 17 | To use the library, import the AiCaptcha class from the aicaptcha module, create an instance of the class with your API key, and call the appropriate method to solve the captcha. 18 | 19 | ## Free API Key 20 | ``` txt 21 | a433a493-bc2c-41a7-baab-fb898442d2ed 22 | ``` 23 | 24 | ## Examples 25 | ### hCaptcha 26 | HCaptcha is a type of captcha that asks users to select certain images that match a given description. To solve an HCaptcha using the AiCaptcha library, you can use the `Hcaptcha` method and pass in the `site_key` and `page_url` parameters, as well as your user agent string. Here's an example: 27 | ``` python 28 | from aicaptcha import AiCaptcha 29 | 30 | api_key = "your_api_key_here" 31 | solver = AiCaptcha(api_key) 32 | 33 | hcaptcha_result = solver.Hcaptcha(site_key="hcaptcha_site_key_here", page_url="hcaptcha_page_url_here", user_agent="your_user_agent_here") 34 | print(hcaptcha_result.token) 35 | print(hcaptcha_result.key) 36 | ``` 37 | 38 | ### ReCaptcha V3 39 | ReCaptchaV3 is a type of captcha that uses a risk analysis engine to determine whether a user is a bot or a human. To solve a ReCaptchaV3 using the AiCaptcha library, you can use the `ReCaptchaV3` method and pass in the `type`, `site_key`, `page_url`, and `action` parameters. Here's an example: 40 | ``` python 41 | from aicaptcha import AiCaptcha 42 | 43 | api_key = "your_api_key_here" 44 | solver = AiCaptcha(api_key) 45 | 46 | recaptchav3_result = solver.ReCaptchaV3(type="recaptchav3_type(enterprise/normal)", site_key="recaptchav3_site_key_here", page_url="recaptchav3_page_url_here", action="recaptchav3_action_here") 47 | print(recaptchav3_result.token) 48 | ``` 49 | 50 | ### Audio Captcha 51 | Audio Captcha is a type of captcha that plays an audio clip containing a sequence of numbers or letters, which the user is required to transcribe. To solve an Audio Captcha using the AiCaptcha library, you can use the `Audio` method and pass in the `audio` parameter, which can be either the filename or content or URL of the audio file. If you set the `numbers_sensitivity` parameter to `True`, the recognition will be performed on both numbers and letters, but with a higher sensitivity to numbers, which can increase the accuracy of the recognition for number sequences. Here's an example: 52 | ``` python 53 | from aicaptcha import AiCaptcha 54 | 55 | api_key = "your_api_key_here" 56 | solver = AiCaptcha(api_key) 57 | 58 | audio_captcha_result = solver.Audio(audio="audio_filename_or_content_or_url", numbers_sensitivity=False) 59 | print(audio_captcha_result.text) 60 | print(audio_captcha_result.confidence) 61 | ``` 62 | 63 | ### Object Recognition Captcha 64 | Object Recognition Captcha is a type of captcha that shows an image containing multiple objects, and the user is required to select all objects of a certain type. To solve an Object Recognition Captcha using the AiCaptcha library, you can use the `ObjectRecognition` method and pass in the `image` parameter, which can be either the filename or content or URL of the image. You can also set the `max_results` parameter to specify the maximum number of objects to return. Here's an example: 65 | ``` python 66 | from aicaptcha import AiCaptcha 67 | 68 | api_key = "your_api_key_here" 69 | solver = AiCaptcha(api_key) 70 | 71 | object_recognition_captcha_result = solver.ObjectRecognition(image="image_filename_or_content_or_url", max_results=5) 72 | print(object_recognition_captcha_result.results) 73 | ``` 74 | 75 | ## 76 | [![Telegram](https://img.shields.io/badge/Telegram-AiCaptcha-red?style=for-the-badge&logo=Telegram)](https://t.me/aicaptcha) 77 | 78 | 🌟 Star the Repository! 🌟 79 | -------------------------------------------------------------------------------- /aicaptcha/__init__.py: -------------------------------------------------------------------------------- 1 | from .api import AiCaptcha 2 | 3 | __version__ = '1.0.3' 4 | -------------------------------------------------------------------------------- /aicaptcha/api.py: -------------------------------------------------------------------------------- 1 | from .utils import * 2 | import requests 3 | from io import BufferedReader 4 | from base64 import b64encode 5 | requests.urllib3.disable_warnings() 6 | 7 | class AiCaptcha: 8 | def __init__(self, api_key) -> None: 9 | self.__api_key = api_key 10 | self.__host = "http://captcha.x-api.tech/" 11 | 12 | def Limits(self) -> limits_class: 13 | response = requests.get(self.__host+"/limit/"+self.__api_key).json() 14 | if response["status"]: 15 | response.pop("status") 16 | return limits_class(response) 17 | else: 18 | raise Exception(response["error"]) 19 | 20 | def Hcaptcha(self, site_key: str, page_url: str, user_agent: str, version: str=None, widget_id: str=None, proxy: dict=None) -> hcaptcha_class: 21 | return hcaptcha_class(self.__request({"task": {"site_key": site_key, "page_url": page_url, "user_agent": user_agent, "version": version, "widget_id": widget_id, "proxy": proxy}, "type": "Hcaptcha"})) 22 | 23 | def ReCaptchaV3(self, site_key: str, page_url: str, action: str, type: str="normal", user_agent: str=None, cb: str=None, cookies=None, v: str=None, co: str=None, domain: str=None, proxy: dict=None) -> recaptchav3_class: 24 | return recaptchav3_class(self.__request({"task": {"type": type, "site_key": site_key, "page_url": page_url, "action": action, "user_agent": user_agent, "cb": cb, "cookies": cookies, "v": v, "co": co, "domain": domain, "proxy": proxy}, "type": "ReCaptchaV3"})) 25 | 26 | def Audio(self, audio: str, numbers_sensitivity: bool=False) -> audio_class: 27 | return audio_class(self.__request({"task": {"audio_base64": self.__get_file(audio), "numbers_sensitivity": numbers_sensitivity}, "type": "Audio"})) 28 | 29 | def ObjectRecognition(self, image: str, max_results: int=5) -> objectrecognition_class: 30 | return objectrecognition_class(self.__request({"task": {"image_base64": self.__get_file(image), "max_results": max_results}, "type": "ObjectRecognition"})) 31 | 32 | # def TikTok(self, install_id: str, device_id: str, version: str) -> tiktok: 33 | # return tiktok(self.__request({"task": {"install_id": install_id, "device_id": device_id}, "type": "TikTok", "version": version})) 34 | # 35 | # def Puzzle(self, background: str, piece: str) -> puzzle: 36 | # return puzzle(self.__request({"task": {"background_image": self.__get_file(background),"piece_image": self.__get_file(piece)}, "type": "Puzzle"})) 37 | # 38 | # def OCR(self, image: str) -> ocr: 39 | # return ocr(self.__request({"task": {"image": self.__get_file(image)}, "type": "OCR"})) 40 | 41 | def __request(self, payload): 42 | payload.update({"api_key": self.__api_key}) 43 | response = requests.post( 44 | self.__host+"solve/captcha", 45 | json=payload, 46 | verify=False 47 | ).json() 48 | if response["status"]: 49 | response.pop("status") 50 | return response 51 | else: 52 | raise Exception(response["error"]) 53 | 54 | def __get_file(self, content): 55 | if isinstance(content, str) and content.startswith("http") and "://" in content: 56 | return b64encode(requests.get(content).content).decode() 57 | elif isinstance(content, bytes): 58 | return b64encode(content).decode() 59 | elif isinstance(content, BufferedReader): 60 | return b64encode(content.read()).decode() 61 | elif isinstance(content, str): 62 | return b64encode(open(content, "rb").read()).decode() 63 | else: 64 | raise ValueError("The file value is incorrect or not supported.") -------------------------------------------------------------------------------- /aicaptcha/utils.py: -------------------------------------------------------------------------------- 1 | from urllib.parse import urlencode 2 | import json 3 | 4 | #class ocr: 5 | # def __init__(self, dict): 6 | # self.dict = dict 7 | # def __str__(self): 8 | # return urlencode(self.dict) 9 | # @property 10 | # def text(self): 11 | # return self.dict["text"] 12 | 13 | #class puzzle: 14 | # def __init__(self, dict): 15 | # self.dict = dict 16 | # def __str__(self): 17 | # return urlencode(self.dict) 18 | # @property 19 | # def text(self): 20 | # return self.dict["text"] 21 | 22 | #class tiktok: 23 | # def __init__(self, dict): 24 | # self.dict = dict 25 | # def __str__(self): 26 | # return urlencode(self.dict) 27 | # @property 28 | # def text(self): 29 | # return self.dict["text"] 30 | 31 | class objectrecognition_class: 32 | def __init__(self, dict): 33 | self.dict = dict 34 | def __str__(self): 35 | return json.dumps(self.dict["results"]) 36 | @property 37 | def results(self): 38 | return self.dict["results"] 39 | 40 | class audio_class: 41 | def __init__(self, dict): 42 | self.dict = dict 43 | def __str__(self): 44 | return urlencode(self.dict) 45 | @property 46 | def text(self): 47 | return self.dict["text"] 48 | @property 49 | def confidence(self): 50 | return self.dict["confidence"] 51 | 52 | class recaptchav3_class: 53 | def __init__(self, dict): 54 | self.dict = dict 55 | def __str__(self): 56 | return urlencode(self.dict) 57 | @property 58 | def token(self): 59 | return self.dict["recaptcha_token"] 60 | 61 | class hcaptcha_class: 62 | def __init__(self, dict): 63 | self.dict = dict 64 | def __str__(self): 65 | return urlencode(self.dict) 66 | @property 67 | def token(self): 68 | return self.dict["recaptcha_token"] 69 | @property 70 | def key(self): 71 | return self.dict["key"] 72 | 73 | class limits_class: 74 | def __init__(self, dict): 75 | self.dict = dict["limits"] 76 | def __str__(self): 77 | return urlencode(self.dict) 78 | @property 79 | def hcaptcha(self): 80 | return self.dict["hcaptcha_limit"] if "hcaptcha_limit" in self.dict else 0 81 | @property 82 | def recaptchav3(self): 83 | return self.dict["recaptcha_v3_limit"] if "recaptcha_v3_limit" in self.dict else 0 84 | @property 85 | def recaptchav2(self): 86 | return self.dict["recaptcha_v2_limit"] if "recaptcha_v2_limit" in self.dict else 0 87 | @property 88 | def ocr(self): 89 | return self.dict["ocr_limit"] if "ocr_limit" in self.dict else 0 90 | @property 91 | def audio(self): 92 | return self.dict["audio_limit"] if "audio_limit" in self.dict else 0 93 | @property 94 | def object_recognition(self): 95 | return self.dict["object_recognition_limit"] if "object_recognition_limit" in self.dict else 0 96 | @property 97 | def puzzle(self): 98 | return self.dict["puzzle_limit"] if "puzzle_limit" in self.dict else 0 99 | @property 100 | def tiktok(self): 101 | return self.dict["tiktok_limit"] if "tiktok_limit" in self.dict else 0 102 | @property 103 | def funcaptcha(self): 104 | return self.dict["funcaptcha_limit"] if "funcaptcha_limit" in self.dict else 0 -------------------------------------------------------------------------------- /examples/hcaptcha_example.py: -------------------------------------------------------------------------------- 1 | from aicaptcha import AiCaptcha 2 | 3 | api_key = "a433a493-bc2c-41a7-baab-fb898442d2ed" 4 | solver = AiCaptcha(api_key) 5 | 6 | hcaptcha_result = solver.Hcaptcha(site_key="a5f74b19-9e45-40e0-b45d-47ff91b7a6c2", page_url="https://accounts.hcaptcha.com/demo", user_agent="Mozilla/5.0 (Linux; Android 10; BLA-L29) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Mobile Safari/537.36") 7 | 8 | # To add a proxy: 9 | #, proxy={"type": "HTTP", "address": "http://ip:port"} 10 | #, proxy={"type": "HTTP", "address": "http://user:pass@ip:port"} 11 | 12 | print(hcaptcha_result.token) 13 | print(hcaptcha_result.key) 14 | -------------------------------------------------------------------------------- /examples/recaptchav3_example.py: -------------------------------------------------------------------------------- 1 | from aicaptcha import AiCaptcha 2 | import requests 3 | 4 | api_key = "a433a493-bc2c-41a7-baab-fb898442d2ed" 5 | solver = AiCaptcha(api_key) 6 | 7 | recaptchav3_result = solver.ReCaptchaV3(type="normal", site_key="6LdyC2cUAAAAACGuDKpXeDorzUDWXmdqeg-xy696", page_url="https://recaptcha-demo.appspot.com/recaptcha-v3-request-scores.php", action="examples/v3scores") 8 | recaptchav3_token = recaptchav3_result.token 9 | 10 | print("captcha token:", recaptchav3_token) 11 | 12 | result = requests.get("https://recaptcha-demo.appspot.com/recaptcha-v3-verify.php?action=examples/v3scores&token={}".format(recaptchav3_token)).json() 13 | 14 | if result["success"]: 15 | print("Done solve captcha!") 16 | else: 17 | print("Captcha could not be solved!") 18 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from setuptools import setup, find_packages 4 | import re 5 | 6 | with open("README.md", "r") as fh: 7 | long_description = fh.read() 8 | 9 | 10 | def get_version(): 11 | with open('aicaptcha/__init__.py', 'r') as f: 12 | return re.search(r'__version__ = ["\'](.*?)["\']', f.read()).group(1) 13 | 14 | 15 | setup(name='aicaptcha', 16 | version=get_version(), 17 | description='Python module for easy integration with AiCaptcha API', 18 | long_description=long_description, 19 | long_description_content_type="text/markdown", 20 | url='https://github.com/Mr-Abood/AiCaptcha', 21 | install_requires=['requests'], 22 | author='AiCaptcha', 23 | author_email='abodawad1111@gmail.com', 24 | packages=find_packages(), 25 | include_package_data=True, 26 | classifiers=[ 27 | "Programming Language :: Python :: 3", 28 | "License :: OSI Approved :: MIT License", 29 | "Operating System :: OS Independent", 30 | ], 31 | python_requires='>=3.6', 32 | ) 33 | --------------------------------------------------------------------------------