bexxcv 1.1.0 → 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 +267 -412
- package/dist/__version__.js +1 -1
- package/dist/fingerprints.d.ts +27 -2
- package/dist/fingerprints.js +122 -15
- package/dist/human_behavior.d.ts +20 -0
- package/dist/human_behavior.js +107 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +4 -0
- package/dist/locale.js +7 -3
- package/dist/pkgman.js +5 -3
- package/dist/plugins/dodge.js +5 -2
- package/dist/plugins/gauntlet.d.ts +1 -0
- package/dist/plugins/gauntlet.js +8 -2
- package/dist/plugins/index.d.ts +3 -3
- package/dist/plugins/lens.js +77 -0
- package/dist/schema.js +11 -2
- package/dist/session.d.ts +26 -0
- package/dist/session.js +96 -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.d.ts +12 -3
- package/dist/utils.js +177 -3
- package/dist/virtdisplay.js +23 -4
- package/dist/webgl/profiles.d.ts +12 -0
- package/dist/webgl/profiles.js +181 -0
- package/package.json +1 -1
package/dist/__version__.js
CHANGED
package/dist/fingerprints.d.ts
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
|
-
import { type Fingerprint, type FingerprintGeneratorOptions } from "fingerprint-generator";
|
|
1
|
+
import { type Fingerprint, type FingerprintGeneratorOptions, type ScreenFingerprint } from "fingerprint-generator";
|
|
2
2
|
export declare const SUPPORTED_OS: readonly ["linux", "macos", "windows"];
|
|
3
|
+
export declare function cryptoRandInt(min: number, max: number): number;
|
|
3
4
|
export declare function cryptoFloat(): number;
|
|
5
|
+
export interface ExtendedScreen extends ScreenFingerprint {
|
|
6
|
+
screenY?: number;
|
|
7
|
+
audioSeed?: number;
|
|
8
|
+
canvasSeed?: number;
|
|
9
|
+
webglVendor?: string;
|
|
10
|
+
webglRenderer?: string;
|
|
11
|
+
webglGLSL?: string;
|
|
12
|
+
webglExtensions?: string[];
|
|
13
|
+
fontSpacingSeed?: number;
|
|
14
|
+
perfJitter?: number;
|
|
15
|
+
timezoneOffsetJitter?: number;
|
|
16
|
+
memoryMultiplier?: number;
|
|
17
|
+
hardwareConcurrencySeed?: number;
|
|
18
|
+
touchSupport?: boolean;
|
|
19
|
+
touchPoints?: number;
|
|
20
|
+
pointerType?: "mouse" | "touch" | "pen";
|
|
21
|
+
onlineState?: boolean;
|
|
22
|
+
platformDeviceMemory?: number;
|
|
23
|
+
}
|
|
24
|
+
export declare function generateFingerprint(window?: [number, number], config?: Partial<FingerprintGeneratorOptions>): Fingerprint & ExtendedScreen;
|
|
4
25
|
export declare function fromBrowserforge(fingerprint: Fingerprint, ffVersion?: string): Record<string, any>;
|
|
5
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Returns a realistic font list for the given OS.
|
|
28
|
+
* These are actual system fonts that would appear on that platform.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getRealisticFonts(os: string): string[];
|
package/dist/fingerprints.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { FingerprintGenerator, } from "fingerprint-generator";
|
|
2
2
|
import BROWSERFORGE_DATA from "./mappings/browserforge.config.js";
|
|
3
|
+
import { sampleGPUProfile, resolveUAOS } from "./webgl/profiles.js";
|
|
3
4
|
export const SUPPORTED_OS = ["linux", "macos", "windows"];
|
|
4
5
|
const FP_GENERATOR = new FingerprintGenerator({
|
|
5
6
|
browsers: ["firefox"],
|
|
6
7
|
operatingSystems: SUPPORTED_OS,
|
|
7
8
|
});
|
|
8
|
-
function
|
|
9
|
+
export function cryptoRandInt(min, max) {
|
|
9
10
|
const buf = new Uint32Array(1);
|
|
10
11
|
crypto.getRandomValues(buf);
|
|
11
12
|
return min + (buf[0] % (max - min + 1));
|
|
@@ -15,6 +16,60 @@ export function cryptoFloat() {
|
|
|
15
16
|
crypto.getRandomValues(buf);
|
|
16
17
|
return buf[0] / 0x100000000;
|
|
17
18
|
}
|
|
19
|
+
// Realistic font lists per OS — these are actual system fonts, not random strings
|
|
20
|
+
const REALISTIC_FONTS = {
|
|
21
|
+
win: [
|
|
22
|
+
"Arial", "Arial Black", "Calibri", "Cambria", "Cambria Math", "Comic Sans MS",
|
|
23
|
+
"Consolas", "Courier New", "Georgia", "Impact", "Segoe UI", "Times New Roman",
|
|
24
|
+
"Trebuchet MS", "Verdana", "Microsoft YaHei", "Microsoft JhengHei",
|
|
25
|
+
],
|
|
26
|
+
mac: [
|
|
27
|
+
"Apple SD Gothic Neo", "Avenir", "Baskerville", "Big Caslon", "Chalkboard",
|
|
28
|
+
"Chalkboard SE", "Chiara Head", "Colorado", "Didot", "Futura", "Geneva",
|
|
29
|
+
"Gill Sans", "Helvetica", "Helvetica Neue", "Hiragino Kaku Gothic Pro",
|
|
30
|
+
"Hiragino Maru Gothic Pro", "Menlo", "Mukta Mahee", "MV Boli", "Noto Sans",
|
|
31
|
+
"Palatino", "San Francisco", "STHeiti", "Symbol", "Tahoma", "Thonburi",
|
|
32
|
+
"Times", "Trattatello", "Zapfino",
|
|
33
|
+
],
|
|
34
|
+
lin: [
|
|
35
|
+
"Arial", "Cantarell", "Comfortaa", "DejaVu Sans", "DejaVu Sans Mono",
|
|
36
|
+
"Fira Code", "Fira Sans", "Google Sans", "Iosevka", "Liberation Mono",
|
|
37
|
+
"Liberation Sans", "Liberation Serif", "Monospace", "Noto Color Emoji",
|
|
38
|
+
"Noto Sans", "Noto Sans CJK", "Roboto", "Source Code Pro", "Ubuntu",
|
|
39
|
+
"Ubuntu Condensed", "Ubuntu Mono",
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
// Realistic canvas noise patterns that match GPU output characteristics
|
|
43
|
+
const CANVAS_NOISE_PATTERNS = [
|
|
44
|
+
{ type: "gaussian", sigma: 0.5 },
|
|
45
|
+
{ type: "gaussian", sigma: 1.0 },
|
|
46
|
+
{ type: "poisson", rate: 0.3 },
|
|
47
|
+
{ type: "saltPepper", density: 0.02 },
|
|
48
|
+
{ type: "none" }, // clean renderers exist too
|
|
49
|
+
];
|
|
50
|
+
// Subtle timing variations that differ by GPU class
|
|
51
|
+
const RENDER_TIME_VARIATIONS = {
|
|
52
|
+
Intel: { minMs: 8, maxMs: 18 },
|
|
53
|
+
NVIDIA: { minMs: 3, maxMs: 8 },
|
|
54
|
+
AMD: { minMs: 4, maxMs: 10 },
|
|
55
|
+
Mesa: { minMs: 15, maxMs: 35 },
|
|
56
|
+
Apple: { minMs: 5, maxMs: 12 },
|
|
57
|
+
Microsoft: { minMs: 20, maxMs: 50 },
|
|
58
|
+
Mozilla: { minMs: 10, maxMs: 20 },
|
|
59
|
+
Google: { minMs: 6, maxMs: 14 },
|
|
60
|
+
};
|
|
61
|
+
function pickWeighted(items, weights) {
|
|
62
|
+
const total = weights.reduce((a, b) => a + b, 0);
|
|
63
|
+
const buf = new Uint32Array(1);
|
|
64
|
+
crypto.getRandomValues(buf);
|
|
65
|
+
let threshold = (buf[0] / 0x100000000) * total;
|
|
66
|
+
for (let i = 0; i < items.length; i++) {
|
|
67
|
+
threshold -= weights[i];
|
|
68
|
+
if (threshold <= 0)
|
|
69
|
+
return items[i];
|
|
70
|
+
}
|
|
71
|
+
return items[items.length - 1];
|
|
72
|
+
}
|
|
18
73
|
function _castToProperties(camoufoxData, castEnum, bfDict, ffVersion) {
|
|
19
74
|
for (let [key, data] of Object.entries(bfDict)) {
|
|
20
75
|
if (!data)
|
|
@@ -53,17 +108,63 @@ function handleScreenXY(camoufoxData, fpScreen) {
|
|
|
53
108
|
camoufoxData["window.screenY"] = 0;
|
|
54
109
|
}
|
|
55
110
|
else if (screenY > 0) {
|
|
56
|
-
camoufoxData["window.screenY"] =
|
|
111
|
+
camoufoxData["window.screenY"] = cryptoRandInt(0, screenY);
|
|
57
112
|
}
|
|
58
113
|
else {
|
|
59
|
-
camoufoxData["window.screenY"] =
|
|
114
|
+
camoufoxData["window.screenY"] = cryptoRandInt(screenY, 0);
|
|
60
115
|
}
|
|
61
116
|
}
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
117
|
+
function applyRealismSeeds(fp, ua) {
|
|
118
|
+
const os = resolveUAOS(ua);
|
|
119
|
+
const gpu = sampleGPUProfile(os);
|
|
120
|
+
// Core audio/canvas/font seeds
|
|
121
|
+
fp.audioSeed = cryptoRandInt(1, 4_294_967_295);
|
|
122
|
+
fp.canvasSeed = cryptoRandInt(1, 4_294_967_295);
|
|
123
|
+
fp.fontSpacingSeed = cryptoRandInt(1, 4_294_967_295);
|
|
124
|
+
fp.webglVendor = gpu.vendor;
|
|
125
|
+
fp.webglRenderer = gpu.renderer;
|
|
126
|
+
fp.webglGLSL = gpu.glslVersion;
|
|
127
|
+
fp.webglExtensions = gpu.webglExtensions;
|
|
128
|
+
// Performance timing jitter based on GPU class
|
|
129
|
+
const perfRange = RENDER_TIME_VARIATIONS[gpu.vendor] ?? { minMs: 5, maxMs: 20 };
|
|
130
|
+
fp.perfJitter = (cryptoFloat() - 0.5) * (perfRange.maxMs - perfRange.minMs);
|
|
131
|
+
// Timezone offset jitter (±15 min)
|
|
132
|
+
fp.timezoneOffsetJitter = cryptoRandInt(-15, 15) * 60; // in seconds
|
|
133
|
+
// Memory multiplier (0.85–1.15x base)
|
|
134
|
+
fp.memoryMultiplier = 0.85 + cryptoFloat() * 0.3;
|
|
135
|
+
// Hardware concurrency from realistic pool
|
|
136
|
+
const possibleCores = [2, 4, 6, 8, 10, 12, 16, 20, 24];
|
|
137
|
+
fp.hardwareConcurrencySeed = possibleCores[cryptoRandInt(0, possibleCores.length - 1)];
|
|
138
|
+
// Touch support correlates with device type (more common on mobile/tablets)
|
|
139
|
+
const touchChance = os === "win" ? 0.15 : os === "mac" ? 0.05 : 0.02;
|
|
140
|
+
fp.touchSupport = cryptoFloat() < touchChance;
|
|
141
|
+
fp.touchPoints = fp.touchSupport ? cryptoRandInt(1, 5) : 0;
|
|
142
|
+
// Pointer type consistency — desktop has mouse, touch devices have pointer+touch
|
|
143
|
+
if (fp.touchSupport) {
|
|
144
|
+
fp.pointerType = cryptoFloat() < 0.3 ? "touch" : "mouse";
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
fp.pointerType = cryptoFloat() < 0.05 ? "pen" : "mouse";
|
|
148
|
+
}
|
|
149
|
+
// Online state is almost always true for real browsers
|
|
150
|
+
fp.onlineState = cryptoFloat() > 0.001;
|
|
151
|
+
}
|
|
152
|
+
export function generateFingerprint(window, config) {
|
|
153
|
+
let fp;
|
|
154
|
+
if (window) {
|
|
155
|
+
const generated = FP_GENERATOR.getFingerprint(config);
|
|
156
|
+
fp = generated.fingerprint;
|
|
157
|
+
handleWindowSize(fp, window[0], window[1]);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
const generated = FP_GENERATOR.getFingerprint(config);
|
|
161
|
+
fp = generated.fingerprint;
|
|
162
|
+
}
|
|
163
|
+
const ua = fp.navigator?.userAgent ?? "";
|
|
164
|
+
if (ua) {
|
|
165
|
+
applyRealismSeeds(fp, ua);
|
|
166
|
+
}
|
|
167
|
+
return fp;
|
|
67
168
|
}
|
|
68
169
|
function handleWindowSize(fp, outerWidth, outerHeight) {
|
|
69
170
|
const sc = { ...fp.screen, screenY: undefined };
|
|
@@ -82,11 +183,17 @@ function handleWindowSize(fp, outerWidth, outerHeight) {
|
|
|
82
183
|
sc.outerHeight = outerHeight;
|
|
83
184
|
fp.screen = sc;
|
|
84
185
|
}
|
|
85
|
-
export function
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
186
|
+
export function fromBrowserforge(fingerprint, ffVersion) {
|
|
187
|
+
const camoufoxData = {};
|
|
188
|
+
_castToProperties(camoufoxData, BROWSERFORGE_DATA, { ...fingerprint }, ffVersion);
|
|
189
|
+
handleScreenXY(camoufoxData, fingerprint.screen);
|
|
190
|
+
return camoufoxData;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Returns a realistic font list for the given OS.
|
|
194
|
+
* These are actual system fonts that would appear on that platform.
|
|
195
|
+
*/
|
|
196
|
+
export function getRealisticFonts(os) {
|
|
197
|
+
const key = os.toLowerCase();
|
|
198
|
+
return REALISTIC_FONTS[key] ?? REALISTIC_FONTS.lin;
|
|
92
199
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Page } from "playwright-core";
|
|
2
|
+
export interface HumanBehaviorOptions {
|
|
3
|
+
speed?: number;
|
|
4
|
+
typoRate?: number;
|
|
5
|
+
scrollPattern?: "natural" | "linear" | "burst";
|
|
6
|
+
idleDrift?: boolean;
|
|
7
|
+
sessionTimeout?: number;
|
|
8
|
+
maxPagesPerSession?: number;
|
|
9
|
+
pageTransitionMinMs?: number;
|
|
10
|
+
pageTransitionMaxMs?: number;
|
|
11
|
+
mouseAcceleration?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function attachHumanBehavior(page: Page, options?: HumanBehaviorOptions): void;
|
|
14
|
+
export declare function detachHumanBehavior(page: Page): void;
|
|
15
|
+
export declare function getSessionInfo(page: Page): {
|
|
16
|
+
id: string | null;
|
|
17
|
+
pageCount: number;
|
|
18
|
+
ageMs: number;
|
|
19
|
+
} | null;
|
|
20
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { initSession, advancePage, endSession, getSessionId } from "./session.js";
|
|
2
|
+
const DEFAULT_MIN_MS = 800;
|
|
3
|
+
const DEFAULT_MAX_MS = 3_000;
|
|
4
|
+
const DEFAULT_TIMEOUT = 1_800_000;
|
|
5
|
+
function ensureOpts(opts) {
|
|
6
|
+
return {
|
|
7
|
+
pageTransitionMinMs: opts.pageTransitionMinMs ?? DEFAULT_MIN_MS,
|
|
8
|
+
pageTransitionMaxMs: opts.pageTransitionMaxMs ?? DEFAULT_MAX_MS,
|
|
9
|
+
sessionTimeout: opts.sessionTimeout ?? DEFAULT_TIMEOUT,
|
|
10
|
+
...opts,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function cryptoRandBetween(min, max) {
|
|
14
|
+
const buf = new Uint32Array(1);
|
|
15
|
+
crypto.getRandomValues(buf);
|
|
16
|
+
return min + (buf[0] / 0x100000000) * (max - min);
|
|
17
|
+
}
|
|
18
|
+
function cryptoGauss(seed, index, mean, sd) {
|
|
19
|
+
let hash = 0x9e3779b9;
|
|
20
|
+
for (let i = 0; i < seed.length; i++) {
|
|
21
|
+
hash = ((hash << 5) - hash + seed[i]) >>> 0;
|
|
22
|
+
}
|
|
23
|
+
hash = (hash + index * 0x5bd1e995) >>> 0;
|
|
24
|
+
const u1 = Math.max((hash >>> 0) / 0x100000000, 1e-10);
|
|
25
|
+
const nextHash = (hash ^ 0x9e3779b9) >>> 0;
|
|
26
|
+
const u2 = nextHash / 0x100000000;
|
|
27
|
+
const z = Math.sqrt(-2 * Math.log(u1)) * Math.cos(2 * Math.PI * u2);
|
|
28
|
+
return mean + sd * z;
|
|
29
|
+
}
|
|
30
|
+
function createSession(page, opts) {
|
|
31
|
+
if (!getSessionId(page)) {
|
|
32
|
+
initSession(page, { timeout: opts.sessionTimeout });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function getPageDelay(page, opts) {
|
|
36
|
+
const resolved = ensureOpts(opts);
|
|
37
|
+
const state = page._bexxcv_session;
|
|
38
|
+
if (!state)
|
|
39
|
+
return cryptoRandBetween(resolved.pageTransitionMinMs, resolved.pageTransitionMaxMs);
|
|
40
|
+
const elapsed = Date.now() - state.createdAt;
|
|
41
|
+
const progress = Math.min(elapsed / resolved.sessionTimeout, 1);
|
|
42
|
+
const baseDelay = cryptoRandBetween(resolved.pageTransitionMinMs, resolved.pageTransitionMaxMs);
|
|
43
|
+
const fatigueFactor = 1 + progress * 0.5;
|
|
44
|
+
return baseDelay * fatigueFactor;
|
|
45
|
+
}
|
|
46
|
+
export function attachHumanBehavior(page, options = {}) {
|
|
47
|
+
const opts = ensureOpts(options);
|
|
48
|
+
createSession(page, opts);
|
|
49
|
+
page._bexxcv_human_options = opts;
|
|
50
|
+
const originalGoto = page.goto.bind(page);
|
|
51
|
+
page.goto = async (...args) => {
|
|
52
|
+
const delay = getPageDelay(page, opts);
|
|
53
|
+
await sleep(cryptoRandBetween(delay * 0.3, delay));
|
|
54
|
+
const result = await originalGoto(...args);
|
|
55
|
+
advancePage(page);
|
|
56
|
+
return result;
|
|
57
|
+
};
|
|
58
|
+
const originalClick = page.click.bind(page);
|
|
59
|
+
page.click = async (selector, ...args) => {
|
|
60
|
+
await sleep(cryptoRandBetween(120, 400));
|
|
61
|
+
return originalClick(selector, ...args);
|
|
62
|
+
};
|
|
63
|
+
const originalEvaluate = page.evaluate.bind(page);
|
|
64
|
+
page.evaluate = async (pageFunction, ...evalArgs) => {
|
|
65
|
+
if (opts.idleDrift) {
|
|
66
|
+
const view = await page.viewportSize();
|
|
67
|
+
if (view) {
|
|
68
|
+
const state = page._bexxcv_session;
|
|
69
|
+
const seed = state?.seedBuffer ?? new Uint8Array(32);
|
|
70
|
+
const timeIndex = Date.now() % 1000;
|
|
71
|
+
const driftX = cryptoGauss(seed, timeIndex, view.width / 2, view.width * 0.15);
|
|
72
|
+
const driftY = cryptoGauss(seed, timeIndex + 1, view.height / 2, view.height * 0.1);
|
|
73
|
+
await page.mouse.move(Math.max(0, Math.min(view.width, driftX)), Math.max(0, Math.min(view.height, driftY)));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return originalEvaluate(pageFunction, ...evalArgs);
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export function detachHumanBehavior(page) {
|
|
80
|
+
const sessionState = page._bexxcv_session;
|
|
81
|
+
if (sessionState) {
|
|
82
|
+
endSession(page);
|
|
83
|
+
}
|
|
84
|
+
delete page._bexxcv_human_options;
|
|
85
|
+
const origGoto = page._orig_goto;
|
|
86
|
+
const origClick = page._orig_click;
|
|
87
|
+
const origEval = page._orig_evaluate;
|
|
88
|
+
if (origGoto)
|
|
89
|
+
page.goto = origGoto;
|
|
90
|
+
if (origClick)
|
|
91
|
+
page.click = origClick;
|
|
92
|
+
if (origEval)
|
|
93
|
+
page.evaluate = origEval;
|
|
94
|
+
}
|
|
95
|
+
export function getSessionInfo(page) {
|
|
96
|
+
const state = page._bexxcv_session;
|
|
97
|
+
if (!state)
|
|
98
|
+
return null;
|
|
99
|
+
return {
|
|
100
|
+
id: getSessionId(page),
|
|
101
|
+
pageCount: state.pageCount,
|
|
102
|
+
ageMs: Date.now() - state.createdAt,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
export function sleep(ms) {
|
|
106
|
+
return new Promise(resolve => setTimeout(resolve, Math.max(0, ms)));
|
|
107
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,10 @@ export { attachTurnstile, watchTurnstile, type TurnstileOptions, } from "./turns
|
|
|
9
9
|
export { attachUam, waitForUam, watchUam, type UamOptions, type UamResult } from "./uam.js";
|
|
10
10
|
export { dataStatus, doctor, type DataStatus } from "./doctor.js";
|
|
11
11
|
export { validateOptions } from "./schema.js";
|
|
12
|
-
export { applyPlugins, auditFingerprint, buildPlugins, gauntletResult, lensReport, runGauntlet, wiretapEntries, type BexxcvPlugin, type BrakeOptions, type DodgeOptions, type GauntletOptions, type LensOptions, type PluginOptions, type StashOptions, type VeneerOptions, type WiretapOptions, } from "./plugins/index.js";
|
|
12
|
+
export { applyPlugins, auditFingerprint, buildPlugins, gauntletResult, lensReport, runGauntlet, wiretapEntries, type BexxcvPlugin, type BrakeOptions, type DodgeOptions, type GauntletOptions, type GauntletResult, type LensOptions, type LensReport, type LensCheck, type PluginOptions, type StashOptions, type VeneerOptions, type WiretapOptions, } from "./plugins/index.js";
|
|
13
13
|
export { solveTurnstile } from "./turnstile.js";
|
|
14
14
|
export { brake, cocoon, dodge, gauntlet, human, lens, stash, turnstile, uam, veneer, wiretap, type HumanPluginOptions, } from "./plugins/index.js";
|
|
15
|
+
export { attachHumanBehavior, detachHumanBehavior, getSessionInfo, type HumanBehaviorOptions, } from "./human_behavior.js";
|
|
16
|
+
export { initSession, getSessionId, advancePage, endSession, isSessionExpired, getSeededFloat, getSeededInt, getSeededGauss, type SessionOptions, } from "./session.js";
|
|
17
|
+
export { generateFingerprint, cryptoRandInt, cryptoFloat, SUPPORTED_OS, type ExtendedScreen } from "./fingerprints.js";
|
|
18
|
+
export { sampleGPUProfile, resolveUAOS, KNOWN_GPUS } from "./webgl/profiles.js";
|
package/dist/index.js
CHANGED
|
@@ -12,3 +12,7 @@ export { validateOptions } from "./schema.js";
|
|
|
12
12
|
export { applyPlugins, auditFingerprint, buildPlugins, gauntletResult, lensReport, runGauntlet, wiretapEntries, } from "./plugins/index.js";
|
|
13
13
|
export { solveTurnstile } from "./turnstile.js";
|
|
14
14
|
export { brake, cocoon, dodge, gauntlet, human, lens, stash, turnstile, uam, veneer, wiretap, } from "./plugins/index.js";
|
|
15
|
+
export { attachHumanBehavior, detachHumanBehavior, getSessionInfo, } from "./human_behavior.js";
|
|
16
|
+
export { initSession, getSessionId, advancePage, endSession, isSessionExpired, getSeededFloat, getSeededInt, getSeededGauss, } from "./session.js";
|
|
17
|
+
export { generateFingerprint, cryptoRandInt, cryptoFloat, SUPPORTED_OS } from "./fingerprints.js";
|
|
18
|
+
export { sampleGPUProfile, resolveUAOS, KNOWN_GPUS } from "./webgl/profiles.js";
|
package/dist/locale.js
CHANGED
|
@@ -144,7 +144,7 @@ class MaxMindDownloader extends GitHubDownloader {
|
|
|
144
144
|
}
|
|
145
145
|
export function geoipAllowed() {
|
|
146
146
|
if (!ALLOW_GEOIP) {
|
|
147
|
-
throw new NotInstalledGeoIPExtra("
|
|
147
|
+
throw new NotInstalledGeoIPExtra("GeoIP is disabled in this build. Reinstall bexxcv with the geoip extra enabled.");
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
export async function downloadMMDB() {
|
|
@@ -266,9 +266,13 @@ class StatisticalLocaleSelector {
|
|
|
266
266
|
total += w;
|
|
267
267
|
}
|
|
268
268
|
if (total === 0) {
|
|
269
|
-
|
|
269
|
+
const buf = new Uint32Array(1);
|
|
270
|
+
crypto.getRandomValues(buf);
|
|
271
|
+
return items[buf[0] % items.length];
|
|
270
272
|
}
|
|
271
|
-
const
|
|
273
|
+
const randBuf = new Uint32Array(1);
|
|
274
|
+
crypto.getRandomValues(randBuf);
|
|
275
|
+
const r = (randBuf[0] / 0x100000000) * total;
|
|
272
276
|
let acc = 0;
|
|
273
277
|
for (let i = 0; i < items.length; i++) {
|
|
274
278
|
acc += weights[i];
|
package/dist/pkgman.js
CHANGED
|
@@ -152,7 +152,8 @@ export class GitHubDownloader {
|
|
|
152
152
|
}
|
|
153
153
|
catch (e) {
|
|
154
154
|
console.error(e, `retrying (${attempts + 1}/${retries})...`);
|
|
155
|
-
const
|
|
155
|
+
const jn = crypto.getRandomValues(new Uint32Array(1))[0] >>> 0;
|
|
156
|
+
const jitter = jn / 0x100000000 * 500;
|
|
156
157
|
const delayMs = Math.min(2_000 * 2 ** attempts + jitter, 30_000);
|
|
157
158
|
await setTimeout(delayMs);
|
|
158
159
|
}
|
|
@@ -462,7 +463,8 @@ export async function webdl(url, desc = "", bar = true, buffer = null, { retries
|
|
|
462
463
|
}
|
|
463
464
|
catch (e) {
|
|
464
465
|
console.error(e, `retrying (${attempts + 1}/${retries})...`);
|
|
465
|
-
const
|
|
466
|
+
const jn = crypto.getRandomValues(new Uint32Array(1))[0] >>> 0;
|
|
467
|
+
const jitter = jn / 0x100000000 * 500;
|
|
466
468
|
const delayMs = Math.min(2_000 * 2 ** attempts + jitter, 30_000);
|
|
467
469
|
await setTimeout(delayMs);
|
|
468
470
|
}
|
|
@@ -483,7 +485,7 @@ export async function webdl(url, desc = "", bar = true, buffer = null, { retries
|
|
|
483
485
|
}
|
|
484
486
|
const chunks = [];
|
|
485
487
|
try {
|
|
486
|
-
for await (const chunk of response.body) {
|
|
488
|
+
for await (const chunk of (response.body ?? [])) {
|
|
487
489
|
if (buffer) {
|
|
488
490
|
buffer.write(chunk);
|
|
489
491
|
}
|
package/dist/plugins/dodge.js
CHANGED
|
@@ -51,15 +51,18 @@ export function dodge(input) {
|
|
|
51
51
|
async beforeLaunch(launch) {
|
|
52
52
|
if (options.healthCheck !== false) {
|
|
53
53
|
const limit = options.healthTimeout ?? 10_000;
|
|
54
|
-
await Promise.
|
|
54
|
+
const healthResults = await Promise.allSettled(states.map(async (state, index) => {
|
|
55
55
|
try {
|
|
56
56
|
state.ip = await timeout(publicIP(state.url), limit);
|
|
57
|
+
return { index, healthy: true };
|
|
57
58
|
}
|
|
58
59
|
catch {
|
|
59
60
|
state.badUntil = Date.now() + cooldown;
|
|
61
|
+
return { index, healthy: false };
|
|
60
62
|
}
|
|
61
63
|
}));
|
|
62
|
-
|
|
64
|
+
const hasHealthy = healthResults.some((r) => r.status === "fulfilled" && r.value.healthy);
|
|
65
|
+
if (!hasHealthy) {
|
|
63
66
|
throw new Error("dodge: no healthy proxy in pool");
|
|
64
67
|
}
|
|
65
68
|
}
|
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();
|
|
@@ -33,6 +33,7 @@ export async function runGauntlet(page, options = {}) {
|
|
|
33
33
|
const timeout = options.timeout ?? 30000;
|
|
34
34
|
const result = { passed: false, tries: 0, uam: null, turnstile: null };
|
|
35
35
|
const wantsTurnstile = solve.includes("turnstile");
|
|
36
|
+
const startAttempt = Date.now();
|
|
36
37
|
for (let attempt = 1; attempt <= maxTries && !page.isClosed(); attempt++) {
|
|
37
38
|
result.tries = attempt;
|
|
38
39
|
for (const stage of solve) {
|
|
@@ -87,7 +88,6 @@ export function gauntlet(options = {}) {
|
|
|
87
88
|
if (WRAPPED.has(page))
|
|
88
89
|
return;
|
|
89
90
|
WRAPPED.add(page);
|
|
90
|
-
trackMitigation(page);
|
|
91
91
|
const originalGoto = page.goto.bind(page);
|
|
92
92
|
page.goto = (async (...args) => {
|
|
93
93
|
const response = await originalGoto(...args);
|
|
@@ -101,8 +101,14 @@ export function gauntlet(options = {}) {
|
|
|
101
101
|
active = false;
|
|
102
102
|
});
|
|
103
103
|
const interval = options.interval ?? 1500;
|
|
104
|
+
const maxRuntimeMs = options.maxRuntime ?? 600_000;
|
|
105
|
+
const runtimeStart = Date.now();
|
|
104
106
|
void (async () => {
|
|
105
107
|
while (active && !page.isClosed()) {
|
|
108
|
+
if (Date.now() - runtimeStart >= maxRuntimeMs) {
|
|
109
|
+
console.warn("[bexxcv] gauntlet: background watcher reached maxRuntime, stopping");
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
106
112
|
try {
|
|
107
113
|
if (!RUNNING.has(page) && (await isChallenge(page))) {
|
|
108
114
|
await runGuarded(page, options, false);
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { brake, type BrakeOptions } from "./brake.js";
|
|
2
2
|
import { cocoon } from "./cocoon.js";
|
|
3
3
|
import { dodge, type DodgeOptions } from "./dodge.js";
|
|
4
|
-
import { gauntlet, type GauntletOptions } from "./gauntlet.js";
|
|
4
|
+
import { gauntlet, type GauntletOptions, type GauntletResult } from "./gauntlet.js";
|
|
5
5
|
import { human, type HumanPluginOptions } from "./human.js";
|
|
6
|
-
import { lens, type LensOptions } from "./lens.js";
|
|
6
|
+
import { lens, type LensOptions, type LensReport, type LensCheck } from "./lens.js";
|
|
7
7
|
import { stash, type StashOptions } from "./stash.js";
|
|
8
8
|
import type { BexxcvPlugin } from "./types.js";
|
|
9
9
|
import { veneer, type VeneerOptions } from "./veneer.js";
|
|
@@ -29,4 +29,4 @@ export { gauntletResult, runGauntlet } from "./gauntlet.js";
|
|
|
29
29
|
export { wiretapEntries } from "./wiretap.js";
|
|
30
30
|
export { brake, cocoon, dodge, gauntlet, human, lens, stash, veneer, wiretap };
|
|
31
31
|
export { turnstile, uam } from "./solvers.js";
|
|
32
|
-
export type { HumanPluginOptions, BrakeOptions, DodgeOptions, GauntletOptions, LensOptions, StashOptions, VeneerOptions, WiretapOptions, };
|
|
32
|
+
export type { HumanPluginOptions, BrakeOptions, DodgeOptions, GauntletOptions, GauntletResult, LensOptions, LensReport, LensCheck, StashOptions, VeneerOptions, WiretapOptions, };
|
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/schema.js
CHANGED
|
@@ -82,7 +82,7 @@ const SPEC = {
|
|
|
82
82
|
speed: positive.optional(),
|
|
83
83
|
nativeCursor: z.boolean().optional(),
|
|
84
84
|
typoRate: z.number().min(0).max(0.2).optional(),
|
|
85
|
-
|
|
85
|
+
Think: z.union([z.tuple([positive, positive]), z.literal(false)]).optional(),
|
|
86
86
|
}),
|
|
87
87
|
]),
|
|
88
88
|
"a boolean or { speed, nativeCursor, typoRate, think }",
|
|
@@ -183,6 +183,15 @@ const SPEC = {
|
|
|
183
183
|
]),
|
|
184
184
|
"a boolean or { timeout, interval, waitOnGoto }",
|
|
185
185
|
],
|
|
186
|
+
hardware_concurrency_override: [z.number().int().positive(), "an integer (e.g., 8)"],
|
|
187
|
+
device_memory_override: [z.number().int().min(2).max(64), "an integer (e.g., 8)"],
|
|
188
|
+
timezone_jitter: [z.boolean(), "a boolean"],
|
|
189
|
+
perf_jitter: [z.boolean(), "a boolean"],
|
|
190
|
+
session_stickiness: [z.boolean(), "a boolean"],
|
|
191
|
+
scroll_pattern: [z.enum(["natural", "linear", "burst"]), '"natural" | "linear" | "burst"'],
|
|
192
|
+
idle_drift: [z.boolean(), "a boolean"],
|
|
193
|
+
typo_rate: [z.number().min(0).max(0.5), "a float between 0 and 0.5"],
|
|
194
|
+
mouse_acceleration: [z.boolean(), "a boolean"],
|
|
186
195
|
};
|
|
187
196
|
const PASSTHROUGH = new Set([
|
|
188
197
|
"allow_webgl",
|
|
@@ -265,6 +274,6 @@ export function validateOptions(options) {
|
|
|
265
274
|
}
|
|
266
275
|
}
|
|
267
276
|
if (problems.length > 0) {
|
|
268
|
-
throw new InvalidOptions(`Invalid bexxcv options:\n
|
|
277
|
+
throw new InvalidOptions(`Invalid bexxcv options:\n ${problems.join("\n ")}`);
|
|
269
278
|
}
|
|
270
279
|
}
|