JAVASCRIPT混淆及反混淆代码工具

介绍

在我们开始学习反混淆之前​​,我们首先要了解一下代码混淆。如果不了解代码是如何混淆的,我们可能无法成功对代码进行反混淆,尤其是使用自定义混淆器对其进行混淆时。

什么是混淆

混淆是一种技术,用于使脚本更难以被人类阅读,但从技术角度来看,它可以发挥相同的功能,尽管性能可能会较慢。这通常是通过使用混淆工具自动实现的,该工具将代码作为输入,并尝试以更难以阅读的方式重写代码,具体取决于其设计。

例如,代码混淆器通常将代码转换成代码中使用的所有单词和符号的字典,然后在执行期间尝试通过引用字典中的每个单词和符号来重建原始代码。以下是一个简单的 JavaScript 代码被混淆的示例:

1690198624_64be626039ffce836c934.png!small

为什么用混淆?

开发人员考虑混淆代码的原因有很多。一个常见的原因是隐藏原始代码及其功能,以防止在未经开发人员许可的情况下重复使用或复制它,从而使对代码的原始功能进行逆向工程变得更加困难。另一个原因是在处理身份验证或加密时提供安全层,以防止对代码中可能发现的漏洞进行攻击。

​必须注意的是,不建议在客户端进行身份验证或加密,因为这样代码更容易受到攻击。​​

然而,混淆最常见的用途是用于恶意行为。攻击者和恶意行为者通常会混淆其恶意脚本,以阻止入侵检测和防御系统检测其脚本。

基础混淆

代码混淆通常不是手动完成的,因为有许多针对各种语言的工具可以自动进行代码混淆。尽管许多恶意行为者和专业开发人员开发了自己的混淆工具以使反混淆变得更加困难,但许多在线工具都可以这样做。

明文示例

让我们以下面这行代码为例,尝试对其进行混淆:

