JavaScript obfuscation - the art of reverse thinking

In this article we will introduce three common JavaScript obfuscation techniques.

1. Hybrid names

We can make the code harder to read by mixing function and variable names. Below is a JavaScript function that uses name mixins.

function c(a){
    
    var b=[2,4,8,a],d=b[0]+b[1]+b[2]+b[3],e=d+"="+a;return e}

The mixed-name technique makes code look more complicated by using unrelated names.

2. Rewrite the code

Rewriting code is a way of transforming code into something else to make it harder to understand and read. Below is a pseudocode version of a JavaScript function that uses obfuscation and rewriting techniques to prevent users or hackers from understanding the intent of the code.

function d(a){
    
    for(var b=[2,4,8,a],d=b[0],e=1;e<b.length;e++)d+=b[e],d*=b[e];var c=d+a;return c}

Obfuscating code makes it as hard to understand as possible. The above code, does not have any actual function, but due to the weird syntax, we can't be too sure about what we are thinking when analyzing the code.

  1. Add spaces and formatting codes

Adding lots of spaces, tabs, and newlines to your code can add complexity to your code. Below is a JavaScript function that uses a lot of whitespace formatting.

function e(a) {
    
    var b = [ 2, 4, 8, a ], d = b [ 0 ] + b [ 1 ] + b [ 2 ] + b [ 3 ], e = d + "=" + a; return e; }

As you can see, the spaces in the code make the content more difficult to understand and help protect its privacy.

In practical applications, multiple obfuscation techniques can be mixed to achieve higher security.

3. Use online

Directly use JS encryption as a professional encryption tool to encrypt and obfuscate codes anytime, anywhere, or solve simple js codes online.

jsjiami.com

If you have different views or questions about the content of the article, please leave a message in the comment area, or send me a private message.

You can also go to the website above, and there is my contact information at the bottom to discuss in detail.

おすすめ

転載: blog.csdn.net/mxd01848/article/details/129420304