使用 2captcha 绕过微软唱出验证码“funcaptcha”

问题描述 投票:0回答:1

所以当我发送请求时我得到了结果,然后我尝试注入它并发布和其他一些方法,但没有人工作正常

有什么特殊的方法或者我可能错过的东西吗?

我试图绕过验证码,但我得到了结果,但我不知道如何将其注入或将其发布到验证码的框架中,它只是不响应任何内容...

async function solveFuncaptcha(driver) {
  try {
    console.log("Waiting for first CAPTCHA frame to load...");
    const firstFrame = await driver.wait(
      until.elementLocated(By.css('iframe[id="enforcementFrame"]')),
      30000
    );
    console.log(
      "First CAPTCHA frame detected. Switching to enforcement frame..."
    );
    await driver.switchTo().frame(firstFrame);

    console.log("Waiting for second CAPTCHA frame to load...");
    const secondFrame = await driver.wait(
      until.elementLocated(By.css('iframe[data-e2e="enforcement-frame"]')),
      30000
    );
    console.log("Second CAPTCHA frame detected. Switching to it...");
    await driver.switchTo().frame(secondFrame);

    console.log("Waiting for game core frame to load...");
    const gameCoreFrame = await driver.wait(
      until.elementLocated(By.css('iframe[id="game-core-frame"]')),
      30000
    );
    console.log("Game core frame detected. Extracting public key...");

    const gameCoreFrameSrc = await gameCoreFrame.getAttribute("src");
    const publicKeyMatch = gameCoreFrameSrc.match(/pk=([^&]+)/);

    if (!publicKeyMatch) {
      throw new Error("Unable to find public key in game-core-frame src");
    }

    const publicKey = publicKeyMatch[1];
    console.log("Extracted public key:", publicKey);

    console.log("Switching back to default content...");
    await driver.switchTo().defaultContent();

    console.log("Attempting to solve CAPTCHA with 2captcha...");
    const result = await solver.funCaptcha({
      publickey: publicKey,
      pageurl: await driver.getCurrentUrl(),
      surl: "https://client-api.arkoselabs.com",
    });

    if (!result || !result.data) {
      throw new Error("CAPTCHA solving failed: No result from 2captcha");
    }

    console.log("CAPTCHA solved. Result:", result);

    console.log("Navigating back through the frames to submit the solution...");
    await driver.switchTo().frame(firstFrame);
    await driver.switchTo().frame(secondFrame);

    console.log("Submitting CAPTCHA solution...");
    await driver.executeScript(`
      parent.postMessage(JSON.stringify({
        eventId: "challenge-complete",
        payload: {
          sessionToken: "${result.data}"
        }
      }), "*");
    `);
  } catch (error) {
    console.error("Error solving CAPTCHA:", error.message);
    return false;
  }
}
node.js selenium-webdriver 2captcha
1个回答
0
投票

你解决了吗? 我也找不到从浏览器中的第三个服务提交已解决令牌的方法。 我尝试挂钩所有 funcaptcha 事件(警告、错误、提交),但它们甚至不启动

© www.soinside.com 2019 - 2024. All rights reserved.