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.95k stars 1.16k forks source link

DataDome not bypassed #693

Closed JackDev-cc closed 2 years ago

JackDev-cc commented 2 years ago

Datadome security varies between site, e.g tidal.com and it is being detected.

datadome_undetected_webddriver t

sebdelsol commented 2 years ago

I'm not sure UC is actually detected because I landed on the same ReCaptcha page on my regular Chrome browser the first time I tried this site... So it's more likely my IP was already flagged. Anyway you can use this workaround.

qhjink commented 2 years ago

36343c772977df941818984656292be url:https://www.cma-cgm.com I also have the same problem. When I open the website, it shows that it has been detected. If I open it manually, it doesn't

sebdelsol commented 2 years ago

I also have the same problem. When I open the website, it shows that it has been detected. If I open it manually, it doesn't

I'm not : your IP or whatever fingerprint has been flagged.

JackDev-cc commented 2 years ago

I also have the same problem. When I open the website, it shows that it has been detected. If I open it manually, it doesn't

I'm not : your IP or whatever fingerprint has been flagged.

I can assure you it's detected.

Brand new residential IP, clean browser Tidal loads fine can browse site, spam requests to a degree nothing. Same IP, launch undetected for Tidal instant recaptcha, once IP has been detected then my normal browser also gets it, until I change IP+ clean browser than cycle repeats.

sebdelsol commented 2 years ago

I'm not talking about tidal (I gave you a workaround btw) but I was replying to @qhjink

JackDev-cc commented 2 years ago

I'm not talking about tidal (I gave you a workaround btw) but I was replying to @qhjink

I know, but your workaround has the same issue it isn't a solution, and I mentioned it as the reason he is having his issue is because this repo is 100% detected by others I can repeatedly prove it it's just a matter of time until more detect it they are noticing something.

qhjink commented 2 years ago

I tried to change the IP, but I still couldn't. But I noticed that when I opened the browser with UC, the breakpoint manually visited the website, and the website was normal, using driver.get is abnormal when opening the website.

`` import undetected_chromedriver as uc

options = uc.ChromeOptions()
options.add_argument("--start-maximized")
driver = uc.Chrome(options=options,driver_executable_path= "ChromeDriver.exe",browser_executable_path="Chrome/chrome.exe")

driver.get('https://www.cma-cgm.com')
print("!11")
sebdelsol commented 2 years ago

Saving and reusing the cookies definitely works for me and the relevant ones for datadome have quite long expiry. I'm not sure about the js timings detection because this site doesn't allow several sessions from the same IP, the subsequent one are always served a captcha, so it's hard to know if reconnecting actually works.

sebdelsol commented 2 years ago

This works for me, when you've passed once (no captcha!) you can reuse the cookies and avoid failed retry that'd flagged you. It seems to bypass other bot detection like #684 or #342 that relies on the same JavaScript math ops timings detection trick.

import os
import pickle
from contextlib import contextmanager
from urllib.parse import urlparse

import undetected_chromedriver as uc

# URL = "https://kipling.com.au/"
URL = "https://tidal.com/"

class Chrome(uc.Chrome):
    def no_timings_detection_get(self, url, wait=0):
        self.execute_script(f"location='{url}'; alert();")
        self.switch_to.alert.accept()
        self.reconnect(wait)

@contextmanager
def get_driver():
    driver = Chrome()
    try:
        yield driver
    finally:
        driver.quit()

class Cookies:
    def __init__(self, driver, url):
        self.driver = driver
        self.domain = urlparse(url).netloc
        self.filename = f"{self.domain}.cookies.pickle"

    def exists(self):
        return os.path.exists(self.filename)

    def preload(self):
        print(f"preload cookies for {self.domain}")
        self.driver.execute_cdp_cmd("Network.enable", {})
        with open(self.filename, mode="rb") as f:
            for cookie in pickle.load(f):
                self.driver.execute_cdp_cmd("Network.setCookie", cookie)
        self.driver.execute_cdp_cmd("Network.disable", {})

    def save(self):
        print(f"save cookies for {self.domain}")
        with open(self.filename, mode="wb") as f:
            pickle.dump(self.driver.get_cookies(), f)

if __name__ == "__main__":
    with get_driver() as driver:
        cookies = Cookies(driver, URL)
        if cookies.exists():
            cookies.preload()
            driver.get(URL)
        else:
            driver.no_timings_detection_get(URL, wait=5)  # you might need to tweak wait
            cookies.save()
        input("hit enter")

EDIT : clean code

qhjink commented 2 years ago

I try to use the no_timings_detection_get method, which works normally at first, but after running for a while, the target website still prompts to block.

sebdelsol commented 2 years ago

Yes if you keep coming with a blank profile from the same IP you'll be quickly blocked. That's why you need to save your first session cookies and reuse them.

qhjink commented 2 years ago

Well, when I use new IP and new cookies, they are not detected at first, but other operations after I log in normally are detected.

sebdelsol commented 2 years ago

Well, I can't help you without minimal reproducible example.

ultrafunkamsterdam commented 2 years ago

no problem here image

mianahmad8949 commented 1 year ago

Datadome security varies between site, e.g tidal.com and it is being detected.

datadome_undetected_webddriver t

Are you found the solutionn?

mianahmad8949 commented 1 year ago

36343c772977df941818984656292be url:https://www.cma-cgm.com I also have the same problem. When I open the website, it shows that it has been detected. If I open it manually, it doesn't

You found the solution?