I am trying to bypass funcaptcha using 2captcha api

Viewed 1730

I have been trying to bypass the captcha but all efforts in vain. I don't know which function triger and thus it move forward as there is no submit button on the website. So it only moves forward to show Challenge completed screen when someone do solve it manually.

I am stuck on injecting token. Please Guide me what to do next because i am noob in javascript here is few javascript functions which i thnk are cause of all this. Please tell me how to trigger a callback function so it moves to next page. or Complete the Funcaptcha.

Thanks

var loadedCheck = 0;
function getAllUrlParams(e) {
    var t = e ? e.split("?")[1] : window.location.search.slice(1),
        a = {};
    if (t)
        for (var n = (t = t.split("#")[0]).split("&"), i = 0; i < n.length; i++) {
            var o = n[i].split("="),
                s = o[0],
                r = void 0 === o[1] || o[1];
            if (((s = s.toLowerCase()), "string" == typeof r && (r = r.toLowerCase()), s.match(/\[(\d+)?\]$/))) {
                var l = s.replace(/\[(\d+)?\]/, "");
                if ((a[l] || (a[l] = []), s.match(/\[\d+\]$/))) {
                    var c = /\[(\d+)\]/.exec(s)[1];
                    a[l][c] = r;
                } else a[l].push(r);
            } else a[s] ? (a[s] && "string" == typeof a[s] ? ((a[s] = [a[s]]), a[s].push(r)) : a[s].push(r)) : (a[s] = r);
        }
    return a;
}
function loadArkose() {
    var e = getAllUrlParams(window.location.href);
    "xbox_1" === e.uitheme
        ? navigator.__defineGetter__("userAgent", function () {
              return "Xbox_Dark";
          })
        : "xbox_2" === e.uitheme
        ? navigator.__defineGetter__("userAgent", function () {
              return "Xbox_Light";
          })
        : "win8wiz" === e.uitheme &&
          navigator.__defineGetter__("userAgent", function () {
              return "Win8Wiz";
          });
    var t = window.location.pathname.split("/"),
        a = new ArkoseEnforcement({
            public_key: t[1],
            language: e.mkt,
            target_html: "arkose",
            callback: function () {
                parent.postMessage(JSON.stringify({ eventId: "challenge-complete", payload: { sessionToken: a.getSessionToken() } }), "*");
            },
            loaded_callback: function () {
                (frameHeight = document.getElementById("fc-iframe-wrap").offsetHeight),
                    (frameWidth = document.getElementById("fc-iframe-wrap").offsetWidth),
                    "xbox_1" === e.uitheme || "xbox_2" === e.uitheme ? a.enableDirectionalInput() : e.uitheme,
                    parent.postMessage(JSON.stringify({ eventId: "challenge-loaded", payload: { sessionToken: a.getSessionToken(), frameHeight: frameHeight, frameWidth: frameWidth } }), "*"),
                    (loadedCheck = 1);
            },
            onsuppress: function () {
                parent.postMessage(JSON.stringify({ eventId: "challenge-suppressed", payload: { sessionToken: a.getSessionToken() } }), "*");
            },
            onshown: function () {
                parent.postMessage(JSON.stringify({ eventId: "challenge-shown", payload: { sessionToken: a.getSessionToken() } }), "*");
            },
        });
}
window.addEventListener("message", function (e) {
    try {
        JSON.parse(e.data);
    } catch (e) {
        return;
    }
    var t = JSON.parse(e.data);
    switch (t.eventId) {
        case "challenge-left":
        case "challenge-right":
        case "challenge-down":
        case "challenge-up":
        case "challenge-proceed":
            window.dispatchEvent(new CustomEvent("FunCaptcha-action", { detail: { action: t.payload.action } }));
    }
});
var interval = setInterval(function () {
    (frameHeight = document.getElementById("fc-iframe-wrap").offsetHeight),
        (frameWidth = document.getElementById("fc-iframe-wrap").offsetWidth),
        1 == loadedCheck && parent.postMessage(JSON.stringify({ eventId: "challenge-iframeSize", payload: { frameHeight: frameHeight, frameWidth: frameWidth } }), "*");
}, 3e3);

1 Answers

Well After trying alot i was unable to find solution but then suddenly anti-captcha api Services updated there extension.

So this method worked for me.

  1. Get Registered on anti-captcha.com and get api

  2. Download Extension from this page Download and set name anticaptcha

  3. add extension to your selenium code through this code snippet.

      co = Options()
      co.add_extension(os.path.abspath('anticaptcha.crx'))
      driver = webdriver.Chrome(options=co)
    
  4. Now define function which will in inject api key into the extension.

    def acp_api_send_request(driver, message_type, data={}):
         message = {
             'receiver': 'antiCaptchaPlugin',
             # request type, for example setOptions
             'type': message_type,
             # merge with additional data
             **data
             }
    
    
              return driver.execute_script("""
              return window.postMessage({});
              """.format(json.dumps(message)))
    
  5. Now Before Going to load a website where you want to solve captcha first load any website just so api can be injected properly. call this above function like this. replace your api key with Your_API_KEY_HERE text.

       acp_api_send_request(
            driver,
            'setOptions',
            {'options': {'antiCaptchaApiKey': 
            'Your_API_KEY_HERE'}}
    
        )
    
  6. Everthing is perfect now just when captcha will load the script will automatically detect it and solve it and submit the form.

happy coding..

Related