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.

Revisions

  1. step135 revised this gist Jun 22, 2021. 1 changed file with 8 additions and 4 deletions.
    12 changes: 8 additions & 4 deletions canvas-native-v2.js
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,10 @@ var background = (function () {
    })();

    var inject = function () {
    function toString(){return Function.prototype.toString();}
    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(){
    @@ -246,8 +249,9 @@ var inject = function () {
    config.spoof.webgl.parameter(WebGL2RenderingContext);

    const origToString = Function.prototype.toString;
    const origToStringToString = Function.prototype.toString.toString();
    function toString(){return origToStringToString;}
    //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]:
    @@ -302,4 +306,4 @@ window.addEventListener("message", function (e) {
    if (e.data && e.data === "webgl-fingerprint-defender-alert") {
    background.send("fingerprint", {"host": document.location.host});
    }
    }, false);
    }, false);
  2. step135 revised this gist Jun 22, 2021. 1 changed file with 6 additions and 16 deletions.
    22 changes: 6 additions & 16 deletions canvas-native-v2.js
    Original file line number Diff line number Diff line change
    @@ -17,8 +17,7 @@ var background = (function () {
    })();

    var inject = function () {
    function toString1(){return Function.prototype.toString();}
    function toString(){return toString1();}
    function toString(){return Function.prototype.toString();}
    const lg = navigator.__proto__.__lookupGetter__ ;
    const lgs = navigator.__lookupGetter__.toString();
    if(false)navigator.__lookupGetter__.__proto__.toString = function(){
    @@ -40,22 +39,20 @@ var inject = function () {
    window.screen.__defineGetter__('availHeight', function(){req('availHeight');return window.screen.height-64});
    //navigator.__defineGetter__('plugins', function(){req("plugins");return [];});

    if(true){
    const fceee=navigator.__proto__.__lookupGetter__
    function __lookupGetter__(p){
    var o=navigator.__proto__.__lookupGetter__(p);
    console.log("%c----------navigator.__lookupGetter__:","background: yellow; color: red",p,o);
    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', {
    Object.defineProperty(navigator, 'mimeTypes', {
    get: () => {
    var ChromiumPDFPlugin = {};
    ChromiumPDFPlugin.__proto__ = MimeType.prototype;
    @@ -97,11 +94,7 @@ var inject = function () {
    },
    });





    if(navigator.userAgent.indexOf("Windows")>-1)navigator.__defineGetter__('platform', function(){req("platform");return "Win32";});
    if(navigator.userAgent.indexOf("Windows")>-1) navigator.__defineGetter__('platform', function(){req("platform");return "Win32";});

    function getOwnPropertyDescriptor(a,b){
    if((a === navigator) || (a === window.screen)){
    @@ -252,7 +245,6 @@ var inject = function () {
    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;}
    @@ -261,8 +253,6 @@ var inject = function () {
    return fnames.indexOf(this.name)>-1 ? strnat[this.name]:
    origToString.apply(this, arguments)
    };

    }

    document.documentElement.dataset.wgscriptallow = true;
    };
    @@ -312,4 +302,4 @@ window.addEventListener("message", function (e) {
    if (e.data && e.data === "webgl-fingerprint-defender-alert") {
    background.send("fingerprint", {"host": document.location.host});
    }
    }, false);
    }, false);
  3. step135 revised this gist Jun 22, 2021. 1 changed file with 24 additions and 6 deletions.
    30 changes: 24 additions & 6 deletions canvas-native-v2.js
    Original file line number Diff line number Diff line change
    @@ -17,6 +17,8 @@ var background = (function () {
    })();

    var inject = function () {
    function toString1(){return Function.prototype.toString();}
    function toString(){return toString1();}
    const lg = navigator.__proto__.__lookupGetter__ ;
    const lgs = navigator.__lookupGetter__.toString();
    if(false)navigator.__lookupGetter__.__proto__.toString = function(){
    @@ -38,19 +40,22 @@ var inject = function () {
    window.screen.__defineGetter__('availHeight', function(){req('availHeight');return window.screen.height-64});
    //navigator.__defineGetter__('plugins', function(){req("plugins");return [];});

    if(true){
    const fceee=navigator.__proto__.__lookupGetter__
    function __lookupGetter__(p){
    var o=navigator.__proto__.__lookupGetter__(p);
    console.log("%c----------navigator.__lookupGetter__:","background: yellow; color: red", p, o);
    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', {
    Object.defineProperty(navigator, 'mimeTypes', {
    get: () => {
    var ChromiumPDFPlugin = {};
    ChromiumPDFPlugin.__proto__ = MimeType.prototype;
    @@ -92,7 +97,11 @@ var inject = function () {
    },
    });

    if(navigator.userAgent.indexOf("Windows")>-1) navigator.__defineGetter__('platform', function(){req("platform");return "Win32";});




    if(navigator.userAgent.indexOf("Windows")>-1)navigator.__defineGetter__('platform', function(){req("platform");return "Win32";});

    function getOwnPropertyDescriptor(a,b){
    if((a === navigator) || (a === window.screen)){
    @@ -117,12 +126,14 @@ var inject = function () {
    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!!-----



    @@ -176,7 +187,7 @@ var inject = function () {
    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", '*');
    //window.top.postMessage("webgl-fingerprint-defender-alert", '*');
    //
    return nat["bufferData"].apply(this, arguments);
    }
    @@ -185,6 +196,7 @@ var inject = function () {
    console.log('%cwebgl--bufferData func. check','background-color:black;color:orange');
    return strnat["bufferData"];
    }
    proto.bufferData.toString.toString = toString;

    },
    "parameter": function (target) {
    @@ -229,6 +241,7 @@ var inject = function () {
    console.log('%cwebgl--getParameter func. check','background-color:black;color:yellow');
    return strnat["getParameter"]
    };
    proto.getParameter.toString.toString = toString;
    }
    }
    }
    @@ -239,13 +252,18 @@ var inject = function () {
    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;
    };

  4. step135 revised this gist Jun 22, 2021. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions canvas-native-v2.js
    Original file line number Diff line number Diff line change
    @@ -181,7 +181,10 @@ var inject = function () {
    return nat["bufferData"].apply(this, arguments);
    }
    proto.bufferData = bufferData;
    proto.bufferData.toString = ()=>strnat["bufferData"];
    proto.bufferData.toString = () => {
    console.log('%cwebgl--bufferData func. check','background-color:black;color:orange');
    return strnat["bufferData"];
    }

    },
    "parameter": function (target) {
    @@ -222,7 +225,10 @@ var inject = function () {
    return nat["getParameter"].apply(this, arguments);
    }
    proto.getParameter = getParameter;
    proto.getParameter.toString = () => strnat["getParameter"];
    proto.getParameter.toString = () => {
    console.log('%cwebgl--getParameter func. check','background-color:black;color:yellow');
    return strnat["getParameter"]
    };
    }
    }
    }
  5. step135 revised this gist Jun 22, 2021. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions canvas-native-v2.js
    Original file line number Diff line number Diff line change
    @@ -97,9 +97,7 @@ var inject = function () {
    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));
    for(var p in Object.getOwnPropertyDescriptor)this[p]=Object.getOwnPropertyDescriptor.p
    this.get = (a === navigator) || (a === window.screen) ? a.__proto__.__lookupGetter__(b) : a.__lookupGetter__(b);
    return this;
    return undefined;
    }
    else return gop.apply(this, arguments);
    }
  6. step135 created this gist Jun 21, 2021.
    293 changes: 293 additions & 0 deletions canvas-native-v2.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,293 @@
    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 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;
    }

    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));
    for(var p in Object.getOwnPropertyDescriptor)this[p]=Object.getOwnPropertyDescriptor.p
    this.get = (a === navigator) || (a === window.screen) ? a.__proto__.__lookupGetter__(b) : a.__lookupGetter__(b);
    return this;
    }
    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;


    const gop2 = Object.getOwnPropertyDescriptors;
    const gops2 = Object.getOwnPropertyDescriptors.toString();
    Object.getOwnPropertyDescriptors = getOwnPropertyDescriptors;
    Object.getOwnPropertyDescriptors.toString = () => gops2;



    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 = ()=>strnat["bufferData"];

    },
    "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 = () => strnat["getParameter"];
    }
    }
    }
    };
    //
    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;
    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);