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?
- 如何使用WebFilter实现授权头检查 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01