上文链接
代码运行
补充基础环境
Window环境
///
// window
window = global;
Window = function Window(){}
Window.prototype.addEventListener = function addEventListener( type, event, opt ){
debugger
}
window[ 'availHeight' ] = 1050;
window[ 'availWidth' ] = 1920;
window[ 'width' ] = 1920;
window[ 'height' ] = 1080
window[ 'DeviceOrientationEvent' ] = function DeviceOrientationEvent(){
debugger
}
window[ 'DeviceMotionEvent' ] = function DeviceMotionEvent(){
debugger
}
window['outerHeight'] = 1050;
window[ 'outerWidth' ] = 1920;
window.__proto__ = Window.prototype;
Navigator环境
///
// navigator
navigator = {
appCodeName: "Mozilla",
appName: "Netscape",
appVersion: "5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
language: "en",
languages: [ "en", "zh-CN", "zh", "ja" ],
platform: "Win32",
product: "Gecko",
productSub: "20030107",
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
vendor: "Google Inc.",
}
Navigator = function Navigator(){}
Navigator.prototype.webdriver = false;
navigator.__proto__ = Navigator.prototype;
Location环境
///
// location
location = {
hash: "",
host: host,
hostname: hostname,
href: href,
origin: origin,
pathname: path,
port: "",
protocol: "https:",
search: ""
}
Location = function Location(){}
location.__proto__ = Location.prototype;
window.location = location;
存在变量请自行替换
Document环境
///
// document
document = {}
HTMLDocument = function Document(){}
document.__proto__ = HTMLDocument.prototype;
window.document = document;
调试环境补充
第一次调试
由此可以得到错误: document.body.classList;
来到原始站点调试输出
那么补充到 Document 中
document = {
body:{
classList: ""
}
}
第二次调试
由此可以得到错误:Unexpected token in JSON at position 1
该自执行函数通看下来, 其实是没做什么事情 可先进行注释。
第三次调试
由此可以得到错误:document.createDocumentFragment is not a function
来到原始站点调试输出 可知该方法为底层返回一个 native code
参考链接:Document.createDocumentFragment() - Web API 接口参考 | MDN
HTMLDocument.prototype.createDocumentFragment = function createDocumentFragment(){
debugger;
return {}
}
第四次调试
由此可以得到错误:document.getElementsByTagName is not a function
来到源网站控制台输出
由此可以看出 document.getElementsByTagName("head")返回是站点头部得合集
HTMLDocument.prototype.getElementsByTagName = function getElementsByTagName( node ){
debugger;
if( 'head' == node ){
return [ '<head></head>' ]
}
}
第五次调试
由此可以得到错误:document.createElement is not a function
参考链接:Document.createElement() - Web API 接口参考 | MDN
HTMLDocument.prototype.createElement = function createElement( node ){
debugger;
if( 'a' == node ){
return '<a></a>'
}
}
第六次调试
由此可以得到错误:document.getElementById is not a function
参考链接:Document:getElementById() 方法 - Web API 接口参考 | MDN
HTMLDocument.prototype.getElementById = function getElementById( id ){
debugger;
return null
}
注:此处我们还应知道变量 H1x 内容,在源站点此处打上断点进行调试输出即可。
第七次调试
由此可以得到错误:top is not defined
(function() {
// 此处发现判定top是否等于self
// 等于则返回
// 不等于得话则执行下面得代码
if (window.NMJ_VipCashier || top === self) {
return
}
var gr2x = document.getElementById("g_top");
if (a1x.v1x(gr2x, "module") === "discover" && a1x.v1x(gr2x, "sub") === "discover" && top["GDegradeConfig"] && top["GDegradeConfig"].degrade) {
return
}
var host = window.location.host;
var online = /music\.163\.com$/.test(host);
var test = (/[a-z-]+\.igame\.163\.com$/.exec(host) || [])[0] || "qa.igame.163.com";
var base = online ? "music.163.com" : test;
var g1x = document.createElement("script");
g1x.setAttribute("type", "text/javascript");
g1x.setAttribute("src", "//st." + base + "/npm-packages/vipcashier/vipcashier.umd.js");
document.head.appendChild(g1x)
}
)();
来到源网站控制台输出
self = window;
top = {};
注:上述代码通读下来 发现对我们来说没有做什么实际得东西 可以先注释
第八次调试
由此可以得到错误:Cannot read properties of undefined (reading 'split')
发现关键词:document.domain
document = {
domain: domain,
body:{
classList: 0
}
}
存在变量请自行替换
第九次调试
发现吐出值了。
结果验证
可以给出结果。
至此已完