Open SPYNARY opened 5 months ago
Here the piece of code who archieve this :
var mtcaptchaConfig = {
"sitekey": "MTPublic-6dZ4hzZ6U",
"theme": "chrome" ,
"lang": "fr",
"loadAnimation": "false",
"verified-callback": function(state) {
if (state.isVerified) {
$('#captchaToken').val(state.verifiedToken);
$('.btn-submit-vote').removeAttr('title').removeAttr('disabled');
}
}
};
(function(){var mt_service = document.createElement('script');mt_service.async = true;mt_service.src = 'https://service.mtcaptcha.com/mtcv1/client/mtcaptcha.min.js';(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(mt_service);
var mt_service2 = document.createElement('script');mt_service2.async = true;mt_service2.src = 'https://service2.mtcaptcha.com/mtcv1/client/mtcaptcha2.min.js';(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(mt_service2);}) ();
@SPYNARY Could you tell me the address of the page with the captcha, and the algorithm for how to get it?
Sure here it is :
I tried some manipulation and i think it may be possible to trick the page because the verification seem to be done on the client side
Here the piece of code who archieve this :
var mtcaptchaConfig = { "sitekey": "MTPublic-6dZ4hzZ6U", "theme": "chrome" , "lang": "fr", "loadAnimation": "false", "verified-callback": function(state) { if (state.isVerified) { $('#captchaToken').val(state.verifiedToken); $('.btn-submit-vote').removeAttr('title').removeAttr('disabled'); } } }; (function(){var mt_service = document.createElement('script');mt_service.async = true;mt_service.src = 'https://service.mtcaptcha.com/mtcv1/client/mtcaptcha.min.js';(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(mt_service); var mt_service2 = document.createElement('script');mt_service2.async = true;mt_service2.src = 'https://service2.mtcaptcha.com/mtcv1/client/mtcaptcha2.min.js';(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(mt_service2);}) ();
And if you want to fidn this you have to type sitekey in dev tool element
I also found in mtcaptcha documentation the mentionned part :
I also had an issue with your package idk why but it was returning an unsolvable error so i built my own using v2 api :
async function waitForTaskCompletion(clientKey, taskId) {
while (true) {
try {
const res = await axios.post("https://api.2captcha.com/getTaskResult", {
"clientKey": clientKey,
"taskId": taskId
});
if (res.data.status === "ready") {
console.log('Solution found');
return res.data.solution;
} else if (res.data.status === "processing") {
console.log('In process, retry');
await new Promise(resolve => setTimeout(resolve, 5000));
} else {
console.log('Solution search failed');
throw new Error(`Error ${res.data.errorId}: ${res.data.errorDescription}`);
}
} catch (error) {
throw error;
}
}
}
const res = await axios.post("https://api.2captcha.com/createTask", {
"clientKey": "",
"task": {
"type": "MtCaptchaTaskProxyless",
"websiteURL": "https://top-serveurs.net/rdr/vote/last-red-line",
"websiteKey": mtCaptchaKey
}
});
const solution = await waitForTaskCompletion('', res.data.taskId);
const captchaAnswer = solution.token;
@SPYNARY Hi.
I checked the MTcaptcha solution on this site using 2captcha-ts
, the captcha is solved in the service, the 2captcha service returns the token, but the site not accepts the token using the code described in this repository.
Sites can add additional protection methods, such as callback
functions, or something else. In order to correctly use the token, it is necessary to figure out how the token is used on this site.
@SPYNARY The easiest way is to use a different method of solving the captcha. Try using the Normal captcha method. To do this, you just need to take a screenshot of the captcha task and send it to the service, then the service will return the text from the image to you. After that, you will only have to enter the text in the text field. And then click on the required button.
Since the text in the task is case-sensitive, it is advisable to send an additional parameter case: true
:
Okay perfect thank's a lot, that blow my mind since 1 day XD
@SPYNARY Hi again, I made a simple demo, it works for me, but apparently you also need to use a proxy, since the number of votes is tied to the ip.
Demo:
import puppeteer from "puppeteer";
import { Solver } from "2captcha-ts";
const solver = new Solver("you_2captcha_api_key");
const sleep = (ms) => new Promise((res) => setTimeout(res, ms));
(async () => {
const browser = await puppeteer.launch({
headless: false,
devtools: true
});
const [page] = await browser.pages();
await page.setViewport({ width: 1080, height: 1024 });
// Open target page that contains MTCaptcha.
await page.goto("https://top-serveurs.net/rdr/vote/last-red-line");
// show sometimes, depends on ip
// await page.waitForSelector(".fc-consent-root");
// await page.waitForSelector(".fc-cta-consent .fc-button-label");
// await page.click('.fc-cta-consent .fc-button-label')
await page.type('#playername', 'user3d3dd')
await page.waitForSelector("#mtcaptcha-iframe-1");
// Getting the frame
const iframeElementHandle = await page.$("#mtcaptcha-iframe-1");
const iframe = await iframeElementHandle.contentFrame();
// Wait
await sleep(2000);
// Grab captcha image(`base64`)
const captcha = await iframe.evaluate(() => {
console.log(document.querySelector('.mtcap-image img'))
const captcha = document.querySelector('.mtcap-image img').src
console.log(captcha)
return captcha
});
// Wait
await sleep(3000)
// console.log(captcha)
// solve image captcha
const res = await solver.imageCaptcha({
body: captcha,
regsense: 1
});
console.log("Answer:");
console.log(res);
const frameHandle = await page.$("#mtcaptcha-iframe-1");
const frame = await frameHandle.contentFrame();
await frame.click('#mtcap-inputtext-1')
// type captcha answer
await frame.type('#mtcap-inputtext-1', res.data)
await sleep(3000)
// click submit btn
await page.click('button[type="submit"]')
})();
@SPYNARY Please check or this method works for you.
It work, thanks ;)
Hi, im facing an issue who block your code to submit the solution token, i have try multiple way to avoid this but the issue persist.
The thing is that the submit button of the website is enabled only when the MTCaptcha is completed by typing the right code, but when the code solve it using the solution token it doesn't enable this button , i have tried to remove the disabled attribute of the buton but i still get the error 'Please fill the captcha correctly'