Warm tip: This article is reproduced from stackoverflow.com, please click
deobfuscation javascript obfuscation

How to restore obfuscated property names?

发布于 2020-04-22 09:33:45

So I'm decrypting a javascript code, and after long time of looking on the internet I have no clue on how to decrypt this a quick way.

The code starts off with a large Array containing all strings of the entire script.

 var _$_21e2 = ["jQuery", "userAgent", "test", "onmouseup", "onmousemove", "pink", "greenyellow", "gold"]

There are more string in the array, but this is just an example.

And then in the rest of the code it just calls the string from the array, by id.

_$_21e2[29]

I know I can just do this manually but there are around 120 strings so it would be taking too much time to do this. Is there a way to quickly decrypt this? Thanks in advance.

Questioner
Bert Janssen
Viewed
18
Bergi 2015-06-17 06:18

A simple regex replace will do:

var _$_21e2 = ["jQuery", "userAgent", "test", "onmouseup", "onmousemove", "pink", "greenyellow", "gold"];
return code.replace(/\[_\$_21e2\[(\d+)\]\]/g, function(_, i) {
    return "."+_$_21e2[i];
}).replace(/_\$_21e2\[(\d+)\]/g, function(_, i) {
    return JSON.stringify(_$_21e2[i]);
});

Given the code as a string, this will yield a code string with human-readable property names and literals.