guise 0.1.2

Canonical browser fingerprint bundles, human-behavior timing, and TLS profile re-exports for the Santh fleet
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
//! Probe catalogue: the live fingerprint surfaces probed at runtime.

use super::catalogue_misc::misc_probes;
use super::classify::*;
use super::{Probe, ProbeOutcome, Severity};
use crate::fingerprint::UserAgentBrowser;

/// Names of probes that encode a **Chromium-only** truth: a surface a real
/// Firefox legitimately lacks (or reports differently). These are dropped when
/// probing a Firefox disguise and replaced by [`firefox_probes`]'s inverse
/// expectations, so the gate measures the disguise against the *target*
/// browser's real fingerprint instead of always against Chrome.
///
/// This is the data-driven contract behind family-aware probing: a `?`-marked
/// intersection in the feature matrix resolved to "Chrome has it, Firefox does
/// not." Add a name here when a probe asserts a Chrome-specific surface.
pub(super) const CHROMIUM_ONLY_PROBES: &[&str] = &[
    "navigator.vendor non-empty",
    "navigator.userAgent",
    "navigator.productSub equals '20030107'",
    "window.chrome.runtime exists",
    "window.chrome.app.RunningState exists",
    "window.chrome.loadTimes returns object",
    "window.chrome.csi returns object",
    "navigator.getBattery() exists",
    "navigator.bluetooth exists",
    "navigator.usb exists",
    "navigator.hid exists",
    "navigator.serial exists",
    "navigator.getInstalledRelatedApps exists",
    "window.PaymentRequest exists",
    "navigator.share exists",
    "navigator.canShare exists",
    "window.cookieStore exists",
    "window.trustedTypes exists",
    "navigator.connection.effectiveType exists",
    "Reporting API exists",
    "Touch exists",
    // A Chrome-CDP-specific heuristic: it probes the Chrome DevTools port
    // (9222). Meaningless for a Firefox disguise (driven over BiDi on a private
    // port), so it is dropped for Firefox.
    "Chrome remote-debugging WS unreachable from page",
];

/// Construct a probe with the boilerplate fields.
pub(super) fn probe(
    name: &'static str,
    js: &'static str,
    severity: Severity,
    classifier: fn(&serde_json::Value) -> ProbeOutcome,
) -> Probe {
    Probe {
        name,
        js,
        severity,
        classifier,
    }
}

/// The full probe catalogue for the default (Chromium) disguise: 100+ live
/// fingerprint surfaces, plus the `sear`-derived red-team probes (adversarial
/// sandbox-detection, inverted).
///
/// This is the back-compatible entry point — it measures against Chrome truth.
/// For a Firefox (or other family) disguise, use [`probes_for`] so the gate
/// validates the disguise against the *target* browser's real fingerprint
/// rather than Chrome's.
pub fn probes() -> Vec<Probe> {
    probes_for(UserAgentBrowser::Chrome)
}

/// The probe catalogue specialised for a target browser family.
///
/// The universal surfaces (DOM APIs, canvas/audio noise, automation-tell
/// scrubbing, the red-team set) are shared. Chromium-only surfaces (listed in
/// [`CHROMIUM_ONLY_PROBES`]) are kept for Chromium-family targets but dropped
/// for Firefox — where they would falsely flag legitimate Firefox absences —
/// and replaced by [`firefox_probes`], which asserts the matching Firefox
/// truths (empty `vendor`, Gecko UA, `productSub` `20100101`, absent
/// `window.chrome`/`usb`/`PaymentRequest`/…, present `oscpu`).
///
/// guise's live browser is Firefox (driven over BiDi by `foxdriver`); the
/// Chrome profiles disguise the HTTP/TLS layer. So `probes_for(Firefox)` is the
/// correct oracle for the live stealth gate.
pub fn probes_for(browser: UserAgentBrowser) -> Vec<Probe> {
    let mut all = core_probes();
    all.extend(misc_probes());
    all.extend(super::redteam::redteam_probes());
    all.extend(super::codec::codec_probes());
    if matches!(browser, UserAgentBrowser::Firefox) {
        all.retain(|p| !CHROMIUM_ONLY_PROBES.contains(&p.name));
        all.extend(firefox_probes());
    }
    all
}

