vvanglro / cf-clearance

Purpose To make a cloudflare v2 challenge pass successfully, Can be use cf_clearance bypassed by cloudflare, However, with the cf_clearance, make sure you use the same IP and UA as when you got it.
https://github.com/vvanglro/cf_clearance
356 stars 59 forks source link

The stealth function is probably not working #9

Closed KohnoseLami closed 1 year ago

KohnoseLami commented 1 year ago

Running this program will load the challenge forever without completing it This is the same behavior as using a detected browser

vvanglro commented 1 year ago

Try the latest.

KohnoseLami commented 1 year ago

Thank you! It has been fixed But it still doesn't work on some pages. Custom pages in Cloudflare Enterprise plans will not work because some elements are different

Examples of non-working sites https://stake.com/

These don't work because the HTML on the challenge page is the original design.

vvanglro commented 1 year ago

Maybe we can add a success condition.

def sync_cf_retry(page: SyncPage, tries: int = 10, wait_until_title: str = None) -> bool:
    success = False
    while tries != 0:
        try:
            title = page.title()
        except Error:
            tries -= 1
            time.sleep(1)
        else:
            if title == 'Please Wait... | Cloudflare':
                raise RecaptchaChallengeException("Encountered recaptcha. Check whether your proxy is an elite proxy.")
            elif title == 'Just a moment...':
                tries -= 1
                time.sleep(2)
            elif "www." in title:
                page.reload()
                tries -= 1
                time.sleep(3)
            else:
                if wait_until_title:
                    if wait_until_title == title:
                        success = True
                        break
                    else:
                        tries -= 1
                        time.sleep(2)
                else:
                    success = True
                    break
    return success
sync_stealth(page)
page.goto('https://stake.com/')
res = sync_cf_retry(page, wait_until_title="Stake.com - Leading Crypto Casino & Sports Betting Platform")
jfb commented 1 year ago

@vvanglro change time.sleep(3) to page.wait_for_timeout(3000) . time.sleep block page.

KohnoseLami commented 1 year ago

@vvanglro change time.sleep(3) to page.wait_for_timeout(3000) . time.sleep block page.

I felt this was a very good idea for me. And as a method of detecting when an IUAM has been completed, I will write here a proposal for various cases If the title or wording of a page changes and stops working, why not get the state of "#challenge-form" in the HTML and wait? I think the challenge itself is probably all the same, even if it's a custom page.

def sync_cf_retry(page: SyncPage, tries=10) -> bool:
    success = False
    while tries != 0:
        if page.query_selector('#challenge-form'):
            tries -= 1
            page.wait_for_timeout(1000)
        else:
            success = True
            break
    return success
vvanglro commented 1 year ago

PR is welcome.

KohnoseLami commented 1 year ago

PR is welcome.

We did. https://github.com/vvanglro/cf-clearance/pull/10 Sorry if I'm wrong because this is my first pull request, I'm new to github

This project is very useful to me.