Skip to content

Latest commit

 

History

History
83 lines (72 loc) · 2.59 KB

1.canvas中的fingerprint.md

File metadata and controls

83 lines (72 loc) · 2.59 KB

snkrs web端分析,canvas中的fingerpint

代码如下

(()=>{
const canvas = document.createElement("canvas");
canvas.width = 280;
canvas.height = 60;
canvas.style.display = "none"
const context = canvas.getContext("2d");
context.fillStyle = "rgb(102, 204, 0)";
context.fillRect(100, 5, 80, 50);
context.fillStyle = "#f60";
context.font = "16pt Arial";
context.fillText("<@nv45. F1n63r,Pr1n71n6!", 10, 40);
context.strokeStyle = "rgb(120, 186, 176)";
context.arc(80, 10, 20, 0, Math.PI, !1);
context.stroke();
const canvasValue = canvas.toDataURL();
console.log(canvasValue)
})();

在这里插入图片描述

在源代码中的akamai指纹代码

t["canvas"] = function () {
        try {
            //是否有缓存
            if (void 0 !== t.cache["canvas"]) return t.cache["canvas"];
            let a = -1;
            if (!t["sf4"]()) {
                const e = document.createElement("canvas");
                e.width = 280;
                e.height = 60;
                // e["style"]["display"] = "none";
                const n = e["getContext"]("2d");
                n.fillStyle = "rgb(102, 204, 0)";
                n.fillRect(100, 5, 80, 50);
                n.fillStyle = "#f60";
                n.font = "16pt Arial";
                n.fillText("<@nv45. F1n63r,Pr1n71n6!", 10, 40);
                n.strokeStyle = "rgb(120, 186, 176)";
                n["arc"](80, 10, 20, 0, Math.pi, !1), n["stroke"]();
                const o = e.toDataURL();
                console.log("c1", o);
                a = 0;
                for (let m = 0; m < o["length"]; m++) {
                    a = (a << 5) - a + o["charCodeAt"](m);
                    a &= a
                }
                a = a.toString();

                //第二个指纹 第二张画布由一个随机生成的数字写入一个16x16像素的画布。
                const r = document.createElement("canvas");
                r.width = 16;
                r.height = 16;
                const ctx = r.getContext("2d");
                ctx.font = "6pt Arial";
                t.rVal = Math.floor(1000 * Math.random()).toString();
                ctx.fillText(t.rVal, 1, 12);

                for (var c = r["toDataURL"](), b = 0, d = 0; d < c["length"]; d++) {
                    b = (b << 5) - b + c["charCodeAt"](d);
                    b &= b
                }
                t.rCFP = b.toString()
            }
            return a
        } catch (a) {
            return "exception"
        }
    };

如何mock出canvs中的fingerpint

contact me