2022-03-21 18:17:02 +08:00

64 lines
2.1 KiB
Markdown
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.

## 如何更加好的补环境
https://github.com/jsdom/jsdom
jsdom 是许多 web 标准的纯 JavaScript 实现,特别是 WHATWG DOM和HTML标准用于 Node.js。一般来说该项目的目标是模拟足够多的 Web 浏览器子集,以用于测试和抓取真实世界的 Web 应用程序。
## 框架
调试框架要有封装的思想,功能单一,可扩展性强,
js调试框架 监控所有的环境
代理,在自己伪造的环境代理,任意代理,包座代理不会被检测,某些对象不能完美被伪造
利用谷歌开源浏览器,进行修改内核代码
代码如果被检测
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 现在我需要拦截代码