5.4.12. Others

5.4.12.1. Command execution

The child_process.exec command in Node.js is called /bin/sh, so you can directly use this command to execute the shell

5.4.12.2. Anti-Debugging Techniques

  • function redefinitio console.log = function(a){}

  • timed breakpoint setInterval(function(){debugger}, 1000);

5.4.12.3. Object Copy

Object copying in JavaScript is divided into shallow copy and deep copy.

When a shallow copy copies an object, only the reference of the object is copied, but the copied object and the source object still refer to the same entity. Changes to one of the objects will affect the other.

When a deep copy copies an object, it not only copies the reference to the object, but also copies the value referenced by the object. The source object and the copy object are independent of each other, and changes to either object will not affect the other object.

Deep copy can be implemented based on spread operator / ... /for-in / object.assign() / JSON.parse(JSON.stringify()) etc. The first three methods only make deep copies of the first layer. If the object structure is more complex, it is necessary to copy deeper layers in a recursive way.

5.4.12.4. Common Sink

  • child_process

  • eval

  • exec

  • execSync