transitive-bullshit / agentic

AI agent stdlib that works with any LLM and TypeScript AI SDK.
https://agentic.so
MIT License
16.27k stars 2.13k forks source link

Thoughts on using Google to bypass reCAPTCHA/hCAPTCHA? #115

Closed saltcute closed 1 year ago

saltcute commented 1 year ago

By login using Google, the only thing that requires user operations appears to be the 2-step verification from Google, and this can be done away using your smart phone.

Or is it going to be detected by Google after a few tries?

Like this:

...
await page.goto('https://chat.openai.com/auth/login')
await page.waitForSelector('#__next .btn-primary', { timeout })
await delay(1000)
try {
    if (email && password) {
        await Promise.all([
            page.click('#__next .btn-primary'),
            page.waitForNavigation({
                waitUntil: 'networkidle0'
            })
        ])
        await page.waitForSelector('button[data-provider="google"]', { timeout });
        await page.click('button[data-provider="google"]');
        await page.waitForNavigation({
            waitUntil: 'networkidle0'
        })
        await page.type('input[type="email"]', email, { delay: 50 })
        await page.keyboard.press("Enter");
        await delay(3000);
        await page.keyboard.type(password, { delay: 50 });
        await page.keyboard.press("Enter");
    }
} catch (err) {
    await browser.close();
    throw err;
}
await page.waitForSelector("items-center");
...
transitive-bullshit commented 1 year ago

I definitely like the idea; probably needs more testing since I'm pretty sure that captchas will show up unexpectedly depending on a very opaque "riskiness score" that Cloudflare associates with a combination of your IP / browser / access patterns / etc.

Even if you don't get a captcha when testing locally, it can still show up at some point if you get flagged.

saltcute commented 1 year ago

So just found that Microsoft doesn't even need a 2-step verification, so the login process is automated if CloudFlare does not kick in and requires captcha. Still, not sure about how this will work after a few logins.

marcorizza commented 1 year ago

Does using this 'puppeteer-extra-plugin-recaptcha' module even though it is paid for make sense because it is too difficult to bypass this problem in other ways, or is it better to think of a free solution?

transitive-bullshit commented 1 year ago

The captcha plugin may be the way to go; I've been traveling so haven't had a chance to really investigate properly.

transitive-bullshit commented 1 year ago

Captcha and/or "ChatGPT is at capacity" screen can appear before you even get to the login screen, and I've also seen them both afterwards.

747745124 commented 1 year ago

I saw reCaptcha before logging in while running through the example, probably Google or Microsoft authentication can be the way to go?

transitive-bullshit commented 1 year ago

Does using this 'puppeteer-extra-plugin-recaptcha' module even though it is paid for make sense because it is too difficult to bypass this problem in other ways, or is it better to think of a free solution?

I've tried it and it's not detecting the recaptchas properly. The plugin doesn't seem to be maintained very well.

marcorizza commented 1 year ago

I still don't understand why, but if anyone has any ideas, please tell me. I've tried making two projects one javascript and one typescript, they both work fine, the only problem I've noticed and I can't figure out why is that in this part of the code:

await page.waitForSelector("#username");
await page.type("#username", email, { delay: 20 });
await delay(100);
if (hasRecaptchaPlugin) {
    const res = await page.solveRecaptchas();
}
await page.click('button[type="submit"]');
await page.waitForSelector("#password", { timeout: timeoutMs });
await page.type("#password", password, { delay: 10 });
submitP = () => page.click('button[type="submit"]');

the line where const res = await page.solveRecaptchas(); is present is not waited for and the process goes on and it always fails because it takes a few seconds before it finishes and so it doesn't solve the captcha. This problem only happens if I run the project in typescript

transitive-bullshit commented 1 year ago

@marcorizza is it working for you in JS?

This may be due to https://github.com/berstend/puppeteer-extra/pull/758 in the TS version or some other related bug with puppeteer-extra-plugin-recaptcha

transitive-bullshit commented 1 year ago

The latest release added support for CAPTCHA automation which may help some folks in this thread. Note that this is a major version bump as it contains breaking changes to the core APIs, so check the docs carefully before upgrading: https://github.com/transitive-bullshit/chatgpt-api/releases/tag/v3.0.0

marcorizza commented 1 year ago

@marcorizza is it working for you in JS?

This may be due to berstend/puppeteer-extra#758 in the TS version or some other related bug with puppeteer-extra-plugin-recaptcha

only in js, in a ts project it does not work for me.

transitive-bullshit commented 1 year ago

Confirming that Google is the way to go to fully bypass CAPTCHAs.

So if you don't want to use a CAPTCHA service, you can use Google logins which will receive much less frequent CAPTCHAs and afaik no Recaptchas, which are the really painful ones.

transitive-bullshit commented 1 year ago

TODO: I still need to add something to the readme explaining all of the CAPTCHA considerations.