JavaScript 代码混淆实战(六):仿obfuscator混淆控制流平坦化

举报
悦来客栈的老板 发表于 2021/01/21 22:46:43 2021/01/21
【摘要】 混淆前: window = {};window.atob = function(r) { e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; var o = String(r).replace(/=+$/, ""); if(o.length % 4 == 1) throw n...

混淆前:


   
  1. window = {};
  2. window.atob = function(r) {
  3. e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  4. var o = String(r).replace(/=+$/, "");
  5. if(o.length % 4 == 1) throw new t("'atob' failed: The string to be decoded is not correctly encoded.");
  6. 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);
  7. return d
  8. }
  9. window.btoa = function(r) {
  10. e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  11. 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)) {
  12. 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.");
  13. o = o << 8 | n
  14. }
  15. return d
  16. }

混淆后:


   
  1. window = {};
  2. window.atob = function (_0xc0750g) {
  3. var _0xfbb16d = "4|1|2|3|0"["split"]("|"),
  4. _0xec2868 = 0;
  5. while (!![]) {
  6. switch (_0xfbb16d[_0xec2868++]) {
  7. case "0":
  8. return _0xec4345;
  9. continue;
  10. case "1":
  11. var _0x1adc16 = String(_0xc0750g).replace(/=+$/, "");
  12. continue;
  13. case "2":
  14. if (_0x1adc16.length % 4 == 1) throw new t("'atob' failed: The string to be decoded is not correctly encoded.");
  15. continue;
  16. case "3":
  17. 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);
  18. continue;
  19. case "4":
  20. e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  21. continue;
  22. }
  23. break;
  24. }
  25. };
  26. window.btoa = function (_0xdc05f0) {
  27. var _0x39674c = "2|1|0"["split"]("|"),
  28. _0x902bcb = 0;
  29. while (!![]) {
  30. switch (_0x39674c[_0x902bcb++]) {
  31. case "0":
  32. return _0xde212b;
  33. continue;
  34. case "1":
  35. 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)) {
  36. var _0xcgcd3c = "0|1"["split"]("|"),
  37. _0x3922ce = 0;
  38. while (!![]) {
  39. switch (_0xcgcd3c[_0x3922ce++]) {
  40. case "0":
  41. 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.");
  42. continue;
  43. case "1":
  44. _0xed1fcd = _0xed1fcd << 8 | _0x33g15b;
  45. continue;
  46. }
  47. break;
  48. }
  49. }
  50. continue;
  51. case "2":
  52. e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  53. continue;
  54. }
  55. break;
  56. }
  57. };

混淆后的代码,就是我们常见的obfuscator混淆代码。

源代码见github地址:

https://github.com/Tsaiboss/ControlFlow

  

文章来源: blog.csdn.net,作者:悦来客栈的老板,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/qq523176585/article/details/112914846

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。