MEGA是Mega Limited公司推出的一款云存储服务。
而很多盗版动漫网站都使用的第三方视频源, 其中就包括了mega
你可以在这里上传你的视频Megacloud.co
某个接口的响应头暴露了这些网站的域名
frame-ancestors 'self' https://aniwatch.to https://aniwatchtv.to https://aniwatch.nz https://aniwatch.se https://hianime.to https://hianime.nz https://hianime.mn https://hianime.sx https://hianime.is https://hianime.bz https://hianime.pe https://hianimez.to/ https://hianimez.is/ https://9anime.vc https://9anime.se https://9anime.pe https://9animetv.to https://anicrush.tohianime 请求参数添加 _debug=ok即可绕过页面回退, like: https://hianime.bz/watch/xiong-bing-lian-12508?ep=117187&_debug=ok
window.location.href = "/home"主要检测的JS: https://hianime.bz/js/watch.min.js?v=3.7
应该是使用了 https://github.com/AEPKILL/devtools-detector
{ "depRegToStringChecker": { "name": "dep-reg-to-string" }, "elementIdChecker": { "name": "element-id" }, "functionToStringChecker": { "name": "function-to-string" }, "regToStringChecker": { "name": "reg-to-string" }, "debuggerChecker": { "name": "debugger-checker" }, "dateToStringChecker": { "name": "date-to-string" }, "performanceChecker": { "name": "performance" }, "erudaChecker": { "name": "eruda" }}获取视频地址的接口由 https://megacloud.blog/embed-2/ajax/e-1/getSources 更新到v2: https://megacloud.blog/embed-2/v2/e-1/getSources
对于v1版本,有开源的补wasm环境实现
https://github.com/drblgn/rabbit_wasm/blob/main/rabbit.ts
Aniwatch-Api/src/routes/src1.js at main · codex0555/Aniwatch-Api
https://github.com/falcon71181/Anime-API/blob/master/src/utils/aniwatch/megacloud.getsrcs.ts
当然也有Python纯算法实现, 整体签名解密算法逻辑如下

但是纽约时间 2025.06.09 凌晨3点左右, mega公司更新了 v2 版本的 getSources, 之前的所有getSources接口全部404
v2接口去除了签名验证, 但是保留了响应加密,xrax具有时效性,密钥在一定时间内为固定值
网页做了对devtool的严格检测, 包括回退网页, 无限debugger, 以及播放视频时走错误逻辑
核心JS: https://megacloud.blog/js/player/a/v2/pro/embed-1.min.js?v=1749522731 被高度混淆,难以分析检测点
发起请求在JS的末尾 类似以下结构的函数中, 包括解密在switch 的 case 4中, 这个是固定的; 但是每次生成混淆的js变量名/函数名是不固定的;
f()函数返回密钥,v6n[8]为解密后的结果,v6n[0][0]['sources']为密文, 解密算法与v1时一致
f() 函数的基本逻辑为,b与k在一定时间内是一个固定值, 也就是说密钥在一定时间是固定的。
b = [17, 0, 11, 2, 14, 12, 13, 9, 20, 7, 19, 1, 22, 21, 3, 16, 6, 4, 5, 15, 18, 10, 8]k = ['b', '5', '8d', 'ea', 'dff6', 'fc7', '9cf', 'f', 'b049', '341', 'a', '2a5', '6e', 'dd7', '2632', '4cd', '214c', '2e', '0d2', '9a4c', 'ed8d', '135', 'df1b']
key = b.map(X => k[X]).join("")
额外添加辅助方法logToDOM, 将日志输出到DOM中, 以实现不打开devtool的调试
// 1. 创建一个日志容器(如果不存在)if (!document.getElementById('log-container')) { const logContainer = document.createElement('div'); logContainer.id = 'log-container'; logContainer.style.position = 'fixed'; logContainer.style.bottom = '0'; logContainer.style.right = '0'; logContainer.style.width = '300px'; logContainer.style.height = '200px'; logContainer.style.overflow = 'auto'; logContainer.style.backgroundColor = 'rgba(0, 0, 0, 0.7)'; logContainer.style.color = 'white'; logContainer.style.padding = '10px'; logContainer.style.zIndex = '9999'; document.body.appendChild(logContainer);}
// 2. 自定义日志函数function logToDOM(message) { const logContainer = document.getElementById('log-container'); const logEntry = document.createElement('div'); logEntry.textContent = `[${new Date().toLocaleTimeString()}] ${message}`; logContainer.appendChild(logEntry); logContainer.scrollTop = logContainer.scrollHeight; // 自动滚动到底部}如何将修改后的JS替换呢?
很多抓包工具都有修改响应值的功能, 比如reqable, fiddler等; 抓包替换响应JS即可


测试
安装插件:https://chromewebstore.google.com/detail/console-importer/hgajpakhafplebkdljleajgbpdmplhie?hl=zh-CN
导入库: $i("crypto-js")
测试密钥解密是否可用:
CryptoJS.AES.decrypt("U2FsdGVkX1+Y2nGwdIy39xTVMHC7twP5k9Buv7lfUtpr7wcfqi+Oi64S4JW2O0hO86TwiZLf+VaJTMd/EDdrep9/mEZA7WYQsd/Dmw1f4bisbGudF4dODw73kYYPGHOa1viOXI2WFXuC8SgiW89NMzK+O/rk2iY8+dcg865etnbfHkq6aOnL7gRBHYJeoO2c+GWmBWPRdLAYnEEMEDXJQiphT71yAt6S4afxX2uySVj2McEIrgKgPjOX5rcQxSB4ZsAY1NJxP6h29i+mgtC3QB7DDeqOHlh796Px3Z3f09H77f0j/xlXPoAd8JSxjjxqKFfPe0xXTIWPFbtHsTi/Oc/wfUQ4ruXOhRcEdS5BXTF1xW5Gmpqzu9ZmNDTPKDUItfQy2PESNu+CUycQNncQ6777A6+EGQ4h/OOIYZgXxhQPM5RnTfXS1sh3O2A6qiRhcCe9tsCSBodL+O/V+T4bgQ==", "041275d6ca8ec6f6773c3349e95b41df2a4d78f429c529f5cc1728e4084692ec").toString(CryptoJS.enc.Utf8)