├── .gitignore
├── LICENSE
├── README.md
├── TwoCaptcha.Examples
├── AmazonWafExample.cs
├── AmazonWafOptionsExample.cs
├── AtbCAPTCHAExample.cs
├── AudioCaptchaExample.cs
├── AudioCaptchaOpdionsExample.cs
├── CanvasBase64Example.cs
├── CanvasExample.cs
├── CanvasOptionsExample.cs
├── CapyExample.cs
├── CapyOptionsExample.cs
├── CoordinatesBase64Example.cs
├── CoordinatesExample.cs
├── CoordinatesOptionsExample.cs
├── CutcaptchaExample.cs
├── CyberSiARAExample.cs
├── DataDomeExample.cs
├── FriendlyCaptchaExample.cs
├── FunCaptchaExample.cs
├── FunCaptchaOptionsExample.cs
├── GeeTestExample.cs
├── GeeTestOptionsExample.cs
├── GeeTestV4Example.cs
├── GeeTestV4OptionsExample.cs
├── GridBase64Example.cs
├── GridExample.cs
├── GridOptionsExample.cs
├── KeyCaptchaExample.cs
├── KeyCaptchaOptionsExample.cs
├── LeminExample.cs
├── LeminOptionsExample.cs
├── MTCaptchaExample.cs
├── NormalBase64Example.cs
├── NormalExample.cs
├── NormalOptionsExample.cs
├── README.md
├── ReCaptchaV2Example.cs
├── ReCaptchaV2OptionsExample.cs
├── ReCaptchaV3Example.cs
├── ReCaptchaV3OptionsExample.cs
├── RotateExample.cs
├── RotateOptionsExample.cs
├── Run.cs
├── TencentExample.cs
├── TextExample.cs
├── TextOptionsExample.cs
├── TurnstileExample.cs
├── TurnstileOptionsExample.cs
├── TwoCaptcha.Examples.csproj
├── YandexExample.cs
├── YandexOptionsExample.cs
└── resources
│ ├── audio-en.mp3
│ ├── audio-ru.mp3
│ ├── canvas.jpg
│ ├── canvas_hint.jpg
│ ├── grid.jpg
│ ├── grid_2.jpg
│ ├── grid_hint.jpg
│ ├── normal.jpg
│ ├── normal_2.jpg
│ ├── normal_hint.jpg
│ ├── rotate.jpg
│ ├── rotate_2.jpg
│ ├── rotate_3.jpg
│ └── rotate_hint.jpg
├── TwoCaptcha.Tests
├── AbstractWrapperTestCase.cs
├── AmazonWafTest.cs
├── AtbCAPTCHATest.cs
├── AudioTest.cs
├── CanvasTest.cs
├── CapyTest.cs
├── CoordinatesTest.cs
├── CutcaptchaTest.cs
├── CyberSiARATest.cs
├── DataDomeTest.cs
├── FriendlyCaptchaTest.cs
├── FunCaptchaTest.cs
├── GeeTestTest.cs
├── GeeTestV4Test.cs
├── GridTest.cs
├── HCaptchaTest.cs
├── KeyCaptchaTest.cs
├── LeminTest.cs
├── MTCaptchaTest.cs
├── NormalTest.cs
├── ReCaptchaTest.cs
├── RotateTest.cs
├── TencentTest.cs
├── TextTest.cs
├── TurnstileTest.cs
├── TwoCaptcha.Tests.csproj
├── YandexTest.cs
└── resources
│ ├── audio-en.mp3
│ ├── audio-ru.mp3
│ ├── canvas.jpg
│ ├── canvas_hint.jpg
│ ├── grid.jpg
│ ├── grid_2.jpg
│ ├── grid_hint.jpg
│ ├── normal.jpg
│ ├── normal_2.jpg
│ ├── rotate.jpg
│ ├── rotate_2.jpg
│ └── rotate_3.jpg
├── TwoCaptcha.sln
└── TwoCaptcha
├── ApiClient.cs
├── Captcha
├── AmazonWaf.cs
├── AtbCAPTCHA.cs
├── AudioCaptcha.cs
├── Canvas.cs
├── Captcha.cs
├── Capy.cs
├── Coordinates.cs
├── Cutcaptcha.cs
├── CyberSiARA.cs
├── DataDome.cs
├── FriendlyCaptcha.cs
├── FunCaptcha.cs
├── GeeTest.cs
├── GeeTestV4.cs
├── Grid.cs
├── HCaptcha.cs
├── KeyCaptcha.cs
├── Lemin.cs
├── MTCaptcha.cs
├── Normal.cs
├── ReCaptcha.cs
├── Rotate.cs
├── Tencent.cs
├── Text.cs
├── Turnstile.cs
└── Yandex.cs
├── Exceptions
├── ApiException.cs
├── NetworkException.cs
├── TimeoutException.cs
└── ValidationException.cs
├── TwoCaptcha.cs
└── TwoCaptcha.csproj
/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | obj/
3 | /packages/
4 | riderModule.iml
5 | /_ReSharper.Caches/
6 | .idea
7 | .vs
8 | info.md
9 | Properties/
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 2captcha
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 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | # C# Module for 2Captcha API (captcha solver)
11 | The easiest way to quickly integrate [2Captcha] into your code to automate solving of any types of captcha.
12 | Examples of API requests for different captcha types are available on the [C# captcha solver](https://2captcha.com/lang/csharp) page.
13 |
14 | - [C# Module for 2Captcha API (captcha solver)](#c-module-for-2captcha-api-captcha-solver)
15 | - [Installation](#installation)
16 | - [Configuration](#configuration)
17 | - [TwoCaptcha instance options](#twocaptcha-instance-options)
18 | - [Solve captcha](#solve-captcha)
19 | - [Captcha options](#captcha-options)
20 | - [Basic example](#basic-example)
21 | - [Normal Captcha](#normal-captcha)
22 | - [Text Captcha](#text-captcha)
23 | - [reCAPTCHA v2](#recaptcha-v2)
24 | - [reCAPTCHA v3](#recaptcha-v3)
25 | - [FunCaptcha](#funcaptcha)
26 | - [GeeTest](#geetest)
27 | - [GeeTest v4](#geetest-v4)
28 | - [KeyCaptcha](#keycaptcha)
29 | - [Capy](#capy)
30 | - [Grid](#grid)
31 | - [Canvas](#canvas)
32 | - [ClickCaptcha](#clickcaptcha)
33 | - [Rotate](#rotate)
34 | - [Audio Captcha](#audio-captcha)
35 | - [Yandex](#yandex)
36 | - [Lemin Cropped Captcha](#lemin-cropped-captcha)
37 | - [Cloudflare Turnstile](#cloudflare-turnstile)
38 | - [Amazon WAF](#amazon-waf)
39 | - [Friendly Captcha](#friendly-captcha)
40 | - [MTCaptcha](#mtcaptcha)
41 | - [Cutcaptcha](#cutcaptcha)
42 | - [CyberSiARA](#cybersiara)
43 | - [DataDome](#datadome)
44 | - [atbCAPTCHA](#atbcaptcha)
45 | - [Tencent](#tencent)
46 | - [Other methods](#other-methods)
47 | - [send / getResult](#send--getresult)
48 | - [balance](#balance)
49 | - [report](#report)
50 | - [Proxies](#proxies)
51 | - [Error handling](#error-handling)
52 | - [Get in touch](#get-in-touch)
53 | - [Join the team 👪](#join-the-team-)
54 | - [License](#license)
55 | - [Graphics and Trademarks](#graphics-and-trademarks)
56 |
57 | ## Installation
58 | Install nuget package from [nuget]:
59 |
60 | `dotnet add package 2captcha-csharp`
61 |
62 | ## Configuration
63 | `TwoCaptcha` instance can be created like this:
64 | ```csharp
65 | TwoCaptcha solver = new TwoCaptcha('YOUR_API_KEY');
66 | ```
67 | Also there are few options that can be configured:
68 | ```csharp
69 | solver.SoftId = 123;
70 | solver.Callback = "https://your.site/result-receiver";
71 | solver.DefaultTimeout = 120;
72 | solver.RecaptchaTimeout = 600;
73 | solver.PollingInterval = 10;
74 | ```
75 |
76 | ### TwoCaptcha instance options
77 |
78 | | Option | Default value | Description |
79 | | ---------------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
80 | | softId | 4582 | your software ID obtained after publishing in [2captcha software catalog] |
81 | | callback | - | URL of your web-sever that receives the captcha recognition result. The URl should be first registered in [pingback settings] of your account |
82 | | defaultTimeout | 120 | Polling timeout in seconds for all captcha types except reCAPTCHA. Defines how long the module tries to get the answer from `res.php` API endpoint |
83 | | recaptchaTimeout | 600 | Polling timeout for reCAPTCHA in seconds. Defines how long the module tries to get the answer from `res.php` API endpoint |
84 | | pollingInterval | 10 | Interval in seconds between requests to `res.php` API endpoint, setting values less than 5 seconds is not recommended |
85 |
86 | > **IMPORTANT:** once `Callback` is defined for `TwoCaptcha` instance, all methods return only the captcha ID and DO NOT poll the API to get the result. The result will be sent to the callback URL.
87 | To get the answer manually use [getResult method](#send--getresult)
88 |
89 | ## Solve captcha
90 | When you submit any image-based captcha use can provide additional options to help 2captcha workers to solve it properly.
91 |
92 | ### Captcha options
93 | | Option | Default Value | Description |
94 | | ------------- | ------------- | -------------------------------------------------------------------------------------------------- |
95 | | numeric | 0 | Defines if captcha contains numeric or other symbols [see more info in the API docs][post options] |
96 | | minLength | 0 | minimal answer length |
97 | | maxLength | 0 | maximum answer length |
98 | | phrase | 0 | defines if the answer contains multiple words or not |
99 | | caseSensitive | 0 | defines if the answer is case sensitive |
100 | | calc | 0 | defines captcha requires calculation |
101 | | lang | - | defines the captcha language, see the [list of supported languages] |
102 | | hintImg | - | an image with hint shown to workers with the captcha |
103 | | hintText | - | hint or task text shown to workers with the captcha |
104 |
105 | Below you can find basic examples for every captcha type. Check out [examples directory] to find more examples with all available options.
106 |
107 | ### Basic example
108 | Example below shows a basic solver call example with error handling.
109 |
110 | ```csharp
111 | Normal captcha = new Normal();
112 | captcha.SetFile("path/to/captcha.jpg");
113 | captcha.SetMinLen(4);
114 | captcha.SetMaxLen(20);
115 | captcha.SetCaseSensitive(true);
116 | captcha.SetLang("en");
117 |
118 | try
119 | {
120 | await solver.Solve(captcha);
121 | Console.WriteLine("Captcha solved: " + captcha.Code);
122 | }
123 | catch (Exception e)
124 | {
125 | Console.WriteLine("Error occurred: " + e.Message);
126 | }
127 | ```
128 |
129 | ### Normal Captcha
130 |
131 | [API method description.](https://2captcha.com/2captcha-api#solving_normal_captcha)
132 |
133 | 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.
134 |
135 | ```csharp
136 | Normal captcha = new Normal();
137 | captcha.SetFile("path/to/captcha.jpg");
138 | captcha.SetNumeric(4);
139 | captcha.SetMinLen(4);
140 | captcha.SetMaxLen(20);
141 | captcha.SetPhrase(true);
142 | captcha.SetCaseSensitive(true);
143 | captcha.SetCalc(false);
144 | captcha.SetLang("en");
145 | captcha.SetHintImg(new FileInfo("path/to/hint.jpg"));
146 | captcha.SetHintText("Type red symbols only");
147 | ```
148 |
149 | ### Text Captcha
150 |
151 | [API method description.](https://2captcha.com/2captcha-api#solving_text_captcha)
152 |
153 | This method can be used to bypass a captcha that requires to answer a question provided in clear text.
154 |
155 | ```csharp
156 | Text captcha = new Text();
157 | captcha.SetText("If tomorrow is Saturday, what day is today?");
158 | captcha.SetLang("en");
159 | ```
160 |
161 | ### reCAPTCHA v2
162 |
163 | [API method description.](https://2captcha.com/2captcha-api#solving_recaptchav2_new)
164 |
165 | Use this method to solve reCAPTCHA V2 and obtain a token to bypass the protection.
166 |
167 | ```csharp
168 | ReCaptcha captcha = new ReCaptcha();
169 | captcha.SetSiteKey("6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-");
170 | captcha.SetUrl("https://mysite.com/page/with/recaptcha");
171 | captcha.SetInvisible(true);
172 | captcha.SetEnterprise(false);
173 | captcha.SetAction("verify");
174 | captcha.SetProxy("HTTPS", "login:password@IP_address:PORT");
175 | ```
176 | ### reCAPTCHA v3
177 |
178 | [API method description.](https://2captcha.com/2captcha-api#solving_recaptchav3)
179 |
180 | This method provides reCAPTCHA V3 solver and returns a token.
181 |
182 | ```csharp
183 | ReCaptcha captcha = new ReCaptcha();
184 | captcha.SetSiteKey("6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-");
185 | captcha.SetUrl("https://mysite.com/page/with/recaptcha");
186 | captcha.SetVersion("v3");
187 | captcha.SetEnterprise(false);
188 | captcha.SetDomain("google.com");
189 | captcha.SetAction("verify");
190 | captcha.SetScore(0.3);
191 | captcha.SetProxy("HTTPS", "login:password@IP_address:PORT");
192 | ```
193 |
194 | ### FunCaptcha
195 |
196 | [API method description.](https://2captcha.com/2captcha-api#solving_funcaptcha_new)
197 |
198 | FunCaptcha (Arkoselabs) solving method. Returns a token.
199 |
200 | ```csharp
201 | FunCaptcha captcha = new FunCaptcha();
202 | captcha.SetSiteKey("69A21A01-CC7B-B9C6-0F9A-E7FA06677FFC");
203 | captcha.SetUrl("https://mysite.com/page/with/funcaptcha");
204 | captcha.SetSUrl("https://client-api.arkoselabs.com");
205 | captcha.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36");
206 | captcha.SetData("anyKey", "anyValue");
207 | captcha.SetProxy("HTTPS", "login:password@IP_address:PORT");
208 | ```
209 |
210 | ### GeeTest
211 |
212 | [API method description.](https://2captcha.com/2captcha-api#solving_geetest)
213 |
214 | Method to solve GeeTest puzzle captcha. Returns a set of tokens as JSON.
215 |
216 | ```csharp
217 | GeeTest captcha = new GeeTest();
218 | captcha.SetGt("f2ae6cadcf7886856696502e1d55e00c");
219 | captcha.SetApiServer("api-na.geetest.com");
220 | captcha.SetChallenge("12345678abc90123d45678ef90123a456b");
221 | captcha.SetUrl("https://mysite.com/captcha.html");
222 | captcha.SetProxy("HTTPS", "login:password@IP_address:PORT");
223 | ```
224 |
225 | ### GeeTest v4
226 |
227 | [API method description.](https://2captcha.com/2captcha-api#geetest-v4)
228 |
229 | Method to solve GeeTest v4 puzzle captcha. Returns a set of tokens as JSON.
230 |
231 | ```csharp
232 | GeeTestV4 captcha = new GeeTestV4();
233 | captcha.SetCaptchaId("72bf15796d0b69c43867452fea615052");
234 | captcha.SetChallenge("12345678abc90123d45678ef90123a456b");
235 | captcha.SetUrl("https://mysite.com/captcha.html");
236 | ```
237 |
238 | ### KeyCaptcha
239 |
240 | [API method description.](https://2captcha.com/2captcha-api#solving_keycaptcha)
241 |
242 | Token-based method to solve KeyCaptcha.
243 |
244 | ```csharp
245 | KeyCaptcha captcha = new KeyCaptcha();
246 | captcha.SetUserId(10);
247 | captcha.SetSessionId("493e52c37c10c2bcdf4a00cbc9ccd1e8");
248 | captcha.SetWebServerSign("9006dc725760858e4c0715b835472f22");
249 | captcha.SetWebServerSign2("2ca3abe86d90c6142d5571db98af6714");
250 | captcha.SetUrl("https://www.keycaptcha.ru/demo-magnetic/");
251 | captcha.SetProxy("HTTPS", "login:password@IP_address:PORT");
252 | ```
253 |
254 | ### Capy
255 |
256 | [API method description.](https://2captcha.com/2captcha-api#solving_capy)
257 |
258 | Token-based method to bypass Capy puzzle captcha.
259 |
260 | ```csharp
261 | Capy captcha = new Capy();
262 | captcha.SetSiteKey("PUZZLE_Abc1dEFghIJKLM2no34P56q7rStu8v");
263 | captcha.SetUrl("https://www.mysite.com/captcha/");
264 | captcha.SetProxy("HTTPS", "login:password@IP_address:PORT");
265 | ```
266 |
267 | ### Grid
268 |
269 | [API method description.](https://2captcha.com/2captcha-api#grid)
270 |
271 | 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.
272 |
273 | ```csharp
274 | Grid captcha = new Grid();
275 | captcha.SetFile("path/to/captcha.jpg");
276 | captcha.SetRows(3);
277 | captcha.SetCols(3);
278 | captcha.SetPreviousId(0);
279 | captcha.SetCanSkip(false);
280 | captcha.SetLang("en");
281 | captcha.SetHintImg(new FileInfo("path/to/hint.jpg"));
282 | captcha.SetHintText("Select all images with an Orange");
283 | ```
284 |
285 | ### Canvas
286 |
287 | [API method description.](https://2captcha.com/2captcha-api#canvas)
288 |
289 | 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.
290 |
291 | ```csharp
292 | Canvas captcha = new Canvas();
293 | captcha.SetFile("path/to/captcha.jpg");
294 | captcha.SetPreviousId(0);
295 | captcha.SetCanSkip(false);
296 | captcha.SetLang("en");
297 | captcha.SetHintImg(new FileInfo("path/to/hint.jpg"));
298 | captcha.SetHintText("Draw around apple");
299 | ```
300 |
301 | ### ClickCaptcha
302 |
303 | [API method description.](https://2captcha.com/2captcha-api#coordinates)
304 |
305 | ClickCaptcha (Coordinates) method returns coordinates of points on captcha image. Can be used if you need to click on particular points on the image.
306 |
307 | ```csharp
308 | Coordinates captcha = new Coordinates();
309 | captcha.SetFile("path/to/captcha.jpg");
310 | captcha.SetLang("en");
311 | captcha.SetHintImg(new FileInfo("path/to/hint.jpg"));
312 | captcha.SetHintText("Select all images with an Orange");
313 | ```
314 |
315 | ### Rotate
316 |
317 | [API method description.](https://2captcha.com/2captcha-api#solving_rotatecaptcha)
318 |
319 | This method can be used to solve a captcha that asks to rotate an object. Mostly used to bypass FunCaptcha. Returns the rotation angle.
320 |
321 | ```csharp
322 | Rotate captcha = new Rotate();
323 | captcha.SetFile("path/to/captcha.jpg");
324 | captcha.SetAngle(40);
325 | captcha.SetLang("en");
326 | captcha.SetHintImg(new FileInfo("path/to/hint.jpg"));
327 | captcha.SetHintText("Put the images in the correct way up");
328 | ```
329 |
330 | ### Audio Captcha
331 |
332 | [API method description.](https://2captcha.com/2captcha-api#audio)
333 |
334 | This method can be used to solve a audio captcha (mp3 formats only).
335 | You must provide the language as `lang = 'en'`. Supported languages are "en", "ru", "de", "el", "pt", "fr".
336 |
337 | ```csharp
338 | AudioCaptcha captcha = new AudioCaptcha();
339 | byte[] bytes = File.ReadAllBytes("../../resources/audio-en.mp3");
340 | string base64EncodedImage = Convert.ToBase64String(bytes);
341 | captcha.SetBase64(base64EncodedImage);
342 | ```
343 |
344 | ### Yandex
345 |
346 | Use this method to solve Yandex and obtain a token to bypass the protection.
347 |
348 | ```csharp
349 | Yandex captcha = new Yandex();
350 | captcha.SetSiteKey("Y5Lh0tiycconMJGsFd3EbbuNKSp1yaZESUOIHfeV");
351 | captcha.SetUrl("https://rutube.ru");
352 | ```
353 |
354 | ### Lemin Cropped Captcha
355 |
356 | [API method description.](https://2captcha.com/2captcha-api#lemin)
357 |
358 | Use this method to solve Lemin and obtain a token to bypass the protection.
359 |
360 | ```csharp
361 | Lemin captcha = new Lemin();
362 | captcha.SetCaptchaId("CROPPED_d3d4d56_73ca4008925b4f83a8bed59c2dd0df6d");
363 | captcha.SetApiServer("api.leminnow.com");
364 | captcha.SetUrl("http://sat2.aksigorta.com.tr");
365 | ```
366 |
367 | ### Cloudflare Turnstile
368 |
369 | [API method description.](https://2captcha.com/2captcha-api#turnstile)
370 |
371 | Use this method to solve Cloudflare Turnstile and obtain a token to bypass the protection.
372 |
373 | ```csharp
374 | Turnstile captcha = new Turnstile();
375 | captcha.SetSiteKey("0x4AAAAAAAChNiVJM_WtShFf");
376 | captcha.SetUrl("https://ace.fusionist.io");
377 | captcha.SetData("foo");
378 | captcha.SetPageData("bar");
379 | captcha.SetAction("baz");
380 | ```
381 |
382 | ### Amazon WAF
383 |
384 | [API method description.](https://2captcha.com/2captcha-api#amazon-waf)
385 |
386 | 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.
387 |
388 | ```csharp
389 | AmazonWaf captcha = new AmazonWaf();
390 | captcha.SetSiteKey("AQIDAHjcYu/GjX+QlghicBgQ/7bFaQZ+m5FKCMDnO+vTbNg96AF5H1K/siwSLK7RfstKtN5bAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglg");
391 | captcha.SetUrl("https://non-existent-example.execute-api.us-east-1.amazonaws.com");
392 | captcha.SetContext("test_iv");
393 | captcha.SetIV("test_context");
394 | ```
395 |
396 | ### Friendly Captcha
397 |
398 | [API method description.](https://2captcha.com/2captcha-api#friendly-captcha)
399 |
400 | Use this method to solve Friendly Captcha. Returns a token to bypass the captcha.
401 |
402 | > [!IMPORTANT]
403 | > To successfully use the received token, the captcha widget must not be loaded on the page. To do this, you need to abort request to `/friendlycaptcha/...module.min.js` on the page. When the captcha widget is already loaded on the page, there is a high probability that the received token will not work.
404 |
405 | ```csharp
406 | FriendlyCaptcha captcha = new FriendlyCaptcha();
407 | captcha.SetSiteKey("2FZFEVS1FZCGQ9");
408 | captcha.SetUrl("https://example.com");
409 | ```
410 |
411 | ### MTCaptcha
412 |
413 | [API method description.](https://2captcha.com/2captcha-api#mtcaptcha)
414 |
415 | Use this method to solve MTCaptcha. Returns a token to bypass the captcha.
416 |
417 | ```csharp
418 | MTCaptcha captcha = new MTCaptcha();
419 | captcha.SetSiteKey("MTPublic-KzqLY1cKH");
420 | captcha.SetPageUrl("https://2captcha.com/demo/mtcaptcha");
421 | ```
422 |
423 | ### Cutcaptcha
424 |
425 | [API method description.](https://2captcha.com/2captcha-api#cutcaptcha)
426 |
427 | Use this method to solve Cutcaptcha. Returns a token to bypass the captcha.
428 |
429 | ```csharp
430 | Cutcaptcha captcha = new Cutcaptcha();
431 | captcha.SetMiseryKey("a1488b66da00bf332a1488993a5443c79047e752");
432 | captcha.SetPageUrl("https://example.cc/foo/bar.html");
433 | captcha.SetApiKey("SAb83IIB");
434 | ```
435 |
436 | ### CyberSiARA
437 |
438 | [API method description.](https://2captcha.com/2captcha-api#cybersiara)
439 |
440 | Use this method to solve CyberSiARA. Returns a token to bypass the captcha.
441 |
442 | ```csharp
443 | CyberSiARA cyberSiARA = new CyberSiARA();
444 | cyberSiARA.SetMasterUrlId("tpjOCKjjpdzv3d8Ub2E9COEWKt1vl1Mv");
445 | cyberSiARA.SetPageUrl("https://demo.mycybersiara.com/");
446 | cyberSiARA.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36");
447 | ```
448 |
449 | ### DataDome
450 |
451 | [API method description.](https://2captcha.com/2captcha-api#datadome)
452 |
453 | Use this method to solve DataDome captcha.
454 |
455 | > [!IMPORTANT]
456 | > To solve the DataDome captcha, you must use a proxy. It is recommended to use [residential proxies].
457 |
458 | ```csharp
459 | DataDome dataDome = new DataDome();
460 | dataDome.SetCapthaUrl("https://geo.captcha-delivery.com/captcha/?initialCid=AHrlqAAA...P~XFrBVptk&t=fe&referer=https%3A%2F%2Fhexample.com&s=45239&e=c538be..c510a00ea");
461 | dataDome.SetPageUrl("https://example.com/");
462 | dataDome.SetProxy("http", "username:password@1.2.3.4:5678");
463 | dataDome.SetUserAgent("Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.3");
464 | ```
465 |
466 | ### atbCAPTCHA
467 |
468 | [API method description.](https://2captcha.com/2captcha-api#atb-captcha)
469 |
470 | Use this method to solve atbCAPTCHA. Returns a token to bypass the captcha.
471 |
472 | ```csharp
473 | AtbCAPTCHA atbCAPTCHA = new AtbCAPTCHA();
474 | atbCAPTCHA.SetAppId("af23e041b22d000a11e22a230fa8991c");
475 | atbCAPTCHA.SetApiServer("https://cap.aisecurius.com");
476 | atbCAPTCHA.SetPageUrl("https://www.example.com/");
477 | ```
478 |
479 | ### Tencent
480 |
481 | [API method description.](https://2captcha.com/2captcha-api#tencent)
482 |
483 | Use this method to solve Tencent captcha. Returns a token to bypass the captcha.
484 |
485 | ```csharp
486 | Tencent tencent = new Tencent();
487 | tencent.SetAppId("190014885");
488 | tencent.SetPageUrl("https://www.example.com/");
489 | ```
490 |
491 |
492 | ## Other methods
493 |
494 | ### send / getResult
495 | These methods can be used for manual captcha submission and answer polling.
496 |
497 | ```csharp
498 | string captchaId = await solver.Send(captcha);
499 |
500 | Task.sleep(20 * 1000);
501 |
502 | string code = await solver.GetResult(captchaId);
503 | ```
504 | ### balance
505 |
506 | [API method description.](https://2captcha.com/2captcha-api#additional-methods)
507 |
508 | Use this method to get your account's balance
509 |
510 | ```csharp
511 | double balance = await solver.Balance();
512 | ```
513 | ### report
514 |
515 | [API method description.](https://2captcha.com/2captcha-api#complain)
516 |
517 | Use this method to report good or bad captcha answer.
518 |
519 | ```csharp
520 | await solver.Report(captcha.Id, true); // captcha solved correctly
521 | await solver.Report(captcha.Id, false); // captcha solved incorrectly
522 | ```
523 | ## Proxies
524 |
525 | You can pass your proxy as an additional argument for methods: recaptcha, funcaptcha, geetest, geetest v4, keycaptcha, capy puzzle, lemin, cloudflare turnstile, amazon waf, friendly captcha, mtcaptcha, cutcaptcha, cybersiara, datadome, atbcaptcha, tencent and etc. The proxy will be forwarded to the API to solve the captcha.
526 |
527 | We have our own proxies that we can offer you. [Buy residential proxies] for avoid restrictions and blocks. [Quick start].
528 |
529 | ```csharp
530 | captcha.SetProxy("HTTPS", "login:password@IP_address:PORT");
531 | ```
532 |
533 |
534 | ## Error handling
535 | If case of an error captcha solver throws an exception. It's important to properly handle these cases. We recommend to use `try catch` to handle exceptions.
536 | The list of all errors can be found in the [API documentation](https://2captcha.com/2captcha-api#list-of-inphp-errors).
537 |
538 | ```csharp
539 | try
540 | {
541 | await solver.Solve(captcha);
542 | }
543 | catch (ValidationException e)
544 | {
545 | // invalid parameters passed
546 | }
547 | catch (NetworkException e)
548 | {
549 | // network error occurred
550 | }
551 | catch (ApiException e)
552 | {
553 | // api respond with error
554 | }
555 | catch (TimeoutException e)
556 | {
557 | // captcha is not solved so far
558 | }
559 | ```
560 |
561 | ## Get in touch
562 |
563 |
564 |
565 |
566 | ## Join the team 👪
567 |
568 | There are many ways to contribute, of which development is only one! Find your next job. Open positions: AI experts, scrapers, developers, technical support, and much more! 😍
569 |
570 |
571 |
572 | # License
573 |
574 | The code in this repository is licensed under the MIT License. See the [LICENSE](./LICENSE) file for more details.
575 |
576 | ### Graphics and Trademarks
577 |
578 | The graphics and trademarks included in this repository are not covered by the MIT License. Please contact support for permissions regarding the use of these materials.
579 |
580 |
581 |
582 | [nuget]: https://www.nuget.org/packages/2captcha-csharp/
583 | [2Captcha]: https://2captcha.com/
584 | [2captcha software catalog]: https://2captcha.com/software
585 | [Pingback settings]: https://2captcha.com/setting/pingback
586 | [Post options]: https://2captcha.com/2captcha-api#normal_post
587 | [list of supported languages]: https://2captcha.com/2captcha-api#language
588 | [Examples directory]: /TwoCaptcha.Examples
589 | [residential proxies]: https://2captcha.com/proxy/residential-proxies
590 | [Buy residential proxies]: https://2captcha.com/proxy/residential-proxies
591 | [Quick start]: https://2captcha.com/proxy?openAddTrafficModal=true
592 |
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/AmazonWafExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class AmazonWafExample
8 | {
9 | public AmazonWafExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | AmazonWaf captcha = new AmazonWaf();
14 | captcha.SetSiteKey("AQIDAHjcYu/GjX+QlghicBgQ/7bFaQZ+m5FKCMDnO+vTbNg96AF5H1K/siwSLK7RfstKtN5bAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglg");
15 | captcha.SetUrl("https://non-existent-example.execute-api.us-east-1.amazonaws.com");
16 | captcha.SetContext("test_iv");
17 | captcha.SetIV("test_context");
18 |
19 | try
20 | {
21 | solver.Solve(captcha).Wait();
22 | Console.WriteLine("Captcha solved: " + captcha.Code);
23 | }
24 | catch (AggregateException e)
25 | {
26 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
27 | }
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/AmazonWafOptionsExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class AmazonWafOptionsExample
8 | {
9 | public AmazonWafOptionsExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | AmazonWaf captcha = new AmazonWaf();
14 | captcha.SetSiteKey("AQIDAHjcYu/GjX+QlghicBgQ/7bFaQZ+m5FKCMDnO+vTbNg96AF5H1K/siwSLK7RfstKtN5bAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglg");
15 | captcha.SetUrl("https://non-existent-example.execute-api.us-east-1.amazonaws.com");
16 | captcha.SetContext("test_iv");
17 | captcha.SetIV("test_context");
18 | captcha.SetProxy("HTTPS", "login:password@IP_address:PORT");
19 |
20 | try
21 | {
22 | solver.Solve(captcha).Wait();
23 | Console.WriteLine("Captcha solved: " + captcha.Code);
24 | }
25 | catch (AggregateException e)
26 | {
27 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
28 | }
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/AtbCAPTCHAExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class AtbCAPTCHAExample
8 | {
9 | public AtbCAPTCHAExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | AtbCAPTCHA atbCAPTCHA = new AtbCAPTCHA();
14 | atbCAPTCHA.SetAppId("af23e041b22d000a11e22a230fa8991c");
15 | atbCAPTCHA.SetApiServer("https://cap.aisecurius.com");
16 | atbCAPTCHA.SetPageUrl("https://www.example.com/");
17 |
18 | try
19 | {
20 | solver.Solve(atbCAPTCHA).Wait();
21 | Console.WriteLine("Captcha solved: " + atbCAPTCHA.Code);
22 | }
23 | catch (AggregateException e)
24 | {
25 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/AudioCaptchaExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Examples
7 | {
8 | public class AudioCaptchaExample
9 | {
10 | public AudioCaptchaExample(string apiKey)
11 | {
12 | TwoCaptcha solver = new TwoCaptcha(apiKey);
13 |
14 | byte[] bytes = File.ReadAllBytes("resources/audio-en.mp3");
15 | string base64EncodedImage = Convert.ToBase64String(bytes);
16 |
17 | AudioCaptcha captcha = new AudioCaptcha();
18 | captcha.SetBase64(base64EncodedImage);
19 |
20 | try
21 | {
22 | solver.Solve(captcha).Wait();
23 | Console.WriteLine("Captcha solved: " + captcha.Code);
24 | }
25 | catch (AggregateException e)
26 | {
27 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
28 | }
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/AudioCaptchaOpdionsExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Examples
7 | {
8 | public class AudioCaptchaOptionsExample
9 | {
10 | public AudioCaptchaOptionsExample(string apiKey)
11 | {
12 | TwoCaptcha solver = new TwoCaptcha(apiKey);
13 |
14 | byte[] bytes = File.ReadAllBytes("resources/audio-ru.mp3");
15 | string base64EncodedImage = Convert.ToBase64String(bytes);
16 |
17 | AudioCaptcha captcha = new AudioCaptcha();
18 | captcha.SetBase64(base64EncodedImage);
19 | captcha.SetLang("ru");
20 |
21 | try
22 | {
23 | solver.Solve(captcha).Wait();
24 | Console.WriteLine("Captcha solved: " + captcha.Code);
25 | }
26 | catch (AggregateException e)
27 | {
28 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
29 | }
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/CanvasBase64Example.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Examples
7 | {
8 | public class CanvasBase64Example
9 | {
10 | public CanvasBase64Example(string apiKey)
11 | {
12 | TwoCaptcha solver = new TwoCaptcha(apiKey);
13 |
14 | byte[] bytes = File.ReadAllBytes("resources/canvas.jpg");
15 | string base64EncodedImage = Convert.ToBase64String(bytes);
16 |
17 | Canvas captcha = new Canvas();
18 | captcha.SetBase64(base64EncodedImage);
19 | captcha.SetHintText("Draw around apple");
20 |
21 | try
22 | {
23 | solver.Solve(captcha).Wait();
24 | Console.WriteLine("Captcha solved: " + captcha.Code);
25 | }
26 | catch (AggregateException e)
27 | {
28 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
29 | }
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/CanvasExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class CanvasExample
8 | {
9 | public CanvasExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | Canvas captcha = new Canvas();
14 | captcha.SetFile("resources/canvas.jpg");
15 | captcha.SetHintText("Draw around apple");
16 |
17 | try
18 | {
19 | solver.Solve(captcha).Wait();
20 | Console.WriteLine("Captcha solved: " + captcha.Code);
21 | }
22 | catch (AggregateException e)
23 | {
24 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
25 | }
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/CanvasOptionsExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Examples
7 | {
8 | public class CanvasOptionsExample
9 | {
10 | public CanvasOptionsExample(string apiKey)
11 | {
12 | TwoCaptcha solver = new TwoCaptcha(apiKey);
13 |
14 | Canvas captcha = new Canvas();
15 | captcha.SetFile("resources/canvas.jpg");
16 | captcha.SetPreviousId(0);
17 | captcha.SetCanSkip(false);
18 | captcha.SetLang("en");
19 | captcha.SetHintImg(new FileInfo("resources/canvas_hint.jpg"));
20 | captcha.SetHintText("Draw around apple");
21 |
22 | try
23 | {
24 | solver.Solve(captcha).Wait();
25 | Console.WriteLine("Captcha solved: " + captcha.Code);
26 | }
27 | catch (AggregateException e)
28 | {
29 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
30 | }
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/CapyExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class CapyExample
8 | {
9 | public CapyExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | Capy captcha = new Capy();
14 | captcha.SetSiteKey("PUZZLE_Abc1dEFghIJKLM2no34P56q7rStu8v");
15 | captcha.SetUrl("https://www.mysite.com/captcha/");
16 | captcha.SetApiServer("https://jp.api.capy.me/");
17 |
18 | try
19 | {
20 | solver.Solve(captcha).Wait();
21 | Console.WriteLine("Captcha solved: " + captcha.Code);
22 | }
23 | catch (AggregateException e)
24 | {
25 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/CapyOptionsExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class CapyOptionsExample
8 | {
9 | public CapyOptionsExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | Capy captcha = new Capy();
14 | captcha.SetSiteKey("PUZZLE_Abc1dEFghIJKLM2no34P56q7rStu8v");
15 | captcha.SetUrl("https://www.mysite.com/captcha/");
16 | captcha.SetApiServer("https://jp.api.capy.me/");
17 | captcha.SetProxy("HTTPS", "login:password@IP_address:PORT");
18 |
19 | try
20 | {
21 | solver.Solve(captcha).Wait();
22 | Console.WriteLine("Captcha solved: " + captcha.Code);
23 | }
24 | catch (AggregateException e)
25 | {
26 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
27 | }
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/CoordinatesBase64Example.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Examples
7 | {
8 | public class CoordinatesBase64Example
9 | {
10 | public CoordinatesBase64Example(string apiKey)
11 | {
12 | TwoCaptcha solver = new TwoCaptcha(apiKey);
13 |
14 | byte[] bytes = File.ReadAllBytes("resources/grid.jpg");
15 | string base64EncodedImage = Convert.ToBase64String(bytes);
16 |
17 | Coordinates captcha = new Coordinates();
18 | captcha.SetBase64(base64EncodedImage);
19 |
20 | try
21 | {
22 | solver.Solve(captcha).Wait();
23 | Console.WriteLine("Captcha solved: " + captcha.Code);
24 | }
25 | catch (AggregateException e)
26 | {
27 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
28 | }
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/CoordinatesExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class CoordinatesExample
8 | {
9 | public CoordinatesExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | Coordinates captcha = new Coordinates("resources/grid.jpg");
14 |
15 | try
16 | {
17 | solver.Solve(captcha).Wait();
18 | Console.WriteLine("Captcha solved: " + captcha.Code);
19 | }
20 | catch (AggregateException e)
21 | {
22 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
23 | }
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/CoordinatesOptionsExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Examples
7 | {
8 | public class CoordinatesOptionsExample
9 | {
10 | public CoordinatesOptionsExample(string apiKey)
11 | {
12 | TwoCaptcha solver = new TwoCaptcha(apiKey);
13 |
14 | Coordinates captcha = new Coordinates();
15 | captcha.SetFile("resources/grid_2.jpg");
16 | captcha.SetLang("en");
17 | captcha.SetHintImg(new FileInfo("resources/grid_hint.jpg"));
18 | captcha.SetHintText("Select all images with an Orange");
19 |
20 | try
21 | {
22 | solver.Solve(captcha).Wait();
23 | Console.WriteLine("Captcha solved: " + captcha.Code);
24 | }
25 | catch (AggregateException e)
26 | {
27 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
28 | }
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/CutcaptchaExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class CutcaptchaExample
8 | {
9 | public CutcaptchaExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | Cutcaptcha cutcaptcha = new Cutcaptcha();
14 | cutcaptcha.SetMiseryKey("a1488b66da00bf332a1488993a5443c79047e752");
15 | cutcaptcha.SetPageUrl("https://example.cc/foo/bar.html");
16 | cutcaptcha.SetApiKey("SAb83IIB");
17 |
18 | try
19 | {
20 | solver.Solve(cutcaptcha).Wait();
21 | Console.WriteLine("Captcha solved: " + cutcaptcha.Code);
22 | }
23 | catch (AggregateException e)
24 | {
25 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/CyberSiARAExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class CyberSiARAExample
8 | {
9 | public CyberSiARAExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | CyberSiARA cyberSiARA = new CyberSiARA();
14 | cyberSiARA.SetMasterUrlId("tpjOCKjjpdzv3d8Ub2E9COEWKt1vl1Mv");
15 | cyberSiARA.SetPageUrl("https://demo.mycybersiara.com/");
16 | cyberSiARA.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36");
17 |
18 | try
19 | {
20 | solver.Solve(cyberSiARA).Wait();
21 | Console.WriteLine("Captcha solved: " + cyberSiARA.Code);
22 | }
23 | catch (AggregateException e)
24 | {
25 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/DataDomeExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class DataDomeExample
8 | {
9 | public DataDomeExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | DataDome dataDome = new DataDome();
14 | dataDome.SetCapthaUrl("https://geo.captcha-delivery.com/captcha/?initialCid=AHrlqAAA...P~XFrBVptk&t=fe&referer=https%3A%2F%2Fhexample.com&s=45239&e=c538be..c510a00ea");
15 | dataDome.SetPageUrl("https://example.com/");
16 | dataDome.SetProxy("http", "username:password@1.2.3.4:5678");
17 | dataDome.SetUserAgent("Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.3");
18 |
19 | try
20 | {
21 | solver.Solve(dataDome).Wait();
22 | Console.WriteLine("Captcha solved: " + dataDome.Code);
23 | }
24 | catch (AggregateException e)
25 | {
26 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
27 | }
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/FriendlyCaptchaExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class FriendlyCaptchaExample
8 | {
9 | public FriendlyCaptchaExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | FriendlyCaptcha captcha = new FriendlyCaptcha();
14 | captcha.SetSiteKey("2FZFEVS1FZCGQ9");
15 | captcha.SetUrl("https://example.com");
16 |
17 | try
18 | {
19 | solver.Solve(captcha).Wait();
20 | Console.WriteLine("Captcha solved: " + captcha.Code);
21 | }
22 | catch (AggregateException e)
23 | {
24 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
25 | }
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/FunCaptchaExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class FunCaptchaExample
8 |
9 | {
10 | public FunCaptchaExample(string apiKey)
11 | {
12 | TwoCaptcha solver = new TwoCaptcha(apiKey);
13 |
14 | FunCaptcha captcha = new FunCaptcha();
15 | captcha.SetSiteKey("69A21A01-CC7B-B9C6-0F9A-E7FA06677FFC");
16 | captcha.SetUrl("https://mysite.com/page/with/funcaptcha");
17 |
18 | try
19 | {
20 | solver.Solve(captcha).Wait();
21 | Console.WriteLine("Captcha solved: " + captcha.Code);
22 | }
23 | catch (AggregateException e)
24 | {
25 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/FunCaptchaOptionsExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class FunCaptchaOptionsExample
8 | {
9 | public FunCaptchaOptionsExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | FunCaptcha captcha = new FunCaptcha();
14 | captcha.SetSiteKey("69A21A01-CC7B-B9C6-0F9A-E7FA06677FFC");
15 | captcha.SetUrl("https://mysite.com/page/with/funcaptcha");
16 | captcha.SetSUrl("https://client-api.arkoselabs.com");
17 | captcha.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36");
18 | captcha.SetData("anyKey", "anyValue");
19 | captcha.SetProxy("HTTPS", "login:password@IP_address:PORT");
20 |
21 | try
22 | {
23 | solver.Solve(captcha).Wait();
24 | Console.WriteLine("Captcha solved: " + captcha.Code);
25 | }
26 | catch (AggregateException e)
27 | {
28 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
29 | }
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/GeeTestExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class GeeTestExample
8 | {
9 | public GeeTestExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | GeeTest captcha = new GeeTest();
14 | captcha.SetGt("f2ae6cadcf7886856696502e1d55e00c");
15 | captcha.SetApiServer("api.geetest.com");
16 | captcha.SetChallenge("12345678abc90123d45678ef90123a456b");
17 | captcha.SetUrl("https://2captcha.com/demo/geetest");
18 |
19 | try
20 | {
21 | solver.Solve(captcha).Wait();
22 | Console.WriteLine("Captcha solved: " + captcha.Code);
23 | }
24 | catch (AggregateException e)
25 | {
26 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
27 | }
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/GeeTestOptionsExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class GeeTestOptionsExample
8 | {
9 | public GeeTestOptionsExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | GeeTest captcha = new GeeTest();
14 | captcha.SetGt("f2ae6cadcf7886856696502e1d55e00c");
15 | captcha.SetApiServer("api.geetest.com");
16 | captcha.SetChallenge("12345678abc90123d45678ef90123a456b");
17 | captcha.SetUrl("https://2captcha.com/demo/geetest");
18 | captcha.SetProxy("HTTPS", "login:password@IP_address:PORT");
19 |
20 | try
21 | {
22 | solver.Solve(captcha).Wait();
23 | Console.WriteLine("Captcha solved: " + captcha.Code);
24 | }
25 | catch (AggregateException e)
26 | {
27 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
28 | }
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/GeeTestV4Example.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class GeeTestV4Example
8 | {
9 | public GeeTestV4Example(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | GeeTestV4 captcha = new GeeTestV4();
14 | captcha.SetCaptchaId("72bf15796d0b69c43867452fea615052");
15 | captcha.SetChallenge("12345678abc90123d45678ef90123a456b");
16 | captcha.SetUrl("https://2captcha.com/demo/geetest-v4");
17 |
18 | try
19 | {
20 | solver.Solve(captcha).Wait();
21 | Console.WriteLine("Captcha solved: " + captcha.Code);
22 | }
23 | catch (AggregateException e)
24 | {
25 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/GeeTestV4OptionsExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class GeeTestV4OptionsExample
8 | {
9 | public GeeTestV4OptionsExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | GeeTestV4 captcha = new GeeTestV4();
14 | captcha.SetCaptchaId("72bf15796d0b69c43867452fea615052");
15 | captcha.SetChallenge("12345678abc90123d45678ef90123a456b");
16 | captcha.SetUrl("https://2captcha.com/demo/geetest-v4");
17 | captcha.SetProxy("HTTPS", "login:password@IP_address:PORT");
18 |
19 | try
20 | {
21 | solver.Solve(captcha).Wait();
22 | Console.WriteLine("Captcha solved: " + captcha.Code);
23 | }
24 | catch (AggregateException e)
25 | {
26 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
27 | }
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/GridBase64Example.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Examples
7 | {
8 | public class GridBase64Example
9 | {
10 | public GridBase64Example(string apiKey)
11 | {
12 | TwoCaptcha solver = new TwoCaptcha(apiKey);
13 |
14 | byte[] bytes = File.ReadAllBytes("resources/grid.jpg");
15 | string base64EncodedImage = Convert.ToBase64String(bytes);
16 |
17 | Grid captcha = new Grid();
18 | captcha.SetBase64(base64EncodedImage);
19 | captcha.SetHintText("Select all images with an Orange");
20 |
21 | try
22 | {
23 | solver.Solve(captcha).Wait();
24 | Console.WriteLine("Captcha solved: " + captcha.Code);
25 | }
26 | catch (AggregateException e)
27 | {
28 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
29 | }
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/GridExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class GridExample
8 | {
9 | public GridExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | Grid captcha = new Grid("resources/grid.jpg");
14 | captcha.SetHintText("Select all images with an Orange");
15 |
16 | try
17 | {
18 | solver.Solve(captcha).Wait();
19 | Console.WriteLine("Captcha solved: " + captcha.Code);
20 | }
21 | catch (AggregateException e)
22 | {
23 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
24 | }
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/GridOptionsExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Examples
7 | {
8 | public class GridOptionsExample
9 | {
10 | public GridOptionsExample(string apiKey)
11 | {
12 | TwoCaptcha solver = new TwoCaptcha(apiKey);
13 |
14 | Grid captcha = new Grid();
15 | captcha.SetFile("resources/grid_2.jpg");
16 | captcha.SetRows(3);
17 | captcha.SetCols(3);
18 | captcha.SetPreviousId(0);
19 | captcha.SetCanSkip(false);
20 | captcha.SetLang("en");
21 | captcha.SetHintImg(new FileInfo("resources/grid_hint.jpg"));
22 | captcha.SetHintText("Select all images with an Orange");
23 |
24 | try
25 | {
26 | solver.Solve(captcha).Wait();
27 | Console.WriteLine("Captcha solved: " + captcha.Code);
28 | }
29 | catch (AggregateException e)
30 | {
31 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
32 | }
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/KeyCaptchaExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class KeyCaptchaExample
8 | {
9 | public KeyCaptchaExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | KeyCaptcha captcha = new KeyCaptcha();
14 | captcha.SetUserId(184015);
15 | captcha.SetSessionId("9ff29e0176e78eb7ba59314f92dbac1b");
16 | captcha.SetWebServerSign("964635241a3e5e76980f2572e5f63452");
17 | captcha.SetWebServerSign2("3ca802a38ffc5831fa293ac2819b1204");
18 | captcha.SetUrl("https://2captcha.com/demo/keycaptcha");
19 |
20 | try
21 | {
22 | solver.Solve(captcha).Wait();
23 | Console.WriteLine("Captcha solved: " + captcha.Code);
24 | }
25 | catch (AggregateException e)
26 | {
27 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
28 | }
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/KeyCaptchaOptionsExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class KeyCaptchaOptionsExample
8 | {
9 | public KeyCaptchaOptionsExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | KeyCaptcha captcha = new KeyCaptcha();
14 | captcha.SetUserId(184015);
15 | captcha.SetSessionId("9ff29e0176e78eb7ba59314f92dbac1b");
16 | captcha.SetWebServerSign("964635241a3e5e76980f2572e5f63452");
17 | captcha.SetWebServerSign2("3ca802a38ffc5831fa293ac2819b1204");
18 | captcha.SetUrl("https://2captcha.com/demo/keycaptcha");
19 | captcha.SetProxy("HTTPS", "login:password@IP_address:PORT");
20 |
21 | try
22 | {
23 | solver.Solve(captcha).Wait();
24 | Console.WriteLine("Captcha solved: " + captcha.Code);
25 | }
26 | catch (AggregateException e)
27 | {
28 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
29 | }
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/LeminExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class LeminExample
8 | {
9 | public LeminExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | Lemin captcha = new Lemin();
14 | captcha.SetCaptchaId("CROPPED_3dfdd5c_d1872b526b794d83ba3b365eb15a200b");
15 | captcha.SetApiServer("api.leminnow.com");
16 | captcha.SetUrl("https://2captcha.com/demo/lemin");
17 |
18 | try
19 | {
20 | solver.Solve(captcha).Wait();
21 | Console.WriteLine("Captcha solved: " + captcha.Code);
22 | }
23 | catch (AggregateException e)
24 | {
25 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/LeminOptionsExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class LeminOptionsExample
8 | {
9 | public LeminOptionsExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | Lemin captcha = new Lemin();
14 | captcha.SetCaptchaId("CROPPED_3dfdd5c_d1872b526b794d83ba3b365eb15a200b");
15 | captcha.SetApiServer("api.leminnow.com");
16 | captcha.SetUrl("https://2captcha.com/demo/lemin");
17 | captcha.SetProxy("HTTPS", "login:password@IP_address:PORT");
18 |
19 | try
20 | {
21 | solver.Solve(captcha).Wait();
22 | Console.WriteLine("Captcha solved: " + captcha.Code);
23 | }
24 | catch (AggregateException e)
25 | {
26 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
27 | }
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/MTCaptchaExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class MTCaptchaExample
8 | {
9 | public MTCaptchaExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | MTCaptcha mtCaptcha = new MTCaptcha();
14 | mtCaptcha.SetSiteKey("MTPublic-KzqLY1cKH");
15 | mtCaptcha.SetPageUrl("https://2captcha.com/demo/mtcaptcha");
16 |
17 | try
18 | {
19 | solver.Solve(mtCaptcha).Wait();
20 | Console.WriteLine("Captcha solved: " + mtCaptcha.Code);
21 | }
22 | catch (AggregateException e)
23 | {
24 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
25 | }
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/NormalBase64Example.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Examples
7 | {
8 | public class NormalBase64Example
9 | {
10 |
11 | public NormalBase64Example(string apiKey)
12 | {
13 | TwoCaptcha solver = new TwoCaptcha(apiKey);
14 |
15 | byte[] bytes = File.ReadAllBytes("resources/normal.jpg");
16 | string base64EncodedImage = Convert.ToBase64String(bytes);
17 |
18 | Normal captcha = new Normal();
19 | captcha.SetBase64(base64EncodedImage);
20 |
21 | try
22 | {
23 | solver.Solve(captcha).Wait();
24 | Console.WriteLine("Captcha solved: " + captcha.Code);
25 | }
26 | catch (AggregateException e)
27 | {
28 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
29 | }
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/NormalExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class NormalExample
8 | {
9 | public NormalExample(string apiKey)
10 | {
11 | var solver = new TwoCaptcha(apiKey);
12 |
13 | Normal captcha = new Normal("resources/normal.jpg");
14 |
15 | try
16 | {
17 | solver.Solve(captcha).Wait();
18 | Console.WriteLine("Captcha solved: " + captcha.Code);
19 | }
20 | catch (AggregateException e)
21 | {
22 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
23 | }
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/NormalOptionsExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Examples
7 | {
8 | public class NormalOptionsExample
9 | {
10 | public NormalOptionsExample(string apiKey)
11 | {
12 | TwoCaptcha solver = new TwoCaptcha(apiKey);
13 |
14 | Normal captcha = new Normal();
15 | captcha.SetFile("resources/normal_2.jpg");
16 | captcha.SetNumeric(4);
17 | captcha.SetMinLen(4);
18 | captcha.SetMaxLen(20);
19 | captcha.SetPhrase(true);
20 | captcha.SetCaseSensitive(true);
21 | captcha.SetCalc(false);
22 | captcha.SetLang("en");
23 | captcha.SetHintImg(new FileInfo("resources/normal_hint.jpg"));
24 | captcha.SetHintText("Type text");
25 |
26 | try
27 | {
28 | solver.Solve(captcha).Wait();
29 | Console.WriteLine("Captcha solved: " + captcha.Code);
30 | }
31 | catch (AggregateException e)
32 | {
33 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
34 | }
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/README.md:
--------------------------------------------------------------------------------
1 | # Examples
2 |
3 | In the `TwoCaptcha.Examples` directory, you will find files with examples of solving supported captcha types.
4 | For the successful execution of some examples, it is necessary to update the parameters of the captcha being sent.
5 |
6 | To run an example, follow these steps:
7 |
8 | 1. Open and build the project `Two Captcha.Examples.csproj`
9 | 2. Navigate to the output directory.
10 | 3. Run the `TwoCaptcha.Examples.exe` file by passing two arguments. The first argument is the class name, which exactly matches the class name from the example. The second argument is the `apikey`.
11 |
12 | Example command to run the `TencentExample.cs` file:
13 |
14 | ```cmd
15 | TwoCaptcha.Examples.exe TencentExample 12345678abcd9012345678abcd901234
16 | ```
17 |
18 | You can find the full list of supported examples in the [Run.cs](./Run.cs) file.
19 |
20 |
21 |
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/ReCaptchaV2Example.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class ReCaptchaV2Example
8 | {
9 | public ReCaptchaV2Example(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | ReCaptcha captcha = new ReCaptcha();
14 | captcha.SetSiteKey("6LfD3PIbAAAAAJs_eEHvoOl75_83eXSqpPSRFJ_u");
15 | captcha.SetUrl("https://2captcha.com/demo/recaptcha-v2");
16 |
17 | try
18 | {
19 | solver.Solve(captcha).Wait();
20 | Console.WriteLine("Captcha solved: " + captcha.Code);
21 | }
22 | catch (AggregateException e)
23 | {
24 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
25 | }
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/ReCaptchaV2OptionsExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class ReCaptchaV2OptionsExample
8 | {
9 | public ReCaptchaV2OptionsExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | ReCaptcha captcha = new ReCaptcha();
14 | captcha.SetSiteKey("6LfD3PIbAAAAAJs_eEHvoOl75_83eXSqpPSRFJ_u");
15 | captcha.SetUrl("https://2captcha.com/demo/recaptcha-v2");
16 | captcha.SetInvisible(true);
17 | captcha.SetDomain("google.com");
18 | captcha.SetAction("verify");
19 | captcha.SetEnterprise(false);
20 | captcha.SetProxy("HTTPS", "login:password@IP_address:PORT");
21 |
22 | try
23 | {
24 | solver.Solve(captcha).Wait();
25 | Console.WriteLine("Captcha solved: " + captcha.Code);
26 | }
27 | catch (AggregateException e)
28 | {
29 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
30 | }
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/ReCaptchaV3Example.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class ReCaptchaV3Example
8 | {
9 | public ReCaptchaV3Example(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | ReCaptcha captcha = new ReCaptcha();
14 | captcha.SetSiteKey("6LfB5_IbAAAAAMCtsjEHEHKqcB9iQocwwxTiihJu");
15 | captcha.SetUrl("https://2captcha.com/demo/recaptcha-v3");
16 | captcha.SetVersion("v3");
17 |
18 | try
19 | {
20 | solver.Solve(captcha).Wait();
21 | Console.WriteLine("Captcha solved: " + captcha.Code);
22 | }
23 | catch (AggregateException e)
24 | {
25 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/ReCaptchaV3OptionsExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class ReCaptchaV3OptionsExample
8 | {
9 | public ReCaptchaV3OptionsExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | ReCaptcha captcha = new ReCaptcha();
14 | captcha.SetSiteKey("6LfB5_IbAAAAAMCtsjEHEHKqcB9iQocwwxTiihJu");
15 | captcha.SetUrl("https://2captcha.com/demo/recaptcha-v3");
16 | captcha.SetVersion("v3");
17 | captcha.SetDomain("google.com");
18 | captcha.SetAction("demo_action");
19 | captcha.SetScore(0.3);
20 | captcha.SetEnterprise(false);
21 | captcha.SetProxy("HTTPS", "login:password@IP_address:PORT");
22 |
23 | try
24 | {
25 | solver.Solve(captcha).Wait();
26 | Console.WriteLine("Captcha solved: " + captcha.Code);
27 | }
28 | catch (AggregateException e)
29 | {
30 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
31 | }
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/RotateExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Examples
7 | {
8 | public class RotateExample
9 | {
10 | public RotateExample(string apiKey)
11 | {
12 | TwoCaptcha solver = new TwoCaptcha(apiKey);
13 |
14 | byte[] bytes = File.ReadAllBytes("resources/rotate.jpg");
15 | string base64EncodedImage = Convert.ToBase64String(bytes);
16 | Console.WriteLine("base64EncodedImage: " + base64EncodedImage);
17 |
18 |
19 | Rotate captcha = new Rotate();
20 | captcha.SetBase64(base64EncodedImage);
21 |
22 | try
23 | {
24 | solver.Solve(captcha).Wait();
25 | Console.WriteLine("Captcha solved: " + captcha.Code);
26 | }
27 | catch (AggregateException e)
28 | {
29 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
30 | }
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/RotateOptionsExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Examples
7 | {
8 | public class RotateOptionsExample
9 | {
10 | public RotateOptionsExample(string apiKey)
11 | {
12 | TwoCaptcha solver = new TwoCaptcha(apiKey);
13 |
14 | byte[] bytes = File.ReadAllBytes("resources/rotate.jpg");
15 | string base64EncodedImage = Convert.ToBase64String(bytes);
16 |
17 |
18 | Rotate captcha = new Rotate();
19 | captcha.SetBase64(base64EncodedImage);
20 | captcha.SetAngle(40);
21 | captcha.SetLang("en");
22 | captcha.SetHintImg(new FileInfo("resources/rotate_hint.jpg"));
23 | captcha.SetHintText("Put the images in the correct way up");
24 |
25 | try
26 | {
27 | solver.Solve(captcha).Wait();
28 | Console.WriteLine("Captcha solved: " + captcha.Code);
29 | }
30 | catch (AggregateException e)
31 | {
32 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
33 | }
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/Run.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.ConstrainedExecution;
3 | using TwoCaptcha.Examples;
4 |
5 | public class Run
6 | {
7 | public static void Main(string[] args)
8 | {
9 | string classToRun = args[0];
10 | string apiKey = args[1];
11 |
12 | switch (classToRun)
13 | {
14 | case "TextExample":
15 | TextExample textExample = new TextExample(apiKey);
16 | break;
17 |
18 | case "TextOptionsExample":
19 | TextOptionsExample TextOptionsExample = new TextOptionsExample(apiKey);
20 | break;
21 |
22 | case "MTCaptchaExample":
23 | MTCaptchaExample mtCaptchaExample = new MTCaptchaExample(apiKey);
24 | break;
25 |
26 | case "CutcaptchaExample":
27 | CutcaptchaExample cutcaptchaExample = new CutcaptchaExample(apiKey);
28 | break;
29 |
30 | case "CyberSiARAExample":
31 | CyberSiARAExample cyberSiARAExample = new CyberSiARAExample(apiKey);
32 | break;
33 |
34 | case "DataDomeExample":
35 | DataDomeExample dataDomeExample = new DataDomeExample(apiKey);
36 | break;
37 |
38 | case "AtbCAPTCHAExample":
39 | AtbCAPTCHAExample atbCAPTCHAExample = new AtbCAPTCHAExample(apiKey);
40 | break;
41 |
42 | case "TencentExample":
43 | TencentExample tencentExample = new TencentExample(apiKey);
44 | break;
45 |
46 | case "AmazonWafExample":
47 | AmazonWafExample amazonWafExample = new AmazonWafExample(apiKey);
48 | break;
49 |
50 | case "AmazonWafOptionsExample":
51 | AmazonWafOptionsExample amazonWafOptionsExample = new AmazonWafOptionsExample(apiKey);
52 | break;
53 |
54 | case "AudioCaptchaExample":
55 | AudioCaptchaExample AudioCaptchaExample = new AudioCaptchaExample(apiKey);
56 | break;
57 |
58 | case "AudioCaptchaOptionsExample":
59 | AudioCaptchaOptionsExample AudioCaptchaOptionsExample = new AudioCaptchaOptionsExample(apiKey);
60 | break;
61 |
62 | case "CanvasExample":
63 | CanvasExample CanvasExample = new CanvasExample(apiKey);
64 | break;
65 |
66 | case "CanvasBase64Example":
67 | CanvasBase64Example CanvasBase64Example = new CanvasBase64Example(apiKey);
68 | break;
69 |
70 | case "CanvasOptionsExample":
71 | CanvasOptionsExample CanvasOptionsExample = new CanvasOptionsExample(apiKey);
72 | break;
73 |
74 | case "CapyExample":
75 | CapyExample CapyExample = new CapyExample(apiKey);
76 | break;
77 |
78 | case "CapyOptionsExample":
79 | CapyOptionsExample CapyOptionsExample = new CapyOptionsExample(apiKey);
80 | break;
81 |
82 | case "CoordinatesExample":
83 | CoordinatesExample CoordinatesExample = new CoordinatesExample(apiKey);
84 | break;
85 |
86 | case "CoordinatesBase64Example":
87 | CoordinatesBase64Example CoordinatesBase64Example = new CoordinatesBase64Example(apiKey);
88 | break;
89 |
90 | case "CoordinatesOptionsExample":
91 | CoordinatesOptionsExample CoordinatesOptionsExample = new CoordinatesOptionsExample(apiKey);
92 | break;
93 |
94 | case "FriendlyCaptchaExample":
95 | FriendlyCaptchaExample FriendlyCaptchaExample = new FriendlyCaptchaExample(apiKey);
96 | break;
97 |
98 | case "FunCaptchaExample":
99 | FunCaptchaExample FunCaptchaExample = new FunCaptchaExample(apiKey);
100 | break;
101 |
102 | case "FunCaptchaOptionsExample":
103 | FunCaptchaOptionsExample FunCaptchaOptionsExample = new FunCaptchaOptionsExample(apiKey);
104 | break;
105 |
106 | case "GeeTestExample":
107 | GeeTestExample GeeTestExample = new GeeTestExample(apiKey);
108 | break;
109 |
110 | case "GeeTestOptionsExample":
111 | GeeTestOptionsExample GeeTestOptionsExample = new GeeTestOptionsExample(apiKey);
112 | break;
113 |
114 | case "GeeTestV4Example":
115 | GeeTestV4Example GeeTestV4Example = new GeeTestV4Example(apiKey);
116 | break;
117 |
118 | case "GeeTestV4OptionsExample":
119 | GeeTestV4OptionsExample GeeTestV4OptionsExample = new GeeTestV4OptionsExample(apiKey);
120 | break;
121 |
122 | case "GridExample":
123 | GridExample GridExample = new GridExample(apiKey);
124 | break;
125 |
126 | case "GridBase64Example":
127 | GridBase64Example GridBase64Example = new GridBase64Example(apiKey);
128 | break;
129 |
130 | case "GridOptionsExample":
131 | GridOptionsExample GridOptionsExample = new GridOptionsExample(apiKey);
132 | break;
133 |
134 | case "KeyCaptchaExample":
135 | KeyCaptchaExample KeyCaptchaExample = new KeyCaptchaExample(apiKey);
136 | break;
137 |
138 | case "KeyCaptchaOptionsExample":
139 | KeyCaptchaOptionsExample KeyCaptchaOptionsExample = new KeyCaptchaOptionsExample(apiKey);
140 | break;
141 |
142 | case "LeminExample":
143 | LeminExample LeminExample = new LeminExample(apiKey);
144 | break;
145 |
146 | case "LeminOptionsExample":
147 | LeminOptionsExample LeminOptionsExample = new LeminOptionsExample(apiKey);
148 | break;
149 |
150 | case "NormalExample":
151 | NormalExample NormalExample = new NormalExample(apiKey);
152 | break;
153 |
154 | case "NormalBase64Example":
155 | NormalBase64Example NormalBase64Example = new NormalBase64Example(apiKey);
156 | break;
157 |
158 | case "NormalOptionsExample":
159 | NormalOptionsExample NormalOptionsExample = new NormalOptionsExample(apiKey);
160 | break;
161 |
162 | case "ReCaptchaV2Example":
163 | ReCaptchaV2Example ReCaptchaV2Example = new ReCaptchaV2Example(apiKey);
164 | break;
165 |
166 | case "ReCaptchaV2OptionsExample":
167 | ReCaptchaV2OptionsExample ReCaptchaV2OptionsExample = new ReCaptchaV2OptionsExample(apiKey);
168 | break;
169 |
170 | case "ReCaptchaV3Example":
171 | ReCaptchaV3Example ReCaptchaV3Example = new ReCaptchaV3Example(apiKey);
172 | break;
173 |
174 | case "ReCaptchaV3OptionsExample":
175 | ReCaptchaV3OptionsExample ReCaptchaV3OptionsExample = new ReCaptchaV3OptionsExample(apiKey);
176 | break;
177 |
178 | case "RotateExample":
179 | RotateExample RotateExample = new RotateExample(apiKey);
180 | break;
181 |
182 | case "RotateOptionsExample":
183 | RotateOptionsExample RotateOptionsExample = new RotateOptionsExample(apiKey);
184 | break;
185 |
186 | case "TurnstileExample":
187 | TurnstileExample TurnstileExample = new TurnstileExample(apiKey);
188 | break;
189 |
190 | case "TurnstileOptionsExample":
191 | TurnstileOptionsExample TurnstileOptionsExample = new TurnstileOptionsExample(apiKey);
192 | break;
193 |
194 | case "YandexExample":
195 | YandexExample YandexExample = new YandexExample(apiKey);
196 | break;
197 |
198 | case "YandexOptionsExample":
199 | YandexOptionsExample YandexOptionsExample = new YandexOptionsExample(apiKey);
200 | break;
201 | }
202 | }
203 | }
204 |
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/TencentExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class TencentExample
8 | {
9 | public TencentExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | Tencent tencent = new Tencent();
14 | tencent.SetAppId("190014885");
15 | tencent.SetPageUrl("https://www.example.com/");
16 |
17 | try
18 | {
19 | solver.Solve(tencent).Wait();
20 | Console.WriteLine("Captcha solved: " + tencent.Code);
21 | }
22 | catch (AggregateException e)
23 | {
24 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
25 | }
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/TextExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class TextExample
8 | {
9 | public TextExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | Text captcha = new Text("If tomorrow is Saturday, what day is today?");
14 |
15 | try
16 | {
17 | solver.Solve(captcha).Wait();
18 | Console.WriteLine("Captcha solved: " + captcha.Code);
19 | }
20 | catch (AggregateException e)
21 | {
22 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
23 | }
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/TextOptionsExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class TextOptionsExample
8 | {
9 | public TextOptionsExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | Text captcha = new Text();
14 | captcha.SetText("If tomorrow is Saturday, what day is today?");
15 | captcha.SetLang("en");
16 |
17 | try
18 | {
19 | solver.Solve(captcha).Wait();
20 | Console.WriteLine("Captcha solved: " + captcha.Code);
21 | }
22 | catch (AggregateException e)
23 | {
24 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
25 | }
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/TurnstileExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class TurnstileExample
8 | {
9 | public TurnstileExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | Turnstile captcha = new Turnstile();
14 | captcha.SetSiteKey("0x4AAAAAAAChNiVJM_WtShFf");
15 | captcha.SetUrl("https://ace.fusionist.io");
16 |
17 | try
18 | {
19 | solver.Solve(captcha).Wait();
20 | Console.WriteLine("Captcha solved: " + captcha.Code);
21 | }
22 | catch (AggregateException e)
23 | {
24 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
25 | }
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/TurnstileOptionsExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class TurnstileOptionsExample
8 | {
9 | public TurnstileOptionsExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | Turnstile captcha = new Turnstile();
14 | captcha.SetSiteKey("0x4AAAAAAAChNiVJM_WtShFf");
15 | captcha.SetUrl("https://ace.fusionist.io");
16 | captcha.SetProxy("HTTPS", "login:password@IP_address:PORT");
17 |
18 | try
19 | {
20 | solver.Solve(captcha).Wait();
21 | Console.WriteLine("Captcha solved: " + captcha.Code);
22 | }
23 | catch (AggregateException e)
24 | {
25 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/TwoCaptcha.Examples.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1;net5.0;net6.0;net7.0
5 | false
6 | Exe
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | PreserveNewest
16 |
17 |
18 |
19 |
20 |
21 | PreserveNewest
22 |
23 |
24 |
25 |
26 |
27 | PreserveNewest
28 |
29 |
30 |
31 |
32 |
33 | PreserveNewest
34 |
35 |
36 |
37 |
38 |
39 | PreserveNewest
40 |
41 |
42 |
43 |
44 |
45 | PreserveNewest
46 |
47 |
48 |
49 |
50 |
51 | PreserveNewest
52 |
53 |
54 |
55 |
56 |
57 | PreserveNewest
58 |
59 |
60 |
61 |
62 |
63 | PreserveNewest
64 |
65 |
66 |
67 |
68 |
69 | PreserveNewest
70 |
71 |
72 |
73 |
74 |
75 | PreserveNewest
76 |
77 |
78 |
79 |
80 |
81 | PreserveNewest
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/YandexExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class YandexExample
8 | {
9 | public YandexExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | Yandex captcha = new Yandex();
14 | captcha.SetSiteKey("Y5Lh0tiycconMJGsFd3EbbuNKSp1yaZESUOIHfeV");
15 | captcha.SetUrl("https://rutube.ru");
16 |
17 | try
18 | {
19 | solver.Solve(captcha).Wait();
20 | Console.WriteLine("Captcha solved: " + captcha.Code);
21 | }
22 | catch (AggregateException e)
23 | {
24 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
25 | }
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/YandexOptionsExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using TwoCaptcha.Captcha;
4 |
5 | namespace TwoCaptcha.Examples
6 | {
7 | public class YandexOptionsExample
8 | {
9 | public YandexOptionsExample(string apiKey)
10 | {
11 | TwoCaptcha solver = new TwoCaptcha(apiKey);
12 |
13 | Yandex captcha = new Yandex();
14 | captcha.SetSiteKey("Y5Lh0tiycconMJGsFd3EbbuNKSp1yaZESUOIHfeV");
15 | captcha.SetUrl("https://rutube.ru");
16 | captcha.SetProxy("HTTPS", "login:password@IP_address:PORT");
17 |
18 | try
19 | {
20 | solver.Solve(captcha).Wait();
21 | Console.WriteLine("Captcha solved: " + captcha.Code);
22 | }
23 | catch (AggregateException e)
24 | {
25 | Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/resources/audio-en.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Examples/resources/audio-en.mp3
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/resources/audio-ru.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Examples/resources/audio-ru.mp3
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/resources/canvas.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Examples/resources/canvas.jpg
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/resources/canvas_hint.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Examples/resources/canvas_hint.jpg
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/resources/grid.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Examples/resources/grid.jpg
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/resources/grid_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Examples/resources/grid_2.jpg
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/resources/grid_hint.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Examples/resources/grid_hint.jpg
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/resources/normal.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Examples/resources/normal.jpg
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/resources/normal_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Examples/resources/normal_2.jpg
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/resources/normal_hint.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Examples/resources/normal_hint.jpg
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/resources/rotate.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Examples/resources/rotate.jpg
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/resources/rotate_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Examples/resources/rotate_2.jpg
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/resources/rotate_3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Examples/resources/rotate_3.jpg
--------------------------------------------------------------------------------
/TwoCaptcha.Examples/resources/rotate_hint.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Examples/resources/rotate_hint.jpg
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/AbstractWrapperTestCase.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.IO;
3 | using System.Threading.Tasks;
4 | using Moq;
5 | using NUnit.Framework;
6 |
7 | namespace TwoCaptcha.Tests
8 | {
9 | public abstract class AbstractWrapperTestCase
10 | {
11 | protected async Task CheckIfCorrectParamsSendAndResultReturned(
12 | Captcha.Captcha captcha,
13 | Dictionary parameters
14 | )
15 | {
16 | var files = new Dictionary();
17 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters, files);
18 | }
19 |
20 | protected async Task CheckIfCorrectParamsSendAndResultReturned(
21 | Captcha.Captcha captcha,
22 | Dictionary parameters,
23 | Dictionary files
24 | )
25 | {
26 | string apiKey = "API_KEY";
27 | string captchaId = "123";
28 | string code = "2763";
29 |
30 | parameters["key"] = apiKey;
31 |
32 | var resParameters = new Dictionary();
33 | resParameters["action"] = "get";
34 | resParameters["id"] = captchaId;
35 | resParameters["key"] = apiKey;
36 |
37 |
38 | var apiClientMock = new Mock();
39 | apiClientMock
40 | .Setup(ac => ac.In(It.IsAny>(), It.IsAny>()))
41 | .Returns(Task.FromResult("OK|" + captchaId));
42 | apiClientMock
43 | .Setup(ac => ac.Res(resParameters))
44 | .Returns(Task.FromResult("OK|" + code));
45 |
46 | TwoCaptcha solver = new TwoCaptcha(apiKey);
47 | solver.PollingInterval = 1;
48 | solver.SetApiClient(apiClientMock.Object);
49 |
50 | await solver.Solve(captcha);
51 |
52 | apiClientMock.Verify(ac => ac.In(
53 | It.Is>(actual => ParametersAreSame(parameters, actual)),
54 | It.Is>(actual => FilesAreSame(files, actual))
55 | ));
56 |
57 | Assert.AreEqual(captchaId, captcha.Id);
58 | Assert.AreEqual(code, captcha.Code);
59 | }
60 |
61 | private bool ParametersAreSame(Dictionary expected, Dictionary actual)
62 | {
63 | if (expected.Count != actual.Count) return false;
64 |
65 | foreach (KeyValuePair entry in expected)
66 | {
67 | if (!actual.ContainsKey(entry.Key)) return false;
68 |
69 | if (!actual[entry.Key].Equals(entry.Value)) return false;
70 | }
71 |
72 | return true;
73 | }
74 |
75 | private bool FilesAreSame(Dictionary expected, Dictionary actual)
76 | {
77 | if (expected.Count != actual.Count) return false;
78 |
79 | foreach (KeyValuePair entry in expected)
80 | {
81 | if (!actual.ContainsKey(entry.Key)) return false;
82 |
83 | if (!actual[entry.Key].FullName.Equals(entry.Value.FullName)) return false;
84 | }
85 |
86 | return true;
87 | }
88 | }
89 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/AmazonWafTest.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using NUnit.Framework;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Tests
7 | {
8 | [TestFixture]
9 | public class AmazonWafTest : AbstractWrapperTestCase
10 | {
11 | [Test]
12 | public async Task TestAllOptions()
13 | {
14 | AmazonWaf captcha = new AmazonWaf();
15 | captcha.SetSiteKey("AQIDAHjcYu/GjX+QlghicBgQ/7bFaQZ+m5FKCMDnO+vTbNg96AF5H1K/siwSLK7RfstKtN5bAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglg");
16 | captcha.SetUrl("https://non-existent-example.execute-api.us-east-1.amazonaws.com");
17 | captcha.SetContext("test_iv");
18 | captcha.SetIV("test_context");
19 |
20 | var parameters = new Dictionary();
21 | parameters["method"] = "amazon_waf";
22 | parameters["sitekey"] = "AQIDAHjcYu/GjX+QlghicBgQ/7bFaQZ+m5FKCMDnO+vTbNg96AF5H1K/siwSLK7RfstKtN5bAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglg";
23 | parameters["pageurl"] = "https://non-existent-example.execute-api.us-east-1.amazonaws.com";
24 | parameters["context"] = "test_iv";
25 | parameters["iv"] = "test_context";
26 | parameters["soft_id"] = "4582";
27 |
28 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/AtbCAPTCHATest.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using NUnit.Framework;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Tests
7 | {
8 | [TestFixture]
9 | public class AtbCaptchaTest : AbstractWrapperTestCase
10 | {
11 | [Test]
12 | public async Task TestAllOptions()
13 | {
14 | AtbCAPTCHA atbCAPTCHA = new AtbCAPTCHA();
15 | atbCAPTCHA.SetAppId("af23e041b22d000a11e22a230fa8991c");
16 | atbCAPTCHA.SetApiServer("https://cap.aisecurius.com");
17 | atbCAPTCHA.SetPageUrl("https://www.example.com/");
18 |
19 | var parameters = new Dictionary();
20 | parameters["method"] = "atb_captcha";
21 | parameters["app_id"] = "af23e041b22d000a11e22a230fa8991c";
22 | parameters["api_server"] = "https://cap.aisecurius.com";
23 | parameters["pageurl"] = "https://www.example.com/";
24 | parameters["soft_id"] = "4582";
25 |
26 | await CheckIfCorrectParamsSendAndResultReturned(atbCAPTCHA, parameters);
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/AudioTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Threading.Tasks;
5 | using NUnit.Framework;
6 | using TwoCaptcha.Captcha;
7 |
8 | namespace TwoCaptcha.Tests
9 | {
10 | [TestFixture]
11 | public class AudioTest : AbstractWrapperTestCase
12 | {
13 |
14 | [Test]
15 | public async Task TestAllParameters()
16 | {
17 | byte[] bytes = File.ReadAllBytes("../../../resources/audio-en.mp3");
18 | string base64EncodedImage = Convert.ToBase64String(bytes);
19 |
20 |
21 | AudioCaptcha captcha = new AudioCaptcha();
22 | captcha.SetBase64(base64EncodedImage);
23 | captcha.SetLang("en");
24 |
25 |
26 | var parameters = new Dictionary();
27 | parameters["method"] = "audio";
28 | parameters["lang"] = "en";
29 | parameters["body"] = base64EncodedImage;
30 | parameters["soft_id"] = "4582";
31 |
32 |
33 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
34 | }
35 |
36 | }
37 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/CanvasTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Threading.Tasks;
5 | using NUnit.Framework;
6 | using TwoCaptcha.Captcha;
7 |
8 | namespace TwoCaptcha.Tests
9 | {
10 | [TestFixture]
11 | public class CanvasTest : AbstractWrapperTestCase
12 | {
13 | private string captchaImgPath = "../../../resources/canvas.jpg";
14 | private string hintImgPath = "../../../resources/canvas_hint.jpg";
15 | private string hintText = "Draw around apple";
16 |
17 | [Test]
18 | public async Task TestSingleFile()
19 | {
20 | FileInfo image = new FileInfo(captchaImgPath);
21 |
22 | Console.WriteLine(image.FullName);
23 |
24 | Canvas captcha = new Canvas();
25 | captcha.SetFile(image);
26 | captcha.SetHintText(hintText);
27 |
28 | var parameters = new Dictionary();
29 | parameters["method"] = "post";
30 | parameters["recaptcha"] = "1";
31 | parameters["canvas"] = "1";
32 | parameters["textinstructions"] = hintText;
33 | parameters["soft_id"] = "4582";
34 |
35 | var files = new Dictionary();
36 | files["file"] = image;
37 |
38 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters, files);
39 | }
40 |
41 | [Test]
42 | public async Task TestBase64()
43 | {
44 | Canvas captcha = new Canvas();
45 | captcha.SetBase64("...");
46 | captcha.SetHintText(hintText);
47 |
48 | var parameters = new Dictionary();
49 | parameters["method"] = "base64";
50 | parameters["recaptcha"] = "1";
51 | parameters["canvas"] = "1";
52 | parameters["body"] = "...";
53 | parameters["textinstructions"] = hintText;
54 | parameters["soft_id"] = "4582";
55 |
56 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
57 | }
58 |
59 | [Test]
60 | public async Task TestAllParameters()
61 | {
62 | FileInfo image = new FileInfo(captchaImgPath);
63 | FileInfo hintImg = new FileInfo(hintImgPath);
64 |
65 | Canvas captcha = new Canvas();
66 | captcha.SetFile(image);
67 | captcha.SetPreviousId(0);
68 | captcha.SetCanSkip(false);
69 | captcha.SetLang("en");
70 | captcha.SetHintImg(hintImg);
71 | captcha.SetHintText(hintText);
72 |
73 | var parameters = new Dictionary();
74 | parameters["method"] = "post";
75 | parameters["recaptcha"] = "1";
76 | parameters["canvas"] = "1";
77 | parameters["previousID"] = "0";
78 | parameters["can_no_answer"] = "0";
79 | parameters["lang"] = "en";
80 | parameters["textinstructions"] = hintText;
81 | parameters["soft_id"] = "4582";
82 |
83 | var files = new Dictionary();
84 | files["file"] = image;
85 | files["imginstructions"] = hintImg;
86 |
87 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters, files);
88 | }
89 | }
90 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/CapyTest.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using NUnit.Framework;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Tests
7 | {
8 | [TestFixture]
9 | public class CapyTest : AbstractWrapperTestCase
10 | {
11 | [Test]
12 | public async Task TestAllOptions()
13 | {
14 | Capy captcha = new Capy();
15 | captcha.SetSiteKey("PUZZLE_Abc1dEFghIJKLM2no34P56q7rStu8v");
16 | captcha.SetUrl("http://mysite.com/");
17 | captcha.SetApiServer("https://myapiserver.com/");
18 |
19 | var parameters = new Dictionary();
20 | parameters["method"] = "capy";
21 | parameters["captchakey"] = "PUZZLE_Abc1dEFghIJKLM2no34P56q7rStu8v";
22 | parameters["pageurl"] = "http://mysite.com/";
23 | parameters["api_server"] = "https://myapiserver.com/";
24 | parameters["soft_id"] = "4582";
25 |
26 |
27 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/CoordinatesTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Threading.Tasks;
5 | using NUnit.Framework;
6 | using TwoCaptcha.Captcha;
7 |
8 | namespace TwoCaptcha.Tests
9 | {
10 | [TestFixture]
11 | public class CoordinatesTest : AbstractWrapperTestCase
12 | {
13 | private string captchaImgPath = "../../../resources/grid.jpg";
14 | private string hintImgPath = "../../../resources/grid_hint.jpg";
15 | private string hintText = "Select all images with an Orange";
16 |
17 | [Test]
18 | public async Task TestSingleFile()
19 | {
20 | FileInfo image = new FileInfo(captchaImgPath);
21 |
22 | Coordinates captcha = new Coordinates(image);
23 |
24 | var parameters = new Dictionary();
25 | parameters["method"] = "post";
26 | parameters["coordinatescaptcha"] = "1";
27 | parameters["soft_id"] = "4582";
28 |
29 | var files = new Dictionary();
30 | files["file"] = image;
31 |
32 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters, files);
33 | }
34 |
35 | [Test]
36 | public async Task TestSingleFileParameter()
37 | {
38 | FileInfo image = new FileInfo(captchaImgPath);
39 |
40 | Coordinates captcha = new Coordinates();
41 | captcha.SetFile(image);
42 |
43 | var parameters = new Dictionary();
44 | parameters["method"] = "post";
45 | parameters["coordinatescaptcha"] = "1";
46 | parameters["soft_id"] = "4582";
47 |
48 | var files = new Dictionary();
49 | files["file"] = image;
50 |
51 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters, files);
52 | }
53 |
54 | [Test]
55 | public async Task TestBase64()
56 | {
57 | Coordinates captcha = new Coordinates();
58 | captcha.SetBase64("...");
59 |
60 | var parameters = new Dictionary();
61 | parameters["method"] = "base64";
62 | parameters["coordinatescaptcha"] = "1";
63 | parameters["body"] = "...";
64 | parameters["soft_id"] = "4582";
65 |
66 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
67 | }
68 |
69 | [Test]
70 | public async Task TestAllParameters()
71 | {
72 | FileInfo image = new FileInfo(captchaImgPath);
73 | FileInfo hintImg = new FileInfo(hintImgPath);
74 |
75 | Coordinates captcha = new Coordinates();
76 | captcha.SetFile(image);
77 | captcha.SetLang("en");
78 | captcha.SetHintImg(hintImg);
79 | captcha.SetHintText(hintText);
80 |
81 | var parameters = new Dictionary();
82 | parameters["method"] = "post";
83 | parameters["coordinatescaptcha"] = "1";
84 | parameters["lang"] = "en";
85 | parameters["textinstructions"] = hintText;
86 | parameters["soft_id"] = "4582";
87 |
88 | var files = new Dictionary();
89 | files["file"] = image;
90 | files["imginstructions"] = hintImg;
91 |
92 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters, files);
93 | }
94 | }
95 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/CutcaptchaTest.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using NUnit.Framework;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Tests
7 | {
8 | class CutcaptchaTest : AbstractWrapperTestCase
9 | {
10 | [Test]
11 | public async Task TestAllOptions()
12 | {
13 | Cutcaptcha cutcaptcha = new Cutcaptcha();
14 | cutcaptcha.SetMiseryKey("a1488b66da00bf332a1488993a5443c79047e752");
15 | cutcaptcha.SetPageUrl("https://example.cc/foo/bar.html");
16 | cutcaptcha.SetApiKey("SAb83IIB");
17 |
18 | var parameters = new Dictionary();
19 | parameters["method"] = "cutcaptcha";
20 | parameters["misery_key"] = "a1488b66da00bf332a1488993a5443c79047e752";
21 | parameters["pageurl"] = "https://example.cc/foo/bar.html";
22 | parameters["api_key"] = "SAb83IIB";
23 | parameters["soft_id"] = "4582";
24 |
25 | await CheckIfCorrectParamsSendAndResultReturned(cutcaptcha, parameters);
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/CyberSiARATest.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using NUnit.Framework;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Tests
7 | {
8 | class CyberSiARATest : AbstractWrapperTestCase
9 | {
10 | [Test]
11 | public async Task TestAllOptions()
12 | {
13 | CyberSiARA cyberSiARA = new CyberSiARA();
14 | cyberSiARA.SetMasterUrlId("tpjOCKjjpdzv3d8Ub2E9COEWKt1vl1Mv");
15 | cyberSiARA.SetPageUrl("https://demo.mycybersiara.com/");
16 | cyberSiARA.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36");
17 |
18 | var parameters = new Dictionary();
19 | parameters["method"] = "cybersiara";
20 | parameters["master_url_id"] = "tpjOCKjjpdzv3d8Ub2E9COEWKt1vl1Mv";
21 | parameters["pageurl"] = "https://demo.mycybersiara.com/";
22 | parameters["userAgent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36";
23 | parameters["soft_id"] = "4582";
24 |
25 | await CheckIfCorrectParamsSendAndResultReturned(cyberSiARA, parameters);
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/DataDomeTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Threading.Tasks;
4 | using NUnit.Framework;
5 | using TwoCaptcha.Captcha;
6 | using static System.Net.WebRequestMethods;
7 |
8 | namespace TwoCaptcha.Tests
9 | {
10 | [TestFixture]
11 | public class DataDomeTest : AbstractWrapperTestCase
12 | {
13 | [Test]
14 | public async Task TestAllOptions()
15 | {
16 | DataDome dataDome = new DataDome();
17 | dataDome.SetCapthaUrl("https://geo.captcha-delivery.com/captcha/?initialCid=AHrlqAAA...P~XFrBVptk&t=fe&referer=https%3A%2F%2Fhexample.com&s=45239&e=c538be..c510a00ea");
18 | dataDome.SetPageUrl("https://example.com/");
19 | dataDome.SetProxy("http", "username:password@1.2.3.4:5678");
20 | dataDome.SetUserAgent("Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.3");
21 |
22 | var parameters = new Dictionary();
23 | parameters["method"] = "datadome";
24 | parameters["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";
25 | parameters["pageurl"] = "https://example.com/";
26 | parameters["proxy"] = "https://example.com/";
27 | parameters["proxy"] = "username:password@1.2.3.4:5678";
28 | parameters["proxytype"] = "http";
29 | parameters["userAgent"] = "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.3";
30 | parameters["soft_id"] = "4582";
31 |
32 | await CheckIfCorrectParamsSendAndResultReturned(dataDome, parameters);
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/FriendlyCaptchaTest.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using NUnit.Framework;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Tests
7 | {
8 | [TestFixture]
9 | public class FriendlyCaptchaTest : AbstractWrapperTestCase
10 | {
11 | [Test]
12 | public async Task TestAllOptions()
13 | {
14 | FriendlyCaptcha captcha = new FriendlyCaptcha();
15 | captcha.SetSiteKey("2FZFEVS1FZCGQ9");
16 | captcha.SetUrl("https://www.site.com/page/");
17 |
18 | var parameters = new Dictionary();
19 | parameters["method"] = "friendly_captcha";
20 | parameters["sitekey"] = "2FZFEVS1FZCGQ9";
21 | parameters["pageurl"] = "https://www.site.com/page/";
22 | parameters["soft_id"] = "4582";
23 |
24 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/FunCaptchaTest.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using NUnit.Framework;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Tests
7 | {
8 | [TestFixture]
9 | public class FunCaptchaTest : AbstractWrapperTestCase
10 | {
11 | [Test]
12 | public async Task TestAllOptions()
13 | {
14 | FunCaptcha captcha = new FunCaptcha();
15 | captcha.SetSiteKey("69A21A01-CC7B-B9C6-0F9A-E7FA06677FFC");
16 | captcha.SetUrl("https://mysite.com/page/with/funcaptcha");
17 | captcha.SetSUrl("https://client-api.arkoselabs.com");
18 | captcha.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36");
19 | captcha.SetData("anyKey", "anyStringValue");
20 |
21 | var parameters = new Dictionary();
22 | parameters["method"] = "funcaptcha";
23 | parameters["publickey"] = "69A21A01-CC7B-B9C6-0F9A-E7FA06677FFC";
24 | parameters["pageurl"] = "https://mysite.com/page/with/funcaptcha";
25 | parameters["surl"] = "https://client-api.arkoselabs.com";
26 | parameters["userAgent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36";
27 | parameters["data[anyKey]"] = "anyStringValue";
28 | parameters["soft_id"] = "4582";
29 |
30 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/GeeTestTest.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using NUnit.Framework;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Tests
7 | {
8 | [TestFixture]
9 | public class GeeTestTest : AbstractWrapperTestCase
10 | {
11 | [Test]
12 | public async Task TestAllOptions()
13 | {
14 | GeeTest captcha = new GeeTest();
15 | captcha.SetGt("f2ae6cadcf7886856696502e1d55e00c");
16 | captcha.SetApiServer("api-na.geetest.com");
17 | captcha.SetChallenge("69A21A01-CC7B-B9C6-0F9A-E7FA06677FFC");
18 | captcha.SetUrl("https://launches.endclothing.com/distil_r_captcha.html");
19 |
20 | var parameters = new Dictionary();
21 | parameters["method"] = "geetest";
22 | parameters["gt"] = "f2ae6cadcf7886856696502e1d55e00c";
23 | parameters["api_server"] = "api-na.geetest.com";
24 | parameters["challenge"] = "69A21A01-CC7B-B9C6-0F9A-E7FA06677FFC";
25 | parameters["pageurl"] = "https://launches.endclothing.com/distil_r_captcha.html";
26 | parameters["soft_id"] = "4582";
27 |
28 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/GeeTestV4Test.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using NUnit.Framework;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Tests
7 | {
8 | [TestFixture]
9 | public class GeeTestV4Test : AbstractWrapperTestCase
10 | {
11 | [Test]
12 | public async Task TestAllOptions()
13 | {
14 | GeeTestV4 captcha = new GeeTestV4();
15 | captcha.SetCaptchaId("72bf15796d0b69c43867452fea615052");
16 | captcha.SetChallenge("12345678abc90123d45678ef90123a456b");
17 | captcha.SetUrl("https://mysite.com/captcha.html");
18 |
19 | var parameters = new Dictionary();
20 | parameters["method"] = "geetest_v4";
21 | parameters["captcha_id"] = "72bf15796d0b69c43867452fea615052";
22 | parameters["challenge"] = "12345678abc90123d45678ef90123a456b";
23 | parameters["pageurl"] = "https://mysite.com/captcha.html";
24 | parameters["soft_id"] = "4582";
25 |
26 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/GridTest.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.IO;
3 | using System.Threading.Tasks;
4 | using NUnit.Framework;
5 | using TwoCaptcha.Captcha;
6 |
7 | namespace TwoCaptcha.Tests
8 | {
9 | [TestFixture]
10 | public class GridTest : AbstractWrapperTestCase
11 | {
12 | private string captchaImgPath = "../../../resources/grid.jpg";
13 | private string hintImgPath = "../../../resources/grid_hint.jpg";
14 | private string hintText = "Select all images with an Orange";
15 |
16 | [Test]
17 | public async Task TestSingleFile()
18 | {
19 | FileInfo image = new FileInfo(captchaImgPath);
20 |
21 | Grid captcha = new Grid(image);
22 |
23 | var parameters = new Dictionary();
24 | parameters["method"] = "post";
25 | parameters["recaptcha"] = "1";
26 | parameters["soft_id"] = "4582";
27 |
28 | var files = new Dictionary();
29 | files["file"] = image;
30 |
31 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters, files);
32 | }
33 |
34 | [Test]
35 | public async Task TestSingleFileParameter()
36 | {
37 | FileInfo image = new FileInfo(captchaImgPath);
38 |
39 | Grid captcha = new Grid();
40 | captcha.SetFile(image);
41 |
42 | var parameters = new Dictionary();
43 | parameters["method"] = "post";
44 | parameters["recaptcha"] = "1";
45 | parameters["soft_id"] = "4582";
46 |
47 | var files = new Dictionary();
48 | files["file"] = image;
49 |
50 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters, files);
51 | }
52 |
53 | [Test]
54 | public async Task TestBase64()
55 | {
56 | Grid captcha = new Grid();
57 | captcha.SetBase64("...");
58 |
59 | var parameters = new Dictionary();
60 | parameters["method"] = "base64";
61 | parameters["body"] = "...";
62 | parameters["recaptcha"] = "1";
63 | parameters["soft_id"] = "4582";
64 |
65 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
66 | }
67 |
68 | [Test]
69 | public async Task TestAllParameters()
70 | {
71 | FileInfo image = new FileInfo(captchaImgPath);
72 | FileInfo hintImg = new FileInfo(hintImgPath);
73 |
74 | Grid captcha = new Grid();
75 | captcha.SetFile(image);
76 | captcha.SetRows(3);
77 | captcha.SetCols(3);
78 | captcha.SetPreviousId(0);
79 | captcha.SetCanSkip(false);
80 | captcha.SetLang("en");
81 | captcha.SetHintImg(hintImg);
82 | captcha.SetHintText(hintText);
83 |
84 | var parameters = new Dictionary();
85 | parameters["method"] = "post";
86 | parameters["recaptcha"] = "1";
87 | parameters["recaptcharows"] = "3";
88 | parameters["recaptchacols"] = "3";
89 | parameters["previousID"] = "0";
90 | parameters["can_no_answer"] = "0";
91 | parameters["lang"] = "en";
92 | parameters["textinstructions"] = hintText;
93 | parameters["soft_id"] = "4582";
94 |
95 | var files = new Dictionary();
96 | files["file"] = image;
97 | files["imginstructions"] = hintImg;
98 |
99 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters, files);
100 | }
101 | }
102 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/HCaptchaTest.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using NUnit.Framework;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Tests
7 | {
8 | [TestFixture]
9 | public class HCaptchaTest : AbstractWrapperTestCase
10 | {
11 | [Test]
12 | public async Task TestAllOptions()
13 | {
14 | HCaptcha captcha = new HCaptcha();
15 | captcha.SetSiteKey("f1ab2cdefa3456789012345b6c78d90e");
16 | captcha.SetUrl("https://www.site.com/page/");
17 | captcha.SetData("foo");
18 |
19 | var parameters = new Dictionary();
20 | parameters["method"] = "hcaptcha";
21 | parameters["sitekey"] = "f1ab2cdefa3456789012345b6c78d90e";
22 | parameters["pageurl"] = "https://www.site.com/page/";
23 | parameters["data"] = "foo";
24 | parameters["soft_id"] = "4582";
25 |
26 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/KeyCaptchaTest.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using NUnit.Framework;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Tests
7 | {
8 | [TestFixture]
9 | public class KeyCaptchaTest : AbstractWrapperTestCase
10 | {
11 | [Test]
12 | public async Task TestAllOptions()
13 | {
14 | KeyCaptcha captcha = new KeyCaptcha();
15 | captcha.SetUserId(10);
16 | captcha.SetSessionId("493e52c37c10c2bcdf4a00cbc9ccd1e8");
17 | captcha.SetWebServerSign("9006dc725760858e4c0715b835472f22-pz-");
18 | captcha.SetWebServerSign2("2ca3abe86d90c6142d5571db98af6714");
19 | captcha.SetUrl("https://www.keycaptcha.ru/demo-magnetic/");
20 |
21 | var parameters = new Dictionary();
22 | parameters["method"] = "keycaptcha";
23 | parameters["s_s_c_user_id"] = "10";
24 | parameters["s_s_c_session_id"] = "493e52c37c10c2bcdf4a00cbc9ccd1e8";
25 | parameters["s_s_c_web_server_sign"] = "9006dc725760858e4c0715b835472f22-pz-";
26 | parameters["s_s_c_web_server_sign2"] = "2ca3abe86d90c6142d5571db98af6714";
27 | parameters["pageurl"] = "https://www.keycaptcha.ru/demo-magnetic/";
28 | parameters["soft_id"] = "4582";
29 |
30 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/LeminTest.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using NUnit.Framework;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Tests
7 | {
8 | [TestFixture]
9 | public class LeminTest : AbstractWrapperTestCase
10 | {
11 | [Test]
12 | public async Task TestAllOptions()
13 | {
14 | Lemin captcha = new Lemin();
15 | captcha.SetCaptchaId("CROPPED_d3d4d56_73ca4008925b4f83a8bed59c2dd0df6d");
16 | captcha.SetApiServer("api.leminnow.com");
17 | captcha.SetUrl("http://sat2.aksigorta.com.tr");
18 |
19 | var parameters = new Dictionary();
20 | parameters["method"] = "lemin";
21 | parameters["captcha_id"] = "CROPPED_d3d4d56_73ca4008925b4f83a8bed59c2dd0df6d";
22 | parameters["api_server"] = "api.leminnow.com";
23 | parameters["pageurl"] = "http://sat2.aksigorta.com.tr";
24 | parameters["soft_id"] = "4582";
25 |
26 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/MTCaptchaTest.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using NUnit.Framework;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Tests
7 | {
8 | [TestFixture]
9 | public class MTCaptchaTest : AbstractWrapperTestCase
10 | {
11 | [Test]
12 | public async Task TestAllOptions()
13 | {
14 | MTCaptcha mtCaptcha = new MTCaptcha();
15 | mtCaptcha.SetSiteKey("MTPublic-KzqLY1cKH");
16 | mtCaptcha.SetPageUrl("https://2captcha.com/demo/mtcaptcha");
17 |
18 | var parameters = new Dictionary();
19 | parameters["method"] = "mt_captcha";
20 | parameters["sitekey"] = "MTPublic-KzqLY1cKH";
21 | parameters["pageurl"] = "https://2captcha.com/demo/mtcaptcha";
22 | parameters["soft_id"] = "4582";
23 |
24 | await CheckIfCorrectParamsSendAndResultReturned(mtCaptcha, parameters);
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/NormalTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Threading.Tasks;
5 | using NUnit.Framework;
6 | using TwoCaptcha.Captcha;
7 |
8 | namespace TwoCaptcha.Tests
9 | {
10 | [TestFixture]
11 | public class NormalTest : AbstractWrapperTestCase
12 | {
13 | private string captchaImgPath = "../../../resources/normal.jpg";
14 | private string hintImgPath = "../../../resources/grid_hint.jpg";
15 | private string hintText = "Type red symbols only";
16 |
17 | [Test]
18 | public async Task TestSingleFile()
19 | {
20 | FileInfo image = new FileInfo(captchaImgPath);
21 |
22 | Normal captcha = new Normal(captchaImgPath);
23 |
24 | var parameters = new Dictionary();
25 | parameters["method"] = "post";
26 | parameters["soft_id"] = "4582";
27 |
28 | var files = new Dictionary();
29 | files["file"] = image;
30 |
31 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters, files);
32 | }
33 |
34 | [Test]
35 | public async Task TestSingleFileParameter()
36 | {
37 | FileInfo image = new FileInfo(captchaImgPath);
38 |
39 | Normal captcha = new Normal();
40 | captcha.SetFile(image);
41 |
42 | var parameters = new Dictionary();
43 | parameters["method"] = "post";
44 | parameters["soft_id"] = "4582";
45 |
46 | var files = new Dictionary();
47 | files["file"] = image;
48 |
49 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters, files);
50 | }
51 |
52 | [Test]
53 | public async Task TestBase64()
54 | {
55 | Normal captcha = new Normal();
56 | captcha.SetBase64("...");
57 |
58 | var parameters = new Dictionary();
59 | parameters["method"] = "base64";
60 | parameters["body"] = "...";
61 | parameters["soft_id"] = "4582";
62 |
63 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
64 | }
65 |
66 | [Test]
67 | public async Task TestAllParameters()
68 | {
69 | FileInfo image = new FileInfo(captchaImgPath);
70 | FileInfo hintImg = new FileInfo(hintImgPath);
71 |
72 | Normal captcha = new Normal();
73 | captcha.SetFile(image);
74 | captcha.SetNumeric(4);
75 | captcha.SetMinLen(5);
76 | captcha.SetMaxLen(20);
77 | captcha.SetPhrase(true);
78 | captcha.SetCaseSensitive(true);
79 | captcha.SetCalc(false);
80 | captcha.SetLang("en");
81 | captcha.SetHintImg(hintImg);
82 | captcha.SetHintText(hintText);
83 |
84 | var parameters = new Dictionary();
85 | parameters["method"] = "post";
86 | parameters["numeric"] = "4";
87 | parameters["min_len"] = "5";
88 | parameters["max_len"] = "20";
89 | parameters["phrase"] = "1";
90 | parameters["regsense"] = "1";
91 | parameters["calc"] = "0";
92 | parameters["lang"] = "en";
93 | parameters["textinstructions"] = hintText;
94 | parameters["soft_id"] = "4582";
95 |
96 | var files = new Dictionary();
97 | files["file"] = image;
98 | files["imginstructions"] = hintImg;
99 |
100 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters, files);
101 | }
102 | }
103 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/ReCaptchaTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Threading.Tasks;
4 | using NUnit.Framework;
5 | using TwoCaptcha.Captcha;
6 |
7 | namespace TwoCaptcha.Tests
8 | {
9 | [TestFixture]
10 | public class ReCaptchaTest : AbstractWrapperTestCase
11 | {
12 | [Test]
13 | public async Task TestV2()
14 | {
15 | ReCaptcha captcha = new ReCaptcha();
16 | captcha.SetSiteKey("6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-");
17 | captcha.SetUrl("https://mysite.com/page/with/recaptcha");
18 | captcha.SetInvisible(true);
19 | captcha.SetAction("verify");
20 | captcha.SetDomain("recaptcha.net");
21 | captcha.SetDataS("foo");
22 |
23 | var parameters = new Dictionary();
24 | parameters["method"] = "userrecaptcha";
25 | parameters["googlekey"] = "6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-";
26 | parameters["pageurl"] = "https://mysite.com/page/with/recaptcha";
27 | parameters["invisible"] = "1";
28 | parameters["action"] = "verify";
29 | parameters["domain"] = "recaptcha.net";
30 | parameters["data-s"] = "foo";
31 | parameters["soft_id"] = "4582";
32 |
33 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
34 | }
35 |
36 | [Test]
37 | public async Task TestV3()
38 | {
39 | ReCaptcha captcha = new ReCaptcha();
40 | captcha.SetSiteKey("6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-");
41 | captcha.SetUrl("https://mysite.com/page/with/recaptcha");
42 | captcha.SetVersion("v3");
43 | captcha.SetAction("verify");
44 | captcha.SetScore(0.3);
45 | captcha.SetDomain("recaptcha.net");
46 |
47 | var parameters = new Dictionary();
48 | parameters["method"] = "userrecaptcha";
49 | parameters["googlekey"] = "6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-";
50 | parameters["pageurl"] = "https://mysite.com/page/with/recaptcha";
51 | parameters["version"] = "v3";
52 | parameters["action"] = "verify";
53 | parameters["min_score"] = "0.3";
54 | parameters["domain"] = "recaptcha.net";
55 | parameters["soft_id"] = "4582";
56 |
57 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/RotateTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Threading.Tasks;
5 | using NUnit.Framework;
6 | using TwoCaptcha.Captcha;
7 |
8 | namespace TwoCaptcha.Tests
9 | {
10 | [TestFixture]
11 | public class RotateTest : AbstractWrapperTestCase
12 | {
13 |
14 | [Test]
15 | public async Task TestAllParameters()
16 | {
17 | byte[] bytes = File.ReadAllBytes("../../../resources/rotate.jpg");
18 | string base64EncodedImage = Convert.ToBase64String(bytes);
19 |
20 |
21 | Rotate captcha = new Rotate();
22 | captcha.SetBase64(base64EncodedImage);
23 | captcha.SetAngle(45);
24 | captcha.SetLang("en");
25 | captcha.SetHintText("Put the images in the correct way up");
26 |
27 |
28 | var parameters = new Dictionary();
29 | parameters["method"] = "rotatecaptcha";
30 | parameters["angle"] = "45";
31 | parameters["lang"] = "en";
32 | parameters["textinstructions"] = "Put the images in the correct way up";
33 | parameters["body"] = base64EncodedImage;
34 | parameters["soft_id"] = "4582";
35 |
36 |
37 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
38 | }
39 |
40 | }
41 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/TencentTest.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using NUnit.Framework;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Tests
7 | {
8 | [TestFixture]
9 | public class TencentTest : AbstractWrapperTestCase
10 | {
11 | [Test]
12 | public async Task TestAllOptions()
13 | {
14 | Tencent tencent = new Tencent();
15 | tencent.SetAppId("190014885");
16 | tencent.SetPageUrl("https://www.example.com/");
17 |
18 | var parameters = new Dictionary();
19 | parameters["method"] = "tencent";
20 | parameters["app_id"] = "190014885";
21 | parameters["pageurl"] = "https://www.example.com/";
22 | parameters["soft_id"] = "4582";
23 |
24 | await CheckIfCorrectParamsSendAndResultReturned(tencent, parameters);
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/TextTest.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using NUnit.Framework;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Tests
7 | {
8 | [TestFixture]
9 | public class TextTest : AbstractWrapperTestCase
10 | {
11 | private string question = "Today is monday?";
12 |
13 | [Test]
14 | public async Task TestSimpleText()
15 | {
16 | Text captcha = new Text(question);
17 |
18 | var parameters = new Dictionary();
19 | parameters["method"] = "post";
20 | parameters["textcaptcha"] = question;
21 | parameters["soft_id"] = "4582";
22 |
23 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
24 | }
25 |
26 | [Test]
27 | public async Task TestTextParameter()
28 | {
29 | Text captcha = new Text();
30 | captcha.SetText(question);
31 |
32 | var parameters = new Dictionary();
33 | parameters["method"] = "post";
34 | parameters["textcaptcha"] = question;
35 | parameters["soft_id"] = "4582";
36 |
37 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
38 | }
39 |
40 | [Test]
41 | public async Task TestAllParameters()
42 | {
43 | Text captcha = new Text();
44 | captcha.SetText(question);
45 | captcha.SetLang("en");
46 |
47 | var parameters = new Dictionary();
48 | parameters["method"] = "post";
49 | parameters["textcaptcha"] = question;
50 | parameters["lang"] = "en";
51 | parameters["soft_id"] = "4582";
52 |
53 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/TurnstileTest.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using NUnit.Framework;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Tests
7 | {
8 | [TestFixture]
9 | public class TurnstileTest : AbstractWrapperTestCase
10 | {
11 | [Test]
12 | public async Task TestAllOptions()
13 | {
14 | Turnstile captcha = new Turnstile();
15 | captcha.SetSiteKey("0x4AAAAAAAChNiVJM_WtShFf");
16 | captcha.SetUrl("https://ace.fusionist.io");
17 | captcha.SetData("foo");
18 | captcha.SetPageData("bar");
19 | captcha.SetAction("baz");
20 |
21 | var parameters = new Dictionary();
22 | parameters["method"] = "turnstile";
23 | parameters["sitekey"] = "0x4AAAAAAAChNiVJM_WtShFf";
24 | parameters["pageurl"] = "https://ace.fusionist.io";
25 | parameters["data"] = "foo";
26 | parameters["pagedata"] = "bar";
27 | parameters["action"] = "baz";
28 | parameters["soft_id"] = "4582";
29 |
30 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/TwoCaptcha.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1;net5.0;net6.0;net7.0
5 | false
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/YandexTest.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using NUnit.Framework;
4 | using TwoCaptcha.Captcha;
5 |
6 | namespace TwoCaptcha.Tests
7 | {
8 | [TestFixture]
9 | public class YandexTest : AbstractWrapperTestCase
10 | {
11 | [Test]
12 | public async Task TestAllOptions()
13 | {
14 | Yandex captcha = new Yandex();
15 | captcha.SetSiteKey("Y5Lh0tiycconMJGsFd3EbbuNKSp1yaZESUOIHfeV");
16 | captcha.SetUrl("https://rutube.ru");
17 |
18 | var parameters = new Dictionary();
19 | parameters["method"] = "yandex";
20 | parameters["sitekey"] = "Y5Lh0tiycconMJGsFd3EbbuNKSp1yaZESUOIHfeV";
21 | parameters["pageurl"] = "https://rutube.ru";
22 | parameters["soft_id"] = "4582";
23 |
24 | await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/resources/audio-en.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Tests/resources/audio-en.mp3
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/resources/audio-ru.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Tests/resources/audio-ru.mp3
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/resources/canvas.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Tests/resources/canvas.jpg
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/resources/canvas_hint.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Tests/resources/canvas_hint.jpg
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/resources/grid.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Tests/resources/grid.jpg
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/resources/grid_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Tests/resources/grid_2.jpg
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/resources/grid_hint.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Tests/resources/grid_hint.jpg
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/resources/normal.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Tests/resources/normal.jpg
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/resources/normal_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Tests/resources/normal_2.jpg
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/resources/rotate.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Tests/resources/rotate.jpg
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/resources/rotate_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Tests/resources/rotate_2.jpg
--------------------------------------------------------------------------------
/TwoCaptcha.Tests/resources/rotate_3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2captcha/2captcha-csharp/5abfdf67d8cc7910bcc7e29a516d133d3ea32d3e/TwoCaptcha.Tests/resources/rotate_3.jpg
--------------------------------------------------------------------------------
/TwoCaptcha.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TwoCaptcha", "TwoCaptcha\TwoCaptcha.csproj", "{43E53565-390B-41C2-B2F9-225505C3C87D}"
4 | EndProject
5 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TwoCaptcha.Examples", "TwoCaptcha.Examples\TwoCaptcha.Examples.csproj", "{954E934C-0515-410C-A7BD-D1B08533A618}"
6 | EndProject
7 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TwoCaptcha.Tests", "TwoCaptcha.Tests\TwoCaptcha.Tests.csproj", "{FAFE124B-3E0B-4836-AC42-6FBBD70F21A8}"
8 | EndProject
9 | Global
10 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
11 | Debug|Any CPU = Debug|Any CPU
12 | Release|Any CPU = Release|Any CPU
13 | EndGlobalSection
14 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
15 | {43E53565-390B-41C2-B2F9-225505C3C87D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
16 | {43E53565-390B-41C2-B2F9-225505C3C87D}.Debug|Any CPU.Build.0 = Debug|Any CPU
17 | {43E53565-390B-41C2-B2F9-225505C3C87D}.Release|Any CPU.ActiveCfg = Release|Any CPU
18 | {43E53565-390B-41C2-B2F9-225505C3C87D}.Release|Any CPU.Build.0 = Release|Any CPU
19 | {954E934C-0515-410C-A7BD-D1B08533A618}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20 | {954E934C-0515-410C-A7BD-D1B08533A618}.Debug|Any CPU.Build.0 = Debug|Any CPU
21 | {954E934C-0515-410C-A7BD-D1B08533A618}.Release|Any CPU.ActiveCfg = Release|Any CPU
22 | {954E934C-0515-410C-A7BD-D1B08533A618}.Release|Any CPU.Build.0 = Release|Any CPU
23 | {FAFE124B-3E0B-4836-AC42-6FBBD70F21A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24 | {FAFE124B-3E0B-4836-AC42-6FBBD70F21A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
25 | {FAFE124B-3E0B-4836-AC42-6FBBD70F21A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
26 | {FAFE124B-3E0B-4836-AC42-6FBBD70F21A8}.Release|Any CPU.Build.0 = Release|Any CPU
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/TwoCaptcha/ApiClient.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.IO;
5 | using System.Net.Http;
6 | using System.Threading.Tasks;
7 | using TwoCaptcha.Exceptions;
8 |
9 | namespace TwoCaptcha
10 | {
11 | public class ApiClient
12 | {
13 | /**
14 | * API server
15 | */
16 | private string baseUrl = "https://2captcha.com/";
17 |
18 | /**
19 | * Network client
20 | */
21 | private readonly HttpClient client = new HttpClient();
22 |
23 | public ApiClient()
24 | {
25 | client.BaseAddress = new Uri(baseUrl);
26 | }
27 |
28 | public virtual async Task In(Dictionary parameters, Dictionary files)
29 | {
30 | var content =
31 | new MultipartFormDataContent("Upload----" + DateTime.Now.ToString(CultureInfo.InvariantCulture));
32 |
33 | foreach (KeyValuePair p in parameters)
34 | {
35 | content.Add(new StringContent(p.Value), p.Key);
36 | }
37 |
38 | foreach (KeyValuePair f in files)
39 | {
40 | var fileStream = new StreamContent(new MemoryStream(File.ReadAllBytes(f.Value.FullName)));
41 | content.Add(fileStream, f.Key, f.Value.Name);
42 | }
43 |
44 | var request = new HttpRequestMessage(HttpMethod.Post, "in.php")
45 | {
46 | Content = content
47 | };
48 |
49 | return await Execute(request);
50 | }
51 |
52 | public virtual async Task Res(Dictionary parameters)
53 | {
54 | var request = new HttpRequestMessage(HttpMethod.Get, "res.php?" + BuildQuery(parameters));
55 |
56 | return await Execute(request);
57 | }
58 |
59 | private string BuildQuery(Dictionary parameters)
60 | {
61 | string query = "";
62 |
63 | foreach (KeyValuePair p in parameters)
64 | {
65 | if (query.Length > 0)
66 | {
67 | query += "&";
68 | }
69 |
70 | query += p.Key + "=" + Uri.EscapeDataString(p.Value);
71 | }
72 |
73 | return query;
74 | }
75 |
76 | private async Task Execute(HttpRequestMessage request)
77 | {
78 | var response = await client.SendAsync(request);
79 |
80 | string body = await response.Content.ReadAsStringAsync();
81 |
82 | if (!response.IsSuccessStatusCode)
83 | {
84 | throw new NetworkException("Unexpected response: " + body);
85 | }
86 |
87 | if (body.StartsWith("ERROR_"))
88 | {
89 | throw new ApiException(body);
90 | }
91 |
92 | return body;
93 | }
94 | }
95 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/AmazonWaf.cs:
--------------------------------------------------------------------------------
1 | namespace TwoCaptcha.Captcha
2 | {
3 | public class AmazonWaf : Captcha
4 | {
5 | public AmazonWaf() : base()
6 | {
7 | parameters["method"] = "amazon_waf";
8 | }
9 |
10 | public void SetSiteKey(string siteKey)
11 | {
12 | parameters["sitekey"] = siteKey;
13 | }
14 |
15 | public void SetUrl(string url)
16 | {
17 | parameters["pageurl"] = url;
18 | }
19 |
20 | public void SetContext(string context)
21 | {
22 | parameters["context"] = context;
23 | }
24 |
25 | public void SetIV(string iv)
26 | {
27 | parameters["iv"] = iv;
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/AtbCAPTCHA.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace TwoCaptcha.Captcha
3 | {
4 | public class AtbCAPTCHA : Captcha
5 | {
6 | public AtbCAPTCHA() : base()
7 | {
8 | parameters["method"] = "atb_captcha";
9 | }
10 |
11 | public void SetPageUrl(string url)
12 | {
13 | parameters["pageurl"] = url;
14 | }
15 |
16 | public void SetApiServer(string apiServer)
17 | {
18 | parameters["api_server"] = apiServer;
19 | }
20 |
21 | public void SetAppId(string appId)
22 | {
23 | parameters["app_id"] = appId;
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/AudioCaptcha.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TwoCaptcha.Captcha
4 | {
5 | public class AudioCaptcha : Captcha
6 | {
7 | public AudioCaptcha() : base()
8 | {
9 | parameters["method"] = "audio";
10 | }
11 | public void SetBase64(String base64)
12 | {
13 | parameters["body"] = base64;
14 | }
15 | public void SetLang(String lang)
16 | {
17 | parameters["lang"] = lang;
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/Canvas.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace TwoCaptcha.Captcha
5 | {
6 | public class Canvas : Captcha
7 | {
8 | public Canvas() : base()
9 | {
10 | parameters["canvas"] = "1";
11 | parameters["recaptcha"] = "1";
12 | }
13 |
14 | public void SetFile(string filePath)
15 | {
16 | SetFile(new FileInfo(filePath));
17 | }
18 |
19 | public void SetFile(FileInfo file)
20 | {
21 | files["file"] = file;
22 | }
23 |
24 | public void SetBase64(string base64)
25 | {
26 | parameters["body"] = base64;
27 | }
28 |
29 | public void SetPreviousId(int previousId)
30 | {
31 | parameters["previousID"] = Convert.ToString(previousId);
32 | }
33 |
34 | public void SetCanSkip(bool canSkip)
35 | {
36 | parameters["can_no_answer"] = canSkip ? "1" : "0";
37 | }
38 |
39 | public void SetLang(string lang)
40 | {
41 | parameters["lang"] = lang;
42 | }
43 |
44 | public void SetHintText(string hintText)
45 | {
46 | parameters["textinstructions"] = hintText;
47 | }
48 |
49 | public void SetHintImg(string base64)
50 | {
51 | parameters["imginstructions"] = base64;
52 | }
53 |
54 | public void SetHintImg(FileInfo hintImg)
55 | {
56 | files["imginstructions"] = hintImg;
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/Captcha.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 |
5 | namespace TwoCaptcha.Captcha
6 | {
7 | public abstract class Captcha
8 | {
9 | public string Id { get; set; }
10 | public string Code { get; set; }
11 |
12 | protected Dictionary parameters;
13 | protected Dictionary files;
14 |
15 | public Captcha()
16 | {
17 | parameters = new Dictionary();
18 | files = new Dictionary();
19 | }
20 |
21 | public void SetProxy(string type, string uri)
22 | {
23 | parameters["proxy"] = uri;
24 | parameters["proxytype"] = type;
25 | }
26 |
27 | public void SetSoftId(int softId)
28 | {
29 | parameters["soft_id"] = Convert.ToString(softId);
30 | }
31 |
32 | public void SetCallback(String callback)
33 | {
34 | parameters["pingback"] = callback;
35 | }
36 |
37 | public Dictionary GetParameters()
38 | {
39 | var parameters = new Dictionary(this.parameters);
40 |
41 | if (!parameters.ContainsKey("method"))
42 | {
43 | if (parameters.ContainsKey("body"))
44 | {
45 | parameters["method"] = "base64";
46 | }
47 | else
48 | {
49 | parameters["method"] = "post";
50 | }
51 | }
52 |
53 | return parameters;
54 | }
55 |
56 | public Dictionary GetFiles()
57 | {
58 | return new Dictionary(files);
59 | }
60 | }
61 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/Capy.cs:
--------------------------------------------------------------------------------
1 | namespace TwoCaptcha.Captcha
2 | {
3 | public class Capy : Captcha
4 | {
5 | public Capy() : base()
6 | {
7 | parameters["method"] = "capy";
8 | }
9 |
10 | public void SetSiteKey(string siteKey)
11 | {
12 | parameters["captchakey"] = siteKey;
13 | }
14 |
15 | public void SetUrl(string url)
16 | {
17 | parameters["pageurl"] = url;
18 | }
19 |
20 | public void SetApiServer(string apiServer)
21 | {
22 | parameters["api_server"] = apiServer;
23 | }
24 |
25 | }
26 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/Coordinates.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace TwoCaptcha.Captcha
4 | {
5 | public class Coordinates : Captcha
6 | {
7 | public Coordinates() : base()
8 | {
9 | parameters["coordinatescaptcha"] = "1";
10 | }
11 |
12 | public Coordinates(string filePath) : this(new FileInfo(filePath))
13 | {
14 | }
15 |
16 | public Coordinates(FileInfo file) : this()
17 | {
18 | SetFile(file);
19 | }
20 |
21 | public void SetFile(string filePath)
22 | {
23 | SetFile(new FileInfo(filePath));
24 | }
25 |
26 | public void SetFile(FileInfo file)
27 | {
28 | files["file"] = file;
29 | }
30 |
31 | public void SetBase64(string base64)
32 | {
33 | parameters["body"] = base64;
34 | }
35 |
36 | public void SetLang(string lang)
37 | {
38 | parameters["lang"] = lang;
39 | }
40 |
41 | public void SetHintText(string hintText)
42 | {
43 | parameters["textinstructions"] = hintText;
44 | }
45 |
46 | public void SetHintImg(string base64)
47 | {
48 | parameters["imginstructions"] = base64;
49 | }
50 |
51 | public void SetHintImg(FileInfo hintImg)
52 | {
53 | files["imginstructions"] = hintImg;
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/Cutcaptcha.cs:
--------------------------------------------------------------------------------
1 | namespace TwoCaptcha.Captcha
2 | {
3 | public class Cutcaptcha : Captcha
4 | {
5 | public Cutcaptcha() : base()
6 | {
7 | parameters["method"] = "cutcaptcha";
8 | }
9 | public void SetMiseryKey(string miseryKey)
10 | {
11 | parameters["misery_key"] = miseryKey;
12 | }
13 | public void SetApiKey(string apiKey)
14 | {
15 | parameters["api_key"] = apiKey;
16 | }
17 | public void SetPageUrl(string pageUrl)
18 | {
19 | parameters["pageurl"] = pageUrl;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/CyberSiARA.cs:
--------------------------------------------------------------------------------
1 | namespace TwoCaptcha.Captcha
2 | {
3 | public class CyberSiARA : Captcha
4 | {
5 | public CyberSiARA() : base()
6 | {
7 | parameters["method"] = "cybersiara";
8 | }
9 | public void SetMasterUrlId(string masterUrlId)
10 | {
11 | parameters["master_url_id"] = masterUrlId;
12 | }
13 | public void SetPageUrl(string pageUrl)
14 | {
15 | parameters["pageurl"] = pageUrl;
16 | }
17 | public void SetUserAgent(string userAgent)
18 | {
19 | parameters["userAgent"] = userAgent;
20 | }
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/DataDome.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace TwoCaptcha.Captcha
3 | {
4 | public class DataDome : Captcha
5 | {
6 | public DataDome() : base()
7 | {
8 | parameters["method"] = "datadome";
9 | }
10 |
11 | public void SetCapthaUrl(string capthaUrl)
12 | {
13 | parameters["captcha_url"] = capthaUrl;
14 | }
15 |
16 | public void SetPageUrl(string url)
17 | {
18 | parameters["pageurl"] = url;
19 | }
20 |
21 | public void SetUserAgent(string userAgent)
22 | {
23 | parameters["userAgent"] = userAgent;
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/FriendlyCaptcha.cs:
--------------------------------------------------------------------------------
1 | namespace TwoCaptcha.Captcha
2 | {
3 | public class FriendlyCaptcha : Captcha
4 | {
5 | public FriendlyCaptcha() : base()
6 | {
7 | parameters["method"] = "friendly_captcha";
8 | }
9 |
10 | public void SetSiteKey(string siteKey)
11 | {
12 | parameters["sitekey"] = siteKey;
13 | }
14 |
15 | public void SetUrl(string url)
16 | {
17 | parameters["pageurl"] = url;
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/FunCaptcha.cs:
--------------------------------------------------------------------------------
1 | namespace TwoCaptcha.Captcha
2 | {
3 | public class FunCaptcha : Captcha
4 | {
5 | public FunCaptcha() : base()
6 | {
7 | parameters["method"] = "funcaptcha";
8 | }
9 |
10 | public void SetSiteKey(string siteKey)
11 | {
12 | parameters["publickey"] = siteKey;
13 | }
14 |
15 | public void SetUrl(string url)
16 | {
17 | parameters["pageurl"] = url;
18 | }
19 |
20 | public void SetSUrl(string sUrl)
21 | {
22 | parameters["surl"] = sUrl;
23 | }
24 |
25 | public void SetUserAgent(string userAgent)
26 | {
27 | parameters["userAgent"] = userAgent;
28 | }
29 |
30 | public void SetData(string key, string value)
31 | {
32 | parameters["data[" + key + "]"] = value;
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/GeeTest.cs:
--------------------------------------------------------------------------------
1 | namespace TwoCaptcha.Captcha
2 | {
3 | public class GeeTest : Captcha
4 | {
5 | public GeeTest() : base()
6 | {
7 | parameters["method"] = "geetest";
8 | }
9 |
10 | public void SetGt(string gt)
11 | {
12 | parameters["gt"] = gt;
13 | }
14 |
15 | public void SetChallenge(string challenge)
16 | {
17 | parameters["challenge"] = challenge;
18 | }
19 |
20 | public void SetUrl(string url)
21 | {
22 | parameters["pageurl"] = url;
23 | }
24 |
25 | public void SetApiServer(string apiServer)
26 | {
27 | parameters["api_server"] = apiServer;
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/GeeTestV4.cs:
--------------------------------------------------------------------------------
1 | namespace TwoCaptcha.Captcha
2 | {
3 | public class GeeTestV4 : Captcha
4 | {
5 | public GeeTestV4() : base()
6 | {
7 | parameters["method"] = "geetest_v4";
8 | }
9 |
10 | public void SetCaptchaId(string captchaId)
11 | {
12 | parameters["captcha_id"] = captchaId;
13 | }
14 |
15 | public void SetChallenge(string challenge)
16 | {
17 | parameters["challenge"] = challenge;
18 | }
19 |
20 | public void SetUrl(string url)
21 | {
22 | parameters["pageurl"] = url;
23 | }
24 |
25 | public void SetApiServer(string apiServer)
26 | {
27 | parameters["api_server"] = apiServer;
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/Grid.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace TwoCaptcha.Captcha
5 | {
6 | public class Grid : Captcha
7 | {
8 | public Grid() : base()
9 | {
10 | parameters["recaptcha"] = "1";
11 | }
12 |
13 | public Grid(string filePath) : this(new FileInfo(filePath))
14 | {
15 | }
16 |
17 | public Grid(FileInfo file) : this()
18 | {
19 | SetFile(file);
20 | }
21 |
22 | public void SetFile(String filePath)
23 | {
24 | SetFile(new FileInfo(filePath));
25 | }
26 |
27 | public void SetFile(FileInfo file)
28 | {
29 | files["file"] = file;
30 | }
31 |
32 | public void SetBase64(String base64)
33 | {
34 | parameters["body"] = base64;
35 | }
36 |
37 | public void SetRows(int rows)
38 | {
39 | parameters["recaptcharows"] = Convert.ToString(rows);
40 | }
41 |
42 | public void SetCols(int cols)
43 | {
44 | parameters["recaptchacols"] = Convert.ToString(cols);
45 | }
46 |
47 | public void SetPreviousId(int previousId)
48 | {
49 | parameters["previousID"] = Convert.ToString(previousId);
50 | }
51 |
52 | public void SetCanSkip(bool canSkip)
53 | {
54 | parameters["can_no_answer"] = canSkip ? "1" : "0";
55 | }
56 |
57 | public void SetLang(String lang)
58 | {
59 | parameters["lang"] = lang;
60 | }
61 |
62 | public void SetHintText(String hintText)
63 | {
64 | parameters["textinstructions"] = hintText;
65 | }
66 |
67 | public void SetHintImg(String base64)
68 | {
69 | parameters["imginstructions"] = base64;
70 | }
71 |
72 | public void SetHintImg(FileInfo hintImg)
73 | {
74 | files["imginstructions"] = hintImg;
75 | }
76 | }
77 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/HCaptcha.cs:
--------------------------------------------------------------------------------
1 | namespace TwoCaptcha.Captcha
2 | {
3 | public class HCaptcha : Captcha
4 | {
5 | public HCaptcha() : base()
6 | {
7 | parameters["method"] = "hcaptcha";
8 | }
9 |
10 | public void SetSiteKey(string siteKey)
11 | {
12 | parameters["sitekey"] = siteKey;
13 | }
14 |
15 | public void SetUrl(string url)
16 | {
17 | parameters["pageurl"] = url;
18 | }
19 |
20 | public void SetData(string data)
21 | {
22 | parameters["data"] = data;
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/KeyCaptcha.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TwoCaptcha.Captcha
4 | {
5 | public class KeyCaptcha : Captcha
6 | {
7 | public KeyCaptcha() : base()
8 | {
9 | parameters["method"] = "keycaptcha";
10 | }
11 |
12 | public void SetUserId(int userId)
13 | {
14 | SetUserId(Convert.ToString(userId));
15 | }
16 |
17 | public void SetUserId(string userId)
18 | {
19 | parameters["s_s_c_user_id"] = userId;
20 | }
21 |
22 | public void SetSessionId(string sessionId)
23 | {
24 | parameters["s_s_c_session_id"] = sessionId;
25 | }
26 |
27 | public void SetWebServerSign(string sign)
28 | {
29 | parameters["s_s_c_web_server_sign"] = sign;
30 | }
31 |
32 | public void SetWebServerSign2(string sign)
33 | {
34 | parameters["s_s_c_web_server_sign2"] = sign;
35 | }
36 |
37 | public void SetUrl(string url)
38 | {
39 | parameters["pageurl"] = url;
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/Lemin.cs:
--------------------------------------------------------------------------------
1 | namespace TwoCaptcha.Captcha
2 | {
3 | public class Lemin : Captcha
4 | {
5 | public Lemin() : base()
6 | {
7 | parameters["method"] = "lemin";
8 | }
9 |
10 | public void SetCaptchaId(string captchaid)
11 | {
12 | parameters["captcha_id"] = captchaid;
13 | }
14 |
15 | public void SetUrl(string url)
16 | {
17 | parameters["pageurl"] = url;
18 | }
19 |
20 | public void SetApiServer(string apiServer)
21 | {
22 | parameters["api_server"] = apiServer;
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/MTCaptcha.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace TwoCaptcha.Captcha
3 | {
4 | public class MTCaptcha : Captcha
5 | {
6 | public MTCaptcha() : base()
7 | {
8 | parameters["method"] = "mt_captcha";
9 | }
10 |
11 | public void SetPageUrl(string url)
12 | {
13 | parameters["pageurl"] = url;
14 | }
15 |
16 | public void SetSiteKey(string siteKey)
17 | {
18 | parameters["sitekey"] = siteKey;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/Normal.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace TwoCaptcha.Captcha
5 | {
6 | public class Normal : Captcha
7 | {
8 | public Normal() : base()
9 | {
10 | }
11 |
12 | public Normal(String filePath) : this(new FileInfo(filePath))
13 | {
14 | }
15 |
16 | public Normal(FileInfo file) : this()
17 | {
18 | SetFile(file);
19 | }
20 |
21 | public void SetFile(string filePath)
22 | {
23 | SetFile(new FileInfo(filePath));
24 | }
25 |
26 | public void SetFile(FileInfo file)
27 | {
28 | files["file"] = file;
29 | }
30 |
31 | public void SetBase64(String base64)
32 | {
33 | parameters["body"] = base64;
34 | }
35 |
36 | public void SetPhrase(bool phrase)
37 | {
38 | parameters["phrase"] = phrase ? "1" : "0";
39 | }
40 |
41 | public void SetCaseSensitive(bool caseSensitive)
42 | {
43 | parameters["regsense"] = caseSensitive ? "1" : "0";
44 | }
45 |
46 | public void SetCalc(bool calc)
47 | {
48 | parameters["calc"] = calc ? "1" : "0";
49 | }
50 |
51 | public void SetNumeric(int numeric)
52 | {
53 | parameters["numeric"] = Convert.ToString(numeric);
54 | }
55 |
56 | public void SetMinLen(int length)
57 | {
58 | parameters["min_len"] = Convert.ToString(length);
59 | }
60 |
61 | public void SetMaxLen(int length)
62 | {
63 | parameters["max_len"] = Convert.ToString(length);
64 | }
65 |
66 | public void SetLang(String lang)
67 | {
68 | parameters["lang"] = lang;
69 | }
70 |
71 | public void SetHintText(String hintText)
72 | {
73 | parameters["textinstructions"] = hintText;
74 | }
75 |
76 | public void SetHintImg(String base64)
77 | {
78 | parameters["imginstructions"] = base64;
79 | }
80 |
81 | public void SetHintImg(FileInfo hintImg)
82 | {
83 | files["imginstructions"] = hintImg;
84 | }
85 | }
86 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/ReCaptcha.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TwoCaptcha.Captcha
4 | {
5 | public class ReCaptcha : Captcha
6 | {
7 | public ReCaptcha() : base()
8 | {
9 | parameters["method"] = "userrecaptcha";
10 | }
11 |
12 | public void SetSiteKey(string siteKey)
13 | {
14 | parameters["googlekey"] = siteKey;
15 | }
16 |
17 | public void SetUrl(string url)
18 | {
19 | parameters["pageurl"] = url;
20 | }
21 |
22 | public void SetInvisible(bool invisible)
23 | {
24 | parameters["invisible"] = invisible ? "1" : "0";
25 | }
26 |
27 | public void SetVersion(string version)
28 | {
29 | parameters["version"] = version;
30 | }
31 |
32 | public void SetAction(string action)
33 | {
34 | parameters["action"] = action;
35 | }
36 |
37 | public void SetDomain(string domain)
38 | {
39 | parameters["domain"] = domain;
40 | }
41 |
42 | public void SetScore(double score)
43 | {
44 | parameters["min_score"] = Convert.ToString(score).Replace(',', '.');
45 | }
46 |
47 | public void SetEnterprise(bool invisible)
48 | {
49 | parameters["enterprise"] = invisible ? "1" : "0";
50 | }
51 |
52 | public void SetDataS(string data)
53 | {
54 | parameters["data-s"] = data;
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/Rotate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 |
5 | namespace TwoCaptcha.Captcha
6 | {
7 | public class Rotate : Captcha
8 | {
9 | public Rotate() : base()
10 | {
11 | parameters["method"] = "rotatecaptcha";
12 | }
13 |
14 |
15 | public void SetBase64(String base64)
16 | {
17 | parameters["body"] = base64;
18 | }
19 |
20 | public void SetAngle(double angle)
21 | {
22 | parameters["angle"] = Convert.ToString(angle).Replace(',', '.');
23 | }
24 |
25 | public void SetLang(String lang)
26 | {
27 | parameters["lang"] = lang;
28 | }
29 |
30 | public void SetHintText(String hintText)
31 | {
32 | parameters["textinstructions"] = hintText;
33 | }
34 |
35 | public void SetHintImg(String base64)
36 | {
37 | parameters["imginstructions"] = base64;
38 | }
39 |
40 | public void SetHintImg(FileInfo hintImg)
41 | {
42 | files["imginstructions"] = hintImg;
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/Tencent.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace TwoCaptcha.Captcha
3 | {
4 | public class Tencent : Captcha
5 | {
6 | public Tencent() : base()
7 | {
8 | parameters["method"] = "tencent";
9 | }
10 |
11 | public void SetPageUrl(string url)
12 | {
13 | parameters["pageurl"] = url;
14 | }
15 |
16 | public void SetAppId(string appId)
17 | {
18 | parameters["app_id"] = appId;
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/Text.cs:
--------------------------------------------------------------------------------
1 | namespace TwoCaptcha.Captcha
2 | {
3 | public class Text : Captcha
4 | {
5 | public Text() : base()
6 | {
7 | parameters["method"] = "post";
8 | }
9 |
10 | public Text(string text) : this()
11 | {
12 | SetText(text);
13 | }
14 |
15 | public void SetText(string text)
16 | {
17 | parameters["textcaptcha"] = text;
18 | }
19 |
20 | public void SetLang(string lang)
21 | {
22 | parameters["lang"] = lang;
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/Turnstile.cs:
--------------------------------------------------------------------------------
1 | namespace TwoCaptcha.Captcha
2 | {
3 | public class Turnstile : Captcha
4 | {
5 | public Turnstile() : base()
6 | {
7 | parameters["method"] = "turnstile";
8 | }
9 |
10 | public void SetSiteKey(string siteKey)
11 | {
12 | parameters["sitekey"] = siteKey;
13 | }
14 |
15 | public void SetUrl(string url)
16 | {
17 | parameters["pageurl"] = url;
18 | }
19 |
20 | public void SetAction(string action)
21 | {
22 | parameters["action"] = action;
23 | }
24 | public void SetData(string data)
25 | {
26 | parameters["data"] = data;
27 | }
28 | public void SetPageData(string pagedata)
29 | {
30 | parameters["pagedata"] = pagedata;
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Captcha/Yandex.cs:
--------------------------------------------------------------------------------
1 | namespace TwoCaptcha.Captcha
2 | {
3 | public class Yandex : Captcha
4 | {
5 | public Yandex() : base()
6 | {
7 | parameters["method"] = "yandex";
8 | }
9 |
10 | public void SetSiteKey(string siteKey)
11 | {
12 | parameters["sitekey"] = siteKey;
13 | }
14 |
15 | public void SetUrl(string url)
16 | {
17 | parameters["pageurl"] = url;
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Exceptions/ApiException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TwoCaptcha.Exceptions
4 | {
5 | public class ApiException : Exception {
6 |
7 | public ApiException(string message) : base (message) {
8 |
9 | }
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/TwoCaptcha/Exceptions/NetworkException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TwoCaptcha.Exceptions
4 | {
5 | public class NetworkException : Exception {
6 |
7 | public NetworkException(string message) : base (message) {
8 |
9 | }
10 |
11 | }
12 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Exceptions/TimeoutException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TwoCaptcha.Exceptions
4 | {
5 | public class TimeoutException : Exception {
6 |
7 | public TimeoutException(string message) : base (message) {
8 |
9 | }
10 |
11 | }
12 | }
--------------------------------------------------------------------------------
/TwoCaptcha/Exceptions/ValidationException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TwoCaptcha.Exceptions
4 | {
5 | public class ValidationException : Exception {
6 |
7 | public ValidationException(string message) : base (message) {
8 |
9 | }
10 |
11 | }
12 | }
--------------------------------------------------------------------------------
/TwoCaptcha/TwoCaptcha.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Globalization;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 | using TwoCaptcha.Captcha;
8 | using TwoCaptcha.Exceptions;
9 | using TimeoutException = TwoCaptcha.Exceptions.TimeoutException;
10 |
11 | namespace TwoCaptcha
12 | {
13 | public class TwoCaptcha
14 | {
15 | /**
16 | * API KEY
17 | */
18 | public string ApiKey { get; set; }
19 |
20 | /**
21 | * ID of software developer. Developers who integrated their software
22 | * with our service get reward: 10% of spendings of their software users.
23 | */
24 | public int SoftId { get; set; } = 4582;
25 |
26 | /**
27 | * URL to which the result will be sent
28 | */
29 | public string Callback { get; set; }
30 |
31 | /**
32 | * How long should wait for captcha result (in seconds)
33 | */
34 | public int DefaultTimeout { get; set; } = 120;
35 |
36 | /**
37 | * How long should wait for recaptcha result (in seconds)
38 | */
39 | public int RecaptchaTimeout { get; set; } = 600;
40 |
41 | /**
42 | * How often do requests to `/res.php` should be made
43 | * in order to check if a result is ready (in seconds)
44 | */
45 | public int PollingInterval { get; set; } = 10;
46 |
47 | /**
48 | * Helps to understand if there is need of waiting
49 | * for result or not (because callback was used)
50 | */
51 | private bool lastCaptchaHasCallback;
52 |
53 | /**
54 | * Network client
55 | */
56 | private ApiClient apiClient;
57 |
58 | /**
59 | * TwoCaptcha constructor
60 | */
61 | public TwoCaptcha()
62 | {
63 | apiClient = new ApiClient();
64 | }
65 |
66 | /**
67 | * TwoCaptcha constructor
68 | *
69 | * @param apiKey
70 | */
71 | public TwoCaptcha(string apiKey) : this()
72 | {
73 | ApiKey = apiKey;
74 | }
75 |
76 | /**
77 | * @param apiClient
78 | */
79 | public void SetApiClient(ApiClient apiClient)
80 | {
81 | this.apiClient = apiClient;
82 | }
83 |
84 | /**
85 | * Sends captcha to `/in.php` and waits for it's result.
86 | * This helper can be used instead of manual using of `send` and `getResult` functions.
87 | *
88 | * @param captcha
89 | * @throws Exception
90 | */
91 | public async Task Solve(Captcha.Captcha captcha)
92 | {
93 | var waitOptions = new Dictionary();
94 |
95 | if (captcha.GetType() == typeof(ReCaptcha))
96 | {
97 | waitOptions["timeout"] = RecaptchaTimeout;
98 | }
99 |
100 | await Solve(captcha, waitOptions);
101 | }
102 |
103 | /**
104 | * Sends captcha to `/in.php` and waits for it's result.
105 | * This helper can be used instead of manual using of `send` and `getResult` functions.
106 | *
107 | * @param captcha
108 | * @param waitOptions
109 | * @throws Exception
110 | */
111 | public async Task Solve(Captcha.Captcha captcha, Dictionary waitOptions)
112 | {
113 | captcha.Id = await Send(captcha);
114 |
115 | if (!lastCaptchaHasCallback)
116 | {
117 | await WaitForResult(captcha, waitOptions);
118 | }
119 | }
120 |
121 | /**
122 | * This helper waits for captcha result, and when result is ready, returns it
123 | *
124 | * @param captcha
125 | * @param waitOptions
126 | * @throws Exception
127 | */
128 | public async Task WaitForResult(Captcha.Captcha captcha, Dictionary waitOptions)
129 | {
130 | long startedAt = CurrentTime();
131 |
132 | int timeout = waitOptions.TryGetValue("timeout", out timeout) ? timeout : DefaultTimeout;
133 | int pollingInterval = waitOptions.TryGetValue("pollingInterval", out pollingInterval)
134 | ? pollingInterval
135 | : PollingInterval;
136 |
137 | while (true)
138 | {
139 | long now = CurrentTime();
140 |
141 | if (now - startedAt < timeout)
142 | {
143 | await Task.Delay(pollingInterval * 1000).ConfigureAwait(false);
144 | }
145 | else
146 | {
147 | break;
148 | }
149 |
150 | try
151 | {
152 | string result = await GetResult(captcha.Id);
153 | if (result != null)
154 | {
155 | captcha.Code = result;
156 | return;
157 | }
158 | }
159 | catch (NetworkException)
160 | {
161 | // ignore network errors
162 | }
163 | }
164 |
165 | throw new TimeoutException("Timeout " + timeout + " seconds reached");
166 | }
167 |
168 | private long CurrentTime()
169 | {
170 | return Convert.ToInt64((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds);
171 | }
172 |
173 | /**
174 | * Sends captcha to '/in.php', and returns its `id`
175 | *
176 | * @param captcha
177 | * @return
178 | * @throws Exception
179 | */
180 | public async Task Send(Captcha.Captcha captcha)
181 | {
182 | var parameters = captcha.GetParameters();
183 | var files = captcha.GetFiles();
184 |
185 | SendAttachDefaultParameters(parameters);
186 |
187 | ValidateFiles(files);
188 |
189 | string response = await apiClient.In(parameters, files);
190 |
191 | if (!response.StartsWith("OK|"))
192 | {
193 | throw new ApiException("Cannot recognise api response (" + response + ")");
194 | }
195 |
196 | return response.Substring(3);
197 | }
198 |
199 | /**
200 | * Returns result of captcha if it was solved or `null`, if result is not ready
201 | *
202 | * @param id
203 | * @return
204 | * @throws Exception
205 | */
206 | public async Task GetResult(String id)
207 | {
208 | var parameters = new Dictionary();
209 | parameters["action"] = "get";
210 | parameters["id"] = id;
211 |
212 | string response = await Res(parameters);
213 |
214 | if (response.Equals("CAPCHA_NOT_READY"))
215 | {
216 | return null;
217 | }
218 |
219 | if (!response.StartsWith("OK|"))
220 | {
221 | throw new ApiException("Cannot recognise api response (" + response + ")");
222 | }
223 |
224 | return response.Substring(3);
225 | }
226 |
227 | /**
228 | * Gets account's balance
229 | *
230 | * @return
231 | * @throws Exception
232 | */
233 | public async Task Balance()
234 | {
235 | string response = await Res("getbalance");
236 | return double.Parse(response, NumberStyles.Any, CultureInfo.InvariantCulture);
237 | }
238 |
239 | /**
240 | * Reports if captcha was solved correctly (sends `reportbad` or `reportgood` to `/res.php`)
241 | *
242 | * @param id
243 | * @param correct
244 | * @throws Exception
245 | */
246 | public async Task Report(string id, bool correct)
247 | {
248 | var parameters = new Dictionary();
249 | parameters["id"] = id;
250 |
251 | if (correct)
252 | {
253 | parameters["action"] = "reportgood";
254 | }
255 | else
256 | {
257 | parameters["action"] = "reportbad";
258 | }
259 |
260 | await Res(parameters);
261 | }
262 |
263 | /**
264 | * Makes request to `/res.php`
265 | *
266 | * @param action
267 | * @return
268 | * @throws Exception
269 | */
270 | private async Task Res(string action)
271 | {
272 | var parameters = new Dictionary();
273 | parameters["action"] = action;
274 | return await Res(parameters);
275 | }
276 |
277 | /**
278 | * Makes request to `/res.php`
279 | *
280 | * @param params
281 | * @return
282 | * @throws Exception
283 | */
284 | private async Task Res(Dictionary parameters)
285 | {
286 | parameters["key"] = ApiKey;
287 | return await apiClient.Res(parameters);
288 | }
289 |
290 | /**
291 | * Attaches default parameters to request
292 | *
293 | * @param params
294 | */
295 | private void SendAttachDefaultParameters(Dictionary parameters)
296 | {
297 | parameters["key"] = ApiKey;
298 |
299 | if (Callback != null)
300 | {
301 | if (!parameters.ContainsKey("pingback"))
302 | {
303 | parameters["pingback"] = Callback;
304 | }
305 | else if (parameters["pingback"].Length == 0)
306 | {
307 | parameters.Remove("pingback");
308 | }
309 | }
310 |
311 | lastCaptchaHasCallback = parameters.ContainsKey("pingback");
312 |
313 | if (SoftId != 0 && !parameters.ContainsKey("soft_id"))
314 | {
315 | parameters["soft_id"] = Convert.ToString(SoftId);
316 | }
317 | }
318 |
319 | /**
320 | * Validates if files parameters are correct
321 | *
322 | * @param files
323 | * @throws ValidationException
324 | */
325 | private void ValidateFiles(Dictionary files)
326 | {
327 | foreach (KeyValuePair entry in files)
328 | {
329 | FileInfo file = entry.Value;
330 |
331 | if (!file.Exists)
332 | {
333 | throw new ValidationException("File not found: " + file.FullName);
334 | }
335 | }
336 | }
337 | }
338 | }
--------------------------------------------------------------------------------
/TwoCaptcha/TwoCaptcha.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | 2captcha-csharp
4 | 1.4.0
5 | README.md
6 | 2captcha
7 | 2captcha
8 | C# library for easy integration with the API of 2captcha captcha solving service to bypass recaptcha, funcaptcha, geetest and solve any other captchas.
9 | 2Captcha;Captcha;reCAPTCHA;CAPTCHA solving;CAPTCHA bypass;C#;.NET;API;Image Recognition;Audio CAPTCHA;Solve CAPTCHA;Anti-bot;CAPTCHA service;CAPTCHA SDK
10 |
11 |
12 | netcoreapp3.1;net5.0;net6.0;net7.0
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------