/// Firefox-family fingerprint truths — the inverse of the Chromium-only
/// surfaces dropped by [`probes_for`]. Each asserts what a *real* Firefox
/// reports, so the gate confirms the disguise is coherent with Gecko rather
/// than penalising it for not being Chrome.
fn firefox_probes() -> Vec<Probe> {
    vec![
        // ─── Identity values that differ from Chromium ───────────────
        probe("navigator.vendor is empty (Firefox)",
            "navigator.vendor",
            Severity::Medium,
            classify_must_be_empty_string),
        probe("navigator.userAgent is Gecko/Firefox",
            "navigator.userAgent",
            Severity::High,
            classify_must_be_firefox_ua),
        probe("navigator.productSub equals '20100101' (Firefox)",
            "navigator.productSub === '20100101'",
            Severity::Low,
            classify_must_be_true),
        probe("navigator.oscpu is a string (Firefox-only surface)",
            "typeof navigator.oscpu === 'string' && navigator.oscpu.length > 0",
            Severity::Medium,
            classify_must_be_true),
        // ─── Chromium-only surfaces that must be ABSENT on Firefox ───
        probe("window.chrome absent (Firefox)",
            "(typeof window.chrome === 'undefined') ? null : 'present'",
            Severity::High,
            classify_must_be_undefined),
        probe("navigator.getBattery absent (Firefox)",
            "(typeof Navigator.prototype.getBattery === 'undefined' && typeof navigator.getBattery === 'undefined') ? null : 'present'",
            Severity::Medium,
            classify_must_be_undefined),
        probe("navigator.usb absent (Firefox)",
            "(typeof navigator.usb === 'undefined') ? null : 'present'",
            Severity::Medium,
            classify_must_be_undefined),
        probe("navigator.hid absent (Firefox)",
            "(typeof navigator.hid === 'undefined') ? null : 'present'",
            Severity::Low,
            classify_must_be_undefined),
        probe("navigator.serial absent (Firefox)",
            "(typeof navigator.serial === 'undefined') ? null : 'present'",
            Severity::Low,
            classify_must_be_undefined),
        probe("navigator.bluetooth absent (Firefox desktop)",
            "(typeof navigator.bluetooth === 'undefined') ? null : 'present'",
            Severity::Low,
            classify_must_be_undefined),
        probe("window.PaymentRequest absent (Firefox)",
            "(typeof window.PaymentRequest === 'undefined') ? null : 'present'",
            Severity::Low,
            classify_must_be_undefined),
        probe("navigator.connection absent (Firefox)",
            "(typeof navigator.connection === 'undefined') ? null : 'present'",
            Severity::Low,
            classify_must_be_undefined),
    ]
}

