What are the two ways to monitor the browser environment in JS reverse?
What are the two ways to monitor the browser environment in JS reverse? in order to solve this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
1. The first thing I want to say is definitely Proxy. Let's skip the introduction and go directly to the code:
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 ("follow the official account [writing code]")} 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
Execution result of node environment:
2. Hook mode of object attributes
Execute in the browser:
3, needless to say, the role of this monitoring system, that is, it is often said that it needs to be used where it is missing. Now there are more and more scenarios of replenishing the environment. Some well-known js anti-climbing products can use this idea. If the environment is good, it can be used everywhere. It can also save a lot of trouble and get more with one stone.
This is the answer to the question about what are the two monitoring methods of the browser environment in reverse of JS. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.