example

mail@pastecode.io avatar
unknown
javascript
2 years ago
3.8 kB
3
Indexable
Never
const puppeteer = require("puppeteer-extra");
const StealthPlugin = require("puppeteer-extra-plugin-stealth");
puppeteer.use(StealthPlugin());
const delay = require("delay");
const fs = require("fs");
const exec = require("child_process").exec;

(async () => {
    const email = "gidhan@dikitin.com";
    console.log(`[+] Email: ${email}`);

    const options = { waitUntil: "networkidle2" };
    const browser = await puppeteer.launch({
        headless: false,
        args: ["--disable-popup-blocking", "--allow-popups-during-page-unload"],
    });
    const page = await browser.newPage();

    let pages = await browser.pages();
    await pages[0].close();

    await page.setUserAgent(
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3419.0 Safari/537.36"
    );

    await page.goto("https://accounts.binance.me/en/register", options);

    const emailField = await page.$("input[name=email]");
    await emailField.type(email);
    await emailField.dispose();

    const passwordField = await page.$("input[name=password]");
    await passwordField.type("Anjay123@");
    await passwordField.dispose();
    await delay(2000);

    await page.click("#click-registration-submit");

    let originalImage = "";
    await Slider(page, originalImage);

    await page.waitForSelector("div[class=css-1s58o4v]", {
        visible: true,
        timeout: 0,
    });

    fs.unlinkSync("./captcha.png");
    fs.unlinkSync("./captcha-0.png");
    fs.unlinkSync("./captcha-1.png");

    console.log("[+] Captcha bypassed!");
})();

async function Slider(page, originalImage) {
    await page.setRequestInterception(true);
    page.on("request", (request) => request.continue().catch(async (e) => {}));
    page.on("response", async (response) => {
        if (response.request().url().includes("image/antibot/image/SLIDE/")) {
            originalImage = await response.buffer().catch(() => {});
        }
    });

    await page.waitForSelector(".verify-slider.css-13rz4tr", { visibe: true, timeout: 60000 });

    await page.waitForSelector(".css-p72bjc", { visibe: true, timeout: 5000 });
    const sliderHandler = await page.$(".css-p72bjc");
    const handler = await sliderHandler.boundingBox();

    fs.writeFileSync("captcha.png", originalImage, "binary");

    exec(
        "magick compare -metric RMSE -subimage-search captcha.png base.png captcha.png",
        async (error, stdout, stderr) => {
            const x = error.toString().split("@")[error.toString().split("@").length - 1].trim().split(",")[0];

            await page.mouse.move(handler.x, handler.y);
            await page.mouse.down();
            const valueData = parseInt(x) - 89;
            let currentPosition = 0;

            for (let index = 0; index < valueData; index++) {
                await page.mouse.move(handler.x + currentPosition, handler.y);
                currentPosition = index;
            }
            await page.mouse.move(handler.x + currentPosition, handler.y, { steps: 10 });
            await page.mouse.up();

            await delay(3000);
            const accept = await page.evaluate(() => {
                return !!document.querySelector('a[class="css-xwod86"]');
            });

            if (!accept) {
                const head = await page.evaluate(() => {
                    return !!document.querySelector('div[class="css-aa8ouv"]');
                });
                if (head) {
                    await page.click("svg[class=css-9z3u57]");
                    await delay(2000);
                    return Slider(page, originalImage);
                }
            } else {
                await page.click("svg[class=css-9z3u57]");
                await delay(2000);
                return Slider(page, originalImage);
            }
        }
    );
}