-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev-clientcode-worker.html
More file actions
190 lines (179 loc) · 7.43 KB
/
Copy pathdev-clientcode-worker.html
File metadata and controls
190 lines (179 loc) · 7.43 KB
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>getClientCode Worker — CreepJS path</title>
<style>
body { font: 13px/1.45 ui-monospace, Consolas, monospace; margin: 16px; max-width: 960px; }
pre { background: #111; color: #ddd; padding: 12px; border-radius: 6px; white-space: pre-wrap; font-size: 12px; }
h4 { margin: 14px 0 6px; }
</style>
</head>
<body>
<h3>getClientCode inside Worker — CreepJS path</h3>
<p>
<b>A)</b> <code>new Worker('dev-clientcode-worker-script.js')</code> — same-origin script (XHR+prepend, как CreepJS)<br>
<b>B)</b> pure blob probe — контроль
</p>
<pre id="out">running…</pre>
<script>
const F = {
canvas:true, audio:true, webgl:true, webrtc:true, navigator:true,
screen:true, timezone:true, geolocation:true, battery:true, fonts:true,
clientRects:false, plugins:true, network:true, hideAdBlocker:true
};
sessionStorage.setItem('v.ui.s', JSON.stringify({
mode: 'normal',
platform: 'Win32', hwConcurrency: 8, deviceMemory: 8,
language: 'et-EE', locale: 'et-EE', countryCode: 'EE',
languages: ['et-EE','et','en','en-US'],
timezone: 'Europe/Tallinn',
noiseSeed: 0x12345678,
webglVendor: 'Google Inc. (Intel)',
webglRenderer: 'ANGLE (Intel, Intel(R) Iris(R) Xe Graphics Direct3D11 vs_5_0 ps_5_0)',
features: F
}));
sessionStorage.setItem('v.ui.m', 'normal');
document.documentElement.setAttribute('data-v-ft', JSON.stringify(F));
const ORDER = [
'profile-injector.js', 'mw/mw-bag.js', 'mw/mw-core.js',
'mw/mw-timezone-screen.js', 'mw/mw-navigator.js', 'mw/mw-canvas-audio.js',
'mw/mw-misc.js', 'mw/mw-workers.js', 'mw/mw-geo.js',
'mw/mw-adblock.js', 'mw/mw-cleanup.js'
];
function load(src) {
return new Promise(r => {
const s = document.createElement('script');
s.src = src + '?t=' + Date.now();
s.onload = () => r(true); s.onerror = () => r(false);
document.head.appendChild(s);
});
}
function runWorker(url, timeoutMs) {
return new Promise((resolve) => {
let w;
try {
w = new Worker(url);
} catch (e) {
resolve({ ok: false, error: 'construct: ' + e.message });
return;
}
const t = setTimeout(() => {
try { w.terminate(); } catch (e) {}
resolve({ ok: false, error: 'timeout' });
}, timeoutMs || 5000);
w.onmessage = (e) => {
clearTimeout(t);
try { w.terminate(); } catch (e2) {}
resolve(e.data);
};
w.onerror = (e) => {
clearTimeout(t);
try { w.terminate(); } catch (e2) {}
resolve({ ok: false, error: e.message || 'worker error' });
};
});
}
function formatResult(label, result) {
const lines = [];
lines.push('═══ ' + label + ' ═══');
if (!result || !result.ok) {
lines.push('ERROR: ' + (result && result.error ? result.error : 'no result'));
return lines.join('\n');
}
lines.push('location: ' + result.location);
lines.push('nav: platform=' + (result.nav && result.nav.platform) +
' hc=' + (result.nav && result.nav.hc) +
' webdriver=' + (result.nav && result.nav.webdriver));
lines.push('clientCode (' + result.clientCode.length + '): ' + JSON.stringify(result.clientCode));
if (result.probes) {
lines.push('probes: ' + JSON.stringify(result.probes));
}
lines.push('keysTail: ' + JSON.stringify(result.keysTail));
if (result.detail && result.detail.length) {
lines.push('detail:');
for (const d of result.detail) {
lines.push(' ' + d.key + ' type=' + d.type + ' name=' + d.name + ' enum=' + d.enumerable);
lines.push(' ' + d.str);
}
}
lines.push(result.clientCode.length === 0
? '>>> EMPTY → code should be unknown'
: '>>> NON-EMPTY → these keys feed code hash');
return lines.join('\n');
}
(async () => {
for (const f of ORDER) await load(f);
await new Promise(r => setTimeout(r, 400));
const blocks = [];
try {
const limit = 50;
const [p1, p2] = (1).constructor.toString().split((1).constructor.name);
const isEngine = (fn) =>
typeof fn === 'function' &&
('' + fn === p1 + fn.name + p2 ||
'' + fn === p1 + (fn.name || '').replace('get ', '') + p2);
const badWin = Object.keys(window).slice(-limit).filter((key) => {
if (/_$/.test(key)) return true;
const d = Object.getOwnPropertyDescriptor(window, key);
if (!d) return true;
if (key === 'chrome') return Object.getOwnPropertyNames(window).slice(-limit).includes(key);
return !isEngine(d.get || d.value);
});
blocks.push('═══ WINDOW ═══');
blocks.push('clientCode (' + badWin.length + '): ' + JSON.stringify(badWin));
const p0 = Object.getOwnPropertyDescriptor(window, '__p0');
const w0 = Object.getOwnPropertyDescriptor(window, '__w0');
const w1 = Object.getOwnPropertyDescriptor(window, '__w1');
blocks.push('__p0 enum=' + (p0 && p0.enumerable) + ' __w0 enum=' + (w0 && w0.enumerable) + ' __w1 enum=' + (w1 && w1.enumerable));
} catch (e) {
blocks.push('WINDOW error: ' + e.message);
}
blocks.push('');
// A) Mimic successful CreepJS path: page fetches script text, builds Blob,
// new Worker(blobURL). Shield intercepts blob:, XHR-reads body, prepends pc.
// (Direct new Worker(http://script) was falling back to importScripts and
// failing under some hosts / sync-XHR conditions.)
try {
const scriptText = await fetch('dev-clientcode-worker-script.js?t=' + Date.now()).then(r => {
if (!r.ok) throw new Error('fetch ' + r.status);
return r.text();
});
const creepsLikeBlob = URL.createObjectURL(new Blob([scriptText], { type: 'application/javascript' }));
const resA = await runWorker(creepsLikeBlob, 6000);
try { URL.revokeObjectURL(creepsLikeBlob); } catch (eR) {}
blocks.push(formatResult('A) fetch+blob script (CreepJS-like XHR+prepend)', resA));
} catch (eA) {
blocks.push('═══ A) fetch+blob ═══\nERROR: ' + eA.message);
}
blocks.push('');
const inline = `
(function(){
try {
var limit=50;
var p=(1).constructor.toString().split((1).constructor.name);
var p1=p[0],p2=p[1];
function isEngine(fn){return typeof fn==='function'&&((''+fn===p1+fn.name+p2)||(''+fn===p1+(fn.name||'').replace('get ','')+p2));}
function isClient(key){
if(/_$/.test(key))return true;
var d=Object.getOwnPropertyDescriptor(self,key);
if(!d)return true;
if(key==='chrome')return Object.getOwnPropertyNames(self).slice(-limit).indexOf(key)!==-1;
return !isEngine(d.get||d.value);
}
var keys=Object.keys(self).slice(-limit);
var bad=keys.filter(isClient);
self.postMessage({ok:true,path:'blob',location:String(self.location&&self.location.href||'').slice(0,160),
clientCode:bad,keysTail:keys,detail:bad.map(function(k){var d=Object.getOwnPropertyDescriptor(self,k);var fn=d&&(d.get||d.value);return{key:k,type:typeof fn,name:fn&&fn.name,str:(typeof fn==='function'?String(fn):String(fn)).slice(0,90),enumerable:d?d.enumerable:null};}),
nav:{platform:self.navigator&&self.navigator.platform,hc:self.navigator&&self.navigator.hardwareConcurrency,webdriver:self.navigator&&self.navigator.webdriver}});
} catch(e){ self.postMessage({ok:false,error:String(e&&e.message||e)}); }
})();`;
const blobUrl = URL.createObjectURL(new Blob([inline], { type: 'application/javascript' }));
const resB = await runWorker(blobUrl, 6000);
try { URL.revokeObjectURL(blobUrl); } catch (e) {}
blocks.push(formatResult('B) pure blob control', resB));
document.getElementById('out').textContent = blocks.join('\n');
})();
</script>
</body>
</html>