Stealth profile consistency (#269)
* feat(stealth): randomize browser profile per session Add a pool of 8 realistic browser profiles (Win10/Win11/macOS, Chrome 143-146). One is picked randomly per BrowserContext instead of always advertising Linux, which is a strong bot signal. Each profile keeps navigator.platform, userAgentData.platform, and userAgentData.platformVersion internally consistent with the UA string. - profiles.rs: static PROFILES pool + random_profile() picker - context.rs: pick profile on construction, store platform fields - page.rs: call rt.set_platform() alongside rt.set_user_agent() - runtime.rs: add set_platform() to inject __obscura_platform globals - bootstrap.js: read platform/userAgentData from globals (default Win32) Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * feat(stealth): match GPU renderer pool to OS profile Windows profiles get ANGLE Direct3D11 renderers; macOS profiles get ANGLE Metal renderers. Vendor strings updated to match (Google Inc. (Apple) for Apple Silicon/Intel Mac, Google Inc. (NVIDIA/AMD/Intel) for Windows). Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * fix(stealth): navigator.webdriver returns false instead of undefined Browsers set navigator.webdriver to false when automation is not active. Returning undefined is a detectable bot signal — fingerprinting scripts check typeof navigator.webdriver === 'boolean' as part of headless detection. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * Make stealth profile stable by default, rotation opt-in Picking a random profile per BrowserContext meant one address would cycle through different browser identities, which is itself a bot signal, and the rotated profile carries no matching TLS or timezone fingerprint. Default to a single stable profile; opt into rotation with OBSCURA_ROTATE_PROFILE, or pin one with OBSCURA_PROFILE=<index>. Drive timezone from the process TZ so Intl.DateTimeFormat and Date report one consistent zone. Default Europe/Berlin; override with OBSCURA_TIMEZONE. Update navigator.webdriver test to expect false, matching real Chrome. --------- Co-authored-by: SGavrl <[email protected]>
This commit is contained in:
1 parent
f20626bdbd
commit
a23dad7cd9
7 files changed
+171
-26
No files matched your search
@@ -206,6 +206,19 @@ impl ObscuraJsRuntime {
|
||||
format!("globalThis.__obscura_ua = '{}';", escaped),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn set_platform(&mut self, platform: &str, ua_platform: &str, ua_platform_version: &str) {
|
||||
let p = platform.replace('\'', "\\'");
|
||||
let uap = ua_platform.replace('\'', "\\'");
|
||||
let uapv = ua_platform_version.replace('\'', "\\'");
|
||||
let _ = self.runtime.execute_script(
|
||||
"<set-platform>",
|
||||
format!(
|
||||
"globalThis.__obscura_platform='{}';globalThis.__obscura_ua_platform='{}';globalThis.__obscura_ua_platform_version='{}';",
|
||||
p, uap, uapv
|
||||
),
|
||||
);
|
||||
}
|
||||
pub fn evaluate(&mut self, expression: &str) -> Result<serde_json::Value, String> {
|
||||
let wrapped = Self::wrap_expression(expression);
|
||||
let result = self
|
||||
@@ -1511,7 +1524,7 @@ mod tests {
|
||||
let ua = rt.evaluate("navigator.userAgent").unwrap();
|
||||
assert!(ua.as_str().unwrap().contains("Chrome"), "UA should contain Chrome: {}", ua);
|
||||
let wd = rt.evaluate("navigator.webdriver").unwrap();
|
||||
assert_eq!(wd, serde_json::Value::Null);
|
||||
assert_eq!(wd, serde_json::json!(false));
|
||||
let plugins = rt.evaluate("navigator.plugins.length").unwrap();
|
||||
assert!(plugins.as_f64().unwrap() > 0.0, "Should have plugins");
|
||||
let chrome = rt.evaluate("typeof window.chrome").unwrap();
|
||||
|
||||
Reference in new issue
Block a user