补环境

This commit is contained in:
luzhisheng 2022-03-21 18:17:02 +08:00
parent e5253b6a6b
commit def2b759ce
3 changed files with 63 additions and 1 deletions

BIN
img/63.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -0,0 +1,15 @@
navigator = {
userAgent: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
};
Object.getOwnPropertyDescriptor_ = Object.getOwnPropertyDescriptor;
Object.getOwnPropertyDescriptor = function (o,p) {
if(navigator.toString() == "[object Navigator]"){
return undefined;
}
Object.getOwnPropertyDescriptor_.apply(this, arguments)
};
const descriptor1 = Object.getOwnPropertyDescriptor(navigator, 'userAgent');
console.log(descriptor1);

View File

@ -13,4 +13,51 @@ jsdom 是许多 web 标准的纯 JavaScript 实现,特别是 WHATWG DOM和HTML
利用谷歌开源浏览器,进行修改内核代码 利用谷歌开源浏览器,进行修改内核代码
代码如果被检测 代码如果被检测
tostringnode tostringnode基于原型连的检测dom环境
## 检测举例 Object.getOwnPropertyDescriptor
在node中运行 Object.getOwnPropertyDescriptor
navigator = {
userAgent: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
};
const descriptor1 = Object.getOwnPropertyDescriptor(navigator, 'userAgent');
console.log(descriptor1);
会出现
{
value: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36',
writable: true,
enumerable: true,
configurable: true
}
浏览器中运行,这里打印的 undefined
![debugger](../img/63.png)
接下来就需要重写 getOwnPropertyDescriptor 逻辑
navigator = {
userAgent: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
};
Object.getOwnPropertyDescriptor_ = Object.getOwnPropertyDescriptor;
Object.getOwnPropertyDescriptor = function (o,p) {
if(navigator.toString() == "[object Navigator]"){
return undefined;
}
Object.getOwnPropertyDescriptor_.apply(this, arguments)
};
const descriptor1 = Object.getOwnPropertyDescriptor(navigator, 'userAgent');
console.log(descriptor1);
## 代理是什么
js代码中读了 window.ayf 现在我需要拦截代码