ultrafunkamsterdam / undetected-chromedriver

Custom Selenium Chromedriver | Zero-Config | Passes ALL bot mitigation systems (like Distil / Imperva/ Datadadome / CloudFlare IUAM)
https://github.com/UltrafunkAmsterdam/undetected-chromedriver
GNU General Public License v3.0
9.15k stars 1.1k forks source link

Personal CF workaround [Doesn't work headless] #1501

Open A-Gebrel opened 10 months ago

A-Gebrel commented 10 months ago

I already saw couple of other solutions Like #1497 by @mdmintz but that meant I would need to rewrite most of my code and use another library (seleniumbase)

Approach

Example code:

# imports and whatnot
driver = uc.Chrome()
driver.get('https://duckduckgo.com')
time.sleep(5)
pyautogui.keyDown('ctrl')
pyautogui.press('t')
pyautogui.keyUp('ctrl') # basically sends CTRL+T to open new tab
pyautogui.write('https://nowsecure') # write up site link
time.sleep(1)
pyautogui.press('enter') # visit
time.sleep(10)
# extra step if you need to press the CF captcha box and pray you don't get a challenge
pyautogui.press('tab')
pyautogui.press('space')
time.sleep(10)
pyautogui.keyDown('ctrl')
pyautogui.press('w')
pyautogui.keyUp('ctrl') # close the tab
driver.get('https://nowsecure')
time.sleep(10)
driver.save_screenshot('nowsecure.png')
driver.quit()
# that should be it

Result: nowsecure

Note:

Avnsx commented 10 months ago

This is not a bypass, you're just simply clicking it and there's better ways to even do that, then just pressing tab and space lol. When speaking of a bypass, people are usually referring to the cloudflare captcha to either not exist in first place or literally be automatically solved.

A-Gebrel commented 10 months ago

This is not a bypass, you're just simply clicking it and there's better ways to even do that, then just pressing tab and space lol. When speaking of a bypass, people are usually referring to the cloudflare captcha to either not exist in first place or literally be automatically solved.

this definitely isn't meant as "enterprise-level" bypass but I agree, I should have named it a "workaround" instead.

or literally be automatically solved

which this does so.. goal achieved?

Avnsx commented 10 months ago

which this does so.. goal achieved?

automatically as in you don't even need any 3rd party code to have it solve itself, you just navigate to the site and it automatically confirms you're not an "automated session", visually you see the green checkmark insantly appearing

A-Gebrel commented 10 months ago

automatically as in you don't even need any 3rd party code to have it solve itself, you just navigate to the site and it automatically confirms you're not an "automated session", visually you see the green checkmark insantly appearing

Understandable, that's the original goal of UC-chromedriver, which is unfortunately hasn't been working the past couple of days.

As I said, this is just a temporary solution until UC-chromedriver, hopefully, receives an update that resolves this issue. Again, nobody is forcing you to use this or any other "workaround" or "bypass" you can find but personally, I would rather use this temporary solution (and I'm sure plenty of others as well) and hope for an update soon rather than having to rewrite code with another library.

Can I rewrite? sure Considering I'm only using this for a personal project, Do I want to rewrite it anytime soon? hell no.

yanxiang-wang commented 10 months ago

Can this be used in the docker? I am curious.

A-Gebrel commented 10 months ago

Can this be used in the docker? I am curious.

Un-tested. I recently rewrote my code in SeleniumBase and it's working great so far, I would suggest doing that rather than follow my workaround.

It's more consistent for me and headless finally works again, no more pop-ups.

lihanchen commented 10 months ago

I think the latest cloudflare "i am human" checkbox cannot be clicked with space or enter, with pyautogui or real key press. I can only click by mouse

lihanchen commented 10 months ago

OK. I confirm that I can skip cloudflare checkbox by using pyautogui mouseclick. pyautogui.moveTo(115, 465) pyautogui.click() I have to hardcoded the checkbox position. Couldn't find a way to calculate it.

A-Gebrel commented 10 months ago

OK. I confirm that I can skip cloudflare checkbox by using pyautogui mouseclick. pyautogui.moveTo(115, 465) pyautogui.click() I have to hardcoded the checkbox position. Couldn't find a way to calculate it.

Pressing TAB > SPACE worked for me, like almost always. (with Selenium, with UC when it was broken and whenever I get one that I have to do manually)