fix: enhance stealth mode with additional anti-detection measures
All checks were successful
CI / build (pull_request) Successful in 47s
CI / vet (pull_request) Successful in 46s
CI / test (pull_request) Successful in 49s

Add 7 new init scripts to cover WebGL fingerprinting, missing Chrome
APIs, permissions behavior, CDP artifacts, and HeadlessChrome UA string.
Enable Chromium's new headless mode (Channel: "chromium") when stealth
is active to use the full UI layer that is harder to detect.

Closes #58

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-17 22:45:12 +00:00
parent 917569dd0b
commit ce95fb1d89
3 changed files with 185 additions and 0 deletions

View File

@@ -47,4 +47,88 @@ var stealthInitScripts = []string{
Object.defineProperty(window, 'outerWidth', { get: () => window.innerWidth });
Object.defineProperty(window, 'outerHeight', { get: () => window.innerHeight });
}`,
// Spoof WebGL renderer to hide SwiftShader (headless GPU) fingerprint.
`(function() {
const getParam = WebGLRenderingContext.prototype.getParameter;
WebGLRenderingContext.prototype.getParameter = function(param) {
if (param === 37445) return 'Google Inc. (Intel)';
if (param === 37446) return 'ANGLE (Intel, Intel(R) UHD Graphics 630, OpenGL 4.5)';
return getParam.call(this, param);
};
if (typeof WebGL2RenderingContext !== 'undefined') {
const getParam2 = WebGL2RenderingContext.prototype.getParameter;
WebGL2RenderingContext.prototype.getParameter = function(param) {
if (param === 37445) return 'Google Inc. (Intel)';
if (param === 37446) return 'ANGLE (Intel, Intel(R) UHD Graphics 630, OpenGL 4.5)';
return getParam2.call(this, param);
};
}
})()`,
// Add chrome.app, chrome.csi, and chrome.loadTimes stubs missing in headless.
`(function() {
if (!window.chrome) window.chrome = {};
if (!window.chrome.app) {
window.chrome.app = { isInstalled: false, InstallState: { DISABLED: 'disabled', INSTALLED: 'installed', NOT_INSTALLED: 'not_installed' }, RunningState: { CANNOT_RUN: 'cannot_run', READY_TO_RUN: 'ready_to_run', RUNNING: 'running' } };
}
if (!window.chrome.csi) {
window.chrome.csi = function() { return { startE: Date.now(), onloadT: Date.now(), pageT: 0, tran: 15 }; };
}
if (!window.chrome.loadTimes) {
window.chrome.loadTimes = function() { return { commitLoadTime: Date.now() / 1000, connectionInfo: 'h2', finishDocumentLoadTime: Date.now() / 1000, finishLoadTime: Date.now() / 1000, firstPaintAfterLoadTime: 0, firstPaintTime: Date.now() / 1000, navigationType: 'Other', npnNegotiatedProtocol: 'h2', requestTime: Date.now() / 1000, startLoadTime: Date.now() / 1000, wasAlternateProtocolAvailable: false, wasFetchedViaSpdy: true, wasNpnNegotiated: true }; };
}
})()`,
// Override navigator.permissions.query to return "denied" for notifications.
`(function() {
if (navigator.permissions && navigator.permissions.query) {
const origQuery = navigator.permissions.query.bind(navigator.permissions);
navigator.permissions.query = function(desc) {
if (desc && desc.name === 'notifications') {
return Promise.resolve({ state: 'denied', onchange: null });
}
return origQuery(desc);
};
}
})()`,
// Stub Notification constructor if missing (headless may lack it).
`(function() {
if (typeof Notification === 'undefined') {
window.Notification = function() {};
Notification.permission = 'denied';
Notification.requestPermission = function() { return Promise.resolve('denied'); };
}
})()`,
// Stub navigator.connection (Network Information API) if missing.
`(function() {
if (!navigator.connection) {
Object.defineProperty(navigator, 'connection', {
get: function() {
return { effectiveType: '4g', rtt: 50, downlink: 10, saveData: false, onchange: null };
},
});
}
})()`,
// Remove CDP artifacts (window.cdc_* globals injected by Chrome DevTools Protocol).
`(function() {
for (var key in window) {
if (key.match(/^cdc_/)) {
delete window[key];
}
}
})()`,
// Strip "HeadlessChrome" from navigator.userAgent if present.
`(function() {
var ua = navigator.userAgent;
if (ua.indexOf('HeadlessChrome') !== -1) {
Object.defineProperty(navigator, 'userAgent', {
get: function() { return ua.replace('HeadlessChrome', 'Chrome'); },
});
}
})()`,
}