Introduction
Hiya! On this tutorial I will likely be displaying tips on how to bypass the captcha recognition course of utilizing a service known as 2Captcha.
What’s 2Captcha?
2Captcha is a service created to automate the captcha recognition course of.
All captchas are acknowledged by people which implies that 2Captcha can recognise all humanly readable kinds of captchas.
In the event you’re like me and generally have bother studying studying the letters and so forth in a captcha, then you may additionally profit from attempting the service out.
I used to be stunned to understand it even handles reCAPTCHA v2. 😎
Getting the 2Captcha API Key
As a way to begin utilizing the service we are going to want an API Key.
First you will have to register an account at:
https://2captcha.com/auth/register
Upon getting created an account merely navigate your browser to following URL and make an observation of your API Key.
https://2captcha.com/setting
Organising the mission
For this instance I will likely be utilizing nodejs.
First we have to create the mission.
npm i -y
Then the necessity to set up the 2captcha module, this may be performed through:
npm i 2captcha
Subsequent we have to create a config file that holds the 2Captcha API key:
mkdir src
Open “src/config.js” and add the next, make certain to interchange the API key with your personal, the API key might be accessed at:
https://2captcha.com/setting
const API_KEY = 'secret';
module.exports = {
API_KEY
}
Utilizing 2Captcha to unravel a easy Captcha
Regular captcha is a picture that incorporates distorted however human-readable textual content. Although generally I am unable to make sense of a number of the letters used. 😅
So let’s attempt utilizing 2Captcha to unravel it.
For this instance I’ll use the next regular captcha picture:
First create the “src/regular.js” file and add the next:
const { Solver } = require('2captcha');
const { readFileSync } = require('fs');
const { API_KEY } = require('./config');
const solver = new Solver(API_KEY);
(async () => {
attempt {
const imageBase64File = await readFileSync('./captcha-image.png', 'base64');
const response = await solver.imageCaptcha(imageBase64File);
console.log(response);
} catch (error) {
console.error(error);
}
})();
The supply itself is fairly easy, we import the 2Captcha module, learn the picture file as Base64 information after which go the info to the 2Captcha module to unravel it.
Subsequent we will attempt working it through:
node src/regular.js
Superb! 😃 Be happy to attempt the pattern with a wide range of pictures.
Utilizing 2Captcha to unravel reCAPTCHA
Subsequent we will attempt utilizing 2Captcha to unravel the extra superior reCAPTCHA. 👀
Personally I all the time have points with the sort of captcha as I all the time appear to be flawed. 😅
For this instance I will likely be utilizing the next web site:
https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox.php
As a way to remedy this captcha we might want to get the sitekey variable, this may be discovered by opening the “Developer Console” and easily filtering the phrase “sitekey” like the next:
Make a remark of this variable as we will likely be needing it.
Subsequent create the “src/recaptcha.js” file and add the next:
const { Solver } = require('2captcha');
const { API_KEY } = require('./config');
const solver = new Solver(API_KEY);
(async () => {
attempt {
const response = await solver.recaptcha(
'6LfW6wATAAAAAHLqO2pb8bDBahxlMxNdo9g947u9',
'https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox.php'
);
console.log(response);
} catch (error) {
console.error(error);
}
})();
Once more the supply may be very easy, this time as an alternative of a picture we simply go the sitekey and the url of the web page to the 2Captcha module.
reCAPTCHA is clearly more durable than a easy picture file so the request my take a while.
If all goes properly you must see the next output:
Superb. 😎
Conclusion
Right here I’ve proven tips on how to use the 2Captcha service to unravel easy and laborious captchas, I used to be amazed at how it may be performed so merely. 👀
Because it’s higher at fixing them higher than me I generally use it for private causes. 😅
I can definetely see one thing like this getting used for automation functions and so forth. 😀
The supply might be discovered right here:
https://github.com/ethand91/2captcha-sample
Like me work? I publish about a wide range of subjects, if you want to see extra please like and observe me.
Additionally I like espresso.