1

I want to connect to a site with Webdriver, but cloudflare challenge(not hcaptcha) detects selenium as a bot and doesnt pass me through the Cloudflare challenge.

I have used these flags and many similar flags in my code, but I have not been able to bypass yet.

    ChromeOptions options=new ChromeOptions();
    options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
    options.setExperimentalOption("useAutomationExtension", false);
    options.addArguments("--disable-blink-features");
    options.addArguments("--disable-blink-features=AutomationControlled");
    System.setProperty("webdriver.chrome.driver", "drivers/chromedriver.exe");
    driver = new ChromeDriver(options);

My chrome version 104.0.5112.81 and chrome driver version is 104.0.5112.79

How can I bypass Cloudflare?

Selman
  • 15
  • 1
  • 4

1 Answers1

1

To bypass cloudflare you need a high score here https://antcpt.com/score_detector/ (green) , this is for reCaptcha but is relevant for cloudflare too i think. Here are some things other that flags you want to try:

  1. Do not use a VPN or TOR , VPN if its paid it can be good but if you use TOR the last node is always public (i am not sure about that , but you cant bypass cloudflare if you use tor)
  2. I dont see in your code if you are changing user agent... i used selenium_stealth in python to change user agent , renderer and such
 stealth(driver,
            languages=["en-US", "en"],
            vendor="Google Inc.",
            platform="Win32",
            webgl_vendor="Intel Inc.",
            renderer="Intel Iris OpenGL Engine",
            fix_hairline=True,
            )

here is another link to test your driver on https://intoli.com/blog/making-chrome-headless-undetectable/chrome-headless-test.html (there was one with more features but i dont remember the link...)

__ 3. You probably would need to use an existing profile , so it doesnt seem like you are a bot , your current one with a lot of cookies and other data would be good (i am not sure if this actually works , but when in practice it seemed for me that it helped) here is a link to how to load one... How to load default profile in Chrome using Python Selenium Webdriver?

__ 4. Remove the flag from chromedriver.exe $cdc_

__ 5. Probably check this too Can a website detect when you are using Selenium with chromedriver?

Also note that bypassing cloudflare too much will worsen your score if the website will detect bot behaviour.

  • 1
    yes adding a profile solves the problem. But it's not a permanent solution. Because it can't always bypass. For example, when I turn the computer off and then on, it detects me as a bot again because the data is cleared. But after a while, doesn't see selenium as a bot. – Selman Aug 07 '22 at 13:15
  • Thats because the website detects the automated queries... maybe try adding wait between them ( i add one based on how fast the website loads ) , or click on random elements like text so it doesnt look so bot-like... i dont know about data deleting when you restart the pc @Selman – S.T.A.L.K.E.R Aug 07 '22 at 19:17