Files
CLOAK/cloakjs.php
T
2026-06-14 14:00:24 +08:00

174 lines
8.5 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* 二次风控前端指纹脚本入口
*
* 输出分两层(由 CLOAK_RISK_ENHANCED 控制):
* 1. 始终输出(轻量):加载动画 + navigator/screen/时区/自动化检测 + POST f_check.php
* 2. 加强判断 ON 时额外输出(耗时):resources/cloakjs_enhanced.inc.php
* - UAParser、Canvas 指纹、WebGL 深度指纹、WebGPU 基准、字体检测
*/
$__cloak_risk_enhanced = defined('CLOAK_RISK_ENHANCED') && strtoupper(CLOAK_RISK_ENHANCED) === 'ON';
if ($__cloak_risk_enhanced) {
require __DIR__ . '/resources/cloakjs_enhanced.inc.php';
}
?>
<script>
/* ===== 加载动画(轻量,始终输出) ===== */
(function () {
function _0x51ac55() {
var _0x1932aa = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var _0x5633ca = "";
var _0x5c3c48 = Math.floor(Math.random() * 10) + 4;
for (var _0x53aa2a = 0; _0x53aa2a < _0x5c3c48; _0x53aa2a++) {
_0x5633ca += _0x1932aa.charAt(Math.floor(Math.random() * _0x1932aa.length));
}
return _0x5633ca;
}
var _0x3ead50 = _0x51ac55();
var _0x666e98 = _0x51ac55();
var _0x5e8e1d = _0x51ac55();
var _0x485aab = _0x51ac55();
var _0xd488af = document.createElement("style");
_0xd488af.textContent = "." + _0x666e98 + " {position: relative;width: 40px;}." + _0x666e98 + ":before {content: '';display: block;padding-top: 100%;}." + _0x5e8e1d + " {animation: rotate 2s linear infinite;height: 100%;transform-origin: center center;width: 100%;position: absolute;top: 0;bottom: 0;left: 0;right: 0;margin: auto;}." + _0x485aab + " {stroke-dasharray: 1, 200;stroke-dashoffset: 0;animation: dash 1.5s ease-in-out infinite;stroke-linecap: round;stroke: #535353;stroke-width: 4px;}@keyframes rotate {to { transform: rotate(360deg);}}@keyframes dash {50% { stroke-dasharray: 89, 200; stroke-dashoffset: -35px;}to { stroke-dasharray: 89, 200; stroke-dashoffset: -124px;}}." + _0x3ead50 + " {position: fixed;top: 0;bottom: 0;left: 0;right: 0;z-index: 9999999;background: rgba(255, 255, 255, 255);display: flex;align-items: center;justify-content: center;}.afabcbccfed ." + _0x3ead50 + " { display: none;}";
document.head.appendChild(_0xd488af);
var _0x432f8c = document.createElement("div");
_0x432f8c.className = _0x3ead50;
var _0x9fd2b1 = document.createElement("div");
_0x9fd2b1.className = _0x666e98;
_0x432f8c.appendChild(_0x9fd2b1);
var _0x36c920 = "http://www.w3.org/2000/svg";
var _0x5f00b3 = document.createElementNS(_0x36c920, "svg");
_0x5f00b3.classList.add(_0x5e8e1d);
_0x5f00b3.setAttribute("viewBox", "25 25 50 50");
_0x9fd2b1.appendChild(_0x5f00b3);
var _0x5ccae7 = document.createElementNS(_0x36c920, "circle");
_0x5ccae7.classList.add(_0x485aab);
_0x5ccae7.setAttribute("cx", "50");
_0x5ccae7.setAttribute("cy", "50");
_0x5ccae7.setAttribute("r", "20");
_0x5ccae7.setAttribute("fill", "none");
_0x5ccae7.setAttribute("stroke-width", "2");
_0x5ccae7.setAttribute("stroke-miterlimit", "10");
_0x5f00b3.appendChild(_0x5ccae7);
if (!document.body) {
document.documentElement.appendChild(document.createElement("body"));
}
document.body.insertAdjacentElement("afterbegin", _0x432f8c);
})();
/* ===== 指纹采集 + 提交(轻量字段始终采集;耗时采集仅加强判断 ON) ===== */
(async function () {
const __cloakRiskEnhanced = <?php echo $__cloak_risk_enhanced ? 'true' : 'false'; ?>;
try {
let _0x3b0528;
let _0x12fad4;
window.addEventListener("message", function (_0x3c51e9) {
if (_0x3c51e9.data === "loaded") {
_0x3b0528 = _0x3c51e9.origin;
_0x12fad4 = parent;
}
}, false);
let _0x5aa8d7 = new Map();
_0x5aa8d7.set('isEmulators', false);
if (__cloakRiskEnhanced) {
/* 耗时指纹:Canvas / WebGL 深度 / WebGPU / 字体 / UAParser(定义于 cloakjs_enhanced.inc.php */
await cloakApplyEnhancedFingerprint(_0x5aa8d7);
} else {
/* 加强判断关闭:跳过全部 GPU/Canvas/字体解析,占位 null 供后端识别为基础模式 */
_0x5aa8d7.set("vendor", null);
_0x5aa8d7.set("renderer", null);
_0x5aa8d7.set("canvas", null);
_0x5aa8d7.set("webgl", null);
_0x5aa8d7.set("webGpuData", null);
_0x5aa8d7.set("fonts", []);
_0x5aa8d7.set("browser", null);
}
/* 轻量环境字段(始终采集) */
_0x5aa8d7.set("screen", [window.screen.width, window.screen.height]).set("availScreen", [window.screen.availWidth, window.screen.availHeight]).set("devicePixelRatio", window.devicePixelRatio).set("timezoneOffset", new Date().getTimezoneOffset()).set("webGPU", !!navigator.gpu);
let _0x370f95 = [["userAgent", "userAgent"], ["hardwareConcurrency", "hardwareConcurrency"], ["language", "language"], ["languages", "languages"], ["webdriver", "webdriver"], ["oscpu", "oscpu"], ["deviceMemory", "deviceMemory"], ["platform", "platform"], ["appVersion", "appVersion"]];
new Map(_0x370f95).forEach(function (_0x30f3e1, _0xc7ac9) {
if (_0x30f3e1 in navigator) {
_0x5aa8d7.set(_0xc7ac9, navigator[_0x30f3e1]);
}
});
if ("visualViewport" in window) {
_0x5aa8d7.set("visualViewport", [visualViewport.width, visualViewport.height]);
_0x5aa8d7.set("visualViewportOffset", [visualViewport.offsetLeft, visualViewport.offsetTop]);
_0x5aa8d7.set("windowInnerWidth", window.innerWidth);
_0x5aa8d7.set("scale", visualViewport.scale);
}
if (window.Intl) {
_0x5aa8d7.set("timezone", new window.Intl.DateTimeFormat().resolvedOptions().timeZone);
}
let _0x4e6c16 = 0;
let _0x2b0c77;
if (typeof navigator.maxTouchPoints !== "undefined") {
_0x4e6c16 = navigator.maxTouchPoints;
} else if (typeof navigator.msMaxTouchPoints !== "undefined") {
_0x4e6c16 = navigator.msMaxTouchPoints;
}
try {
document.createEvent("TouchEvent");
_0x2b0c77 = true;
} catch (_0x3035c4) {
_0x2b0c77 = false;
}
let _0x142582 = "ontouchstart" in window;
_0x5aa8d7.set("touchscreen", [_0x4e6c16, _0x2b0c77, _0x142582]);
let _0xae8ab2 = [];
let _0x2b1b36 = () => !!window.RTCPeerConnection || !!window.webkitRTCPeerConnection ? 1 : 0;
_0xae8ab2.push({
isWebRTCSupported: _0x2b1b36()
});
_0x5aa8d7.set("experimental", _0xae8ab2);
let automation = {
isChrome: !!window.chrome,
phantom: !!window.callPhantom || !!window._phantom || false,
selenium: !!document.__selenium_unwrapped__ || !!document.__webdriver_evaluate || false
};
_0x5aa8d7.set('automation', automation);
_0x5aa8d7.set('ip', '<?php echo isset($v_info) && is_object($v_info) ? htmlspecialchars((string) $v_info->v_ip, ENT_QUOTES, 'UTF-8') : ''; ?>');
_0x5aa8d7.set('ciso', '<?php echo isset($v_info) && is_object($v_info) ? htmlspecialchars((string) $v_info->v_country, ENT_QUOTES, 'UTF-8') : ''; ?>');
_0x5aa8d7.set('log_id', '<?php echo (int) ($log_id ?? 0); ?>');
_0x5aa8d7.set('isEmulator', false);
_0x5aa8d7.set('referer', document.referrer);
_0x5aa8d7.set('risk_enhanced', __cloakRiskEnhanced);
let _0x4abcf1 = {};
_0x5aa8d7.forEach((_0x24ebea, _0x3bf077) => {
_0x4abcf1[_0x3bf077] = _0x24ebea;
});
_0x4abcf1['domain'] = window.location.href;
let _0x1120a3 = btoa(JSON.stringify(_0x4abcf1));
let _0x58478a = window.location.search.length > 0 ? decodeURI(window.location.search) : "";
let _0x8edc71 = new XMLHttpRequest();
_0x8edc71.responseType = "json";
_0x8edc71.withCredentials = true;
const apiPath = 'f_check.php';
const targetUrl = new URL(apiPath, window.location.origin).href;
_0x8edc71.open("POST", targetUrl + _0x58478a, true);
_0x8edc71.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
_0x8edc71.send("hdata=" + _0x1120a3);
_0x8edc71.addEventListener("readystatechange", () => {
if (_0x8edc71.readyState === 4 && _0x8edc71.status === 200) {
let link = _0x8edc71.response.link;
if (link) {
window.location.href=link;
} else {
document.body.classList.add("afabcbccfed");
}
}
});
} catch (_0xcloakErr) {
console.error('cloak fingerprint failed', _0xcloakErr);
}
})();
</script>