How to Conceal WebDriver in Geckodriver from BotD in Java?(如何从 Java 中的 BotD 中隐藏 Geckodriver 中的 WebDriver?)
问题描述
我按照 确认:
<块引用><块引用>此实现必须符合此要求.像这样我们不会提供规避方法.
结论
所以,底线是:
<块引用>Selenium 自我识别
并且无法隐藏浏览器是 WebDriver 驱动.
建议
然而,一些权威人士提出了一些不同的方法,这些方法可以掩盖 Mozilla Firefox 浏览器是通过使用 Firefox 配置文件 和 代理如下:
<块引用>selenium4 兼容 python 代码
从 selenium.webdriver 导入 Firefox从硒导入网络驱动程序从 selenium.webdriver.firefox.service 导入服务从 selenium.webdriver.firefox.options 导入选项profile_path = r'C:UsersAdminAppDataRoamingMozillaFirefoxProfiless8543x41.default-release'选项=选项()options.set_preference('profile', profile_path)options.set_preference('network.proxy.type', 1)options.set_preference('network.proxy.socks', '127.0.0.1')options.set_preference('network.proxy.socks_port', 9050)options.set_preference('network.proxy.socks_remote_dns', False)服务 = 服务('C:\BrowserDrivers\geckodriver.exe')驱动程序= Firefox(服务=服务,选项=选项)driver.get("https://www.google.com")driver.quit()
潜在解决方案
一个潜在的解决方案是使用 tor 浏览器如下:
<块引用>selenium4 兼容 python 代码
从 selenium.webdriver 导入 Firefox从硒导入网络驱动程序从 selenium.webdriver.firefox.service 导入服务从 selenium.webdriver.firefox.options 导入选项导入操作系统torexe = os.popen(r'C:UsersusernameDesktopTor BrowserBrowserTorBrowserTor or.exe')profile_path = r'C:UsersusernameDesktopTor BrowserBrowserTorBrowserDataBrowserprofile.default'firefox_options=选项()firefox_options.set_preference('profile', profile_path)firefox_options.set_preference('network.proxy.type', 1)firefox_options.set_preference('network.proxy.socks', '127.0.0.1')firefox_options.set_preference('network.proxy.socks_port', 9050)firefox_options.set_preference("network.proxy.socks_remote_dns", False)firefox_options.binary_location = r'C:UsersusernameDesktopTor BrowserBrowserfirefox.exe'服务 = 服务('C:\BrowserDrivers\geckodriver.exe')驱动程序= webdriver.Firefox(服务=服务,选项=firefox_options)driver.get("https://www.tiktok.com/")
参考文献
您可以在
中找到一些相关的详细讨论- 如何通过 Python 使用 GeckoDriver 和 Selenium 启动 Tor Browser 9.5,使用默认 Firefox 到 68.9.0esr
- 如何使用 Python 连接 Tor 浏览器
- 如何在 Chrome 浏览器中使用 Tor通过硒
I followed this post on Stackoverflow to disable Firefox WebDriver
detection.
Launch Geckodriver:
System.setProperty("webdriver.gecko.driver", geckdriverExecutableFilePath);
File firefoxProfileFile = new File(fullPathOfFirefoxInstallationFolder);
FirefoxProfile firefoxProfile = null;
try {
firefoxProfile = new FirefoxProfile(firefoxProfileFile);
} catch (Exception e) {
e.printStackTrace();
}
I disabled WebDriver
:
WebDriver Disabled
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setProfile(firefoxProfile);
// Disables WebRTC
firefoxProfile.setPreference("media.peerconnection.enabled", false);
I disabled Automation Extensions:
Automation Extension Disabled
// Disables Automation Extension
firefoxProfile.setPreference("useAutomationExtension", false);
I added Proxy:
DesiredCapabilities dc = DesiredCapabilities.firefox();
Proxy proxy = new Proxy();
proxy.setHttpProxy(ipAddress + ":" + port);
proxy.setFtpProxy(ipAddress + ":" + port);
proxy.setSslProxy(ipAddress + ":" + port);
dc.setCapability(CapabilityType.PROXY, proxy);
firefoxOptions.merge(dc);
driver = new FirefoxDriver(firefoxOptions);
Yet BotD still detects my browser as being controlled by automation tool.
BotD Detection
How can I solve this?
When using Selenium driven GeckoDriver initiated firefox Browsing Context
The webdriver-active flag is set to true
when the user agent is under remote control. It is initially false
.
where, webdriver
returns true
if webdriver-active flag is set, false
otherwise.
As:
navigator.webdriver Defines a standard way for co-operating user agents to inform the document that it is controlled by WebDriver, for example so that alternate code paths can be triggered during automation.
Further @whimboo
in his comments confirmed:
This implementation have to be conformant to this requirement. As such we will not provide a way to circumvent that.
Conclusion
So, the bottom line is:
Selenium identifies itself
and there is no way to conceal the fact that the browser is WebDriver driven.
Recommendations
However some pundits have suggested some different approaches which can conceal the fact that the Mozilla Firefox browser is WebDriver controled through the usage of Firefox Profiles and Proxies as follows:
selenium4 compatible python code
from selenium.webdriver import Firefox
from selenium import webdriver
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.firefox.options import Options
profile_path = r'C:UsersAdminAppDataRoamingMozillaFirefoxProfiless8543x41.default-release'
options=Options()
options.set_preference('profile', profile_path)
options.set_preference('network.proxy.type', 1)
options.set_preference('network.proxy.socks', '127.0.0.1')
options.set_preference('network.proxy.socks_port', 9050)
options.set_preference('network.proxy.socks_remote_dns', False)
service = Service('C:\BrowserDrivers\geckodriver.exe')
driver = Firefox(service=service, options=options)
driver.get("https://www.google.com")
driver.quit()
Potential Solution
A potential solution would be to use the tor browser as follows:
selenium4 compatible python code
from selenium.webdriver import Firefox
from selenium import webdriver
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.firefox.options import Options
import os
torexe = os.popen(r'C:UsersusernameDesktopTor BrowserBrowserTorBrowserTor or.exe')
profile_path = r'C:UsersusernameDesktopTor BrowserBrowserTorBrowserDataBrowserprofile.default'
firefox_options=Options()
firefox_options.set_preference('profile', profile_path)
firefox_options.set_preference('network.proxy.type', 1)
firefox_options.set_preference('network.proxy.socks', '127.0.0.1')
firefox_options.set_preference('network.proxy.socks_port', 9050)
firefox_options.set_preference("network.proxy.socks_remote_dns", False)
firefox_options.binary_location = r'C:UsersusernameDesktopTor BrowserBrowserfirefox.exe'
service = Service('C:\BrowserDrivers\geckodriver.exe')
driver = webdriver.Firefox(service=service, options=firefox_options)
driver.get("https://www.tiktok.com/")
References
You can find a couple of relevant detailed discussions in
- How to initiate a Tor Browser 9.5 which uses the default Firefox to 68.9.0esr using GeckoDriver and Selenium through Python
- How to connect to Tor browser using Python
- How to use Tor with Chrome browser through Selenium
这篇关于如何从 Java 中的 BotD 中隐藏 Geckodriver 中的 WebDriver?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何从 Java 中的 BotD 中隐藏 Geckodriver 中的 WebDriver?
基础教程推荐
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 降序排序:Java Map 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01