JavaScript 代码混淆实战(六):仿obfuscator混淆控制流平坦化
【摘要】
混淆前:
window = {};window.atob = function(r) { e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; var o = String(r).replace(/=+$/, ""); if(o.length % 4 == 1) throw n...
混淆前:
-
window = {};
-
window.atob = function(r) {
-
e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
-
var o = String(r).replace(/=+$/, "");
-
if(o.length % 4 == 1) throw new t("'atob' failed: The string to be decoded is not correctly encoded.");
-
for(var n, a, i = 0, c = 0, d = ""; a = o.charAt(c++); ~a && (n = i % 4 ? 64 * n + a : a, i++ % 4) ? d += String.fromCharCode(255 & n >> (-2 * i & 6)) : 0) a = e.indexOf(a);
-
return d
-
}
-
window.btoa = function(r) {
-
e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
-
for(var o, n, a = String(r), i = 0, c = e, d = ""; a.charAt(0 | i) || (c = "=", i % 1); d += c.charAt(63 & o >> 8 - i % 1 * 8)) {
-
if(n = a.charCodeAt(i += .75), n > 255) throw new t("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");
-
o = o << 8 | n
-
}
-
return d
-
}
混淆后:
-
window = {};
-
-
-
window.atob = function (_0xc0750g) {
-
var _0xfbb16d = "4|1|2|3|0"["split"]("|"),
-
_0xec2868 = 0;
-
-
-
while (!![]) {
-
switch (_0xfbb16d[_0xec2868++]) {
-
case "0":
-
return _0xec4345;
-
continue;
-
-
-
case "1":
-
var _0x1adc16 = String(_0xc0750g).replace(/=+$/, "");
-
-
-
continue;
-
-
-
case "2":
-
if (_0x1adc16.length % 4 == 1) throw new t("'atob' failed: The string to be decoded is not correctly encoded.");
-
continue;
-
-
-
case "3":
-
for (var _0xb342a5, _0x7ecb47, _0xc54a87 = 0, _0xa14d1g = 0, _0xec4345 = ""; _0x7ecb47 = _0x1adc16.charAt(_0xa14d1g++); ~_0x7ecb47 && (_0xb342a5 = _0xc54a87 % 4 ? 64 * _0xb342a5 + _0x7ecb47 : _0x7ecb47, _0xc54a87++ % 4) ? _0xec4345 += String.fromCharCode(255 & _0xb342a5 >> (-2 * _0xc54a87 & 6)) : 0) _0x7ecb47 = e.indexOf(_0x7ecb47);
-
-
-
continue;
-
-
-
case "4":
-
e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
-
continue;
-
}
-
-
-
break;
-
}
-
};
-
-
-
window.btoa = function (_0xdc05f0) {
-
var _0x39674c = "2|1|0"["split"]("|"),
-
_0x902bcb = 0;
-
-
-
while (!![]) {
-
switch (_0x39674c[_0x902bcb++]) {
-
case "0":
-
return _0xde212b;
-
continue;
-
-
-
case "1":
-
for (var _0xed1fcd, _0x33g15b, _0x5153cd = String(_0xdc05f0), _0xeea791 = 0, _0xc94d67 = e, _0xde212b = ""; _0x5153cd.charAt(0 | _0xeea791) || (_0xc94d67 = "=", _0xeea791 % 1); _0xde212b += _0xc94d67.charAt(63 & _0xed1fcd >> 8 - _0xeea791 % 1 * 8)) {
-
var _0xcgcd3c = "0|1"["split"]("|"),
-
_0x3922ce = 0;
-
-
-
while (!![]) {
-
switch (_0xcgcd3c[_0x3922ce++]) {
-
case "0":
-
if (_0x33g15b = _0x5153cd.charCodeAt(_0xeea791 += .75), _0x33g15b > 255) throw new t("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");
-
continue;
-
-
-
case "1":
-
_0xed1fcd = _0xed1fcd << 8 | _0x33g15b;
-
continue;
-
}
-
-
-
break;
-
}
-
}
-
-
-
continue;
-
-
-
case "2":
-
e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
-
continue;
-
}
-
-
-
break;
-
}
-
};
混淆后的代码,就是我们常见的obfuscator混淆代码。
源代码见github地址:
https://github.com/Tsaiboss/ControlFlow
文章来源: blog.csdn.net,作者:悦来客栈的老板,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/qq523176585/article/details/112914846
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)