JS 环境检测点总结
关注开源指纹库: fingerprintjs
window.matchMedia
window.matchMedia() 方法用于检测当前浏览器是否支持某种 CSS 指定的媒体查询。
canvas指纹
相同的HTML5 Canvas元素绘制操作,在不同操作系统、不同浏览器上,产生的图片内容不完全相同。在图片格式上,不同浏览器使用了不同的图形处理引擎、不同的图片导出选项、不同的默认压缩级别等。在像素级别来看,操作系统各自使用了不同的设置和算法来进行抗锯齿和子像素渲染操作。即使相同的绘图操作,产生的图片数据的CRC检验也不相同。
示例代码如下:
document.createElement("mycanvas");
const canvas = document.getElementById("mycanvas");
const ctx = canvas.getContext("2d");
const txt = 'qwertyuiop!@#$%^&*()_+'
ctx.textBaseline = 'top'
ctx.font = '14px \'Arial\''
ctx.textBaseline = 'tencent'
ctx.fillStyle = '#f60'
ctx.fillRect(125, 1, 62, 20)
ctx.fillStyle = '#069'
ctx.fillText(txt, 2, 15)
ctx.fillStyle = 'rgba(102, 204, 0, 0.7)'
ctx.fillText(txt, 4, 17);
const canvasData = canvas.toDataURL();
webgl指纹
- WebGL报告——完整的WebGL浏览器报告表是可获取、可被检测的。通过读取报告中的vendor和renderer信息,可以获取到显卡的供应商和型号信息。
- WebGL图像——渲染和转换为哈希值的隐藏3D图像。由于最终结果取决于进行计算的硬件设备,因此此方法会为设备及其驱动程序的不同组合生成唯一值.
ja3指纹
Ja3指纹是一种用于识别和追踪SSL/TLS加密流量的哈希值。它是通过计算客户端SSL/TLS握手期间使用的加密协议参数,包括TLS版本和密码套件等得出的。Ja3指纹的长度为32个16进制数字符(64个字符),可以用于识别加密流量的来源,例如,某个应用程序,某个操作系统,某个设备或者一个独立的网络节点。
常规检测点
- navigator.webdriver
- navigator.platform(Win32/MacOSX/Linux)
- navigator.userAgent
- window._phantom
- window.__nightmare
- window._selenium
- window.callPhantom
- window.callSelenium
- window._Selenium_IDE_Recorder
- window.document.__webdriver_evaluate
- window.document.__selenium_evaluate
- window.document.__webdriver_script_function
- window.document.__webdriver_script_func
- window.document.__webdriver_script_fn
- window.document.__fxdriver_evaluate
- window.document.__driver_unwrapped
- window.document.__webdriver_unwrapped
- window.document.__driver_evaluate
- window.document.__selenium_unwrapped
- window.document.__fxdriver_unwrapped
- window.document.documentElement.getAttribute(“selenium”)
- window.document.documentElement.getAttribute(“webdriver”)
- window.document.documentElement.getAttribute(“driver”)
检测TypeError对象属性
检测一个普通的TypeError对象的这些属性: [“line”,“column”,“lineNumber”,“columnNumber”,“fileName”,“message”,“number”,“description”,“sourceURL”,“stack”], 一些特别的运行环境中可能会有这些属性, 从而知道js代码是否运行在浏览器中, 正常浏览器只会有message和stack两个属性.