console.log(\'Hello JavaScript Deobfuscation\');

明文运行打印出来是:

Hello JavaScript Deobfuscation

混淆示例

现在,让我们混淆我们的代码行,使其更加晦涩难懂。首先,我们将尝试使用BeautifyTools来混淆我们的代码:

console.log(\'Hello JavaScript Deobfuscation\');

混淆输出

eval(function(p,a,c,k,e,d){e=function(c){return c};if(!\'\'.replace(/^/,String)){while(c--){d[c]=k[c]||c}k=[function(e){return d[e]}];e=function(){return\'\\w \'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp(\'\\b\' e(c) \'\\b\',\'g\'),k[c])}}return p}(\'0.1(\\'2 3 4\\');\',5,5,\'console|log|Hello|JavaScript|Deobfuscation\'.split(\'|\'),0,{}))

我们发现我们的代码变得更加混乱且难以阅读。我们可以将此代码复制到https://jsconsole.com,以验证它仍然执行其主要功能:

1690199186_64be6492e6a86c606b98d.png!small?1690199187437

虽然加壳器在降低代码的可读性方面做得很好,但我们仍然可以看到它的主要字符串以明文形式编写,这可能会揭示它的一些功能。这就是为什么我们可能想要寻找更好的方法来混淆我们的代码。

高级混淆工具

到目前为止,我们已经能够使我们的代码变得模糊并且更难以阅读。但是,该代码仍然包含明文字符串,这可能会揭示其原始功能。我们将尝试一些工具,它们应该完全混淆代码并隐藏其原始功能的任何残留。

#0x1 JavaScript Obfuscator Tool – JS混淆工具

有一个在线的混淆工具:JavaScript Obfuscator Tool

一个免费且高效的 JavaScript 混淆器(包括对 ES2022 的支持)。使您的代码更难复制,并防止人们窃取您的工作。这个工具是一个由Timofey Kachalov创建的优秀(和开源) javascript-obfuscator@4.0.0的Web UI。

让我们访问https://obfuscator.io。在单击 之前obfuscate​​,我们将更改为:[Strings Transformations]->[String Array Encoding​​]->Base64​​如下所示:

1690199596_64be662c9cd2a25a95a3a.png!small?1690199597180

现在,我们可以粘贴代码并单击obfuscate​​:

var _0x1a54f6=_0x5936;function _0x5271(){var _0x3bb17a=[\'otKWodqYnNfIBgPSua\',\'mtb0vNnJt3q\',\'mtKZnfHYt3vnrW\',\'otH1tMPpBNC\',\'mtG2og9jufLKEa\',\'mtaXyKvOD2TP\',\'mJm1oty1ouzyCwLnzW\',\'ntmYmtu5mLr0rKLYwq\',\'Bg9N\',\'mZe2mdC3m2jgvLjizW\',\'ntG3oduWwwrzqwD4\',\'mtaWBwvpzgjc\'];_0x5271=function(){return _0x3bb17a;};return _0x5271();}function _0x5936(_0x25a7d9,_0x1f51f9){var _0x5271e3=_0x5271();return _0x5936=function(_0x593653,_0x103659){_0x593653=_0x593653-0x1e3;var _0x38866e=_0x5271e3[_0x593653];if(_0x5936[\'CXFyxS\']===undefined){var _0x55d0c5=function(_0x417d06){var _0x32ee69=\'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 /=\';var _0x49cddd=\'\',_0x2f60dc=\'\';for(var _0x22561b=0x0,_0x45c65d,_0x24071e,_0x4b6047=0x0;_0x24071e=_0x417d06[\'charAt\'](_0x4b6047  );~_0x24071e&&(_0x45c65d=_0x22561b%0x4?_0x45c65d*0x40 _0x24071e:_0x24071e,_0x22561b  %0x4)?_0x49cddd =String[\'fromCharCode\'](0xff&_0x45c65d>>(-0x2*_0x22561b&0x6)):0x0){_0x24071e=_0x32ee69[\'indexOf\'](_0x24071e);}for(var _0x450e46=0x0,_0x71cdac=_0x49cddd[\'length\'];_0x450e46<_0x71cdac;_0x450e46  ){_0x2f60dc =\'%\' (\'00\' _0x49cddd[\'charCodeAt\'](_0x450e46)[\'toString\'](0x10))[\'slice\'](-0x2);}return decodeURIComponent(_0x2f60dc);};_0x5936[\'trxXbR\']=_0x55d0c5,_0x25a7d9=arguments,_0x5936[\'CXFyxS\']=!![];}var _0xd2632a=_0x5271e3[0x0],_0x376564=_0x593653 _0xd2632a,_0x6361f9=_0x25a7d9[_0x376564];return!_0x6361f9?(_0x38866e=_0x5936[\'trxXbR\'](_0x38866e),_0x25a7d9[_0x376564]=_0x38866e):_0x38866e=_0x6361f9,_0x38866e;},_0x5936(_0x25a7d9,_0x1f51f9);}(function(_0x4625fd,_0x16a961){var _0x1627a6=_0x5936,_0x5197f8=_0x4625fd();while(!![]){try{var _0x40e3f4=parseInt(_0x1627a6(0x1e7))/0x1*(parseInt(_0x1627a6(0x1e4))/0x2) parseInt(_0x1627a6(0x1e8))/0x3 -parseInt(_0x1627a6(0x1e6))/0x4*(parseInt(_0x1627a6(0x1ed))/0x5) -parseInt(_0x1627a6(0x1ec))/0x6*(parseInt(_0x1627a6(0x1e5))/0x7) parseInt(_0x1627a6(0x1e9))/0x8 -parseInt(_0x1627a6(0x1eb))/0x9 parseInt(_0x1627a6(0x1e3))/0xa*(parseInt(_0x1627a6(0x1ee))/0xb);if(_0x40e3f4===_0x16a961)break;else _0x5197f8[\'push\'](_0x5197f8[\'shift\']());}catch(_0x5f50ba){_0x5197f8[\'push\'](_0x5197f8[\'shift\']());}}}(_0x5271,0xaf4ae),console[_0x1a54f6(0x1ea)](\'Hello\x20JavaScript\x20Deobfuscation\'));

这段代码显然更加混乱,我们看不到原始代码的任何残余。我们现在可以尝试在https://jsconsole.com中运行它,以验证它是否仍然执行其原始功能。尝试使用https://obfuscator.io中的混淆设置来生成更多混淆代码,然后尝试在https://jsconsole.com中重新运行它以验证它仍然执行其原始功能。

现在我们应该清楚地了解代码混淆是如何工作的。代码混淆工具仍然有很多变体,每种工具对代码的混淆方式都不同。

#x02 JSFuck

我们可以尝试在JSF中使用相同的工具来混淆代码,然后重新运行它。我们会注意到,代码可能需要一些时间才能运行,这表明代码混淆如何影响性能,如前所述。

明文代码:

console.log(\'Hello JavaScript Deobfuscation\');

混淆代码:

[][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]][([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]] [])[! [] ! [] ! []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] ([][[]] [])[ ! []] (![] [])[! [] ! [] ! []] (!![] [])[ []] (!![] [])[ ! []] ([][[]] [])[ []] ([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]] [])[! [] ! [] ! []] (!![] [])[ []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] (!![] [])[ ! []]]((!![] [])[ ! []] (!![] [])[! [] ! [] ! []] (!![] [])[ []] ([][[]] [])[ []] (!![] [])[ ! []] ([][[]] [])[ ! []] ( [![]] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ ! []]] (!![] [])[! [] ! [] ! []] ( (! [] ! [] ! [] [ ! []]))[(!![] [])[ []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] ([] [])[([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]] [])[! [] ! [] ! []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] ([][[]] [])[ ! []] (![] [])[! [] ! [] ! []] (!![] [])[ []] (!![] [])[ ! []] ([][[]] [])[ []] ([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]] [])[! [] ! [] ! []] (!![] [])[ []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] (!![] [])[ ! []]][([][[]] [])[ ! []] (![] [])[ ! []] (( [])[([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]] [])[! [] ! [] ! []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] ([][[]] [])[ ! []] (![] [])[! [] ! [] ! []] (!![] [])[ []] (!![] [])[ ! []] ([][[]] [])[ []] ([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]] [])[! [] ! [] ! []] (!![] [])[ []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] (!![] [])[ ! []]] [])[ ! [] [ ! []]] (!![] [])[! [] ! [] ! []]]](! [] ! [] ! [] [! [] ! []]) (![] [])[ ! []] (![] [])[! [] ! []])()([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]][([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]] [])[! [] ! [] ! []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] ([][[]] [])[ ! []] (![] [])[! [] ! [] ! []] (!![] [])[ []] (!![] [])[ ! []] ([][[]] [])[ []] ([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]] [])[! [] ! [] ! []] (!![] [])[ []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] (!![] [])[ ! []]]((!![] [])[ ! []] (!![] [])[! [] ! [] ! []] (!![] [])[ []] ([][[]] [])[ []] (!![] [])[ ! []] ([][[]] [])[ ! []] ([] [])[(![] [])[ []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] ([][[]] [])[ ! []] (!![] [])[ []] ([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]] [])[! [] ! [] ! []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] (![] [])[! [] ! []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] (!![] [])[ ! []]]()[ ! [] [! [] ! []]] ((!![] [])[ []] [ ! []] [! [] ! [] ! [] ! []] [! [] ! [] ! []] (!![] [])[ []] [ ! []] [! [] ! [] ! [] ! [] ! []] [! [] ! [] ! [] ! [] ! [] ! [] ! []] ([][[]] [])[ ! []] (![] [])[! [] ! [] ! []] (!![] [])[ []] [ ! []] [! [] ! [] ! [] ! [] ! []] [! [] ! [] ! [] ! [] ! [] ! [] ! []] (![] [])[! [] ! []] (!![] [])[! [] ! [] ! []] ( ( ! [] [ ! []] (!![] [])[! [] ! [] ! []] [! [] ! []] [ []]) [])[ ! []] (![] [])[! [] ! []] (!![] [])[ []] [ ! []] [! [] ! [] ! [] ! [] ! []] [! [] ! [] ! [] ! [] ! [] ! [] ! []] (!![] [])[ []] [ ! []] [! [] ! [] ! [] ! []] [! [] ! [] ! [] ! [] ! [] ! [] ! []] (!![] [])[ []] [! [] ! [] ! [] ! [] ! []] [ []] (!![] [])[ []] [! [] ! [] ! [] ! []] [! [] ! [] ! [] ! [] ! [] ! [] ! []] (!![] [])[ []] [ ! []] [ ! []] [ []] (!![] [])[! [] ! [] ! []] (![] [])[! [] ! []] (![] [])[! [] ! []] (!![] [])[ []] [ ! []] [! [] ! [] ! [] ! [] ! []] [! [] ! [] ! [] ! [] ! [] ! [] ! []] (!![] [])[ []] [! [] ! [] ! [] ! []] [ []] (!![] [])[ []] [ ! []] [ ! []] [! [] ! []] (![] [])[ ! []] (!![] [])[ []] [ ! []] [! [] ! [] ! [] ! [] ! [] ! []] [! [] ! [] ! [] ! [] ! [] ! []] (![] [])[ ! []] (!![] [])[ []] [ ! []] [! [] ! []] [! [] ! [] ! []] (!![] [])[ []] [ ! []] [! [] ! [] ! [] ! []] [! [] ! [] ! []] (!![] [])[ ! []] ([![]] [][[]])[ ! [] [ []]] (!![] [])[ []] [ ! []] [! [] ! [] ! [] ! [] ! [] ! []] [ []] (!![] [])[ []] [ ! []] [! [] ! [] ! [] ! [] ! [] ! []] [! [] ! [] ! [] ! []] (!![] [])[ []] [! [] ! [] ! [] ! []] [ []] (!![] [])[ []] [ ! []] [ []] [! [] ! [] ! [] ! []] (!![] [])[! [] ! [] ! []] (!![] [])[ []] [ ! []] [! [] ! [] ! [] ! [] ! []] [! [] ! [] ! [] ! [] ! [] ! [] ! []] (!![] [])[ []] [ ! []] [! [] ! [] ! [] ! []] [! [] ! []] (![] [])[ []] ([][[]] [])[ []] (![] [])[! [] ! [] ! []] (!![] [])[ []] [ ! []] [! [] ! [] ! [] ! []] [! [] ! [] ! []] (![] [])[ ! []] (!![] [])[ []] [ ! []] [! [] ! [] ! [] ! [] ! [] ! []] [! [] ! [] ! [] ! []] ([![]] [][[]])[ ! [] [ []]] (!![] [])[ []] [ ! []] [! [] ! [] ! [] ! [] ! []] [! [] ! [] ! [] ! [] ! [] ! [] ! []] ([][[]] [])[ ! []] (!![] [])[ []] [! [] ! [] ! [] ! []] [! [] ! [] ! [] ! [] ! [] ! [] ! []] (!![] [])[ []] [! [] ! [] ! [] ! [] ! []] [ ! []] (!![] [])[ []] [! [] ! [] ! [] ! [] ! [] ! [] ! []] [! [] ! [] ! []])[(![] [])[! [] ! [] ! []] ( (! [] ! [] [ ! []] [ ! []]))[(!![] [])[ []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] ([] [])[([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]] [])[! [] ! [] ! []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] ([][[]] [])[ ! []] (![] [])[! [] ! [] ! []] (!![] [])[ []] (!![] [])[ ! []] ([][[]] [])[ []] ([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]] [])[! [] ! [] ! []] (!![] [])[ []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] (!![] [])[ ! []]][([][[]] [])[ ! []] (![] [])[ ! []] (( [])[([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]] [])[! [] ! [] ! []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] ([][[]] [])[ ! []] (![] [])[! [] ! [] ! []] (!![] [])[ []] (!![] [])[ ! []] ([][[]] [])[ []] ([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]] [])[! [] ! [] ! []] (!![] [])[ []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] (!![] [])[ ! []]] [])[ ! [] [ ! []]] (!![] [])[! [] ! [] ! []]]](! [] ! [] ! [] [ ! []])[ ! []] (![] [])[! [] ! []] ([![]] [][[]])[ ! [] [ []]] (!![] [])[ []]]((!![] [])[ []])[([][(!![] [])[! [] ! [] ! []] ([][[]] [])[ ! []] (!![] [])[ []] (!![] [])[ ! []] ([![]] [][[]])[ ! [] [ []]] (!![] [])[! [] ! [] ! []] (![] [])[! [] ! [] ! []]]() [])[! [] ! [] ! []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] ([![]] [][[]])[ ! [] [ []]] ([][[]] [])[ ! []]](([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]][([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]] [])[! [] ! [] ! []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] ([][[]] [])[ ! []] (![] [])[! [] ! [] ! []] (!![] [])[ []] (!![] [])[ ! []] ([][[]] [])[ []] ([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]] [])[! [] ! [] ! []] (!![] [])[ []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] (!![] [])[ ! []]]((!![] [])[ ! []] (!![] [])[! [] ! [] ! []] (!![] [])[ []] ([][[]] [])[ []] (!![] [])[ ! []] ([][[]] [])[ ! []] (![] [ []])[([![]] [][[]])[ ! [] [ []]] (!![] [])[ []] (![] [])[ ! []] (![] [])[! [] ! []] ([![]] [][[]])[ ! [] [ []]] ([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]] [])[! [] ! [] ! []] (![] [])[! [] ! [] ! []]]()[ ! [] [ []]] ![] (![] [ []])[([![]] [][[]])[ ! [] [ []]] (!![] [])[ []] (![] [])[ ! []] (![] [])[! [] ! []] ([![]] [][[]])[ ! [] [ []]] ([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]] [])[! [] ! [] ! []] (![] [])[! [] ! [] ! []]]()[ ! [] [ []]])()[([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]] [])[! [] ! [] ! []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] ([][[]] [])[ ! []] (![] [])[! [] ! [] ! []] (!![] [])[ []] (!![] [])[ ! []] ([][[]] [])[ []] ([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]] [])[! [] ! [] ! []] (!![] [])[ []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] (!![] [])[ ! []]]((![] [ []])[([![]] [][[]])[ ! [] [ []]] (!![] [])[ []] (![] [])[ ! []] (![] [])[! [] ! []] ([![]] [][[]])[ ! [] [ []]] ([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]] [])[! [] ! [] ! []] (![] [])[! [] ! [] ! []]]()[ ! [] [ []]]) [])[ ! []]) ([] [])[(![] [])[ []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] ([][[]] [])[ ! []] (!![] [])[ []] ([][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]] [])[! [] ! [] ! []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] (![] [])[! [] ! []] (!![] [][(![] [])[ []] (![] [])[! [] ! []] (![] [])[ ! []] (!![] [])[ []]])[ ! [] [ []]] (!![] [])[ ! []]]()[ ! [] [! [] ! []]])())

