1

我是一个使用 JS 编码的完整菜鸟,需要帮助解决 hCaptcha。

目前有问题的网站是 coinhunt.cc,有两个验证码,我可以解决 reCaptcha,但是使用 hCaptcha 我不知道如何解决这个问题。

当前代码可以解析 reCaptcha(我从 2Captcha 收到令牌,并有一个代码将 myjs 替换为令牌代码):

document.getElementById("g-recaptcha-response").value="myjs"

function excuteCallback(obj, name) {

ret = null;

if (Object.hasOwnProperty(obj, name)) {

ret = Object.getOwnPropertyDescriptor(obj, name).value;

}

if (ret != null) {

return ret;

}

for (var objName in obj) {

var o=obj[objName];

if (o.hasOwnProperty(name)) {

ret = Object.getOwnPropertyDescriptor(o, name).value;

}

if (ret != null) {

return ret;

}

excuteCallback(o, name);

}

}

excuteCallback(window.___grecaptcha_cfg.clients[0], "callback")("myjs");

根据 2Captcha,我需要在 h-captcha-response 和 g-captcha-response 中输入回报,目前我可以通过以下方式执行此操作:

document.getElementsByName("h-captcha-response").value="myjs"
document.getElementsByName("g-recaptcha-response").value="myjs"

但是,当我尝试运行此脚本时,我遇到了错误:

javascript 错误:无法读取未定义的属性“客户”

我不知道回调是否正确,也不知道在哪里可以从该站点获取正确的 hcaptcha 回调,如前所述,我是菜鸟,刚开始学习 JS。

4

1 回答 1

1

我认为您正在寻找 javascript 来解决 Cloudflare 保护网站上的 hCaptcha。如果不是,这段代码应该可以工作。

let frame = document.getElementById("hcaptcha_widget");
frame || (frame = document.getElementById("cf-hcaptcha-container")), t = document.getElementsByName("h-captcha-response"), t[0].innerHTML = "myjs", frame.closest("form").submit();

如果是 cloudflare,他们最近改变了提交解决方案的方式。详细信息:https : //2captcha.com/blog/hcaptcha-cloudflare-en 您可以参考他们的 chrome 扩展代码,该代码成功解决了启用 cloudflare 的网站上的 hcaptcha。因为我也不是 js 程序员,所以我无法导出有效的 js 代码。我认为 2captcha 扩展上的这两种方法是相关的。

function doActionsOnSuccess(msg) {
    debugger;
    let widget = getWidgetInfo(msg.request.captchaType, msg.request.widgetId);
    let processor = CaptchaProcessors.get(msg.request.captchaType);
    processor.onSolved(widget, msg.response.code);

    Config.getAll().then(config => {
        let callback = processor.getCallback(widget);

        if (callback) {
            location.href = `javascript: window["${callback}"]("${msg.response.code}")`;
        }

        if (config.autoSubmitForms === true) {
            let timeout = parseInt(config.submitFormsDelay) * 1000;

            setTimeout(function() {
                processor.getForm(widget).submit();
            }, timeout);
        }
    });
}


onSolved: function(widget, answer) {
    let container = $("#" + widget.containerId);

    container.find("textarea").val(answer);
    container.find("iframe").attr("data-hcaptcha-response", answer);
},
于 2021-08-29T09:53:32.993 回答