前言
今天要说的扁平化和普通的不太一样,今天看到一个比较有意思的js加密代码,我一开始分析了很多遍没发现问题,最后才发现和普通的扁平化有什么不同。
源代码(一小部分做示例)
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="js" cid="n5" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">function _0x1bcb87(_0x2ab100, _0x467715) {
var _0x456db6 = {
'jentQ': function (_0x829220, _0x5590eb) {
return _0x829220 + _0x5590eb;
}, 'EBoOQ': function (_0x25c12c, _0x1d2a2f) {
return _0x25c12c * _0x1d2a2f;
}, 'ZOjgN': function (_0x37f007, _0x4ec00f) {
return _0x37f007 - _0x4ec00f;
}
};
return _0x456db6['jentQ'](Math['floor'](_0x456db6['EBoOQ'](Math'random', _0x456db6['ZOjgN'](_0x467715, _0x2ab100))), _0x2ab100);
}</pre>
解密后
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="js" cid="n7" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">function getRand(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}</pre>
过程分析
这种将简单代码扁平化的加密方法,属于比较高级的加密方法,利用多重表达式将一句原本简单的js复杂化,利用一个json或者数组将函数组合起来。
人工分析还原这类扁平化的代码特别麻烦,不信的可以自己试试。
而将普通的js加密成这样形式的代码更是麻烦,不过目前已经有成熟可用的工具站做到了这一点,并且这只是其中的一个小功能。
我们直接将js源代码复制到www.jsjiami.com直接点击JS混淆加密就可以了。一键加密。
2.png
网友评论