Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Antibots detecting because of poor _hook_remove_cdc_props implementation #986

Open
lukect opened this issue Jan 12, 2023 · 8 comments
Open

Comments

@lukect
Copy link

lukect commented Jan 12, 2023

The antibot scripts are adding fake cdc_props (props which match the regex) and undetected-chromedriver is removing them because of a poor implementation.

Optimal fix, use my fork here here: #1010

Temporary fix until my PR is accepted

Add this after initializing the Chrome instance, but before using it (Chrome.get("url")).

cdc_props = driver.execute_script('const j=[];for(const p in window){'
                                  'if(/^[a-z]{3}_[a-zA-Z0-9]{22}_.*/i.test(p)){'
                                  'j.push(p);delete window[p];}}return j;')
if len(cdc_props) > 0:
    cdc_props_js_array = '[' + ','.join('"' + p + '"' for p in cdc_props) + ']'
    driver.execute_cdp_cmd('Page.addScriptToEvaluateOnNewDocument',
                          {'source': cdc_props_js_array + '.forEach(k=>delete window[k]);'})

Example

import undetected_chromedriver as uc
driver = uc.Chrome()

cdc_props = driver.execute_script('const j=[];for(const p in window){'
                                  'if(/^[a-z]{3}_[a-zA-Z0-9]{22}_.*/i.test(p)){'
                                  'j.push(p);delete window[p];}}return j;')
if len(cdc_props) > 0:
    cdc_props_js_array = '[' + ','.join('"' + p + '"' for p in cdc_props) + ']'
    driver.execute_cdp_cmd('Page.addScriptToEvaluateOnNewDocument',
                          {'source': cdc_props_js_array + '.forEach(k=>delete window[k]);'})

driver.get("https://fingerprint.com/products/bot-detection/")

Why does this work?

We are now correctly removing the cdc_props before undetected-chromedriver 3.2.1 detects any cdc_props and triggers a flawed deletion implementation. The flawed deletion implementation runs if there are any cdc_props when you use Chrome.get(url). My quick fix removes the cdc_props beforehand, preventing the flawed deletion implementation from being triggered.

lukect added a commit to lukect/undetected-chromedriver that referenced this issue Jan 14, 2023
lukect added a commit to lukect/undetected-chromedriver that referenced this issue Jan 14, 2023
@lukect
Copy link
Author

lukect commented Jan 27, 2023

Full 100% stable, optimal fix here: #1010

@mrafieefard
Copy link

mrafieefard commented Jan 30, 2023

Still detectable by discord

@L4BORG
Copy link

L4BORG commented Jan 31, 2023

Still detectable by discord

Using clean IP?

@lukect
Copy link
Author

lukect commented Jan 31, 2023

Still detectable by discord

Send your code that triggers detection please. There can be many reasons why you get 'detected' that don't involve ChromeDriver specifically. It can be your browser fingerprint or your behavior.

@mrafieefard
Copy link

Still detectable by discord

Send your code that triggers detection please. There can be many reasons why you get 'detected' that don't involve ChromeDriver specifically. It can be your browser fingerprint or your behavior.

Thanks a lot its my bad now it working

@Alexei17
Copy link

How did you fix it?

@mrafieefard
Copy link

mrafieefard commented Jan 31, 2023

How did you fix it?

use lukect fork

@Alexei17
Copy link

Alexei17 commented Feb 1, 2023

Thanks, that worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants