JS逆向之補(bǔ)瀏覽器環(huán)境的兩種監(jiān)控方式
1,首先要說的肯定是 Proxy 了,介紹就不說了,直接上代碼:
window = new Proxy(global, {get: function (target, key, receiver) {console.log("window.get", key, target[key]);if (key=="location"){location = new Proxy(target[key], {get: function (_target, _key, _receiver) {console.log("window.get", key, _key, _target[_key]);if (_key=="port"){console.log("關(guān)注公眾號【妄為寫代碼】")}return _target[_key];}})}return target[key];},set: function (target, key, value, receiver) {console.log("window.set", key, value);target[key] = value;}});window.a = {};window.a;window.location = {a: 2};window.location.a;window.b = {a: 2};window.b.a;location.port;console.log("--------------");window.location.port;
node 環(huán)境執(zhí)行結(jié)果:

重點(diǎn)關(guān)注【嵌套Proxy】和【重復(fù)Proxy】
2,對象屬性的 hook 方式
在瀏覽器中執(zhí)行:


重點(diǎn)關(guān)注【未在固定范圍的新增屬性】和【對比兩種方式的?location.port】和【多層屬性的獲取?window.location.port】
3,這個監(jiān)控的作用就不用說了吧,就是大家常說的缺哪補(bǔ)哪需要用到的,現(xiàn)在補(bǔ)環(huán)境的場景越來越多了,一些知名 js 反爬產(chǎn)品,就可以用這個思路,環(huán)境補(bǔ)的好,可以到處用,還能省好多事,一舉多得。
推薦閱讀
THANKS
- End -
點(diǎn)個“在看”必升職加薪喔!
評論
圖片
表情

