From ad4251e6ffdb49abcfb0935eba9a7d9e758e9ca6 Mon Sep 17 00:00:00 2001 From: Victor Date: Wed, 24 Jul 2024 17:26:43 -0300 Subject: [PATCH] RC-2363 Add new API methods (#20) * Added Tencent support * Add Tencent to README.md * Added MTCaptcha support * Add Cutcaptcha support * Added Friendly Captcha support * Added atbCAPTCHA support * Added DataDome support --- .gitignore | 5 +- README.md | 92 ++++++++++++++++++++++++++-- examples/atb_captcha.php | 19 ++++++ examples/cutcaptcha.php | 19 ++++++ examples/datadome.php | 23 +++++++ examples/friendly_captcha.php | 18 ++++++ examples/mt_captcha.php | 18 ++++++ examples/tencent.php | 18 ++++++ src/TwoCaptcha.php | 110 ++++++++++++++++++++++++++++++++++ tests/AtbCaptchaTest.php | 37 ++++++++++++ tests/CutcaptchaTest.php | 37 ++++++++++++ tests/DatadomeTest.php | 37 ++++++++++++ tests/FriendlyCaptchaTest.php | 35 +++++++++++ tests/MTCaptchaTest.php | 35 +++++++++++ tests/TencentTest.php | 35 +++++++++++ 15 files changed, 533 insertions(+), 5 deletions(-) create mode 100644 examples/atb_captcha.php create mode 100644 examples/cutcaptcha.php create mode 100644 examples/datadome.php create mode 100644 examples/friendly_captcha.php create mode 100644 examples/mt_captcha.php create mode 100644 examples/tencent.php create mode 100644 tests/AtbCaptchaTest.php create mode 100644 tests/CutcaptchaTest.php create mode 100644 tests/DatadomeTest.php create mode 100644 tests/FriendlyCaptchaTest.php create mode 100644 tests/MTCaptchaTest.php create mode 100644 tests/TencentTest.php diff --git a/.gitignore b/.gitignore index 50a6ee2..f22bb09 100644 --- a/.gitignore +++ b/.gitignore @@ -69,4 +69,7 @@ $RECYCLE.BIN/ .Trash-* # .nfs files are created when an open file is removed but is still being accessed -.nfs* \ No newline at end of file +.nfs* + +# PHPUnit cache +.phpunit.result.cache diff --git a/README.md b/README.md index 406dfca..e90ce51 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,11 @@ Examples of API requests for different captcha types are available on the [PHP c - [Composer](#composer) - [Manual](#manual) - [Configuration](#configuration) + - [TwoCaptcha instance options](#twocaptcha-instance-options) - [Solve captcha](#solve-captcha) + - [Captcha options](#captcha-options) - [Normal Captcha](#normal-captcha) - - [Text](#text-captcha) + - [Text Captcha](#text-captcha) - [ReCaptcha v2](#recaptcha-v2) - [ReCaptcha v3](#recaptcha-v3) - [FunCaptcha](#funcaptcha) @@ -26,7 +28,7 @@ Examples of API requests for different captcha types are available on the [PHP c - [hCaptcha](#hcaptcha) - [KeyCaptcha](#keycaptcha) - [Capy](#capy) - - [Grid (ReCaptcha V2 Old Method)](#grid) + - [Grid](#grid) - [Canvas](#canvas) - [ClickCaptcha](#clickcaptcha) - [Rotate](#rotate) @@ -35,14 +37,20 @@ Examples of API requests for different captcha types are available on the [PHP c - [Lemin](#lemin) - [Turnstile](#turnstile) - [AmazonWaf](#amazonwaf) + - [Tencent](#tencent) + - [MTCaptcha](#mtcaptcha) + - [Cutcaptcha](#cutcaptcha) + - [Friendly Captcha](#friendly-captcha) + - [atbCAPTCHA](#atbcaptcha) + - [DataDome](#datadome) - [Other methods](#other-methods) - [send / getResult](#send--getresult) - [balance](#balance) - [report](#report) - [Proxies](#proxies) - [Error handling](#error-handling) -- [Get in touch](#get-in-touch) -- [Join the team 👪](#join-the-team-) + - [Get in touch](#get-in-touch) + - [Join the team 👪](#join-the-team-) ## Installation @@ -249,6 +257,82 @@ $result = $solver->amazon_waf([ ]); ``` +### Tencent + +Use this method to bypass Tencent. + +```php +$result = $solver->tencent([ + 'sitekey' => '123456789', + 'url' => 'https://www.site.com/page/', +]); +``` + + +### MTCaptcha + +Use this method to bypass MTCaptcha. + +```php +$result = $solver->mt_captcha([ + 'sitekey' => 'MTPublic-KzqLY1cKH', + 'url' => 'https://2captcha.com/demo/mtcaptcha', +]); +``` + +### Cutcaptcha + +Use this method to bypass Cutcaptcha. + +```php +$result = $solver->cutcaptcha([ + 'misery_key' => 'a1488b66da00bf332a1488993a5443c79047e752', + 'api_key' => 'SAb83IIB', + 'url' => 'https://example.cc/foo/bar.html', +]); +``` + +### Friendly Captcha + +Use this method to bypass Friendly Captcha. + +```php +$result = $solver->friendly_captcha([ + 'sitekey' => '2FZFEVS1FZCGQ9', + 'url' => 'https://example.com/', +]); +``` + +### atbCAPTCHA + +Use this method to bypass atbCAPTCHA. + +```php +$result = $solver->atb_captcha([ + 'sitekey' => 'af23e041b22d000a11e22a230fa8991c', + 'api_server' => 'https://cap.aisecurius.com', + 'url' => 'https://example.com/', +]); +``` + +### DataDome + +Use this method to bypass DataDome. + +```php +$result = $solver->datadome([ + 'captcha_url' => 'af23e041b22d000a11e22a230fa8991c', + 'userAgent' => 'https://cap.aisecurius.com', + 'url' => 'https://example.com/', + 'proxy' => [ + 'type' => 'HTTPS', + 'uri' => 'username:str0ngP@$$W0rd@1.2.3.4:4321', + ], +]); +``` + + + ## Other methods ### send / getResult diff --git a/examples/atb_captcha.php b/examples/atb_captcha.php new file mode 100644 index 0000000..7bb10be --- /dev/null +++ b/examples/atb_captcha.php @@ -0,0 +1,19 @@ +atb_captcha([ + 'sitekey' => 'af23e041b22d000a11e22a230fa8991c', + 'api_server' => 'https://cap.aisecurius.com', + 'url' => 'https://example.com/', + ]); +} catch (\Exception $e) { + die($e->getMessage()); +} + +die('Captcha solved: ' . $result->code); diff --git a/examples/cutcaptcha.php b/examples/cutcaptcha.php new file mode 100644 index 0000000..cc7d680 --- /dev/null +++ b/examples/cutcaptcha.php @@ -0,0 +1,19 @@ +cutcaptcha([ + 'misery_key' => 'a1488b66da00bf332a1488993a5443c79047e752', + 'api_key' => 'SAb83IIB', + 'url' => 'https://example.cc/foo/bar.html', + ]); +} catch (\Exception $e) { + die($e->getMessage()); +} + +die('Captcha solved: ' . $result->code); diff --git a/examples/datadome.php b/examples/datadome.php new file mode 100644 index 0000000..5f2b27a --- /dev/null +++ b/examples/datadome.php @@ -0,0 +1,23 @@ +datadome([ + 'captcha_url' => 'https://geo.captcha-delivery.com/captcha/?initialCid=AHrlqAAA...P~XFrBVptk&t=fe&referer=https%3A%2F%2Fhexample.com&s=45239&e=c538be..c510a00ea', + 'userAgent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36', + 'url' => 'https://example.com/', + 'proxy' => [ + 'type' => 'HTTPS', + 'uri' => 'username:str0ngP@$$W0rd@1.2.3.4:4321', + ], + ]); +} catch (\Exception $e) { + die($e->getMessage()); +} + +die('Captcha solved: ' . $result->code); diff --git a/examples/friendly_captcha.php b/examples/friendly_captcha.php new file mode 100644 index 0000000..1e5cf39 --- /dev/null +++ b/examples/friendly_captcha.php @@ -0,0 +1,18 @@ +friendly_captcha([ + 'sitekey' => '2FZFEVS1FZCGQ9', + 'url' => 'https://example.com/', + ]); +} catch (\Exception $e) { + die($e->getMessage()); +} + +die('Captcha solved: ' . $result->code); diff --git a/examples/mt_captcha.php b/examples/mt_captcha.php new file mode 100644 index 0000000..63442c1 --- /dev/null +++ b/examples/mt_captcha.php @@ -0,0 +1,18 @@ +mt_captcha([ + 'sitekey' => 'MTPublic-KzqLY1cKH', + 'url' => 'https://2captcha.com/demo/mtcaptcha', + ]); +} catch (\Exception $e) { + die($e->getMessage()); +} + +die('Captcha solved: ' . $result->code); diff --git a/examples/tencent.php b/examples/tencent.php new file mode 100644 index 0000000..e316eb6 --- /dev/null +++ b/examples/tencent.php @@ -0,0 +1,18 @@ +tencent([ + 'sitekey' => '123456789', + 'url' => 'https://www.site.com/page/', + ]); +} catch (\Exception $e) { + die($e->getMessage()); +} + +die('Captcha solved: ' . $result->code); diff --git a/src/TwoCaptcha.php b/src/TwoCaptcha.php index 305e6bf..32496ef 100644 --- a/src/TwoCaptcha.php +++ b/src/TwoCaptcha.php @@ -344,6 +344,110 @@ public function capy($captcha) return $this->solve($captcha); } + /** + * Wrapper for solving Tencent + * + * @param $captcha + * @return \stdClass + * @throws ApiException + * @throws NetworkException + * @throws TimeoutException + * @throws ValidationException + */ + public function tencent($captcha) + { + $captcha['method'] = 'tencent'; + + return $this->solve($captcha); + } + + /** + * Wrapper for solving MTCaptcha + * + * @param $captcha + * @return \stdClass + * @throws ApiException + * @throws NetworkException + * @throws TimeoutException + * @throws ValidationException + */ + public function mt_captcha($captcha) + { + $captcha['method'] = 'mt_captcha'; + + return $this->solve($captcha); + } + + /** + * Wrapper for solving Cutcaptcha + * + * @param $captcha + * @return \stdClass + * @throws ApiException + * @throws NetworkException + * @throws TimeoutException + * @throws ValidationException + */ + public function cutcaptcha($captcha) + { + $captcha['method'] = 'cutcaptcha'; + + return $this->solve($captcha); + } + + /** + * Wrapper for solving Friendly Captcha + * + * @param $captcha + * @return \stdClass + * @throws ApiException + * @throws NetworkException + * @throws TimeoutException + * @throws ValidationException + */ + public function friendly_captcha($captcha) + { + $captcha['method'] = 'friendly_captcha'; + + return $this->solve($captcha); + } + + /** + * Wrapper for solving atbCAPTCHA + * + * @param $captcha + * @return \stdClass + * @throws ApiException + * @throws NetworkException + * @throws TimeoutException + * @throws ValidationException + */ + public function atb_captcha($captcha) + { + $captcha['method'] = 'atb_captcha'; + + return $this->solve($captcha); + } + + + /** + * Wrapper for solving DataDome + * + * @param $captcha + * @return \stdClass + * @throws ApiException + * @throws NetworkException + * @throws TimeoutException + * @throws ValidationException + */ + public function datadome($captcha) + { + $captcha['method'] = 'datadome'; + + return $this->solve($captcha); + } + + /** * Wrapper for solving grid captcha * @@ -801,6 +905,12 @@ private function getParamsMap($method) 'capy' => [ 'sitekey' => 'captchakey', ], + 'tencent' => [ + 'sitekey' => 'app_id', + ], + 'atb_captcha' => [ + 'sitekey' => 'app_id', + ], ]; if (isset($methodMap[$method])) { diff --git a/tests/AtbCaptchaTest.php b/tests/AtbCaptchaTest.php new file mode 100644 index 0000000..48f7d44 --- /dev/null +++ b/tests/AtbCaptchaTest.php @@ -0,0 +1,37 @@ + 'af23e041b22d000a11e22a230fa8991c', + 'api_server' => 'https://cap.aisecurius.com', + 'url' => 'https://example.com/', + 'proxy' => [ + 'type' => 'HTTPS', + 'uri' => 'username:str0ngP@$$W0rd@1.2.3.4:4321', + ] + ]; + + $sendParams = [ + 'method' => 'atb_captcha', + 'app_id' => 'af23e041b22d000a11e22a230fa8991c', + 'api_server' => 'https://cap.aisecurius.com', + 'pageurl' => 'https://example.com/', + 'proxy' => 'username:str0ngP@$$W0rd@1.2.3.4:4321', + 'proxytype' => 'HTTPS', + 'soft_id' => '4585', + ]; + + $this->checkIfCorrectParamsSendAndResultReturned([ + 'params' => $params, + 'sendParams' => $sendParams, + 'sendFiles' => [], + ]); + } +} diff --git a/tests/CutcaptchaTest.php b/tests/CutcaptchaTest.php new file mode 100644 index 0000000..b70c7d9 --- /dev/null +++ b/tests/CutcaptchaTest.php @@ -0,0 +1,37 @@ + 'a1488b66da00bf332a1488993a5443c79047e752', + 'api_key' => 'SAb83IIB', + 'url' => 'https://example.cc/foo/bar.html', + 'proxy' => [ + 'type' => 'HTTPS', + 'uri' => 'username:str0ngP@$$W0rd@1.2.3.4:4321', + ] + ]; + + $sendParams = [ + 'method' => 'cutcaptcha', + 'misery_key' => 'a1488b66da00bf332a1488993a5443c79047e752', + 'api_key' => 'SAb83IIB', + 'pageurl' => 'https://example.cc/foo/bar.html', + 'proxy' => 'username:str0ngP@$$W0rd@1.2.3.4:4321', + 'proxytype' => 'HTTPS', + 'soft_id' => '4585', + ]; + + $this->checkIfCorrectParamsSendAndResultReturned([ + 'params' => $params, + 'sendParams' => $sendParams, + 'sendFiles' => [], + ]); + } +} diff --git a/tests/DatadomeTest.php b/tests/DatadomeTest.php new file mode 100644 index 0000000..6acec6f --- /dev/null +++ b/tests/DatadomeTest.php @@ -0,0 +1,37 @@ + 'https://geo.captcha-delivery.com/captcha/?initialCid=AHrlqAAA...P~XFrBVptk&t=fe&referer=https%3A%2F%2Fhexample.com&s=45239&e=c538be..c510a00ea', + 'userAgent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36', + 'url' => 'https://example.com/', + 'proxy' => [ + 'type' => 'HTTPS', + 'uri' => 'username:str0ngP@$$W0rd@1.2.3.4:4321', + ], + ]; + + $sendParams = [ + 'method' => 'datadome', + 'captcha_url' => 'https://geo.captcha-delivery.com/captcha/?initialCid=AHrlqAAA...P~XFrBVptk&t=fe&referer=https%3A%2F%2Fhexample.com&s=45239&e=c538be..c510a00ea', + 'userAgent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36', + 'pageurl' => 'https://example.com/', + 'proxy' => 'username:str0ngP@$$W0rd@1.2.3.4:4321', + 'proxytype' => 'HTTPS', + 'soft_id' => '4585', + ]; + + $this->checkIfCorrectParamsSendAndResultReturned([ + 'params' => $params, + 'sendParams' => $sendParams, + 'sendFiles' => [], + ]); + } +} diff --git a/tests/FriendlyCaptchaTest.php b/tests/FriendlyCaptchaTest.php new file mode 100644 index 0000000..d4e927f --- /dev/null +++ b/tests/FriendlyCaptchaTest.php @@ -0,0 +1,35 @@ + '2FZFEVS1FZCGQ9', + 'url' => 'https://example.com/', + 'proxy' => [ + 'type' => 'HTTPS', + 'uri' => 'username:str0ngP@$$W0rd@1.2.3.4:4321', + ] + ]; + + $sendParams = [ + 'method' => 'friendly_captcha', + 'sitekey' => '2FZFEVS1FZCGQ9', + 'pageurl' => 'https://example.com/', + 'proxy' => 'username:str0ngP@$$W0rd@1.2.3.4:4321', + 'proxytype' => 'HTTPS', + 'soft_id' => '4585', + ]; + + $this->checkIfCorrectParamsSendAndResultReturned([ + 'params' => $params, + 'sendParams' => $sendParams, + 'sendFiles' => [], + ]); + } +} diff --git a/tests/MTCaptchaTest.php b/tests/MTCaptchaTest.php new file mode 100644 index 0000000..4b52179 --- /dev/null +++ b/tests/MTCaptchaTest.php @@ -0,0 +1,35 @@ + 'MTPublic-AbcDE1fgH', + 'url' => 'https://www.site.com/page/', + 'proxy' => [ + 'type' => 'HTTPS', + 'uri' => 'username:str0ngP@$$W0rd@1.2.3.4:4321', + ] + ]; + + $sendParams = [ + 'method' => 'mt_captcha', + 'sitekey' => 'MTPublic-AbcDE1fgH', + 'pageurl' => 'https://www.site.com/page/', + 'proxy' => 'username:str0ngP@$$W0rd@1.2.3.4:4321', + 'proxytype' => 'HTTPS', + 'soft_id' => '4585', + ]; + + $this->checkIfCorrectParamsSendAndResultReturned([ + 'params' => $params, + 'sendParams' => $sendParams, + 'sendFiles' => [], + ]); + } +} diff --git a/tests/TencentTest.php b/tests/TencentTest.php new file mode 100644 index 0000000..cb70549 --- /dev/null +++ b/tests/TencentTest.php @@ -0,0 +1,35 @@ + '123456789', + 'url' => 'https://www.site.com/page/', + 'proxy' => [ + 'type' => 'HTTPS', + 'uri' => 'username:str0ngP@$$W0rd@1.2.3.4:4321', + ] + ]; + + $sendParams = [ + 'method' => 'tencent', + 'app_id' => '123456789', + 'pageurl' => 'https://www.site.com/page/', + 'proxy' => 'username:str0ngP@$$W0rd@1.2.3.4:4321', + 'proxytype' => 'HTTPS', + 'soft_id' => '4585', + ]; + + $this->checkIfCorrectParamsSendAndResultReturned([ + 'params' => $params, + 'sendParams' => $sendParams, + 'sendFiles' => [], + ]); + } +}