From 99c8bcb050bd6614aea7dc4ef0813a280f0b1f82 Mon Sep 17 00:00:00 2001 From: PBadicean Date: Tue, 4 Jul 2023 12:02:57 +0300 Subject: [PATCH 1/2] change sintax for ruby 2.6 --- README.md | 172 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 89 insertions(+), 83 deletions(-) diff --git a/README.md b/README.md index 26b86d2..5c6cba6 100644 --- a/README.md +++ b/README.md @@ -100,19 +100,22 @@ Below you can find basic examples for every captcha type, check out the code bel ### Normal Captcha To bypass a normal captcha (distorted text on image) use the following method. This method also can be used to recognize any text on the image. ```ruby -result = client.normal({ image: 'path/to/captcha.jpg'}) +result = client.normal({ + "image" => 'path/to/captcha.jpg' +}) # OR result = client.normal({ - image: 'https://site-with-captcha.com/path/to/captcha.jpg' + "image" => 'https://site-with-captcha.com/path/to/captcha.jpg' }) + ``` ### Text Captcha This method can be used to bypass a captcha that requires to answer a question provided in clear text. ```ruby result = client.text({ - textcaptcha:'If tomorrow is Saturday, what day is today?', - lang: "en" + "textcaptcha" => 'If tomorrow is Saturday, what day is today?', + "lang" => "en" }) ``` @@ -120,9 +123,9 @@ result = client.text({ Use this method to solve reCAPTCHA V2 and obtain a token to bypass the protection. ```ruby result = client.recaptcha_v2({ - googlekey: '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', - pageurl: 'https://mysite.com/page/with/recaptcha_v2', - invisible: 1 + "googlekey" => '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', + "pageurl" => 'https://mysite.com/page/with/recaptcha_v2', + "invisible" => 1 }) ``` @@ -130,11 +133,11 @@ result = client.recaptcha_v2({ This method provides reCAPTCHA V3 solver and returns a token. ```ruby result = client.recaptcha_v3({ - googlekey: '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', - pageurl: 'https://mysite.com/page/with/recaptcha_v3', - version: 'v3', - score: 0.3, - action: 'verify' + "googlekey" => '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', + "pageurl" => 'https://mysite.com/page/with/recaptcha_v3', + "version" => 'v3', + "score" => 0.3, + "action" => 'verify' }) ``` @@ -144,19 +147,19 @@ reCAPTCHA Enterprise can be used as reCAPTCHA V2 and reCAPTCHA V3. Below is a us ```ruby # reCAPTCHA V2 result = client.recaptcha_v2({ - googlekey: '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', - pageurl: 'https://mysite.com/page/with/recaptcha_v2_enterprise', - enterprise: 1 + "googlekey" => '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', + "pageurl" => 'https://mysite.com/page/with/recaptcha_v2_enterprise', + "enterprise" => 1 }) # reCAPTCHA V3 result = client.recaptcha_v3({ - googlekey: '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', - pageurl: 'https://mysite.com/page/with/recaptcha_v3_enterprise', - version: 'v3', - score: 0.3, - action: 'verify', - enterprise: 1, + "googlekey" => '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', + "pageurl" => 'https://mysite.com/page/with/recaptcha_v3_enterprise', + "version" => 'v3', + "score" => 0.3, + "action" => 'verify', + "enterprise" => 1, }) ``` @@ -165,19 +168,20 @@ FunCaptcha (Arkoselabs) solving method. Returns a token. ```ruby result = client.funcaptcha({ - publickey: "69A21A01-CC7B-B9C6-0F9A-E7FA06677FFC", - pageurl: "https://mysite.com/page/with/funcaptcha", - surl: "https://client-api.arkoselabs.com"}) + "publickey" => "69A21A01-CC7B-B9C6-0F9A-E7FA06677FFC", + "pageurl" => "https://mysite.com/page/with/funcaptcha", + "surl" => "https://client-api.arkoselabs.com" +}) ``` ### GeeTest Method to solve GeeTest puzzle captcha. Returns a set of tokens as JSON. ```ruby result = client.geetest({ - gt: 'f1ab2cdefa3456789012345b6c78d90e', - api_server: 'api-na.geetest.com', - challenge: '12345678abc90123d45678ef90123a456b', - pageurl: 'https://www.site.com/page/' + "gt" => 'f1ab2cdefa3456789012345b6c78d90e', + "api_server" => 'api-na.geetest.com', + "challenge" => '12345678abc90123d45678ef90123a456b', + "pageurl" => 'https://www.site.com/page/' }) ``` @@ -185,8 +189,8 @@ result = client.geetest({ Use this method to solve hCaptcha challenge. Returns a token to bypass captcha. ```ruby result = client.hcaptcha({ - sitekey: '10000000-ffff-ffff-ffff-000000000001', - pageurl: 'https://www.site.com/page/' + "sitekey" => '10000000-ffff-ffff-ffff-000000000001', + "pageurl" => 'https://www.site.com/page/' }) ``` @@ -194,21 +198,22 @@ result = client.hcaptcha({ Token-based method to solve KeyCaptcha. ```ruby result = client.keycaptcha({ - s_s_c_user_id: 10, - s_s_c_session_id: '493e52c37c10c2bcdf4a00cbc9ccd1e8', - s_s_c_web_server_sign: '9006dc725760858e4c0715b835472f22-pz-', - s_s_c_web_server_sign2: '2ca3abe86d90c6142d5571db98af6714', - pageurl: 'https://www.keycaptcha.ru/demo-magnetic/' + "s_s_c_user_id" => 10, + "s_s_c_session_id" => '493e52c37c10c2bcdf4a00cbc9ccd1e8', + "s_s_c_web_server_sign" => '9006dc725760858e4c0715b835472f22-pz-', + "s_s_c_web_server_sign2" => '2ca3abe86d90c6142d5571db98af6714', + "pageurl" => 'https://www.keycaptcha.ru/demo-magnetic/' }) + ``` ### Capy Token-based method to bypass Capy puzzle captcha. ```ruby result = client.capy({ - sitekey: 'PUZZLE_Abc1dEFghIJKLM2no34P56q7rStu8v', - pageurl: 'http://mysite.com/', - api_server: 'https://jp.api.capy.me/' + "sitekey" => 'PUZZLE_Abc1dEFghIJKLM2no34P56q7rStu8v', + "pageurl" => 'http://mysite.com/', + "api_server" => 'https://jp.api.capy.me/' }) ``` @@ -216,13 +221,13 @@ result = client.capy({ Grid method is originally called Old reCAPTCHA V2 method. The method can be used to bypass any type of captcha where you can apply a grid on image and need to click specific grid boxes. Returns numbers of boxes. ```ruby result = client.grid({ - image: 'path/to/captcha.jpg', - rows: 3, - cols: 3, - previous_id: 0, - lang: 'en', - hint_image: 'path/to/hint.jpg', - hint_text: 'Select all images with an Orange' + "image" => 'path/to/captcha.jpg', + "rows" => 3, + "cols" => 3, + "previous_id" => 0, + "lang" => 'en', + "hint_image" => 'path/to/hint.jpg', + "hint_text" => 'Select all images with an Orange' }) ``` @@ -230,11 +235,11 @@ result = client.grid({ Canvas method can be used when you need to draw a line around an object on image. Returns a set of points' coordinates to draw a polygon. ```ruby result = client.canvas({ - image: 'path/to/captcha.jpg', - previous_id: 0, - lang: 'en', - hint_image: 'path/to/hint.jpg', - hint_text: 'Draw around apple' + "image" => 'path/to/captcha.jpg', + "previous_id" => 0, + "lang" => 'en', + "hint_image" => 'path/to/hint.jpg', + "hint_text" => 'Draw around apple' }) ``` @@ -242,10 +247,10 @@ result = client.canvas({ ClickCaptcha method returns coordinates of points on captcha image. Can be used if you need to click on particular points on the image. ```ruby result = client.coordinates({ - image: 'path/to/captcha.jpg', - lang: 'en', - hint_image: 'path/to/hint.jpg', - hint_text: 'Connect the dots' + "image" => 'path/to/captcha.jpg', + "lang" => 'en', + "hint_image" => 'path/to/hint.jpg', + "hint_text" => 'Connect the dots' }) ``` @@ -253,11 +258,11 @@ result = client.coordinates({ This method can be used to solve a captcha that asks to rotate an object. Mostly used to bypass FunCaptcha. Returns the rotation angle. ```ruby result = client.rotate({ - image: 'path/to/captcha.jpg', - angle: 40, - lang: 'en', - hint_image: 'path/to/hint.jpg', - hint_text: 'Put the images in the correct way' + "image" => 'path/to/captcha.jpg', + "angle" => 40, + "lang" => 'en', + "hint_image" => 'path/to/hint.jpg', + "hint_text" => 'Put the images in the correct way' }) ``` @@ -265,10 +270,10 @@ result = client.rotate({ Use this method to solve hCaptcha challenge. Returns JSON with answer containing the following values: answer, challenge_id. ```ruby result = client.lemin({ - captcha_id: 'CROPPED_1abcd2f_a1234b567c890d12ef3a456bc78d901d', - div_id: 'lemin-cropped-captcha', - pageurl: 'https://www.site.com/page/', - api_server: "https://api.leminnow.com/" + "captcha_id" => 'CROPPED_1abcd2f_a1234b567c890d12ef3a456bc78d901d', + "div_id" => 'lemin-cropped-captcha', + "pageurl" => 'https://www.site.com/page/', + "api_server" => "https://api.leminnow.com/" }) ``` @@ -276,8 +281,8 @@ result = client.lemin({ Use this method to solve Cloudflare Turnstile. Returns JSON with the token. ```ruby result = client.turnstile({ - sitekey: '0x1AAAAAAAAkg0s2VIOD34y5', - pageurl: 'http://mysite.com/' + "sitekey" => '0x1AAAAAAAAkg0s2VIOD34y5', + "pageurl" => 'http://mysite.com/' }) ``` @@ -285,21 +290,22 @@ result = client.turnstile({ Use this method to solve Amazon WAF Captcha also known as AWS WAF Captcha is a part of Intelligent threat mitigation for Amazon AWS. Returns JSON with the token. ```ruby result = client.amazon_waf({ - sitekey: '0x1AAAAAAAAkg0s2VIOD34y5', - iv: 'CgAHbCe2GgAAAAAj', - context: '9BUgmlm48F92WUoqv97a49ZuEJJ50TCk9MVr3C7WMtQ0X6flVbufM4n8mjFLmbLVAPgaQ1Jydeaja94iAS49ljb+sUNLoukWedAQZKrlY4RdbOOzvcFqmD/ZepQFS9N5w15Exr4VwnVq+HIxTsDJwRviElWCdzKDebN/mk8/eX2n7qJi5G3Riq0tdQw9+C4diFZU5E97RSeahejOAAJTDqduqW6uLw9NsjJBkDRBlRjxjn5CaMMo5pYOxYbGrM8Un1JH5DMOLeXbq1xWbC17YSEoM1cRFfTgOoc+VpCe36Ai9Kc=', - pageurl: 'https://non-existent-example.execute-api.us-east-1.amazonaws.com/latest', - challenge_script: "https://41bcdd4fb3cb.610cd090.us-east-1.token.awswaf.com/41bcdd4fb3cb/0d21de737ccb/cd77baa6c832/challenge.js", - captcha_script: "https://41bcdd4fb3cb.610cd090.us-east-1.captcha.awswaf.com/41bcdd4fb3cb/0d21de737ccb/cd77baa6c832/captcha.js" -}) + "sitekey" => '0x1AAAAAAAAkg0s2VIOD34y5', + "iv" => 'CgAHbCe2GgAAAAAj', + "context" => '9BUgmlm48F92WUoqv97a49ZuEJJ50TCk9MVr3C7WMtQ0X6flVbufM4n8mjFLmbLVAPgaQ1Jydeaja94iAS49ljb+sUNLoukWedAQZKrlY4RdbOOzvcFqmD/ZepQFS9N5w15Exr4VwnVq+HIxTsDJwRviElWCdzKDebN/mk8/eX2n7qJi5G3Riq0tdQw9+C4diFZU5E97RSeahejOAAJTDqduqW6uLw9NsjJBkDRBlRjxjn5CaMMo5pYOxYbGrM8Un1JH5DMOLeXbq1xWbC17YSEoM1cRFfTgOoc+VpCe36Ai9Kc=', + "pageurl" => 'https://non-existent-example.execute-api.us-east-1.amazonaws.com/latest', + "challenge_script" => "https://41bcdd4fb3cb.610cd090.us-east-1.token.awswaf.com/41bcdd4fb3cb/0d21de737ccb/cd77baa6c832/challenge.js", + "captcha_script" => "https://41bcdd4fb3cb.610cd090.us-east-1.captcha.awswaf.com/41bcdd4fb3cb/0d21de737ccb/cd77baa6c832/captcha.js" +})``` ``` ### GeeTest v4 Use this method to solve GeeTest v4. Returns the response in JSON. ```ruby result = client.geetest_v4({ - captcha_id: 'e392e1d7fd421dc63325744d5a2b9c73', - pageurl: 'https://www.site.com/page/' + "captcha_id" => 'e392e1d7fd421dc63325744d5a2b9c73', + "challenge" => 'd1a9ddd7-e36f-4100-be9f-231f11743656', + "pageurl" => 'https://www.site.com/page/' }) ``` @@ -307,8 +313,8 @@ result = client.geetest_v4({ This method can be used to solve a audio captcha ```ruby result = client.audio({ - audio: 'path/to/audio.jpg', - lang: "en" + "audio" => 'path/to/audio.jpg', + "lang" => "en" }) ``` @@ -316,8 +322,8 @@ result = client.audio({ Use this method to solve Yandex and obtain a token to bypass the protection. ```ruby result = client.yandex({ - sitekey: 'Y5Lh0tiycconMJGsFd3EbbuNKSp1yaZESUOIHfeV', - url: "https://rutube.ru" + "sitekey" => 'Y5Lh0tiycconMJGsFd3EbbuNKSp1yaZESUOIHfeV', + "url" => "https://rutube.ru" }) ``` @@ -332,11 +338,11 @@ captcha_id = client.send('path/to/captcha.jpg') # or for another captcha, for example for lemin captcha_id = client.send({ - method:"lemin", - captcha_id: "CROPPED_3dfdd5c_d1872b526b794d83ba3b365eb15a200b", - api_server: "api.leminnow.com", - div_id: "lemin-cropped-captcha", - pageurl: "https://www.site.com/page/" + "method" => "lemin", + "captcha_id" => "CROPPED_3dfdd5c_d1872b526b794d83ba3b365eb15a200b", + "api_server" => "api.leminnow.com", + "div_id" => "lemin-cropped-captcha", + "pageurl" => "https://www.site.com/page/" }) time.sleep(20) From c90e2047d0664980bc2ac55b712971c1d29f7e6d Mon Sep 17 00:00:00 2001 From: PBadicean Date: Tue, 4 Jul 2023 16:11:59 +0300 Subject: [PATCH 2/2] add captcha_id to response --- README.md | 172 ++++++++++++++++++------------------- lib/api_2captcha/client.rb | 16 ++-- 2 files changed, 92 insertions(+), 96 deletions(-) diff --git a/README.md b/README.md index 5c6cba6..26b86d2 100644 --- a/README.md +++ b/README.md @@ -100,22 +100,19 @@ Below you can find basic examples for every captcha type, check out the code bel ### Normal Captcha To bypass a normal captcha (distorted text on image) use the following method. This method also can be used to recognize any text on the image. ```ruby -result = client.normal({ - "image" => 'path/to/captcha.jpg' -}) +result = client.normal({ image: 'path/to/captcha.jpg'}) # OR result = client.normal({ - "image" => 'https://site-with-captcha.com/path/to/captcha.jpg' + image: 'https://site-with-captcha.com/path/to/captcha.jpg' }) - ``` ### Text Captcha This method can be used to bypass a captcha that requires to answer a question provided in clear text. ```ruby result = client.text({ - "textcaptcha" => 'If tomorrow is Saturday, what day is today?', - "lang" => "en" + textcaptcha:'If tomorrow is Saturday, what day is today?', + lang: "en" }) ``` @@ -123,9 +120,9 @@ result = client.text({ Use this method to solve reCAPTCHA V2 and obtain a token to bypass the protection. ```ruby result = client.recaptcha_v2({ - "googlekey" => '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', - "pageurl" => 'https://mysite.com/page/with/recaptcha_v2', - "invisible" => 1 + googlekey: '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', + pageurl: 'https://mysite.com/page/with/recaptcha_v2', + invisible: 1 }) ``` @@ -133,11 +130,11 @@ result = client.recaptcha_v2({ This method provides reCAPTCHA V3 solver and returns a token. ```ruby result = client.recaptcha_v3({ - "googlekey" => '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', - "pageurl" => 'https://mysite.com/page/with/recaptcha_v3', - "version" => 'v3', - "score" => 0.3, - "action" => 'verify' + googlekey: '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', + pageurl: 'https://mysite.com/page/with/recaptcha_v3', + version: 'v3', + score: 0.3, + action: 'verify' }) ``` @@ -147,19 +144,19 @@ reCAPTCHA Enterprise can be used as reCAPTCHA V2 and reCAPTCHA V3. Below is a us ```ruby # reCAPTCHA V2 result = client.recaptcha_v2({ - "googlekey" => '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', - "pageurl" => 'https://mysite.com/page/with/recaptcha_v2_enterprise', - "enterprise" => 1 + googlekey: '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', + pageurl: 'https://mysite.com/page/with/recaptcha_v2_enterprise', + enterprise: 1 }) # reCAPTCHA V3 result = client.recaptcha_v3({ - "googlekey" => '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', - "pageurl" => 'https://mysite.com/page/with/recaptcha_v3_enterprise', - "version" => 'v3', - "score" => 0.3, - "action" => 'verify', - "enterprise" => 1, + googlekey: '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', + pageurl: 'https://mysite.com/page/with/recaptcha_v3_enterprise', + version: 'v3', + score: 0.3, + action: 'verify', + enterprise: 1, }) ``` @@ -168,20 +165,19 @@ FunCaptcha (Arkoselabs) solving method. Returns a token. ```ruby result = client.funcaptcha({ - "publickey" => "69A21A01-CC7B-B9C6-0F9A-E7FA06677FFC", - "pageurl" => "https://mysite.com/page/with/funcaptcha", - "surl" => "https://client-api.arkoselabs.com" -}) + publickey: "69A21A01-CC7B-B9C6-0F9A-E7FA06677FFC", + pageurl: "https://mysite.com/page/with/funcaptcha", + surl: "https://client-api.arkoselabs.com"}) ``` ### GeeTest Method to solve GeeTest puzzle captcha. Returns a set of tokens as JSON. ```ruby result = client.geetest({ - "gt" => 'f1ab2cdefa3456789012345b6c78d90e', - "api_server" => 'api-na.geetest.com', - "challenge" => '12345678abc90123d45678ef90123a456b', - "pageurl" => 'https://www.site.com/page/' + gt: 'f1ab2cdefa3456789012345b6c78d90e', + api_server: 'api-na.geetest.com', + challenge: '12345678abc90123d45678ef90123a456b', + pageurl: 'https://www.site.com/page/' }) ``` @@ -189,8 +185,8 @@ result = client.geetest({ Use this method to solve hCaptcha challenge. Returns a token to bypass captcha. ```ruby result = client.hcaptcha({ - "sitekey" => '10000000-ffff-ffff-ffff-000000000001', - "pageurl" => 'https://www.site.com/page/' + sitekey: '10000000-ffff-ffff-ffff-000000000001', + pageurl: 'https://www.site.com/page/' }) ``` @@ -198,22 +194,21 @@ result = client.hcaptcha({ Token-based method to solve KeyCaptcha. ```ruby result = client.keycaptcha({ - "s_s_c_user_id" => 10, - "s_s_c_session_id" => '493e52c37c10c2bcdf4a00cbc9ccd1e8', - "s_s_c_web_server_sign" => '9006dc725760858e4c0715b835472f22-pz-', - "s_s_c_web_server_sign2" => '2ca3abe86d90c6142d5571db98af6714', - "pageurl" => 'https://www.keycaptcha.ru/demo-magnetic/' + s_s_c_user_id: 10, + s_s_c_session_id: '493e52c37c10c2bcdf4a00cbc9ccd1e8', + s_s_c_web_server_sign: '9006dc725760858e4c0715b835472f22-pz-', + s_s_c_web_server_sign2: '2ca3abe86d90c6142d5571db98af6714', + pageurl: 'https://www.keycaptcha.ru/demo-magnetic/' }) - ``` ### Capy Token-based method to bypass Capy puzzle captcha. ```ruby result = client.capy({ - "sitekey" => 'PUZZLE_Abc1dEFghIJKLM2no34P56q7rStu8v', - "pageurl" => 'http://mysite.com/', - "api_server" => 'https://jp.api.capy.me/' + sitekey: 'PUZZLE_Abc1dEFghIJKLM2no34P56q7rStu8v', + pageurl: 'http://mysite.com/', + api_server: 'https://jp.api.capy.me/' }) ``` @@ -221,13 +216,13 @@ result = client.capy({ Grid method is originally called Old reCAPTCHA V2 method. The method can be used to bypass any type of captcha where you can apply a grid on image and need to click specific grid boxes. Returns numbers of boxes. ```ruby result = client.grid({ - "image" => 'path/to/captcha.jpg', - "rows" => 3, - "cols" => 3, - "previous_id" => 0, - "lang" => 'en', - "hint_image" => 'path/to/hint.jpg', - "hint_text" => 'Select all images with an Orange' + image: 'path/to/captcha.jpg', + rows: 3, + cols: 3, + previous_id: 0, + lang: 'en', + hint_image: 'path/to/hint.jpg', + hint_text: 'Select all images with an Orange' }) ``` @@ -235,11 +230,11 @@ result = client.grid({ Canvas method can be used when you need to draw a line around an object on image. Returns a set of points' coordinates to draw a polygon. ```ruby result = client.canvas({ - "image" => 'path/to/captcha.jpg', - "previous_id" => 0, - "lang" => 'en', - "hint_image" => 'path/to/hint.jpg', - "hint_text" => 'Draw around apple' + image: 'path/to/captcha.jpg', + previous_id: 0, + lang: 'en', + hint_image: 'path/to/hint.jpg', + hint_text: 'Draw around apple' }) ``` @@ -247,10 +242,10 @@ result = client.canvas({ ClickCaptcha method returns coordinates of points on captcha image. Can be used if you need to click on particular points on the image. ```ruby result = client.coordinates({ - "image" => 'path/to/captcha.jpg', - "lang" => 'en', - "hint_image" => 'path/to/hint.jpg', - "hint_text" => 'Connect the dots' + image: 'path/to/captcha.jpg', + lang: 'en', + hint_image: 'path/to/hint.jpg', + hint_text: 'Connect the dots' }) ``` @@ -258,11 +253,11 @@ result = client.coordinates({ This method can be used to solve a captcha that asks to rotate an object. Mostly used to bypass FunCaptcha. Returns the rotation angle. ```ruby result = client.rotate({ - "image" => 'path/to/captcha.jpg', - "angle" => 40, - "lang" => 'en', - "hint_image" => 'path/to/hint.jpg', - "hint_text" => 'Put the images in the correct way' + image: 'path/to/captcha.jpg', + angle: 40, + lang: 'en', + hint_image: 'path/to/hint.jpg', + hint_text: 'Put the images in the correct way' }) ``` @@ -270,10 +265,10 @@ result = client.rotate({ Use this method to solve hCaptcha challenge. Returns JSON with answer containing the following values: answer, challenge_id. ```ruby result = client.lemin({ - "captcha_id" => 'CROPPED_1abcd2f_a1234b567c890d12ef3a456bc78d901d', - "div_id" => 'lemin-cropped-captcha', - "pageurl" => 'https://www.site.com/page/', - "api_server" => "https://api.leminnow.com/" + captcha_id: 'CROPPED_1abcd2f_a1234b567c890d12ef3a456bc78d901d', + div_id: 'lemin-cropped-captcha', + pageurl: 'https://www.site.com/page/', + api_server: "https://api.leminnow.com/" }) ``` @@ -281,8 +276,8 @@ result = client.lemin({ Use this method to solve Cloudflare Turnstile. Returns JSON with the token. ```ruby result = client.turnstile({ - "sitekey" => '0x1AAAAAAAAkg0s2VIOD34y5', - "pageurl" => 'http://mysite.com/' + sitekey: '0x1AAAAAAAAkg0s2VIOD34y5', + pageurl: 'http://mysite.com/' }) ``` @@ -290,22 +285,21 @@ result = client.turnstile({ Use this method to solve Amazon WAF Captcha also known as AWS WAF Captcha is a part of Intelligent threat mitigation for Amazon AWS. Returns JSON with the token. ```ruby result = client.amazon_waf({ - "sitekey" => '0x1AAAAAAAAkg0s2VIOD34y5', - "iv" => 'CgAHbCe2GgAAAAAj', - "context" => '9BUgmlm48F92WUoqv97a49ZuEJJ50TCk9MVr3C7WMtQ0X6flVbufM4n8mjFLmbLVAPgaQ1Jydeaja94iAS49ljb+sUNLoukWedAQZKrlY4RdbOOzvcFqmD/ZepQFS9N5w15Exr4VwnVq+HIxTsDJwRviElWCdzKDebN/mk8/eX2n7qJi5G3Riq0tdQw9+C4diFZU5E97RSeahejOAAJTDqduqW6uLw9NsjJBkDRBlRjxjn5CaMMo5pYOxYbGrM8Un1JH5DMOLeXbq1xWbC17YSEoM1cRFfTgOoc+VpCe36Ai9Kc=', - "pageurl" => 'https://non-existent-example.execute-api.us-east-1.amazonaws.com/latest', - "challenge_script" => "https://41bcdd4fb3cb.610cd090.us-east-1.token.awswaf.com/41bcdd4fb3cb/0d21de737ccb/cd77baa6c832/challenge.js", - "captcha_script" => "https://41bcdd4fb3cb.610cd090.us-east-1.captcha.awswaf.com/41bcdd4fb3cb/0d21de737ccb/cd77baa6c832/captcha.js" -})``` + sitekey: '0x1AAAAAAAAkg0s2VIOD34y5', + iv: 'CgAHbCe2GgAAAAAj', + context: '9BUgmlm48F92WUoqv97a49ZuEJJ50TCk9MVr3C7WMtQ0X6flVbufM4n8mjFLmbLVAPgaQ1Jydeaja94iAS49ljb+sUNLoukWedAQZKrlY4RdbOOzvcFqmD/ZepQFS9N5w15Exr4VwnVq+HIxTsDJwRviElWCdzKDebN/mk8/eX2n7qJi5G3Riq0tdQw9+C4diFZU5E97RSeahejOAAJTDqduqW6uLw9NsjJBkDRBlRjxjn5CaMMo5pYOxYbGrM8Un1JH5DMOLeXbq1xWbC17YSEoM1cRFfTgOoc+VpCe36Ai9Kc=', + pageurl: 'https://non-existent-example.execute-api.us-east-1.amazonaws.com/latest', + challenge_script: "https://41bcdd4fb3cb.610cd090.us-east-1.token.awswaf.com/41bcdd4fb3cb/0d21de737ccb/cd77baa6c832/challenge.js", + captcha_script: "https://41bcdd4fb3cb.610cd090.us-east-1.captcha.awswaf.com/41bcdd4fb3cb/0d21de737ccb/cd77baa6c832/captcha.js" +}) ``` ### GeeTest v4 Use this method to solve GeeTest v4. Returns the response in JSON. ```ruby result = client.geetest_v4({ - "captcha_id" => 'e392e1d7fd421dc63325744d5a2b9c73', - "challenge" => 'd1a9ddd7-e36f-4100-be9f-231f11743656', - "pageurl" => 'https://www.site.com/page/' + captcha_id: 'e392e1d7fd421dc63325744d5a2b9c73', + pageurl: 'https://www.site.com/page/' }) ``` @@ -313,8 +307,8 @@ result = client.geetest_v4({ This method can be used to solve a audio captcha ```ruby result = client.audio({ - "audio" => 'path/to/audio.jpg', - "lang" => "en" + audio: 'path/to/audio.jpg', + lang: "en" }) ``` @@ -322,8 +316,8 @@ result = client.audio({ Use this method to solve Yandex and obtain a token to bypass the protection. ```ruby result = client.yandex({ - "sitekey" => 'Y5Lh0tiycconMJGsFd3EbbuNKSp1yaZESUOIHfeV', - "url" => "https://rutube.ru" + sitekey: 'Y5Lh0tiycconMJGsFd3EbbuNKSp1yaZESUOIHfeV', + url: "https://rutube.ru" }) ``` @@ -338,11 +332,11 @@ captcha_id = client.send('path/to/captcha.jpg') # or for another captcha, for example for lemin captcha_id = client.send({ - "method" => "lemin", - "captcha_id" => "CROPPED_3dfdd5c_d1872b526b794d83ba3b365eb15a200b", - "api_server" => "api.leminnow.com", - "div_id" => "lemin-cropped-captcha", - "pageurl" => "https://www.site.com/page/" + method:"lemin", + captcha_id: "CROPPED_3dfdd5c_d1872b526b794d83ba3b365eb15a200b", + api_server: "api.leminnow.com", + div_id: "lemin-cropped-captcha", + pageurl: "https://www.site.com/page/" }) time.sleep(20) diff --git a/lib/api_2captcha/client.rb b/lib/api_2captcha/client.rb index adef6b6..29b6c4b 100644 --- a/lib/api_2captcha/client.rb +++ b/lib/api_2captcha/client.rb @@ -27,7 +27,8 @@ def initialize(api_key, soft_id = 0, callback = nil) @domain = DEFAULT_DOMAIN end - def solve(method, params = {}, file_path = nil, return_id: false) + def solve(method, file_path = nil, return_id: false, **params) + params = params.transform_keys(&:to_s) params["method"] = method params["key"] = @api_key params["soft_id"] = @soft_id @@ -70,7 +71,8 @@ def get_result(captcha_id) when Net::HTTPSuccess response_json = JSON.parse(response.body) if response_json["status"] == 1 - return response_json["request"] + response_json["captcha_id"] = captcha_id + return response_json elsif response_json["request"] == "CAPCHA_NOT_READY" sleep(polling_interval) else @@ -169,12 +171,12 @@ def amazon_waf(params) end def audio(params) - audio = params.delete(:audio) + audio = params.delete("audio") audio_content = File.file?(audio) ? File.binread(audio) : audio params = params.merge( "body" => Base64.strict_encode64(audio_content), - "lang" => params[:lang] + "lang" => params["lang"] ) solve("audio", params) end @@ -198,12 +200,12 @@ def send_request(params) end def get_params(params) - params[:image].nil? ? params : file_params(params) + params["image"].nil? ? params : file_params(params) end def file_params(params) - image = params.delete(:image) - hint_image = params.delete(:hint_image) + image = params.delete("image") + hint_image = params.delete("hint_image") image_content = get_image_content(image) hint_image_content = get_image_content(hint_image) if hint_image