fn core_probes() -> Vec<Probe> {
    vec![
        // ─── Tier 0 - native-shape ────────────────────────────────────
        probe("Function.prototype.toString returns native code for Navigator.prototype.webdriver getter",
            "Object.getOwnPropertyDescriptor(Navigator.prototype, 'webdriver').get.toString()",
            Severity::High,
            classify_must_be_native_code),
        probe("Function.prototype.toString native for WebGL getParameter",
            "WebGLRenderingContext.prototype.getParameter.toString()",
            Severity::High,
            classify_must_be_native_code),
        probe("Function.prototype.toString native for toDataURL",
            "HTMLCanvasElement.prototype.toDataURL.toString()",
            Severity::High,
            classify_must_be_native_code),
        // ─── Tier 1 - navigator basics ────────────────────────────────
        probe("navigator.webdriver",
            "navigator.webdriver === undefined ? null : navigator.webdriver",
            Severity::High,
            classify_webdriver_ok),
        // webdriver must be INHERITED (Navigator.prototype), never an OWN
        // property of the instance — `_.has`/hasOwnProperty exposes an own-prop
        // override (bot.sannysoft "WebDriver (New)").
        probe("navigator.webdriver is inherited, not an own property",
            "!Object.prototype.hasOwnProperty.call(navigator, 'webdriver')",
            Severity::High,
            classify_must_be_true),
        probe("navigator.plugins.length > 0",
            "(navigator.plugins || []).length",
            Severity::High,
            classify_must_be_nonzero_int),
        probe("navigator.plugins is a real PluginArray",
            "(() => { try { return (typeof PluginArray !== 'undefined') ? (navigator.plugins instanceof PluginArray) : true; } catch (_) { return false; } })()",
            Severity::High,
            classify_must_be_true),
        probe("navigator.mimeTypes.length > 0",
            "(navigator.mimeTypes || []).length",
            Severity::Medium,
            classify_must_be_nonzero_int),
        probe("navigator.languages.length > 0",
            "(navigator.languages || []).length",
            Severity::High,
            classify_must_be_nonzero_int),
        probe("navigator.language",
            "navigator.language",
            Severity::Low,
            classify_must_be_nonempty_string),
        probe("navigator.vendor non-empty",
            "navigator.vendor",
            Severity::Medium,
            classify_must_be_nonempty_string),
        probe("navigator.userAgent",
            "navigator.userAgent",
            Severity::High,
            classify_must_be_chromium_ua),
        probe("navigator.appVersion non-empty",
            "navigator.appVersion",
            Severity::Low,
            classify_must_be_nonempty_string),
        probe("navigator.platform non-empty",
            "navigator.platform",
            Severity::Medium,
            classify_must_be_nonempty_string),
        probe("navigator.cookieEnabled true",
            "navigator.cookieEnabled",
            Severity::Low,
            classify_must_be_true),
        probe("navigator.onLine true",
            "navigator.onLine",
            Severity::Low,
            classify_must_be_true),
        probe("navigator.pdfViewerEnabled true",
            "navigator.pdfViewerEnabled === true",
            Severity::Low,
            classify_must_be_true),
        probe("navigator.product equals 'Gecko'",
            "navigator.product === 'Gecko'",
            Severity::Low,
            classify_must_be_true),
        probe("navigator.productSub equals '20030107'",
            "navigator.productSub === '20030107'",
            Severity::Low,
            classify_must_be_true),
        probe("navigator.appName equals 'Netscape'",
            "navigator.appName === 'Netscape'",
            Severity::Low,
            classify_must_be_true),
        probe("navigator.appCodeName equals 'Mozilla'",
            "navigator.appCodeName === 'Mozilla'",
            Severity::Low,
            classify_must_be_true),
        // ─── Tier 1b - WebGL ──────────────────────────────────────────
        probe("WebGL UNMASKED_VENDOR not SwiftShader",
            "(() => { const c = document.createElement('canvas').getContext('webgl'); if (!c) return ''; const ext = c.getExtension('WEBGL_debug_renderer_info'); return ext ? c.getParameter(ext.UNMASKED_VENDOR_WEBGL) : ''; })()",
            Severity::High,
            classify_must_not_contain_swiftshader),
        probe("WebGL UNMASKED_RENDERER not SwiftShader",
            "(() => { const c = document.createElement('canvas').getContext('webgl'); if (!c) return ''; const ext = c.getExtension('WEBGL_debug_renderer_info'); return ext ? c.getParameter(ext.UNMASKED_RENDERER_WEBGL) : ''; })()",
            Severity::High,
            classify_must_not_contain_swiftshader),
        // ─── Tier 1c - Notification + Permissions ────────────────────
        probe("Notification.permission not 'denied'",
            "(() => { try { return Notification.permission !== 'denied'; } catch (_) { return false; } })()",
            Severity::Medium,
            classify_must_be_true),
        // ─── Tier 1d - chrome object ──────────────────────────────────
        probe("window.chrome.runtime exists",
            "(() => { try { return !!(window.chrome && window.chrome.runtime); } catch (_) { return false; } })()",
            Severity::High,
            classify_must_be_true),
        probe("window.chrome.app.RunningState exists",
            "(() => { try { return !!(window.chrome && window.chrome.app && window.chrome.app.RunningState); } catch (_) { return false; } })()",
            Severity::Medium,
            classify_must_be_true),
        probe("window.chrome.loadTimes returns object",
            "(() => { try { return typeof window.chrome.loadTimes === 'function' && typeof window.chrome.loadTimes() === 'object'; } catch (_) { return false; } })()",
            Severity::Medium,
            classify_must_be_true),
        probe("window.chrome.csi returns object",
            "(() => { try { return typeof window.chrome.csi === 'function' && typeof window.chrome.csi() === 'object'; } catch (_) { return false; } })()",
            Severity::Medium,
            classify_must_be_true),
        // ─── Tier 2a - canvas randomization (session strategy) ────────
        // These measure whether the canvas/audio fingerprint is RANDOMIZED per
        // read. That is an optional defense strategy, not a realness invariant:
        // a genuine browser is deterministic here, and per-read randomization is
        // itself a tell. So absence is an informational Drift, never a Critical
        // (see `classify_session_noise`) — else a real Firefox false-positives.
        probe("CanvasRenderingContext2D getImageData randomized (session strategy)",
            "(() => { const c = document.createElement('canvas'); c.width = c.height = 100; const ctx = c.getContext('2d'); ctx.fillStyle = 'red'; ctx.fillRect(0,0,100,100); const a = ctx.getImageData(0,0,100,100).data; const b = ctx.getImageData(0,0,100,100).data; let diff = 0; for (let i = 3; i < a.length; i += 4) { if (a[i] !== b[i]) diff++; } return diff > 0; })()",
            Severity::Medium,
            classify_session_noise),
        probe("HTMLCanvasElement.toDataURL randomized (session strategy)",
            "(() => { const c = document.createElement('canvas'); c.width = c.height = 50; const ctx = c.getContext('2d'); ctx.fillStyle = 'blue'; ctx.fillRect(0,0,50,50); return c.toDataURL() !== c.toDataURL(); })()",
            Severity::Medium,
            classify_session_noise),
        // ─── Tier 2b - audio randomization (session strategy) ─────────
        probe("AudioBuffer.getChannelData randomized (session strategy)",
            "(() => { try { const ctx = new (window.OfflineAudioContext || window.webkitOfflineAudioContext)(1, 100, 44100); const buf = ctx.createBuffer(1, 100, 44100); const a = Array.from(buf.getChannelData(0)); const b = Array.from(buf.getChannelData(0)); return JSON.stringify(a) !== JSON.stringify(b); } catch (_) { return false; } })()",
            Severity::Medium,
            classify_session_noise),
        // ─── Tier 2c - WebRTC ─────────────────────────────────────────
        probe("RTCPeerConnection exists",
            "(() => typeof RTCPeerConnection !== 'undefined')()",
            Severity::Medium,
            classify_must_be_true),
        // ─── Tier 2d - hardware ──────────────────────────────────────
        probe("navigator.hardwareConcurrency in [2, 16]",
            "navigator.hardwareConcurrency",
            Severity::Low,
            classify_hardware_concurrency),
        probe("navigator.deviceMemory in [1, 64]",
            "navigator.deviceMemory || 8",
            Severity::Low,
            classify_device_memory),
        // ─── Tier 3 - peripheral APIs ────────────────────────────────
        probe("navigator.getBattery() exists",
            "(() => typeof Navigator.prototype.getBattery === 'function')()",
            Severity::Medium,
            classify_must_be_true),
        probe("navigator.permissions.query exists",
            "(() => !!(navigator.permissions && typeof navigator.permissions.query === 'function'))()",
            Severity::Medium,
            classify_must_be_true),
        probe("navigator.mediaDevices.enumerateDevices returns >=2",
            "(() => navigator.mediaDevices ? navigator.mediaDevices.enumerateDevices().then(d => d.length).catch(() => 0) : Promise.resolve(0))()",
            Severity::Medium,
            classify_must_be_nonzero_int),
        probe("navigator.bluetooth exists",
            "(() => typeof navigator.bluetooth === 'object')()",
            Severity::Low,
            classify_must_be_true),
        probe("navigator.usb exists",
            "(() => typeof navigator.usb === 'object')()",
            Severity::Low,
            classify_must_be_true),
        probe("navigator.hid exists",
            "(() => typeof navigator.hid === 'object')()",
            Severity::Low,
            classify_must_be_true),
        probe("navigator.serial exists",
            "(() => typeof navigator.serial === 'object')()",
            Severity::Low,
            classify_must_be_true),
        probe("navigator.getInstalledRelatedApps exists",
            "(() => typeof navigator.getInstalledRelatedApps === 'function')()",
            Severity::Low,
            classify_must_be_true),
        probe("navigator.mediaSession exists",
            "(() => typeof navigator.mediaSession === 'object')()",
            Severity::Low,
            classify_must_be_true),
        probe("navigator.wakeLock exists",
            "(() => typeof navigator.wakeLock === 'object')()",
            Severity::Low,
            classify_must_be_true),
        probe("window.PaymentRequest exists",
            "(() => typeof window.PaymentRequest === 'function')()",
            Severity::Low,
            classify_must_be_true),
        probe("navigator.share exists",
            "(() => typeof navigator.share === 'function')()",
            Severity::Low,
            classify_must_be_true),
        probe("navigator.canShare exists",
            "(() => typeof navigator.canShare === 'function')()",
            Severity::Low,
            classify_must_be_true),
        probe("navigator.serviceWorker exists",
            "(() => typeof navigator.serviceWorker === 'object')()",
            Severity::Medium,
            classify_must_be_true),
        probe("window.trustedTypes exists",
            "(() => typeof window.trustedTypes === 'object')()",
            Severity::Low,
            classify_must_be_true),
        probe("speechSynthesis.getVoices returns >=16 voices",
            "(() => (window.speechSynthesis ? window.speechSynthesis.getVoices().length : 0))()",
            Severity::Medium,
            classify_must_be_at_least_4_int),
        probe("window.visualViewport exists",
            "(() => typeof window.visualViewport === 'object')()",
            Severity::Low,
            classify_must_be_true),
        probe("window.cookieStore exists",
            "(() => typeof window.cookieStore === 'object')()",
            Severity::Low,
            classify_must_be_true),
        // ─── Tier 3e - screen surfaces ───────────────────────────────
        probe("screen.colorDepth == 24",
            "screen.colorDepth",
            Severity::Low,
            classify_color_depth),
        probe("screen.pixelDepth == 24",
            "screen.pixelDepth",
            Severity::Low,
            classify_color_depth),
        probe("screen.orientation.type exists",
            "(() => screen.orientation && typeof screen.orientation.type === 'string')()",
            Severity::Low,
            classify_must_be_true),
        probe("screen.width plausible",
            "screen.width",
            Severity::Low,
            classify_screen_size),
        probe("screen.height plausible",
            "screen.height",
            Severity::Low,
            classify_screen_size),
        probe("window.outerWidth >= innerWidth",
            "window.outerWidth >= window.innerWidth || window.outerWidth >= 100",
            Severity::Medium,
            classify_must_be_true),
        probe("window.outerHeight >= 100",
            "window.outerHeight >= 100",
            Severity::Medium,
            classify_must_be_true),
        probe("window.devicePixelRatio sensible",
            "Math.round(window.devicePixelRatio)",
            Severity::Low,
            classify_dpr),
        // ─── Tier 3f - Performance ────────────────────────────────────
        probe("performance.now precision floored",
            "(() => { const a = performance.now(); for (let i=0;i<100;i++){}; const b = performance.now(); return (b - a) >= 0.1 || b === a; })()",
            Severity::Low,
            classify_must_be_true),
        // ─── Tier 3g - connection ────────────────────────────────────
        probe("navigator.connection.effectiveType exists",
            "(() => navigator.connection && typeof navigator.connection.effectiveType === 'string')()",
            Severity::Low,
            classify_must_be_true),
        // ─── Tier 4 - CDP tells (Error.stack scrubbed) ───────────────
        probe("Error.stack does not leak puppeteer marker",
            "(() => { try { throw new Error('probe'); } catch (e) { return !/_puppeteer_evaluation_script_/.test(e.stack || ''); } })()",
            Severity::High,
            classify_must_be_true),
        probe("Error.stack does not leak cdpEvaluate marker",
            "(() => { try { throw new Error('probe'); } catch (e) { return !/_cdpEvaluate/.test(e.stack || ''); } })()",
            Severity::High,
            classify_must_be_true),
        // ─── Tier 4 - automation globals scrubbed ────────────────────
        probe("window.__nightmare undefined",
            "typeof window.__nightmare === 'undefined' ? null : window.__nightmare",
            Severity::Medium,
            classify_must_be_undefined),
        probe("window._phantom undefined",
            "typeof window._phantom === 'undefined' ? null : window._phantom",
            Severity::Medium,
            classify_must_be_undefined),
        probe("window.callPhantom undefined",
            "typeof window.callPhantom === 'undefined' ? null : window.callPhantom",
            Severity::Medium,
            classify_must_be_undefined),
        probe("window._selenium undefined",
            "typeof window._selenium === 'undefined' ? null : window._selenium",
            Severity::Medium,
            classify_must_be_undefined),
        // ─── Tier 4 - Chrome remote-debugging port not reachable from page JS ─
        // A real headless-detection heuristic: try to open a WebSocket to the
        // Chrome DevTools endpoint. If it OPENS, the debugging transport is
        // exposed to page script (automation leak); if it errors/closes (or
        // never connects within the budget) the port is unreachable — which is
        // what a normal browser, AND a correctly-driven CDP automation, both
        // present, because Chrome rejects DevTools WS upgrades that carry an
        // `Origin` header (every page-JS WebSocket does). The OLD probe used a
        // SYNCHRONOUS `new WebSocket(...); return false` which never reflects the
        // async connection outcome — it returned `false` for humans and bots
        // alike, so it always flagged critical. This async form actually tests
        // the surface. chromiumoxide awaits the returned Promise by default.
        probe("Chrome remote-debugging WS unreachable from page",
            "(() => new Promise((resolve) => { \
                var settled = false; \
                var done = function (v) { if (!settled) { settled = true; resolve(v); } }; \
                try { \
                    var ws = new WebSocket('ws://127.0.0.1:9222/devtools/page/00000000000000000000000000000000'); \
                    ws.onopen = function () { try { ws.close(); } catch (_) {} done(false); }; \
                    ws.onerror = function () { done(true); }; \
                    ws.onclose = function () { done(true); }; \
                } catch (_) { done(true); } \
                setTimeout(function () { done(true); }, 700); \
            }))()",
            Severity::Medium,
            classify_must_be_true),
        // ─── Tier 5 - document timing ────────────────────────────────
        probe("document.head.children.length >= 1",
            "document.head ? document.head.children.length : 0",
            Severity::Low,
            classify_must_be_nonzero_int),
    ]
}