bexxcv 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -0
- package/dist/plugins/gauntlet.js +1 -2
- package/dist/plugins/lens.js +77 -0
- package/dist/turnstile.d.ts +2 -0
- package/dist/turnstile.js +8 -1
- package/dist/uam.d.ts +15 -1
- package/dist/uam.js +44 -81
- package/dist/utils.js +96 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -329,6 +329,108 @@ See individual plugin documentation for configuration options.
|
|
|
329
329
|
|
|
330
330
|
---
|
|
331
331
|
|
|
332
|
+
## Lens Fingerprint Audit
|
|
333
|
+
|
|
334
|
+
The `lens` plugin audits the running browser's fingerprint in real time and reports any inconsistencies:
|
|
335
|
+
|
|
336
|
+
```ts
|
|
337
|
+
import { bexxcv, lens, lensReport } from "bexxcv";
|
|
338
|
+
|
|
339
|
+
const browser = await bexxcv({ headless: true });
|
|
340
|
+
const page = await browser.newPage();
|
|
341
|
+
await page.goto("https://example.com");
|
|
342
|
+
|
|
343
|
+
// The lens plugin runs automatically when added to plugins
|
|
344
|
+
const report = lensReport(page);
|
|
345
|
+
if (report) {
|
|
346
|
+
console.log(`Score: ${report.score}/100`);
|
|
347
|
+
for (const check of report.checks) {
|
|
348
|
+
if (!check.ok) console.log(` ❌ ${check.id}: ${check.detail}`);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
Run the audit manually on any page:
|
|
354
|
+
|
|
355
|
+
```ts
|
|
356
|
+
import { auditFingerprint } from "bexxcv";
|
|
357
|
+
|
|
358
|
+
const report = await auditFingerprint(page);
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Checks performed
|
|
362
|
+
|
|
363
|
+
| Check ID | What it validates |
|
|
364
|
+
|---|---|
|
|
365
|
+
| `webdriver` | `navigator.webdriver` is `undefined` / falsy |
|
|
366
|
+
| `ua-platform` | `navigator.platform` matches OS in UA string |
|
|
367
|
+
| `language` | First language in `navigator.languages` equals `navigator.language` |
|
|
368
|
+
| `locale-intl` | `Intl.DateTimeFormat()` locale matches `navigator.language` prefix |
|
|
369
|
+
| `dpr-screen` | CSS × DPR lands on a known physical monitor resolution |
|
|
370
|
+
| `window-size` | inner ≤ outer ≤ screen + 16 px (Chrome frame buffer) |
|
|
371
|
+
| `cores` | hardwareConcurrency is a plausible CPU core count |
|
|
372
|
+
| `touch` | `maxTouchPoints` is 0 on desktop UAs |
|
|
373
|
+
| `webgl` | WebGL vendor/renderer are present and non-null |
|
|
374
|
+
| `webgl-software` | Renderer is not a software fallback (llvmpipe/swiftshader) |
|
|
375
|
+
| `native-code` | Core APIs have `[native code]` toString output |
|
|
376
|
+
| `ua-hints` | `userAgentData` absent for Firefox, present for Chrome-like UAs |
|
|
377
|
+
| `chrome-object` | `window.chrome` absent for Firefox |
|
|
378
|
+
| `pdf-viewer` | `navigator.pdfViewerEnabled` is `true` on Firefox |
|
|
379
|
+
| `focus` | Page is focused and visible |
|
|
380
|
+
| `media-devices` | At least one media device or headless timeout fallback |
|
|
381
|
+
| `audio-sample-rate` | `AudioContext.sampleRate` is 44100 or 48000 |
|
|
382
|
+
| `fonts-enumerated` | `document.fonts.size > 0` and no load error |
|
|
383
|
+
| `webgl-shader-precision` | Highp float shader precision ≥ 23 (desktop GPU) |
|
|
384
|
+
| `client-hints-platform` | `userAgentData.platform` consistent with `navigator.platform` |
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
## Context Isolation
|
|
389
|
+
|
|
390
|
+
Every Playwright `browserContext` gets an independent fingerprint, storage, and cookies. Cross-context leakage is guarded by test coverage:
|
|
391
|
+
|
|
392
|
+
```ts
|
|
393
|
+
import { Camoufox } from "bexxcv";
|
|
394
|
+
|
|
395
|
+
const browser = await Camoufox({ headless: true });
|
|
396
|
+
|
|
397
|
+
const ctxA = await browser.newContext();
|
|
398
|
+
const ctxB = await browser.newContext();
|
|
399
|
+
|
|
400
|
+
const pageA = await ctxA.newPage();
|
|
401
|
+
const pageB = await ctxB.newPage();
|
|
402
|
+
|
|
403
|
+
await pageA.goto("https://example.com");
|
|
404
|
+
await pageB.goto("https://example.com");
|
|
405
|
+
|
|
406
|
+
// localStorage set in A is invisible from B
|
|
407
|
+
await pageA.evaluate(() => localStorage.setItem("key", "secret-a"));
|
|
408
|
+
const leaked = await pageB.evaluate(() => localStorage.getItem("key"));
|
|
409
|
+
console.log(leaked); // null ✓
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
Tests are in `test/isolation.test.ts`.
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
## Behavioral Seeding
|
|
417
|
+
|
|
418
|
+
Beyond raw fingerprint properties, bexxcv seeds high-level behavioral signals that detectors flag as suspicious when missing or default:
|
|
419
|
+
|
|
420
|
+
| Property Group | What Gets Seeded | Realism Logic |
|
|
421
|
+
|---|---|---|
|
|
422
|
+
| **Battery** | `battery:level`, `charging`, `dischargingTime` | Desktop → full & discharging; Laptop/Mac → 20–95% with ~25% charging state |
|
|
423
|
+
| **Media devices** | `mediaDevices:micros/webcams/speakers` | OS-weighted pools: mics [0-2], cams [0-2], speakers [0-4] |
|
|
424
|
+
| **Speech voices** | `voices[]`, `blockIfNotDefined`, `fakeCompletion` | 2–10 voices matching locale language |
|
|
425
|
+
| **Do Not Track** | `navigator.doNotTrack` | ~20% of real users enable DNT |
|
|
426
|
+
| **GPC** | `navigator.globalPrivacyControl` | ~10% signal GPC |
|
|
427
|
+
| **Referrer policy** | Firefox pref `privacy.referrer_policy` | Same-Origin on cross-origin for non-headless |
|
|
428
|
+
| **Online/cookies** | `navigator.onLine`, `cookieEnabled` | Almost always online and cookies enabled |
|
|
429
|
+
|
|
430
|
+
These are applied automatically when the installed Camoufox build supports the corresponding properties. Run `npx bexxcv doctor` to see your build's supported properties.
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
332
434
|
## Persistent context
|
|
333
435
|
|
|
334
436
|
```ts
|
package/dist/plugins/gauntlet.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { sleep } from "../random.js";
|
|
2
2
|
import { createClicker, findWidgets, solveTurnstile } from "../turnstile.js";
|
|
3
|
-
import { humanActivity, isChallenge,
|
|
3
|
+
import { humanActivity, isChallenge, waitForUam, } from "../uam.js";
|
|
4
4
|
const RESULTS = new WeakMap();
|
|
5
5
|
const WRAPPED = new WeakSet();
|
|
6
6
|
const RUNNING = new WeakSet();
|
|
@@ -88,7 +88,6 @@ export function gauntlet(options = {}) {
|
|
|
88
88
|
if (WRAPPED.has(page))
|
|
89
89
|
return;
|
|
90
90
|
WRAPPED.add(page);
|
|
91
|
-
trackMitigation(page);
|
|
92
91
|
const originalGoto = page.goto.bind(page);
|
|
93
92
|
page.goto = (async (...args) => {
|
|
94
93
|
const response = await originalGoto(...args);
|
package/dist/plugins/lens.js
CHANGED
|
@@ -48,6 +48,65 @@ export async function auditFingerprint(page) {
|
|
|
48
48
|
mediaDevices = null;
|
|
49
49
|
}
|
|
50
50
|
const nav = navigator;
|
|
51
|
+
// AudioContext sampling
|
|
52
|
+
let audioSampleRate = null;
|
|
53
|
+
let audioLatency = null;
|
|
54
|
+
try {
|
|
55
|
+
const ac = new (window.AudioContext || window.webkitAudioContext)();
|
|
56
|
+
audioSampleRate = ac.sampleRate;
|
|
57
|
+
audioLatency = typeof ac.outputLatency === "number" ? ac.outputLatency : null;
|
|
58
|
+
ac.close();
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
audioSampleRate = null;
|
|
62
|
+
}
|
|
63
|
+
// Font enumeration
|
|
64
|
+
let fontCount = null;
|
|
65
|
+
let fontLoadError = null;
|
|
66
|
+
try {
|
|
67
|
+
await document.fonts.ready;
|
|
68
|
+
fontCount = document.fonts.size;
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
fontLoadError = true;
|
|
72
|
+
fontCount = null;
|
|
73
|
+
}
|
|
74
|
+
// WebGL shader precision
|
|
75
|
+
let webglPrecisionHighpFloat = null;
|
|
76
|
+
let webglPrecisionLowpFloat = null;
|
|
77
|
+
try {
|
|
78
|
+
const canvas2 = document.createElement("canvas");
|
|
79
|
+
const gl2 = canvas2.getContext("webgl");
|
|
80
|
+
if (gl2) {
|
|
81
|
+
const fmt = gl2.getShaderPrecisionFormat(WebGLRenderingContext.FRAGMENT_SHADER, WebGLRenderingContext.HIGH_FLOAT);
|
|
82
|
+
if (fmt)
|
|
83
|
+
webglPrecisionHighpFloat = fmt.precision;
|
|
84
|
+
const fmtLow = gl2.getShaderPrecisionFormat(WebGLRenderingContext.FRAGMENT_SHADER, WebGLRenderingContext.LOW_FLOAT);
|
|
85
|
+
if (fmtLow)
|
|
86
|
+
webglPrecisionLowpFloat = fmtLow.precision;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
// WebGL unavailable — non-fatal
|
|
91
|
+
}
|
|
92
|
+
// Client Hints (userAgentData)
|
|
93
|
+
const uad = navigator.userAgentData;
|
|
94
|
+
let userAgentDataPlatform = null;
|
|
95
|
+
let clientHintsMobile = null;
|
|
96
|
+
if (uad && typeof uad.getHighEntropyValues === "function") {
|
|
97
|
+
try {
|
|
98
|
+
const hints = await uad.getHighEntropyValues(["platform", "mobile"]);
|
|
99
|
+
userAgentDataPlatform = hints.platform ?? null;
|
|
100
|
+
clientHintsMobile = hints.mobile ?? null;
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
// Permission denied or not available
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else if (uad && uad.platform) {
|
|
107
|
+
userAgentDataPlatform = String(uad.platform);
|
|
108
|
+
clientHintsMobile = Boolean(uad.mobile);
|
|
109
|
+
}
|
|
51
110
|
return {
|
|
52
111
|
ua: navigator.userAgent,
|
|
53
112
|
platform: navigator.platform,
|
|
@@ -74,6 +133,14 @@ export async function auditFingerprint(page) {
|
|
|
74
133
|
visible: document.visibilityState === "visible",
|
|
75
134
|
mediaDevices,
|
|
76
135
|
mediaTimeout,
|
|
136
|
+
audioSampleRate,
|
|
137
|
+
audioLatency,
|
|
138
|
+
fontCount,
|
|
139
|
+
fontLoadError,
|
|
140
|
+
webglPrecisionHighpFloat,
|
|
141
|
+
webglPrecisionLowpFloat,
|
|
142
|
+
userAgentDataPlatform,
|
|
143
|
+
clientHintsMobile,
|
|
77
144
|
};
|
|
78
145
|
});
|
|
79
146
|
const checks = [];
|
|
@@ -101,6 +168,16 @@ export async function auditFingerprint(page) {
|
|
|
101
168
|
add("media-devices", (probe.mediaDevices === null || probe.mediaDevices > 0), probe.mediaTimeout
|
|
102
169
|
? "enumerateDevices timeout (headless fallback, non-fatal)"
|
|
103
170
|
: `${probe.mediaDevices} media devices`);
|
|
171
|
+
// --- Audio Context sample rate ---
|
|
172
|
+
add("audio-sample-rate", probe.audioSampleRate !== null && (probe.audioSampleRate === 44100 || probe.audioSampleRate === 48000), `AudioContext sampleRate ${probe.audioSampleRate ?? "unavailable"} (expected 44100 or 48000)`);
|
|
173
|
+
// --- Font enumeration ---
|
|
174
|
+
add("fonts-enumerated", probe.fontCount !== null && probe.fontCount > 0 && !probe.fontLoadError, `${probe.fontCount ?? "unknown"} fonts available${probe.fontLoadError ? " (load error)" : ""}`);
|
|
175
|
+
// --- WebGL shader precision (desktop GPUs should report highp float precision >= 23) ---
|
|
176
|
+
add("webgl-shader-precision", probe.webglPrecisionHighpFloat !== null && probe.webglPrecisionHighpFloat >= 23, `highp float precision ${probe.webglPrecisionHighpFloat ?? "unknown"} (expected ≥23 on desktop GPU)`);
|
|
177
|
+
// --- Client Hints platform consistency ---
|
|
178
|
+
// Firefox must NOT expose userAgentData; when it does, platform must match navigator.platform
|
|
179
|
+
add("client-hints-platform", !firefox || probe.userAgentDataPlatform === null ||
|
|
180
|
+
probe.userAgentDataPlatform === probe.platform.toLowerCase().replace("winnt", "windows").replace("macintosh", "mac"), `userAgentData.platform "${probe.userAgentDataPlatform ?? "absent"}" vs navigator.platform "${probe.platform}"`);
|
|
104
181
|
const passed = checks.filter((check) => check.ok).length;
|
|
105
182
|
return { score: Math.round((passed / checks.length) * 100), checks };
|
|
106
183
|
}
|
package/dist/turnstile.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Browser, BrowserContext, Page } from "playwright-core";
|
|
2
2
|
export interface TurnstileOptions {
|
|
3
|
+
/** Polling interval for checking widget state (ms). */
|
|
3
4
|
interval?: number;
|
|
5
|
+
/** Minimum time between repeated clicks on the same widget (ms). */
|
|
4
6
|
retryAfter?: number;
|
|
5
7
|
}
|
|
6
8
|
export interface Widget {
|
package/dist/turnstile.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { onEachPage } from "./pagehooks.js";
|
|
2
2
|
import { between, sleep } from "./random.js";
|
|
3
3
|
const WATCHED = new WeakSet();
|
|
4
|
+
// --- Widget discovery --------------------------------------------------------
|
|
4
5
|
export async function findWidgets(page) {
|
|
5
6
|
return page.evaluate(() => {
|
|
6
7
|
const out = [];
|
|
@@ -19,12 +20,14 @@ export async function findWidgets(page) {
|
|
|
19
20
|
seen.add(key);
|
|
20
21
|
out.push({ x: rect.x, y: rect.y, w: rect.width, h: rect.height, solved, key });
|
|
21
22
|
};
|
|
23
|
+
// 1. Implicit rendering: hidden input with the token
|
|
22
24
|
for (const input of Array.from(document.querySelectorAll('[name="cf-turnstile-response"]'))) {
|
|
23
25
|
const parent = input.parentElement;
|
|
24
26
|
if (!parent)
|
|
25
27
|
continue;
|
|
26
|
-
push(parent, !!input.value && input.value.length >
|
|
28
|
+
push(parent, !!(input.value && input.value.length > 20));
|
|
27
29
|
}
|
|
30
|
+
// 2. Fallback: bare widget box heuristic (width ~300px, empty, compact)
|
|
28
31
|
if (out.length === 0) {
|
|
29
32
|
for (const strict of [true, false]) {
|
|
30
33
|
for (const div of Array.from(document.querySelectorAll("div"))) {
|
|
@@ -45,6 +48,7 @@ export async function findWidgets(page) {
|
|
|
45
48
|
return out;
|
|
46
49
|
});
|
|
47
50
|
}
|
|
51
|
+
// --- Token reading -----------------------------------------------------------
|
|
48
52
|
export async function readTurnstileToken(page) {
|
|
49
53
|
try {
|
|
50
54
|
return await page.evaluate(() => {
|
|
@@ -68,6 +72,7 @@ export async function readTurnstileToken(page) {
|
|
|
68
72
|
return null;
|
|
69
73
|
}
|
|
70
74
|
}
|
|
75
|
+
// --- Click helpers -----------------------------------------------------------
|
|
71
76
|
async function clickAt(page, x, y) {
|
|
72
77
|
await page.mouse.move(x + between(-60, 60), y + between(-40, 40), { steps: 4 });
|
|
73
78
|
await sleep(between(60, 160));
|
|
@@ -101,6 +106,7 @@ export function createClicker(retryAfter = 8000) {
|
|
|
101
106
|
return result.clicks > 0;
|
|
102
107
|
};
|
|
103
108
|
}
|
|
109
|
+
// --- Solve -------------------------------------------------------------------
|
|
104
110
|
export async function solveTurnstile(page, timeout = 30000, idleChecks = 4, retryAfter = 8000) {
|
|
105
111
|
const end = Date.now() + timeout;
|
|
106
112
|
const clicked = new Map();
|
|
@@ -122,6 +128,7 @@ export async function solveTurnstile(page, timeout = 30000, idleChecks = 4, retr
|
|
|
122
128
|
}
|
|
123
129
|
return readTurnstileToken(page);
|
|
124
130
|
}
|
|
131
|
+
// --- Watcher -----------------------------------------------------------------
|
|
125
132
|
export function watchTurnstile(page, options = {}) {
|
|
126
133
|
if (WATCHED.has(page))
|
|
127
134
|
return;
|
package/dist/uam.d.ts
CHANGED
|
@@ -1,18 +1,32 @@
|
|
|
1
1
|
import type { Browser, BrowserContext, Page } from "playwright-core";
|
|
2
|
+
import { type HumanOptions } from "./human.js";
|
|
2
3
|
export interface UamOptions {
|
|
4
|
+
/** Max time to wait for a cf_clearance cookie after navigation (ms). */
|
|
3
5
|
timeout?: number;
|
|
6
|
+
/** Polling interval when watching for new challenges (ms). */
|
|
4
7
|
interval?: number;
|
|
8
|
+
/** Whether to wait for clearance right after each page.goto(). */
|
|
5
9
|
waitOnGoto?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Optional external helper that can perform an action on the challenge page
|
|
12
|
+
* (e.g. click a checkbox). Return true if an action was taken.
|
|
13
|
+
*/
|
|
6
14
|
assist?: (page: Page) => Promise<boolean>;
|
|
15
|
+
/** Forwarded to the internal {@link Human} actor for mouse movements. */
|
|
16
|
+
human?: HumanOptions;
|
|
7
17
|
}
|
|
8
18
|
export interface UamResult {
|
|
9
19
|
challenged: boolean;
|
|
10
20
|
bypassed: boolean;
|
|
11
21
|
cookie: string | null;
|
|
12
22
|
}
|
|
13
|
-
export declare function trackMitigation(page: Page): void;
|
|
14
23
|
export declare function isChallenge(page: Page): Promise<boolean>;
|
|
15
24
|
export declare function humanActivity(page: Page, scale?: number): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Waits until a `cf_clearance` cookie is present for the current page origin.
|
|
27
|
+
* If a challenge page was seen, performs light human-like activity while
|
|
28
|
+
* polling — matching the strategy used by cf-clearance-scraper.
|
|
29
|
+
*/
|
|
16
30
|
export declare function waitForUam(page: Page, options?: UamOptions): Promise<UamResult>;
|
|
17
31
|
export declare function watchUam(page: Page, options?: UamOptions): void;
|
|
18
32
|
export declare function attachUam<T extends Browser | BrowserContext>(target: T, options?: UamOptions): T;
|
package/dist/uam.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { onEachPage } from "./pagehooks.js";
|
|
2
2
|
import { between, sleep } from "./random.js";
|
|
3
|
+
import { Human } from "./human.js";
|
|
3
4
|
const CHALLENGE_TITLES = [
|
|
4
5
|
"just a moment",
|
|
5
6
|
"tunggu sebentar",
|
|
@@ -13,86 +14,65 @@ const CHALLENGE_TITLES = [
|
|
|
13
14
|
];
|
|
14
15
|
const WATCHED = new WeakSet();
|
|
15
16
|
const BUSY = new WeakSet();
|
|
16
|
-
|
|
17
|
-
const TRACKED = new WeakSet();
|
|
18
|
-
export function trackMitigation(page) {
|
|
19
|
-
if (TRACKED.has(page))
|
|
20
|
-
return;
|
|
21
|
-
TRACKED.add(page);
|
|
22
|
-
page.on("response", (response) => {
|
|
23
|
-
const request = response.request();
|
|
24
|
-
if (!request.isNavigationRequest())
|
|
25
|
-
return;
|
|
26
|
-
if (request.frame() !== page.mainFrame())
|
|
27
|
-
return;
|
|
28
|
-
MITIGATED.set(page, response.headers()["cf-mitigated"] === "challenge");
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
export async function isChallenge(page) {
|
|
32
|
-
if (MITIGATED.get(page))
|
|
33
|
-
return true;
|
|
34
|
-
const title = (await page.title().catch(() => "")).toLowerCase();
|
|
35
|
-
return CHALLENGE_TITLES.some((t) => title.includes(t));
|
|
36
|
-
}
|
|
17
|
+
// --- Helpers -----------------------------------------------------------------
|
|
37
18
|
async function cookieValue(page, name) {
|
|
38
19
|
try {
|
|
39
|
-
const
|
|
20
|
+
const url = page.url();
|
|
21
|
+
if (!url || url === "about:blank")
|
|
22
|
+
return null;
|
|
23
|
+
const cookies = await page.context().cookies(url);
|
|
40
24
|
return cookies.find((c) => c.name === name)?.value ?? null;
|
|
41
25
|
}
|
|
42
26
|
catch {
|
|
43
27
|
return null;
|
|
44
28
|
}
|
|
45
29
|
}
|
|
30
|
+
export async function isChallenge(page) {
|
|
31
|
+
const title = (await page.title().catch(() => "")).toLowerCase();
|
|
32
|
+
return CHALLENGE_TITLES.some((t) => title.includes(t));
|
|
33
|
+
}
|
|
46
34
|
export async function humanActivity(page, scale = 1) {
|
|
47
|
-
let width = 1280;
|
|
48
|
-
let height = 720;
|
|
49
35
|
const view = page.viewportSize();
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
try {
|
|
56
|
-
const size = await page.evaluate(() => ({
|
|
57
|
-
w: window.innerWidth,
|
|
58
|
-
h: window.innerHeight,
|
|
59
|
-
}));
|
|
60
|
-
width = size.w;
|
|
61
|
-
height = size.h;
|
|
62
|
-
}
|
|
63
|
-
catch {
|
|
64
|
-
width = 1280;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
const moves = Math.max(1, Math.floor(between(4, 8) * scale));
|
|
68
|
-
for (let i = 0; i < moves; i++) {
|
|
69
|
-
await page.mouse.move(between(width * 0.1, width * 0.9), between(height * 0.1, height * 0.9), { steps: Math.floor(between(6, 14)) });
|
|
70
|
-
await sleep(between(250, 650));
|
|
71
|
-
}
|
|
72
|
-
const scrolls = Math.max(1, Math.floor(between(2, 5) * scale));
|
|
73
|
-
for (let i = 0; i < scrolls; i++) {
|
|
74
|
-
await page.mouse.wheel(0, between(60, 180));
|
|
75
|
-
await sleep(between(400, 900));
|
|
36
|
+
const opts = { speed: scale < 1 ? 0.4 : 1 };
|
|
37
|
+
const actor = new Human(page, opts);
|
|
38
|
+
await actor.idle(Math.round(800 * (2 - scale)));
|
|
39
|
+
for (let i = 0; i < Math.max(1, Math.floor(2 * scale)); i++) {
|
|
40
|
+
await actor.scroll(between(60, 180));
|
|
76
41
|
}
|
|
77
42
|
}
|
|
43
|
+
// --- Main wait loop ----------------------------------------------------------
|
|
44
|
+
/**
|
|
45
|
+
* Waits until a `cf_clearance` cookie is present for the current page origin.
|
|
46
|
+
* If a challenge page was seen, performs light human-like activity while
|
|
47
|
+
* polling — matching the strategy used by cf-clearance-scraper.
|
|
48
|
+
*/
|
|
78
49
|
export async function waitForUam(page, options = {}) {
|
|
79
|
-
trackMitigation(page);
|
|
80
50
|
const timeout = options.timeout ?? 30000;
|
|
81
51
|
const start = Date.now();
|
|
82
52
|
let challenged = false;
|
|
83
|
-
let
|
|
53
|
+
let consecutiveMisses = 0;
|
|
84
54
|
while (Date.now() - start < timeout && !page.isClosed()) {
|
|
85
|
-
|
|
55
|
+
const cookie = await cookieValue(page, "cf_clearance");
|
|
56
|
+
// Cookie present — done
|
|
57
|
+
if (cookie) {
|
|
58
|
+
return { challenged, bypassed: true, cookie };
|
|
59
|
+
}
|
|
60
|
+
// Detect whether we're currently on a challenge page
|
|
61
|
+
const challenging = await isChallenge(page);
|
|
62
|
+
if (challenging) {
|
|
86
63
|
challenged = true;
|
|
64
|
+
// Give the external assist callback a chance to interact
|
|
87
65
|
if (options.assist) {
|
|
88
66
|
const acted = await options.assist(page).catch(() => false);
|
|
89
67
|
if (acted) {
|
|
90
|
-
|
|
68
|
+
consecutiveMisses = 0;
|
|
69
|
+
await sleep(2000);
|
|
91
70
|
continue;
|
|
92
71
|
}
|
|
93
72
|
}
|
|
73
|
+
// Light human activity while waiting for the JS challenge to complete
|
|
94
74
|
try {
|
|
95
|
-
await humanActivity(page);
|
|
75
|
+
await humanActivity(page, 0.5);
|
|
96
76
|
}
|
|
97
77
|
catch {
|
|
98
78
|
await sleep(500);
|
|
@@ -100,36 +80,20 @@ export async function waitForUam(page, options = {}) {
|
|
|
100
80
|
await sleep(1500);
|
|
101
81
|
continue;
|
|
102
82
|
}
|
|
103
|
-
|
|
104
|
-
if (!
|
|
105
|
-
|
|
106
|
-
return { challenged: false, bypassed: false, cookie: null };
|
|
107
|
-
missing++;
|
|
108
|
-
if (missing > 3)
|
|
109
|
-
return { challenged: true, bypassed: true, cookie: null };
|
|
110
|
-
await sleep(1000);
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
const retry = await cookieValue(page, "cf_chl_rc_ni");
|
|
114
|
-
if (!challenged && !retry) {
|
|
115
|
-
return { challenged: false, bypassed: true, cookie };
|
|
116
|
-
}
|
|
117
|
-
try {
|
|
118
|
-
await humanActivity(page, 0.4);
|
|
119
|
-
}
|
|
120
|
-
catch {
|
|
121
|
-
await sleep(500);
|
|
83
|
+
// Not challenged but no cookie yet — could be mid-navigation or still loading
|
|
84
|
+
if (!challenged) {
|
|
85
|
+
return { challenged: false, bypassed: false, cookie: null };
|
|
122
86
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return { challenged, bypassed: true, cookie: second };
|
|
87
|
+
// Challenged before but cookie still missing after repeated polls
|
|
88
|
+
consecutiveMisses++;
|
|
89
|
+
if (consecutiveMisses > 8) {
|
|
90
|
+
return { challenged: true, bypassed: true, cookie: null };
|
|
128
91
|
}
|
|
129
|
-
await sleep(
|
|
92
|
+
await sleep(1000);
|
|
130
93
|
}
|
|
131
94
|
return { challenged, bypassed: false, cookie: null };
|
|
132
95
|
}
|
|
96
|
+
// --- Watcher -----------------------------------------------------------------
|
|
133
97
|
async function runWait(page, options) {
|
|
134
98
|
if (BUSY.has(page))
|
|
135
99
|
return undefined;
|
|
@@ -145,7 +109,6 @@ export function watchUam(page, options = {}) {
|
|
|
145
109
|
if (WATCHED.has(page))
|
|
146
110
|
return;
|
|
147
111
|
WATCHED.add(page);
|
|
148
|
-
trackMitigation(page);
|
|
149
112
|
const interval = options.interval ?? 1500;
|
|
150
113
|
const timeout = options.timeout ?? 30000;
|
|
151
114
|
const waitOnGoto = options.waitOnGoto ?? true;
|
package/dist/utils.js
CHANGED
|
@@ -4,7 +4,7 @@ import path from "node:path";
|
|
|
4
4
|
import { UAParser } from "ua-parser-js";
|
|
5
5
|
import { addDefaultAddons, confirmPaths, } from "./addons.js";
|
|
6
6
|
import { InvalidOS, InvalidPropertyType, NonFirefoxFingerprint, UnknownProperty, } from "./exceptions.js";
|
|
7
|
-
import { fromBrowserforge, generateFingerprint, SUPPORTED_OS, } from "./fingerprints.js";
|
|
7
|
+
import { cryptoFloat, fromBrowserforge, generateFingerprint, SUPPORTED_OS, } from "./fingerprints.js";
|
|
8
8
|
import { publicIP, validIPv4, validIPv6 } from "./ip.js";
|
|
9
9
|
import { coherentDprWeights, languageList, realismDefaults, reconcileWebglKeys, snapScreen, } from "./realism.js";
|
|
10
10
|
import { geoipAllowed, getGeolocation, handleLocales } from "./locale.js";
|
|
@@ -94,6 +94,97 @@ function loadProperties(filePath) {
|
|
|
94
94
|
return acc;
|
|
95
95
|
}, {});
|
|
96
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* High-level behavioral property seeding.
|
|
99
|
+
* These are properties that aren't part of the raw fingerprint generator output
|
|
100
|
+
* but significantly affect detection scores when left at defaults or missing.
|
|
101
|
+
*/
|
|
102
|
+
function seedBehavioralProperties(config, fpExtended, targetOS, headless, knownProperties, firefoxUserPrefs) {
|
|
103
|
+
// --- Battery API ---
|
|
104
|
+
// Desktops → always discharging with long remaining time.
|
|
105
|
+
// Laptops/macs → mixed charging states (real Macs report ~50-90% on most machines).
|
|
106
|
+
if ("battery:level" in knownProperties) {
|
|
107
|
+
const isLaptop = targetOS === "mac" || (targetOS === "win" && cryptoFloat() < 0.6);
|
|
108
|
+
if (isLaptop) {
|
|
109
|
+
setInto(config, "battery:level", +(0.2 + cryptoFloat() * 0.75).toFixed(2));
|
|
110
|
+
if (cryptoFloat() < 0.25) {
|
|
111
|
+
setInto(config, "battery:charging", true);
|
|
112
|
+
setInto(config, "battery:chargingTime", 0);
|
|
113
|
+
setInto(config, "battery:dischargingTime", +(900 + cryptoRandInt(0, 7200)).toString());
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
setInto(config, "battery:charging", false);
|
|
117
|
+
setInto(config, "battery:chargingTime", Infinity);
|
|
118
|
+
setInto(config, "battery:dischargingTime", +(600 + cryptoRandInt(0, 10800)).toString());
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
setInto(config, "battery:level", 1);
|
|
123
|
+
setInto(config, "battery:charging", false);
|
|
124
|
+
setInto(config, "battery:chargingTime", Infinity);
|
|
125
|
+
setInto(config, "battery:dischargingTime", Infinity);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// --- Media devices ---
|
|
129
|
+
// Realistic counts per OS: desktops often have 0-1 mic, laptops 1-2, webcams 0-2
|
|
130
|
+
const micPool = [0, 0, 1, 1, 1, 2, 2];
|
|
131
|
+
const camPool = [0, 0, 0, 1, 1, 2];
|
|
132
|
+
const spkPool = [0, 1, 1, 1, 2, 2, 3, 4];
|
|
133
|
+
if ("mediaDevices:enabled" in knownProperties)
|
|
134
|
+
setInto(config, "mediaDevices:enabled", true);
|
|
135
|
+
if ("mediaDevices:micros" in knownProperties)
|
|
136
|
+
setInto(config, "mediaDevices:micros", micPool[cryptoRandInt(0, micPool.length - 1)]);
|
|
137
|
+
if ("mediaDevices:webcams" in knownProperties)
|
|
138
|
+
setInto(config, "mediaDevices:webcams", camPool[cryptoRandInt(0, camPool.length - 1)]);
|
|
139
|
+
if ("mediaDevices:speakers" in knownProperties)
|
|
140
|
+
setInto(config, "mediaDevices:speakers", spkPool[cryptoRandInt(0, spkPool.length - 1)]);
|
|
141
|
+
// --- Speech synthesis voices ---
|
|
142
|
+
// Match locale language; vary count realistically
|
|
143
|
+
if ("voices" in knownProperties) {
|
|
144
|
+
const voiceCount = 2 + cryptoRandInt(0, 8);
|
|
145
|
+
const voiceList = [];
|
|
146
|
+
const lang = config["locale:language"] ?? "en";
|
|
147
|
+
for (let i = 0; i < voiceCount; i++) {
|
|
148
|
+
voiceList.push({ lang, name: `${lang}-Voice-${i + 1}` });
|
|
149
|
+
}
|
|
150
|
+
config["voices"] = voiceList;
|
|
151
|
+
if ("voices:blockIfNotDefined" in knownProperties)
|
|
152
|
+
setInto(config, "voices:blockIfNotDefined", false);
|
|
153
|
+
if ("voices:fakeCompletion" in knownProperties)
|
|
154
|
+
setInto(config, "voices:fakeCompletion", false);
|
|
155
|
+
}
|
|
156
|
+
// --- Do Not Track ---
|
|
157
|
+
// ~20% of real users have DNT enabled
|
|
158
|
+
if ("navigator.doNotTrack" in knownProperties) {
|
|
159
|
+
setInto(config, "navigator.doNotTrack", cryptoFloat() < 0.2 ? "1" : "0");
|
|
160
|
+
}
|
|
161
|
+
// --- Global Privacy Control ---
|
|
162
|
+
// ~10% of browsers signal GPC
|
|
163
|
+
if ("navigator.globalPrivacyControl" in knownProperties) {
|
|
164
|
+
setInto(config, "navigator.globalPrivacyControl", cryptoFloat() < 0.1);
|
|
165
|
+
}
|
|
166
|
+
// --- Cookie enabled ---
|
|
167
|
+
if ("navigator.cookieEnabled" in knownProperties)
|
|
168
|
+
setInto(config, "navigator.cookieEnabled", true);
|
|
169
|
+
// --- Online state ---
|
|
170
|
+
// Very rarely offline
|
|
171
|
+
if ("navigator.onLine" in knownProperties) {
|
|
172
|
+
setInto(config, "navigator.onLine", cryptoFloat() > 0.002);
|
|
173
|
+
}
|
|
174
|
+
if (!headless) {
|
|
175
|
+
firefoxUserPrefs["privacy.referrer_policy"] = 1; // Same-Origin on cross-origin
|
|
176
|
+
}
|
|
177
|
+
// --- Max touch points consistency ---
|
|
178
|
+
if ("navigator.maxTouchPoints" in knownProperties) {
|
|
179
|
+
if (fpExtended.touchSupport) {
|
|
180
|
+
setInto(config, "navigator.maxTouchPoints", fpExtended.touchPoints);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
setInto(config, "navigator.maxTouchPoints", 0);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// --- Performance timing jitter is already handled via performance:now_jitter above
|
|
187
|
+
}
|
|
97
188
|
function formatTimezoneOffset(minutes) {
|
|
98
189
|
const sign = minutes >= 0 ? "+" : "-";
|
|
99
190
|
const abs = Math.abs(minutes);
|
|
@@ -473,6 +564,10 @@ export async function launchOptions({ config, os, block_images, block_webrtc, bl
|
|
|
473
564
|
setInto(config, "session:stickiness", true);
|
|
474
565
|
}
|
|
475
566
|
const targetOS = getTargetOS(config);
|
|
567
|
+
// --- Behavioral property seeding (battery, media devices, DNT, etc.) ---
|
|
568
|
+
if (fpExtended) {
|
|
569
|
+
seedBehavioralProperties(config, fpExtended, targetOS, Boolean(headlessBoolean), knownProperties, firefox_user_prefs);
|
|
570
|
+
}
|
|
476
571
|
setInto(config, "window.history.length", weightedPick([1, 2, 3, 4, 5, 6], [40, 25, 15, 10, 6, 4]));
|
|
477
572
|
if (fonts) {
|
|
478
573
|
config.fonts = fonts;
|