Skip to content

Instantly share code, notes, and snippets.

@step135
Last active September 14, 2023 03:20
Show Gist options
  • Save step135/a0b8dc52d4fb51401bd651ea1fb64111 to your computer and use it in GitHub Desktop.
Save step135/a0b8dc52d4fb51401bd651ea1fb64111 to your computer and use it in GitHub Desktop.
var background = (function () {
var tmp = {};
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
for (var id in tmp) {
if (tmp[id] && (typeof tmp[id] === "function")) {
if (request.path === "background-to-page") {
if (request.method === id) tmp[id](request.data);
}
}
}
});
/* */
return {
"receive": function (id, callback) {tmp[id] = callback},
"send": function (id, data) {chrome.runtime.sendMessage({"path": "page-to-background", "method": id, "data": data})}
}
})();
var inject = function () {
const toStr = Function.prototype.toString.toString();
function toString(){
return toStr;
}
const lg = navigator.__proto__.__lookupGetter__ ;
const lgs = navigator.__lookupGetter__.toString();
if(false)navigator.__lookupGetter__.__proto__.toString = function(){
console.log("%c++++++ navigator.__lookupGetter__",'background: #222; color: #bada55',arguments[0]);
return lg.apply(this,arguments);
}
function req(c){console.log("%c"+c,"background:lightblue");};
var pl = {};
delete navigator.__proto__.connection;
delete navigator.__proto__.brave;
//delete navigator.__proto__.deviceMemory;
navigator.__defineGetter__('deviceMemory', function(){req("deviceMemory");return 4;});
window.screen.__defineGetter__('availHeight', function(){req('availHeight');return window.screen.height-64});
//navigator.__defineGetter__('plugins', function(){req("plugins");return [];});
function __lookupGetter__(p){
var o=navigator.__proto__.__lookupGetter__(p);
console.log("%c----------navigator.__lookupGetter__:", "background: yellow; color: red", p, o);
return o;
}
navigator.__lookupGetter__ = __lookupGetter__
navigator.__lookupGetter__.toString = () => {
console.log("%c++++++ navigator.__lookupGetter__ itself",'background: orange; color: blue');
return lgs;
}
navigator.__lookupGetter__.toString.toString = toString;
Object.defineProperty(navigator, 'mimeTypes', {
get: () => {
var ChromiumPDFPlugin = {};
ChromiumPDFPlugin.__proto__ = MimeType.prototype;
var plugins = {
0: {
__proto__: ChromiumPDFPlugin,
type: 'application/pdf',
suffixes: 'pdf',
description: '',
enabledPlugin: null,
length:1,
},
length: 1,
__proto__: MimeTypeArray.prototype,
};
req("mimeTypes");
return plugins;
},
});
Object.defineProperty(navigator, 'plugins', {
get: () => {
var ChromiumPDFPlugin = {};
ChromiumPDFPlugin.__proto__ = Plugin.prototype;
var plugins = {
0: {
__proto__: ChromiumPDFPlugin,
description: 'Portable Document Format',
filename: 'gjhy6t5r4yvbszanjhvr4ghy43s',
name: 'PDF Plugin',
length: 1,
0: navigator.mimeTypes[0]
},
length: 1,
__proto__: PluginArray.prototype,
};
req("plugins");
return plugins;
},
});
if(navigator.userAgent.indexOf("Windows")>-1) navigator.__defineGetter__('platform', function(){req("platform");return "Win32";});
function getOwnPropertyDescriptor(a,b){
if((a === navigator) || (a === window.screen)){
console.log("%c----descriptor:" + (typeof a) + " :","background-color:violet;color:white", a, "el: ",b, "output: ", a.__lookupGetter__(b));
return undefined;
}
else return gop.apply(this, arguments);
}
function getOwnPropertyDescriptors(a){
if((a === navigator) || (a === window.screen))console.log("%c----descriptors: " + (typeof a) + " :","background-color:violet;color:yellow", a, "output: ", gop2.apply(this, arguments));
return (a === navigator) || (a === window.screen) ? {} : gop2.apply(this, arguments);
var desc = Object.getOwnPropertyDescriptors(a);
for(let i in desc){
for(let k in desc[i])this[i][k] = desc[i][k];
this[i].get = a.__proto__.__lookupGetter__(i);
}
return this;
}
const gop = Object.getOwnPropertyDescriptor;
const gops = Object.getOwnPropertyDescriptor.toString();
Object.getOwnPropertyDescriptor = getOwnPropertyDescriptor;
Object.getOwnPropertyDescriptor.toString = () => gops;
Object.getOwnPropertyDescriptor.toString.toString = toString;
const gop2 = Object.getOwnPropertyDescriptors;
const gops2 = Object.getOwnPropertyDescriptors.toString();
Object.getOwnPropertyDescriptors = getOwnPropertyDescriptors;
Object.getOwnPropertyDescriptors.toString = () => gops2;
Object.getOwnPropertyDescriptors.toString.toString = toString; //anonym!!-----
var rn = 4 < 9;
var nat = {};
var strnat = {};
var config = {
"random": {
"value": function () {
return rn ? 0.80834 : Math.random();
},
"item": function (e) {
var rand = e.length * config.random.value();
return e[Math.floor(rand)];
},
"number": function (power) {
var tmp = [];
for (var i = 0; i < power.length; i++) {
tmp.push(Math.pow(2, power[i]));
}
/* */
return config.random.item(tmp);
},
"int": function (power) {
var tmp = [];
for (var i = 0; i < power.length; i++) {
var n = Math.pow(2, power[i]);
tmp.push(new Int32Array([n, n]));
}
/* */
return config.random.item(tmp);
},
"float": function (power) {
var tmp = [];
for (var i = 0; i < power.length; i++) {
var n = Math.pow(2, power[i]);
tmp.push(new Float32Array([1, n]));
}
/* */
return config.random.item(tmp);
}
},
"spoof": {
"webgl": {
"buffer": function (target) {
var proto = target.prototype ? target.prototype : target.__proto__;
nat["bufferData"] = proto.bufferData;
strnat["bufferData"] = nat["bufferData"].toString();
function bufferData() {
var index = Math.floor(config.random.value() * arguments[1].length);
var noise = arguments[1][index] !== undefined ? 0.1 * config.random.value() * arguments[1][index] : 0;
//
arguments[1][index] = arguments[1][index] + noise;
//window.top.postMessage("webgl-fingerprint-defender-alert", '*');
//
return nat["bufferData"].apply(this, arguments);
}
proto.bufferData = bufferData;
proto.bufferData.toString = () => {
console.log('%cwebgl--bufferData func. check','background-color:black;color:orange');
return strnat["bufferData"];
}
proto.bufferData.toString.toString = toString;
},
"parameter": function (target) {
var proto = target.prototype ? target.prototype : target.__proto__;
nat["getParameter"] = proto.getParameter;
strnat["getParameter"] = nat["getParameter"].toString();
function getParameter() {
window.top.postMessage("webgl-fingerprint-defender-alert", '*');
//
if (arguments[0] === 3415) return 0;
else if (arguments[0] === 3414) return 24;
else if (arguments[0] === 36348) return 30;
else if (arguments[0] === 7936) return "WebKit";
else if (arguments[0] === 37445) return "Google Inc.";
else if (arguments[0] === 7937) return "WebKit WebGL";
else if (arguments[0] === 3379) return config.random.number([14, 15]);
else if (arguments[0] === 36347) return config.random.number([12, 13]);
else if (arguments[0] === 34076) return config.random.number([14, 15]);
else if (arguments[0] === 34024) return config.random.number([14, 15]);
else if (arguments[0] === 3386) return config.random.int([13, 14, 15]);
else if (arguments[0] === 3413) return config.random.number([1, 2, 3, 4]);
else if (arguments[0] === 3412) return config.random.number([1, 2, 3, 4]);
else if (arguments[0] === 3411) return config.random.number([1, 2, 3, 4]);
else if (arguments[0] === 3410) return config.random.number([1, 2, 3, 4]);
else if (arguments[0] === 34047) return config.random.number([1, 2, 3, 4]);
else if (arguments[0] === 34930) return config.random.number([1, 2, 3, 4]);
else if (arguments[0] === 34921) return config.random.number([1, 2, 3, 4]);
else if (arguments[0] === 35660) return config.random.number([1, 2, 3, 4]);
else if (arguments[0] === 35661) return config.random.number([4, 5, 6, 7, 8]);
else if (arguments[0] === 36349) return config.random.number([10, 11, 12, 13]);
else if (arguments[0] === 33902) return config.random.float([0, 10, 11, 12, 13]);
else if (arguments[0] === 33901) return config.random.float([0, 10, 11, 12, 13]);
else if (arguments[0] === 37446) return config.random.item(["Graphics", "HD Graphics", "Intel(R) HD Graphics"]);
else if (arguments[0] === 7938) return config.random.item(["WebGL 1.0", "WebGL 1.0 (OpenGL)", "WebGL 1.0 (OpenGL Chromium)"]);
else if (arguments[0] === 35724) return config.random.item(["WebGL", "WebGL GLSL", "WebGL GLSL ES", "WebGL GLSL ES (OpenGL Chromium)"]);
//
return nat["getParameter"].apply(this, arguments);
}
proto.getParameter = getParameter;
proto.getParameter.toString = () => {
console.log('%cwebgl--getParameter func. check','background-color:black;color:yellow');
return strnat["getParameter"]
};
proto.getParameter.toString.toString = toString;
}
}
}
};
//
config.spoof.webgl.buffer(WebGLRenderingContext);
config.spoof.webgl.buffer(WebGL2RenderingContext);
config.spoof.webgl.parameter(WebGLRenderingContext);
config.spoof.webgl.parameter(WebGL2RenderingContext);
const origToString = Function.prototype.toString;
//const origToStringToString = Function.prototype.toString.toString();
//function toString(){return origToStringToString;}
Function.prototype.toString = function(){
const fnames = Object.keys(nat);
return fnames.indexOf(this.name)>-1 ? strnat[this.name]:
origToString.apply(this, arguments)
};
document.documentElement.dataset.wgscriptallow = true;
};
function ochrana(){
if(
true ||
document.createElemement.toString().indexOf("native")==-1||
document.constructor.prototype.createElemement.toString().indexOf("native")==-1
){
document.documentElement.innerHTML="error";
return false;
}else console.log("ochrana OK");
return true;
}
var script_1 = document.createElement("script");
script_1.textContent = "(" + inject + ")()";
document.documentElement.appendChild(script_1);
script_1.remove();
delete script_1;
if (document.documentElement.dataset.wgscriptallow !== "true") {
var script_2 = document.createElement("script");
script_2.textContent = `{
const iframes = [...window.top.document.querySelectorAll("iframe[sandbox]")];
for (var i = 0; i < iframes.length; i++) {
if (iframes[i].contentWindow) {
if (iframes[i].contentWindow.WebGLRenderingContext) {
iframes[i].contentWindow.WebGLRenderingContext.prototype.bufferData = WebGLRenderingContext.prototype.bufferData;
iframes[i].contentWindow.WebGLRenderingContext.prototype.getParameter = WebGLRenderingContext.prototype.getParameter;
}
if (iframes[i].contentWindow.WebGL2RenderingContext) {
iframes[i].contentWindow.WebGL2RenderingContext.prototype.bufferData = WebGL2RenderingContext.prototype.bufferData;
iframes[i].contentWindow.WebGL2RenderingContext.prototype.getParameter = WebGL2RenderingContext.prototype.getParameter;
}
}
}
}`;
//
window.top.document.documentElement.appendChild(script_2);
script_2.remove();
delete script_2;
}
window.addEventListener("message", function (e) {
if (e.data && e.data === "webgl-fingerprint-defender-alert") {
background.send("fingerprint", {"host": document.location.host});
}
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment