* 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]>
104 lines
3.7 KiB
Rust
104 lines
3.7 KiB
Rust
pub struct BrowserProfile {
|
|
pub user_agent: &'static str,
|
|
pub platform: &'static str,
|
|
pub ua_platform: &'static str,
|
|
pub ua_platform_version: &'static str,
|
|
}
|
|
|
|
pub static PROFILES: &[BrowserProfile] = &[
|
|
BrowserProfile {
|
|
user_agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36",
|
|
platform: "Win32",
|
|
ua_platform: "Windows",
|
|
ua_platform_version: "10.0.0",
|
|
},
|
|
BrowserProfile {
|
|
user_agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36",
|
|
platform: "Win32",
|
|
ua_platform: "Windows",
|
|
ua_platform_version: "10.0.0",
|
|
},
|
|
BrowserProfile {
|
|
user_agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36",
|
|
platform: "Win32",
|
|
ua_platform: "Windows",
|
|
ua_platform_version: "15.0.0",
|
|
},
|
|
BrowserProfile {
|
|
user_agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36",
|
|
platform: "Win32",
|
|
ua_platform: "Windows",
|
|
ua_platform_version: "15.0.0",
|
|
},
|
|
BrowserProfile {
|
|
user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36",
|
|
platform: "MacIntel",
|
|
ua_platform: "macOS",
|
|
ua_platform_version: "13.6.7",
|
|
},
|
|
BrowserProfile {
|
|
user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36",
|
|
platform: "MacIntel",
|
|
ua_platform: "macOS",
|
|
ua_platform_version: "14.4.1",
|
|
},
|
|
BrowserProfile {
|
|
user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36",
|
|
platform: "MacIntel",
|
|
ua_platform: "macOS",
|
|
ua_platform_version: "14.5.0",
|
|
},
|
|
BrowserProfile {
|
|
user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36",
|
|
platform: "MacIntel",
|
|
ua_platform: "macOS",
|
|
ua_platform_version: "14.6.0",
|
|
},
|
|
];
|
|
|
|
pub fn random_profile() -> &'static BrowserProfile {
|
|
let idx = (std::time::SystemTime::now()
|
|
.duration_since(std::time::UNIX_EPOCH)
|
|
.unwrap_or_default()
|
|
.subsec_nanos() as usize)
|
|
% PROFILES.len();
|
|
&PROFILES[idx]
|
|
}
|
|
|
|
/// Pick the profile for a new browser context.
|
|
///
|
|
/// The default is a single stable profile. Cycling through different browser
|
|
/// identities from one address is itself a bot signal (a real address maps to a
|
|
/// stable device), and the rotated profile does not yet carry a matching TLS or
|
|
/// timezone fingerprint, so rotation is opt-in:
|
|
/// OBSCURA_PROFILE=<index> pin a specific profile from PROFILES
|
|
/// OBSCURA_ROTATE_PROFILE=1 pick a random profile per context
|
|
pub fn select_profile() -> &'static BrowserProfile {
|
|
if let Some(idx) = std::env::var("OBSCURA_PROFILE")
|
|
.ok()
|
|
.as_deref()
|
|
.map(str::trim)
|
|
.and_then(|s| s.parse::<usize>().ok())
|
|
{
|
|
if idx < PROFILES.len() {
|
|
return &PROFILES[idx];
|
|
}
|
|
}
|
|
if env_enabled("OBSCURA_ROTATE_PROFILE") {
|
|
return random_profile();
|
|
}
|
|
&PROFILES[0]
|
|
}
|
|
|
|
fn env_enabled(key: &str) -> bool {
|
|
matches!(
|
|
std::env::var(key)
|
|
.ok()
|
|
.as_deref()
|
|
.map(str::trim)
|
|
.map(str::to_ascii_lowercase)
|
|
.as_deref(),
|
|
Some("1") | Some("true") | Some("yes") | Some("on")
|
|
)
|
|
}
|