@2captcha/captcha-solver 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 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.
package/README.md ADDED
@@ -0,0 +1,451 @@
1
+ <b>[English](README.md)</b> (recommended) | [中国语文科](README.zh.md) | [Русский](README.ru.md)
2
+
3
+
4
+ # JavaScript Module for 2Captcha API
5
+
6
+ ## Description
7
+ A wrapper around the [2captcha](https://2captcha.com/) API. This wrapper support reCAPTCHA V2, reCAPTCHA V3, hCaptcha, Arkose Labs FunCaptcha, image captcha, Coordinates (Click Captcha), Geetest, Geetest V4, Yandex Smart Captcha, Lemin captcha, Amazon WAF, Cloudflare Turnstile, Capy Puzzle, DataDome CAPTCHA, CyberSiARA, MTCaptcha, Friendly Captcha.
8
+
9
+ Also added support for the `bounding_box` method. The Bounding Box Method allows you to mark data on the image. This method can be used to mark up datasets or highlight any objects in an image according to the given instructions. Read more about using *Bounding Box Method* on [documentation](https://2captcha.com/2captcha-api#bounding_box).
10
+
11
+ [2captcha](https://2captcha.com/) is a service that solves many different types of captchas, this library serves as a wrapper around API 2captcha to bring easy, promise-based functionality to NodeJS. This library specializes in concurrent solves, and bulk-api usage.
12
+
13
+ - [Install](#install)
14
+ - [Configuration](#configuration)
15
+ - [Solve captcha](#solve-captcha)
16
+ - [reCAPTCHA v2](#recaptcha-v2)
17
+ - [reCAPTCHA v3](#recaptcha-v3)
18
+ - [hCaptcha](#hcaptcha)
19
+ - [Arkose Labs FunCaptcha](#arkose-labs-funcaptcha)
20
+ - [Image captchas](#image-captcha) (`base64` format)
21
+ - [GeeTest](#geetest-captcha)
22
+ - [GeeTest V4](#geetest-v4-captcha)
23
+ - [Yandex Smart Captcha](#yandex-smart-captcha)
24
+ - [Lemin Cropped Captcha](#lemin-captcha)
25
+ - [Cloudflare Turnstile](#cloudflare-turnstile)
26
+ - [Amazon WAF Captcha](#amazon-waf-captcha)
27
+ - [Capy Puzzle](#capy-puzzle)
28
+ - [Coordinates (Click Captcha)](#coordinates-captcha)
29
+ - [DataDome CAPTCHA](#datadome-captcha)
30
+ - [CyberSiARA](#cybersiara)
31
+ - [MTCaptcha](#mtcaptcha)
32
+ - [Friendly Captcha](#friendly-captcha)
33
+ - [Bounding Box Method](#bounding-box-method)
34
+ - [Usage of proxy](#usage-of-proxy)
35
+ - [Other methods](#other-methods)
36
+ - [badReport](#badreport)
37
+ - [goodReport](#goodreport)
38
+ - [balance](#balance)
39
+ - [Useful articles](#useful-articles)
40
+ - [How to bypass Geetest v4 CAPTCHA](https://2captcha.com/blog/geetest-v4-support)
41
+ - [Automatic reCAPTCHA V3 resolution - a tutorial for developers and customers](https://2captcha.com/blog/recaptcha-v3-automatic-resolution)
42
+ - Finding Sitekey <a href="./docs/hcaptcha.md">hCaptcha</a>
43
+
44
+
45
+ ## Install
46
+
47
+ ```sh
48
+ npm install @2captcha/captcha-solver
49
+ ```
50
+ or
51
+ ```sh
52
+ yarn add @2captcha/captcha-solver
53
+ ```
54
+
55
+ ## Configuration
56
+
57
+ Instance can be created like this:
58
+
59
+ ```js
60
+ const Captcha = require("@2captcha/captcha-solver")
61
+ const solver = new Captcha.Solver("<Your 2captcha api key>")
62
+ ```
63
+
64
+ ## Solve captcha
65
+
66
+ ### reCAPTCHA V2
67
+
68
+ Use this method to solve reCAPTCHA V2 and obtain a token to bypass the protection.
69
+
70
+ ```js
71
+ solver.recaptcha({
72
+ pageurl: 'https://2captcha.com/demo/recaptcha-v2',
73
+ googlekey: '6LfD3PIbAAAAAJs_eEHvoOl75_83eXSqpPSRFJ_u'
74
+ })
75
+ .then((res) => {
76
+ console.log(res);
77
+ })
78
+ .catch((err) => {
79
+ console.log(err);
80
+ })
81
+ ```
82
+
83
+ ### reCAPTCHA V3
84
+
85
+ This method provides reCAPTCHA V3 solver and returns a token.
86
+
87
+ ```js
88
+ solver.recaptcha({
89
+ pageurl: 'https://2captcha.com/demo/recaptcha-v3',
90
+ googlekey: '6Lcyqq8oAAAAAJE7eVJ3aZp_hnJcI6LgGdYD8lge',
91
+ version: "v3",
92
+ min_score: "0.4",
93
+ action: 'demo_action'
94
+ })
95
+ .then((res) => {
96
+ console.log(res);
97
+ })
98
+ .catch((err) => {
99
+ console.log(err);
100
+ })
101
+ ```
102
+
103
+
104
+ ### hCaptcha
105
+
106
+ Use this method to solve hCaptcha challenge. Returns a token to bypass captcha.
107
+
108
+ ```js
109
+ solver.hcaptcha({
110
+ pageurl: "https://2captcha.com/demo/hcaptcha?difficulty=moderate",
111
+ sitekey: "b76cd927-d266-4cfb-a328-3b03ae07ded6"
112
+ })
113
+ .then((res) => {
114
+ console.log(res);
115
+ })
116
+ .catch((err) => {
117
+ console.log(err);
118
+ })
119
+ ```
120
+
121
+ ### Arkose Labs FunCaptcha
122
+
123
+ FunCaptcha (Arkoselabs) solving method. Returns a token.
124
+
125
+ ```js
126
+ solver.funCaptcha({
127
+ pageurl: "https://funcaptcha.com/tile-game-lite-mode/fc/api/nojs/?pkey=804380F4-6844-FFA1-ED4E-5877CA1F1EA4&lang=en",
128
+ publickey: "804380F4-6844-FFA1-ED4E-5877CA1F1EA4"
129
+ })
130
+ .then((res) => {
131
+ console.log(res);
132
+ })
133
+ .catch((err) => {
134
+ console.log(err);
135
+ })
136
+ ```
137
+
138
+ ### Image captcha
139
+
140
+ To bypass a normal captcha (distorted text on image) use this method. This method also can be used to recognize any text on the image.
141
+
142
+ ```js
143
+ // Read from a file as base64 text
144
+ const imageBase64 = fs.readFileSync("./tests/media/imageCaptcha_6e584.png", "base64")
145
+
146
+ solver.imageCaptcha({
147
+ body: imageBase64,
148
+ numeric: 4,
149
+ min_len: 5,
150
+ max_len: 5
151
+ })
152
+ .then((res) => {
153
+ // Logs the image text
154
+ console.log(res);
155
+ })
156
+ .catch((err) => {
157
+ console.log(err);
158
+ })
159
+ ```
160
+
161
+
162
+ ### GeeTest Captcha
163
+
164
+ Method to solve GeeTest puzzle captcha. Returns a set of tokens as JSON.
165
+
166
+ ```js
167
+ // Read more about `challenge` on the page https://2captcha.com/p/geetest
168
+ solver.geetest({
169
+ pageurl: 'https://2captcha.com/demo/geetest',
170
+ gt: '81388ea1fc187e0c335c0a8907ff2625',
171
+ challenge: '<you need to get a new challenge value each time>'
172
+ })
173
+ .then((res) => {
174
+ console.log(res);
175
+ })
176
+ .catch((err) => {
177
+ console.log(err);
178
+ })
179
+ ```
180
+
181
+ ### GeeTest V4 Captcha
182
+
183
+ Method to solve GeeTest V4 puzzle captcha. Returns a set of tokens as JSON.
184
+
185
+ ```js
186
+ solver.geetestV4({
187
+ pageurl: 'https://2captcha.com/demo/geetest-v4',
188
+ captcha_id: 'e392e1d7fd421dc63325744d5a2b9c73'
189
+ })
190
+ .then((res) => {
191
+ console.log(res);
192
+ })
193
+ .catch((err) => {
194
+ console.log(err);
195
+ })
196
+ ```
197
+
198
+ ### Yandex Smart Captcha
199
+
200
+ Use this method to solve Yandex and obtain a token to bypass the protection.
201
+
202
+ ```js
203
+ solver.yandexSmart({
204
+ pageurl: "https://captcha-api.yandex.ru/demo",
205
+ sitekey: "FEXfAbHQsToo97VidNVk3j4dC74nGW1DgdxjtNB9"
206
+ })
207
+ .then((res) => {
208
+ console.log(res);
209
+ })
210
+ .catch((err) => {
211
+ console.log(err);
212
+ })
213
+ ```
214
+
215
+ ### Lemin captcha
216
+
217
+ Use this method to solve Lemin and obtain a token to bypass the protection.
218
+
219
+ ```js
220
+ solver.lemin({
221
+ pageurl:'https://2captcha.com/demo/lemin',
222
+ captcha_id: 'CROPPED_3dfdd5c_d1872b526b794d83ba3b365eb15a200b',
223
+ div_id: 'lemin-cropped-captcha',
224
+ api_server: 'api.leminnow.com'
225
+ })
226
+ .then((res) => {
227
+ console.log(res);
228
+ })
229
+ .catch((err) => {
230
+ console.log(err);
231
+ })
232
+ ```
233
+
234
+ ### Cloudflare Turnstile
235
+
236
+ Use this method to solve Turnstile and obtain a token to bypass the protection.
237
+
238
+ ```js
239
+ solver.cloudflareTurnstile({
240
+ pageurl: "https://app.nodecraft.com/login",
241
+ sitekey: "0x4AAAAAAAAkg0s3VIOD10y4"
242
+ })
243
+ .then((res) => {
244
+ console.log(res);
245
+ })
246
+ .catch((err) => {
247
+ console.log(err);
248
+ })
249
+ ```
250
+
251
+ <h3 id="amazon-waf-captcha">Amazon WAF Captcha (AWS WAF):</h3>
252
+
253
+ Use this method to solve AmazonWaf and obtain a token to bypass the protection.
254
+
255
+ ```js
256
+ //INFO: The `context` value is dynamic, it is necessary to take the actual value from the page each time.
257
+ solver.amazonWaf({
258
+ pageurl: "https://non-existent-example.execute-api.us-east-1.amazonaws.com/latest",
259
+ sitekey: "AQIDAHjcYu/GjX+QlghicBgQ/7bFaQZ+m5FKCMDnO+vTbNg96AHMDLodoefdvyOnsHMRt...",
260
+ context: "9BUgmlm48F92WUoqv97a49ZuEJJ50TCk9MVr3C7WMtQ0X6flVbufM4n8mjFLmbLVAPgaQ...",
261
+ iv: "CgAHbCe2GgAAAAAj",
262
+ })
263
+ .then((res) => {
264
+ console.log(res);
265
+ })
266
+ .catch((err) => {
267
+ console.log(err);
268
+ })
269
+ ```
270
+
271
+ ### Capy Puzzle
272
+
273
+ Token-based method to bypass Capy puzzle captcha.
274
+
275
+ ```js
276
+ solver.capyPuzzle({
277
+ pageurl: "https://www.capy.me/account/register/",
278
+ captchakey: "PUZZLE_Cme4hZLjuZRMYC3uh14C52D3uNms5w"
279
+ })
280
+ .then((res) => {
281
+ console.log(res);
282
+ })
283
+ .catch((err) => {
284
+ console.log(err);
285
+ })
286
+ ```
287
+
288
+ ### DataDome CAPTCHA
289
+
290
+ Use this method to solve DataDome and obtain a token to bypass the protection.
291
+
292
+ > [!IMPORTANT]
293
+ > To solve the DataDome captcha, you must use a proxy. It is recommended to use mobile residential proxies.
294
+
295
+ ```js
296
+ solver.dataDome({
297
+ pageurl: "https://rendezvousparis.hermes.com/client/register",
298
+ captcha_url: "https://geo.captcha-delivery.com/captcha/?initialCid=AHrlqAAAAAMAEuQtkf4k1c0ABZhYZA%3D%3D&hash=789361B674144528D0B7EE76B35826&cid=mY4z7GNmh7Nt1lAFwpbNHAOcWPhyPgjHD2K1Pm~Od1iEKYLUnK3t7N2ZGUj8OqDK65cnwJHtHwd~t902vlwpSBA5l4ZHbS1Qszv~jEuEUJNQ_jMAjar2Kj3kq20MRJYh&t=fe&referer=https%3A%2F%2Frendezvousparis.hermes.com%2Fclient%2Fregister&s=40119&e=67fef144ac1a54dbd7507776367d2f9d5e36ec3add17fa22f3cb881db8385838",
299
+ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36",
300
+ proxy: "login:password@1.2.3.4:8888", // The (Username : Password @ Address : Port) of our chosen proxy
301
+ proxytype: "http" // The 'Type' of proxy, http, https, socks, ect.
302
+ })
303
+ .then((res) => {
304
+ console.log(res);
305
+ })
306
+ .catch((err) => {
307
+ console.log(err);
308
+ })
309
+ ```
310
+
311
+ ### CyberSiARA
312
+
313
+ Use this method to solve CyberSiARA and obtain a token to bypass the protection.
314
+
315
+ ```js
316
+ solver.cyberSiARA({
317
+ pageurl: "https://www.cybersiara.com/book-a-demo",
318
+ master_url_id: "OXR2LVNvCuXykkZbB8KZIfh162sNT8S2",
319
+ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36"
320
+ })
321
+ .then((res) => {
322
+ console.log(res);
323
+ })
324
+ .catch((err) => {
325
+ console.log(err);
326
+ })
327
+ ```
328
+
329
+ ### MTCaptcha
330
+
331
+ Use this method to solve MTCaptcha and obtain a token to bypass the protection.
332
+
333
+ ```js
334
+ solver.mtCaptcha({
335
+ pageurl: "https://service.mtcaptcha.com/mtcv1/demo/index.html",
336
+ sitekey: "MTPublic-DemoKey9M"
337
+ })
338
+ .then((res) => {
339
+ console.log(res);
340
+ })
341
+ .catch((err) => {
342
+ console.log(err);
343
+ })
344
+ ```
345
+
346
+ ### Friendly Captcha
347
+
348
+ Use this method to solve Friendly Captcha and obtain a token to bypass the protection.
349
+ > **Important:** 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.
350
+
351
+ ```js
352
+ solver.friendlyCaptcha({
353
+ pageurl: "https://geizhals.de/?liftban=1&from=/455973138?fsean=5901747021356",
354
+ sitekey: "FCMST5VUMCBOCGQ9"
355
+ })
356
+ .then((res) => {
357
+ console.log(res);
358
+ })
359
+ .catch((err) => {
360
+ console.log(err);
361
+ })
362
+ ```
363
+
364
+ <h3 id="coordinates-captcha">Coordinates (Click Captcha):</h3>
365
+
366
+ ClickCaptcha method returns coordinates of points on captcha image. Can be used if you need to click on particular points on the image.
367
+
368
+ ```js
369
+ const imageBase64 = fs.readFileSync("./tests/media/hCaptchaImage.jpg", "base64")
370
+
371
+ solver.coordinates({
372
+ body: imageBase64,
373
+ textinstructions: 'Select all photos containing the boat'
374
+ })
375
+ .then((res) => {
376
+ console.log(res);
377
+ })
378
+ .catch((err) => {
379
+ console.log(err);
380
+ })
381
+ ```
382
+
383
+ ### Bounding Box Method:
384
+
385
+ Bounding Box Method allows you to select objects specified in the image. To do this, you need to pass markup instructions. The instructions can be sent as text or as an image encoded in `base64` format. It is mandatory to pass at least one instruction `imginstructions` or `textinstructions`.
386
+
387
+ ```js
388
+ solver.boundingBox({
389
+ image: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAR4AAACwCAIAAAB...",
390
+ textinstructions: "Circle all the cars in the image.",
391
+ })
392
+ .then((res) => {
393
+ console.log(res);
394
+ })
395
+ .catch((err) => {
396
+ console.log(err);
397
+ })
398
+ ```
399
+
400
+ ### Usage of proxy
401
+
402
+ Solving reCAPTCHA V2 whis a proxy, code example:
403
+
404
+ ```js
405
+ solver.recaptcha({
406
+ pageurl: 'https://2captcha.com/demo/recaptcha-v2',
407
+ googlekey: '6LfD3PIbAAAAAJs_eEHvoOl75_83eXSqpPSRFJ_u',
408
+ proxy: "login:password@1.2.3.4:8888", // The (Username : Password @ Address : Port) of our chosen proxy
409
+ proxytype: "http" // The 'Type' of proxy, http, https, socks4, socks5.
410
+ })
411
+ .then((res) => {
412
+ console.log(res)
413
+ })
414
+ .catch((err) => {
415
+ console.error(err.message)
416
+ })
417
+ ```
418
+
419
+ ## Other methods
420
+
421
+ ### goodReport
422
+
423
+ Use this method to report good captcha answer.
424
+
425
+ ```js
426
+ solver.goodReport('7031846604')
427
+ ```
428
+
429
+ ### badReport
430
+
431
+ Use this method to report bad captcha answer.
432
+
433
+ ```js
434
+ solver.badReport('7031854546')
435
+ ```
436
+
437
+ ### balance
438
+
439
+ Use this method to get your account's balance
440
+
441
+ ```js
442
+ solver.balance()
443
+ .then((res) => {
444
+ console.log(res)
445
+ })
446
+ ```
447
+
448
+ ## Useful articles
449
+ * [How to bypass Geetest v4 CAPTCHA](https://2captcha.com/blog/geetest-v4-support)
450
+ * [Automatic reCAPTCHA V3 resolution - a tutorial for developers and customers](https://2captcha.com/blog/recaptcha-v3-automatic-resolution)
451
+ * Finding Sitekey <a href="./docs/hcaptcha.md">hCaptcha</a>