расшифровать изображение base64 captcha, пожалуйста, помогите

dokleat

Новичок
Регистрация
05.06.2022
Сообщения
1
Благодарностей
0
Баллы
1
Привет, меня зовут Доклеат, и я здесь новый участник. Я пытаюсь сделать скрипт Tampermonkey, который будет решать капчу посольства Германии. Вот ссылка на систему записи в посольство Германии:

https://service2.diplo.de/rktermin/extern/appointment_showMonth.do?locationCode=pris&realmId=362&categoryId=591

Итак, прежде всего, вам нужно написать первую капчу, чтобы войти в форму заполнения системы. Вот ссылка на то, как выглядит форма заполнения записи:


Как видите, капча находится в формате base64, и я пытаюсь использовать сервер AzCaptcha для решения таких капч. Я сделал код, но он у меня вообще не работает. Вот код, который я написал:

// ==UserScript==
// @name Syrnia Botcheck Bot
// @namespace http://github.com/Makeshift
// @author PatchworkTiger
// @include https://service2.diplo.de/*
// @version 0.7
// @description Bots the unbottable botcheck
// @grant GM_log
// @grant GM_xmlhttpRequest
// ==/UserScript==
//Configs
//Safetimes

//GlobalVariables
apikey = "mnzdtpmln3x6wj8yrhcrvfwjvqpgkb92";
var imgsrc = document.querySelector("#appointment_captcha_month > div:nth-child(1) > captcha");
var base64 = getBase64Image(imgsrc);
sendToAPI(base64);

//Convert to base64
function getBase64Image(img) {
var canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);
var dataURL = canvas.toDataURL("image/jpeg", 0.5);
return dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
}

function sendToAPI(base64) {
base64 = encodeURIComponent(base64);
GM_xmlhttpRequest({
method: "POST",
url: "http://azcaptcha.com/in.php",
data: "method=base64&key=" + apikey + "&body=" + base64,
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
onload: function(response) {
var responseString = response.responseText;
GM_log("Debug(Send): " + responseString);
if (responseString == "ERROR_WRONG_USER_KEY" || responseString == "ERROR_KEY_DOES_NOT_EXIST" || responseString == "ERROR_ZERO_BALANCE" || responseString == "ERROR_ZERO_CAPTCHA_FILESIZE" || responseString == "ERROR_TOO_BIG_CAPTCHA_FILESIZE" || responseString == "ERROR_WRONG_FILE_EXTENSION" || responseString == "ERROR_IMAGE_TYPE_NOT_SUPPORTED") {
userLog("There has been a pretty severe error:" + responseString + ", you should disable the plugin and report this.", "error");
throw new Error("Stopping execution");
} else if (responseString == "ERROR_IP_NOT_ALLOWED" || responseString == "IP_BANNED") {
userLog("For some reason your IP has been banned from the service. You should disable the plugin and report this.", "error");
throw new Error("Stopping execution");
} else if (responseString == "ERROR_NO_SLOT_AVAILABLE") {
userLog("The server is at maximum capacity, we are resubmitting in 15s.", "warning");
} else {
userLog("Captcha sent, awaiting response", "success"); //Should really if this to deal with other responses sooner
setTimeout(parseResponse, 15000, responseString);
}
}
});
}
}
function parseResponse(prevResponse) {
var captchaID = prevResponse.split("|");
GM_xmlhttpRequest({
method: "GET",
url: "http://azcaptcha.com/res.php?key=" + apikey + "&action=get&id=" + captchaID[1],
onload: function(response) {
var getResponse = response.responseText;
if (getResponse == "CAPCHA_NOT_READY" || getResponse == "CAPTCHA_NOT_READY") {
userLog("Captcha is not ready yet. Let's wait 10 seconds", "warning");
captchaID = null;
setTimeout(parseResponse, 10000, prevResponse);
//Deal with errors
} else if (getResponse == "ERROR_KEY_DOES_NOT_EXIST" || getResponse == "ERROR_WRONG_ID_FORMAT") {
userLog("Fatal error! We have to quit out of the script. The error was: " + getResponse, "error");
throw new Error("Stopping execution");
} else if (getResponse == "ERROR_WRONG_CAPTCHA_ID") {
userLog("Our ID is wrong, so the server is probably having issues. Wait 15s and attempting resubmit.", "warning");
setTimeout(checkBotcheck, 15000);
} else if (getResponse == "ERROR_CAPTCHA_UNSOLVABLE") {
userLog("Server thought the captcha was unsolvable, so we're going to resend it.", "warning");
setTimeout(checkBotcheck, 5000);
} else {
GM_log("Debug(Response): " + getResponse);
//Assuming we're all good
var captchaArray = getResponse.split("|");
var captchaAnswer = captchaArray[1];
submitToCaptcha(captchaAnswer);
count++;
setTimeout(userLog, 3000, "We think the botcheck is: " + captchaAnswer + ". We are going to wait 15 seconds to see if it was. We have attempted to solve " + count + " botchecks (including retries).", "success");
setTimeout(15000);
}
}
});

}

function submitToCaptcha(answer) {
var botInputField = document.getElementById('appointment_captcha_month_captchaText');
botInputField.value = answer;
}
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)