#x03 JJ Encode

使用 jjencode 进行实际攻击并不是一个好主意。它轻松解码。jjencode 不是功利性的混淆,只是一个编码器。太有特色了。很容易被发现。取决于浏览器。该代码无法在某些类型的浏览器上运行。

1690200089_64be6819f1a3f31f82ca4.png!small?1690200090611

#x04 AA Encode

aaencode – 将任何 JavaScript 程序编码为日式表情符号 (^_^) 方式进行混淆,挺有意思的

明文代码:

console.log(\'Hello JavaScript Deobfuscation\');

混淆代码:

゚ω゚ノ= /`m´)ノ ~┻━┻   //*´∇`*/ [\'_\']; o=(゚ー゚)  =_=3; c=(゚Θ゚) =(゚ー゚)-(゚ー゚); (゚Д゚) =(゚Θ゚)= (o^_^o)/ (o^_^o);(゚Д゚)={゚Θ゚: \'_\' ,゚ω゚ノ : ((゚ω゚ノ==3)  \'_\') [゚Θ゚] ,゚ー゚ノ :(゚ω゚ノ  \'_\')[o^_^o -(゚Θ゚)] ,゚Д゚ノ:((゚ー゚==3)  \'_\')[゚ー゚] }; (゚Д゚) [゚Θ゚] =((゚ω゚ノ==3)  \'_\') [c^_^o];(゚Д゚) [\'c\'] = ((゚Д゚) \'_\') [ (゚ー゚) (゚ー゚)-(゚Θ゚) ];(゚Д゚) [\'o\'] = ((゚Д゚) \'_\') [゚Θ゚];(゚o゚)=(゚Д゚) [\'c\'] (゚Д゚) [\'o\'] (゚ω゚ノ  \'_\')[゚Θ゚]  ((゚ω゚ノ==3)  \'_\') [゚ー゚]   ((゚Д゚)  \'_\') [(゚ー゚) (゚ー゚)]  ((゚ー゚==3)  \'_\') [゚Θ゚] ((゚ー゚==3)  \'_\') [(゚ー゚) - (゚Θ゚)] (゚Д゚) [\'c\'] ((゚Д゚) \'_\') [(゚ー゚) (゚ー゚)]  (゚Д゚) [\'o\'] ((゚ー゚==3)  \'_\') [゚Θ゚];(゚Д゚) [\'_\'] =(o^_^o) [゚o゚] [゚o゚];(゚ε゚)=((゚ー゚==3)  \'_\') [゚Θ゚]  (゚Д゚) .゚Д゚ノ ((゚Д゚) \'_\') [(゚ー゚)   (゚ー゚)] ((゚ー゚==3)  \'_\') [o^_^o -゚Θ゚] ((゚ー゚==3)  \'_\') [゚Θ゚]  (゚ω゚ノ  \'_\') [゚Θ゚]; (゚ー゚) =(゚Θ゚); (゚Д゚)[゚ε゚]=\'\\\'; (゚Д゚).゚Θ゚ノ=(゚Д゚  ゚ー゚)[o^_^o -(゚Θ゚)];(o゚ー゚o)=(゚ω゚ノ  \'_\')[c^_^o];(゚Д゚) [゚o゚]=\'\"\';(゚Д゚) [\'_\'] ( (゚Д゚) [\'_\'] (゚ε゚ (゚Д゚)[゚o゚]  (゚Д゚)[゚ε゚] (゚Θ゚)  (゚ー゚)  (o^_^o)  (゚Д゚)[゚ε゚] (゚Θ゚)  ((゚ー゚)   (゚Θ゚))  ((゚ー゚)   (o^_^o))  (゚Д゚)[゚ε゚] (゚Θ゚)  ((゚ー゚)   (゚Θ゚))  ((o^_^o)  (o^_^o))  (゚Д゚)[゚ε゚] (゚Θ゚)  ((o^_^o)  (o^_^o))  (o^_^o)  (゚Д゚)[゚ε゚] (゚Θ゚)  ((゚ー゚)   (゚Θ゚))  ((゚ー゚)   (o^_^o))  (゚Д゚)[゚ε゚] (゚Θ゚)  ((゚ー゚)   (゚Θ゚))  (゚ー゚)  (゚Д゚)[゚ε゚] (゚Θ゚)  (゚ー゚)  ((゚ー゚)   (゚Θ゚))  (゚Д゚)[゚ε゚] ((゚ー゚)   (゚Θ゚))  ((o^_^o)  (o^_^o))  (゚Д゚)[゚ε゚] (゚Θ゚)  ((゚ー゚)   (゚Θ゚))  (゚ー゚)  (゚Д゚)[゚ε゚] (゚Θ゚)  ((゚ー゚)   (゚Θ゚))  ((゚ー゚)   (o^_^o))  (゚Д゚)[゚ε゚] (゚Θ゚)  (゚ー゚)  ((゚ー゚)   (o^_^o))  (゚Д゚)[゚ε゚] ((゚ー゚)   (゚Θ゚))  (c^_^o)  (゚Д゚)[゚ε゚] (゚ー゚)  ((゚ー゚)   (o^_^o))  (゚Д゚)[゚ε゚] (゚Θ゚)  (゚Θ゚)  (c^_^o)  (゚Д゚)[゚ε゚] (゚Θ゚)  (゚ー゚)  ((゚ー゚)   (゚Θ゚))  (゚Д゚)[゚ε゚] (゚Θ゚)  ((゚ー゚)   (゚Θ゚))  (゚ー゚)  (゚Д゚)[゚ε゚] (゚Θ゚)  ((゚ー゚)   (゚Θ゚))  (゚ー゚)  (゚Д゚)[゚ε゚] (゚Θ゚)  ((゚ー゚)   (゚Θ゚))  ((゚ー゚)   (o^_^o))  (゚Д゚)[゚ε゚] (゚ー゚)  (c^_^o)  (゚Д゚)[゚ε゚] (゚Θ゚)  (゚Θ゚)  ((o^_^o) - (゚Θ゚))  (゚Д゚)[゚ε゚] (゚Θ゚)  (゚ー゚)  (゚Θ゚)  (゚Д゚)[゚ε゚] (゚Θ゚)  ((o^_^o)  (o^_^o))  ((o^_^o)  (o^_^o))  (゚Д゚)[゚ε゚] (゚Θ゚)  (゚ー゚)  (゚Θ゚)  (゚Д゚)[゚ε゚] (゚Θ゚)  ((o^_^o) - (゚Θ゚))  (o^_^o)  (゚Д゚)[゚ε゚] (゚Θ゚)  (゚ー゚)  (o^_^o)  (゚Д゚)[゚ε゚] (゚Θ゚)  ((o^_^o)  (o^_^o))  ((o^_^o) - (゚Θ゚))  (゚Д゚)[゚ε゚] (゚Θ゚)  ((゚ー゚)   (゚Θ゚))  (゚Θ゚)  (゚Д゚)[゚ε゚] (゚Θ゚)  ((o^_^o)  (o^_^o))  (c^_^o)  (゚Д゚)[゚ε゚] (゚Θ゚)  ((o^_^o)  (o^_^o))  (゚ー゚)  (゚Д゚)[゚ε゚] (゚ー゚)  (c^_^o)  (゚Д゚)[゚ε゚] (゚Θ゚)  (c^_^o)  (゚ー゚)  (゚Д゚)[゚ε゚] (゚Θ゚)  (゚ー゚)  ((゚ー゚)   (゚Θ゚))  (゚Д゚)[゚ε゚] (゚Θ゚)  ((゚ー゚)   (゚Θ゚))  ((゚ー゚)   (o^_^o))  (゚Д゚)[゚ε゚] (゚Θ゚)  (゚ー゚)  ((o^_^o) - (゚Θ゚))  (゚Д゚)[゚ε゚] (゚Θ゚)  (゚ー゚)  ((o^_^o)  (o^_^o))  (゚Д゚)[゚ε゚] (゚Θ゚)  ((o^_^o)  (o^_^o))  ((゚ー゚)   (゚Θ゚))  (゚Д゚)[゚ε゚] (゚Θ゚)  ((o^_^o)  (o^_^o))  (o^_^o)  (゚Д゚)[゚ε゚] (゚Θ゚)  (゚ー゚)  (o^_^o)  (゚Д゚)[゚ε゚] (゚Θ゚)  (゚ー゚)  (゚Θ゚)  (゚Д゚)[゚ε゚] (゚Θ゚)  ((o^_^o)  (o^_^o))  (゚ー゚)  (゚Д゚)[゚ε゚] (゚Θ゚)  ((゚ー゚)   (゚Θ゚))  (゚Θ゚)  (゚Д゚)[゚ε゚] (゚Θ゚)  ((゚ー゚)   (゚Θ゚))  ((゚ー゚)   (o^_^o))  (゚Д゚)[゚ε゚] (゚Θ゚)  ((゚ー゚)   (゚Θ゚))  ((o^_^o)  (o^_^o))  (゚Д゚)[゚ε゚] (゚ー゚)  ((゚ー゚)   (o^_^o))  (゚Д゚)[゚ε゚] ((゚ー゚)   (゚Θ゚))  (゚Θ゚)  (゚Д゚)[゚ε゚] ((゚ー゚)   (o^_^o))  (o^_^o)  (゚Д゚)[゚o゚]) (゚Θ゚)) (\'_\');

然而,此类混淆器通常会使代码执行/编译速度非常慢,因此不建议使用它,除非有明显的原因,例如绕过网络过滤器或限制。

反混淆工具

现在我们了解了代码混淆的工作原理,让我们开始学习反混淆。正如有自动混淆代码的工具一样,也有自动美化和反混淆代码的工具。

#x01 JSNice

1690200533_64be69d5a8602b1847f67.png!small?1690200534421

我们可以找到许多优秀的在线工具来反混淆 JavaScript 代码并将其转换为我们可以理解的东西。JSNice是一个很好的工具。让我们尝试复制上面的混淆代码并通过单击Nicify JavaScript​​按钮在 JSNice 中运行它。

示例

如之前代码:

eval(function(p,a,c,k,e,d){e=function(c){return c};if(!\'\'.replace(/^/,String)){while(c--){d[c]=k[c]||c}k=[function(e){return d[e]}];e=function(){return\'\\w \'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp(\'\\b\' e(c) \'\\b\',\'g\'),k[c])}}return p}(\'0.1(\\'2 3 4\\');\',5,5,\'console|log|Hello|JavaScript|Deobfuscation\'.split(\'|\'),0,{}))

使用JSNice进行反混淆得到结果:

1690200718_64be6a8e096777e56e4ee.png!small?1690200718639

混淆注意事项

尽管到目前为止,这些工具在将代码清理成我们可以理解的内容方面做得很好,但一旦代码变得更加模糊和编码,自动化工具清理它就会变得更加困难。如果使用自定义混淆工具对代码进行混淆,则尤其如此。

我们需要手动对代码进行逆向工程,以了解它是如何被混淆的以及它在这种情况下的功能。

内容出处:,

声明:本网站所收集的部分公开资料来源于互联网,转载的目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。如果您发现网站上有侵犯您的知识产权的作品,请与我们取得联系,我们会及时修改或删除。文章链接:http://www.yixao.com/procedure/30892.html

发表评论

登录后才能评论