如何恢复混淆的属性名称? [英] How to restore obfuscated property names?

查看:151
本文介绍了如何恢复混淆的属性名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在解密一个javascript代码,经过长时间的互联网搜索,我不知道如何快速解密这个问题。

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.

然后在其余代码中它只调用字符串数组,按id。

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

_$_21e2[29]

我知道我可以手动执行此操作,但是大约有120个字符串,因此这需要花费太多时间。
有没有办法快速解密?在此先感谢。

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.

推荐答案

一个简单的正则表达式替换 将执行:

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.

这篇关于如何恢复混淆的属性名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