-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix detection due to cdc_props removal. #986 #993
Conversation
Hi, is there a way to trigger cdc_props removal when opening an url in a new tab? Sometimes a click can open a new tab with a pre-loaded url. You can simulate that with: driver.execute_script("window.open('https://www.google.com','_blank');") |
You have found an edge-case which hasn't been covered yet in this project. I will update my issue (#986) and my PR (#993) to address this when we know more about it. From my initial findings, it seems that the cdc_props are only added by ChromeDriver after you We also need to check if cdc_props get added when switching to an |
Yes, actually I am using the workaround you described above, but as you noticed there's always a short time period when antibot can detect you. Another dirty solution could be turning off your network (with network namespaces maybe), check if the click has opened a new tab, switch to it, remove cdc_props, turn on the network and refresh the page. |
Simplest quick fix (if the website isn't ensuring you still have the old window open):
Simply override the window.open/tab/pop-up behaviour. Run this function once on every native I have a more comprehensive patch in the works. |
cdc_props likely get added when switching to an iFrame. I have an edge case right now where switching to an iFrame gets me detected. |
Does it work using my current PR? I'm passing all the cdc_props tests in my own testing setup, even within one |
I will be able to check a little later, but what’s interesting in my case, is that all of the iFrames seems to be blocked, even if they aren’t specifically switched to using selenium. For example, opening a normal browser window will result in the iFrame loading correctly. But opening a window using UndetectedChomedriver and navigating to the same iFrame (even without explicitly switching to it using Selenium) results in a bot detected, and sometimes a “refused to connect” error, from the iFrame.
|
I will close this PR, because after reading the JavaScript hack
I did make a lot of progress on a JavaScript hack to override the
Call How it worksWe are preventing a new tab/window from being opened by a page, opening a new one ourselves, then protecting that window (removing the CaveatsYou might still get detected when new pop-ups/windows/tabs get opened by a website, because:
|
Use this 100% stable fix: |
@lukect The #1010 update worked on some sites, eg: https://nowsecure.nl/#relax, https://pixelscan.net/, and https://fingerprint.com/products/bot-detection, but not on others, such as Google Login. |
We have a click_safe() method for this... |
And driver.tab_new().... There is even a method which removes cdc Js vars. def _hook_remove_cdc_props(self)
self.execute_cdp_cmd(
"Page.addScriptToEvaluateOnNewDocument",
{
"source": """
let objectToInspect = window,
result = [];
while(objectToInspect !== null)
{ result = result.concat(Object.getOwnPropertyNames(objectToInspect));
objectToInspect = Object.getPrototypeOf(objectToInspect); }
result.forEach(p => p.match(/.+_.+_(Array|Promise|Symbol)/ig)
&&delete window[p]&&console.log('removed',p))
|
This has a race condition (the click could occur before ChromeDriver IPC disconnects).
We are talking about a page's script opening a new window without user action.
This implementation is flawed: #986. |
#986