Skip to content

Commit

Permalink
Support 2Captcha.com and solving all issues and tested on 8/16/2022.
Browse files Browse the repository at this point in the history
Issues:
#1
#4
#8
#10
#11
  • Loading branch information
masterking32 committed Aug 16, 2022
1 parent 3fce615 commit 586e84f
Show file tree
Hide file tree
Showing 5 changed files with 238 additions and 90 deletions.
20 changes: 0 additions & 20 deletions anti-captcha.js

This file was deleted.

119 changes: 103 additions & 16 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ const fs = require('fs');
const axios = require('axios');
const {generateRandomCredentials} = require('./utils');
const {getEmail, waitFirstMail} = require('./trash-mail');
const {solveFunCaptcha} = require('./anti-captcha');
const readline = require("readline");
const ac = require("@antiadmin/anticaptchaofficial");
const { isFunction } = require('util');

// Get API Key from Anti-Captcha.com or 2Captcha.com.
const Anti_Captcha_KEY = 'YOUR anti-captcha.com API KEY';
const Token_2CAPTCHA = 'YOUR 2captcha.com API KEY';

const CLIENT_ID = 'kimne78kx3ncx6brgo4mv6wki5h1ko';
const funcaptchaSignupPublicKey = 'E5554D43-23CC-1982-971D-6A2262A2CA24';
Expand All @@ -17,15 +22,73 @@ const rl = readline.createInterface({
output: process.stdout
});

const solveArkoseCaptcha = async () => {
ac.setAPIKey(Anti_Captcha_KEY);
ac.settings.funcaptchaApiJSSubdomain = 'twitch-api.arkoselabs.com';
ac.setSoftId(1034);

const API_2Captcha_Validate = async (requestID) => {
await new Promise(r => setTimeout(r, 2000));
let URL = "http://2captcha.com/res.php?key=" + Token_2CAPTCHA + "&action=get&id=" + requestID + "&json=1";
response = await axios.get(URL);
if(response.data.status == 0)
{
if(response.data.request == 'ERROR_CAPTCHA_UNSOLVABLE')
{
console.log('ERROR_CAPTCHA_UNSOLVABLE');
return false;
}
return await API_2Captcha_Validate(requestID);
} else {
// console.log(response.data);
return response.data.request;
}
};

const API_2Captcha_Request = async () => {
let URL = "http://2captcha.com/in.php?key=" + Token_2CAPTCHA + "&method=funcaptcha&publickey=" + funcaptchaSignupPublicKey + "&surl=https://twitch-api.arkoselabs.com&pageurl=https://www.twitch.tv/signup&json=1";
response = await axios.get(URL);
try{
return await solveFunCaptcha(
'https://www.twitch.tv/signup',
funcaptchaSignupPublicKey,
);
if(response.data.status == 1) {
console.log("Request sent to the 2captcha wait a bit, Request ID: " + response.data.request);
console.log("Wating to reslove ... (15 - 300 sec)");
let validate_resp = await API_2Captcha_Validate(response.data.request);
if (validate_resp == false) {
console.log("Starting new funcaptcha.");
return await API_2Captcha_Request();
}
return validate_resp;
} else {
console.log("Something is wrong with 2Captcha, Check your 2Captcha API Key.");
return await API_2Captcha_Request();
}
} catch (e) {
return await solveArkoseCaptcha();
console.log("Something is wrong with 2Captcha, Check your 2Captcha API Key!" + e);
return await API_2Captcha_Request();
}
}

// function replaceAll(str, find, replace) {
// return str.replace(new RegExp(find, 'g'), replace);
// }

const solveArkoseCaptcha = async () => {
let captcha = null;
ac.solveFunCaptchaProxyless('https://www.twitch.tv/signup', funcaptchaSignupPublicKey)
.then(token => {
// console.log('response: '+token);
// token = replaceAll(token, 'funcaptcha.com', 'client-api.arkoselabs.com');
// token = replaceAll(token, 'funcaptcha.com', 'twitch-api.arkoselabs.com');
// token = token.replace('|pk=','|lang=en|pk=');
// token = replaceAll(token, 'ap-southeast-1', 'eu-west-1');
captcha = token;
})
.catch(error => {console.log('test received error '+error); captcha = false;});

while(captcha == null) {
await new Promise(r => setTimeout(r, 100));
}

return captcha;
};

const generatePayload = async ({username, password, birthday}, email, captchaToken) => {
Expand All @@ -42,6 +105,7 @@ const generatePayload = async ({username, password, birthday}, email, captchaTok

const registerAccount = async payload => {
try {
// console.log(payload);
const response = await axios.post('https://passport.twitch.tv/register', payload);
const headers = response.headers;
let output = {};
Expand All @@ -50,27 +114,50 @@ const registerAccount = async payload => {
return output;
} catch (e) {
console.log(e.response.data.error);
if(e.response.data.error == 'Please complete the CAPTCHA correctly.') {
return 'captcha';
}

return false;
}
};

async function CaptchaAndRegister(credentials, email) {
console.log('Solving captcha');
let captchaToken = '';
if(Anti_Captcha_KEY != 'YOUR anti-captcha.com API KEY') {
console.log('Using anti-captcha.com');
captchaToken = await solveArkoseCaptcha();
} else if(Token_2CAPTCHA != 'YOUR 2captcha.com API KEY') {
console.log("Using 2Captcha.");
captchaToken = await API_2Captcha_Request();
} else {
console.log("Please set your anti-captcha.com API KEY or 2Captcha API KEY.");
return false;
}

console.log('Generating payload');
const payload = await generatePayload(credentials, email, captchaToken);
console.log('Captcha found, registering account ...');
const registerData = await registerAccount(payload);
if(registerData === 'captcha')
{
console.log("Try resolve captcha again");
return await CaptchaAndRegister(credentials, email)
}

return registerData;
}
async function StartCreate(uname) {
const credentials = generateRandomCredentials(uname);
console.log("Username: " + credentials.username + " Password:" + credentials.password + " BDay: " + credentials.birthday.year + "/" + + credentials.birthday.month + "/"+ credentials.birthday.day);
console.log('Getting email');
const email = await getEmail(credentials.username);
console.log('Solving captcha');
const captchaToken = await solveArkoseCaptcha();
console.log('Generating payload');
const payload = await generatePayload(credentials, email, captchaToken);
console.log('Registering account');
const registerData = await registerAccount(payload);
if(registerData === false)
const registerData = await CaptchaAndRegister(credentials, email);
if(registerData == false)
{
// return await StartCreate(uname);
return false;
}

const userId = registerData.userid;
const accessToken = registerData.access_token;
console.log('Wait verification mail');
Expand Down
Loading

0 comments on commit 586e84f

Please sign in to comment.