Add stealth mode for Chrome headless to evade bot detection

Implements comprehensive anti-detection measures:
- Override navigator.webdriver to return undefined
- Inject fake chrome.runtime, chrome.loadTimes, chrome.csi objects
- Add realistic plugins and mimeTypes arrays
- Patch permissions API to hide automation
- Set realistic navigator properties (languages, hardwareConcurrency, deviceMemory)
- Remove ChromeDriver-specific window properties (cdc_*)
- Patch Function.prototype.toString to hide modifications
- Add Chrome flags: --disable-blink-features=AutomationControlled
- Set realistic user-agent without HeadlessChrome identifier
- Exclude 'enable-automation' switch

Tested against bot detection sites:
- bot.sannysoft.com: All major tests pass
- Search engines: Works with DuckDuckGo, Yahoo, Brave, Startpage
- Still detected by: Google reCAPTCHA, Cloudflare Turnstile, Bing
This commit is contained in:
Dhanji R. Prasanna
2026-01-10 20:34:14 +11:00
parent 7da21d7e81
commit 60aeb67c56
5 changed files with 183 additions and 5 deletions

View File

@@ -134,6 +134,10 @@ pub struct WebDriverConfig {
/// If not set, ChromeDriver will use the default Chrome installation
pub chrome_binary: Option<String>,
#[serde(default)]
/// Optional path to ChromeDriver binary
/// If not set, looks for 'chromedriver' in PATH
pub chromedriver_binary: Option<String>,
#[serde(default)]
pub browser: WebDriverBrowser,
}
@@ -144,6 +148,7 @@ impl Default for WebDriverConfig {
safari_port: 4444,
chrome_port: 9515,
chrome_binary: None,
chromedriver_binary: None,
browser: WebDriverBrowser::Safari,
}
}