• JavaScript解密日记6


    引言:

    • 在从事JAVA工作的第五个年头,突然开始对js加密js解密感兴趣。开始了探索的路程

    1. JavaScript基础知识:

    • JavaScript是一种用于Web开发的脚本语言,它包括以下基础概念:
      1. 变量(Variables):用于存储数据的容器,可使用 varletconst 关键字声明。
      2. 数据类型(Data Types):包括数字、字符串、布尔值等基本数据类型,以及对象、数组等引用数据类型。
      3. 运算符(Operators):用于执行各种操作,如加法、比较、逻辑运算。
      4. 条件语句(Conditional Statements):用于根据条件执行不同的代码块,如 ifelse
      5. 循环(Loops):用于多次执行相同的代码块,如 forwhile 循环。

    2. 加密和解密的概念:

    • 加密是将数据转化为不可读的形式,以保护其安全性,但又确保正常运行,而解密是恢复加密数据的过程,将其还原为可读的形式。

    3. JavaScript中的加密:

    • JavaScript中常见的加密算法包括:

      1. AES(Advanced Encryption Standard)
        • AES是一种对称加密算法,用于加密和解密数据。
        • 它支持不同的密钥长度(128位、192位和256位),提供了强大的数据保护。
        • 在JavaScript中,可以使用现成的库如CryptoJS来实现AES加密和解密操作。
      2. DES(Data Encryption Standard)
        • DES是一种早期的对称加密算法,已经不再被广泛使用,因为其56位密钥长度相对较短,容易受到暴力破解攻击。
        • 在JavaScript中,你可以找到一些实现DES加密和解密的库,但不推荐在安全应用中使用它。
      3. RSA(Rivest–Shamir–Adleman)
        • RSA是一种非对称加密算法,用于加密和解密数据以及数字签名。
        • 它使用公钥和私钥,其中公钥用于加密,私钥用于解密。
        • JavaScript中通常用于加密数据的传输,如HTTPS通信中的密钥交换。
      4. SHA(Secure Hash Algorithm)
        • SHA系列算法用于生成数据的哈希值,而不是加密和解密数据。
        • 常见的SHA算法包括SHA-1、SHA-256、SHA-3等,用于数据完整性校验和密码散列存储。
      5. HMAC(Hash-based Message Authentication Code)
        • HMAC是一种用于验证消息完整性和身份的哈希消息认证码。
        • 它通常与其他加密算法一起使用,确保数据在传输过程中没有被篡改。

      这些加密算法在JavaScript中有不同的实现方式,可以根据具体需求选择合适的算法来保护数据的安全性。在实际应用中,要注意选择足够强大且适合特定用途的加密算法,以确保数据的安全性。

    今日案例

    var _0x2608=['WmVHdUM=','RnJVdG8=','VFBGYWE=','XihbXiBdKyggK1teIF0rKSspK1teIF19','Mnw5fDN8N3w4fDV8MXw2fDR8MA==','dWVuRW8=','clhHc20=','eEJkQkg=','ZXhjZXB0aW9u','TURKZ0I=','Z1lUU1g=','VXRmOA==','ZW5jcnlwdA==','ZGVidWc=','UXhjelk=','WFhzVkc=','YXBwbHk=','bW9kZQ==','dHJhY2U=','bG9n','ZGVjcnlwdA==','T1ZQRGQ=','e30uY29uc3RydWN0b3IoInJldHVybiB0aGlzIikoICk=','aXl1cWk=','VVhDdmE=','d3NwVmU=','dGVzdA==','d2Fybg==','dG9TdHJpbmc=','dGibGU=','c3BsaXQ=','TGJTY0k=','Y29uc29sZQ==','ZFNjdEE=','aUxEU1g=','ZXJyb3I=','VXNwVWo=','cGFyc2U=','cmV0dXJuIChmdW5jdGlvbigpIA==','WGN4T2c=','dndycFM=','T3JjRUE=','ZkFFWnM=','cmV0dXJuC8iICsgdGhpcyArICIv','UGtjczc=','UmtnVEI=','aW5mbw==','bUR0em0=','ZW5j','c3B0bmk=','Q0JD','cVF4Umg=','MHw1fDJ8NnwxfDN8N3w0','UXdpYXY=','Y29tcGlsZQ==','cGFk','QUVT'];(function(_0x49a2af,_0x260822){var _0x4c7674=function(_0x3ab62c){while(--_0x3ab62c){_0x49a2af['push'](_0x49a2af['shift']());}};var _0x2863df=function(){var _0x35228c={'data':{'key':'cookie','value':'timeout'},'setCookie':function(_0x1e7170,_0x2e20a1,_0x1463d8,_0x4fc1a4){_0x4fc1a4=_0x4fc1a4||{};var _0x396e7d=_0x2e20a1+'='+_0x1463d8;var _0x3781be=0x0;for(var _0x42e8ef=0x0,_0x4edf23=_0x1e7170['length'];_0x42e8ef<_0x4edf23;_0x42e8ef++){var _0x4beebe=_0x1e7170[_0x42e8ef];_0x396e7d+=';\x20'+_0x4beebe;var _0x23c51d=_0x1e7170[_0x4beebe];_0x1e7170['push'](_0x23c51d);_0x4edf23=_0x1e7170['length'];if(_0x23c51d!==!![]){_0x396e7d+='='+_0x23c51d;}}_0x4fc1a4['cookie']=_0x396e7d;},'removeCookie':function(){return'dev';},'getCookie':function(_0x913dd,_0x49cbd3){_0x913dd=_0x913dd||function(_0xcc8b68){return _0xcc8b68;};var _0x13684f=_0x913dd(new RegExp('(?:^|;\x20)'+_0x49cbd3['replace'](/([.$?*|{}()[]\/+^])/g,'$1')+'=([^;]*)'));var _0x25ee6d=function(_0x21d01b,_0x38ba57){_0x21d01b(++_0x38ba57);};_0x25ee6d(_0x4c7674,_0x260822);return _0x13684f?decodeURIComponent(_0x13684f[0x1]):undefined;}};var _0x446aee=function(){var _0x458bf2=new RegExp('\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*[\x27|\x22].+[\x27|\x22];?\x20*}');return _0x458bf2['test'](_0x35228c['removeCookie']['toString']());};_0x35228c['updateCookie']=_0x446aee;var _0x160af2='';var _0x60dd22=_0x35228c['updateCookie']();if(!_0x60dd22){_0x35228c['setCookie'](['*'],'counter',0x1);}else if(_0x60dd22){_0x160af2=_0x35228c['getCookie'](null,'counter');}else{_0x35228c['removeCookie']();}};_0x2863df();}(_0x2608,0x199));var _0x4c76=function(_0x49a2af,_0x260822){_0x49a2af=_0x49a2af-0x0;var _0x4c7674=_0x2608[_0x49a2af];if(_0x4c76['IQAcip']===undefined){(function(){var _0x3ab62c=function(){var _0x160af2;try{_0x160af2=Function('return\x20(function()\x20'+'{}.constructor(\x22return\x20this\x22)(\x20)'+');')();}catch(_0x60dd22){_0x160af2=window;}return _0x160af2;};var _0x35228c=_0x3ab62c();var _0x446aee='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';_0x35228c['atob']||(_0x35228c['atob']=function(_0x1e7170){var _0x2e20a1=String(_0x1e7170)['replace'](/=+$/,'');var _0x1463d8='';for(var _0x4fc1a4=0x0,_0x396e7d,_0x3781be,_0x42e8ef=0x0;_0x3781be=_0x2e20a1['charAt'](_0x42e8ef++);~_0x3781be&&(_0x396e7d=_0x4fc1a4%0x4?_0x396e7d*0x40+_0x3781be:_0x3781be,_0x4fc1a4++%0x4)?_0x1463d8+=String['fromCharCode'](0xff&_0x396e7d>>(-0x2*_0x4fc1a4&0x6)):0x0){_0x3781be=_0x446aee['indexOf'](_0x3781be);}return _0x1463d8;});}());_0x4c76['CRIONQ']=function(_0x4edf23){var _0x4beebe=atob(_0x4edf23);var _0x23c51d=[];for(var _0x913dd=0x0,_0x49cbd3=_0x4beebe['length'];_0x913dd<_0x49cbd3;_0x913dd++){_0x23c51d+='%'+('00'+_0x4beebe['charCodeAt'](_0x913dd)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x23c51d);};_0x4c76['UjemjR']={};_0x4c76['IQAcip']=!![];}var _0x2863df=_0x4c76['UjemjR'][_0x49a2af];if(_0x2863df===undefined){var _0x13684f=function(_0x25ee6d){this['lHjNkC']=_0x25ee6d;this['UcZDmY']=[0x1,0x0,0x0];this['HmphmA']=function(){return'newState';};this['drDcpe']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*';this['TCqeqI']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x13684f['prototype']['vDegzs']=function(){var _0xcc8b68=new RegExp(this['drDcpe']+this['TCqeqI']);var _0x21d01b=_0xcc8b68['test'](this['HmphmA']['toString']())?--this['UcZDmY'][0x1]:--this['UcZDmY'][0x0];return this['JdJHuI'](_0x21d01b);};_0x13684f['prototype']['JdJHuI']=function(_0x38ba57){if(!Boolean(~_0x38ba57)){return _0x38ba57;}return this['LbwrMN'](this['lHjNkC']);};_0x13684f['prototype']['LbwrMN']=function(_0x458bf2){for(var _0x220992=0x0,_0x77b828=this['UcZDmY']['length'];_0x220992<_0x77b828;_0x220992++){this['UcZDmY']['push'](Math['round'](Math['random']()));_0x77b828=this['UcZDmY']['length'];}return _0x458bf2(this['UcZDmY'][0x0]);};new _0x13684f(_0x4c76)['vDegzs']();_0x4c7674=_0x4c76['CRIONQ'](_0x4c7674);_0x4c76['UjemjR'][_0x49a2af]=_0x4c7674;}else{_0x4c7674=_0x2863df;}return _0x4c7674;};var _0x1e7170=function(){var _0x199a29={};_0x199a29[_0x4c76('0x0')]='cjwYs';var _0x137e13=_0x199a29;var _0x2e793c=!![];return function(_0xeb3a2c,_0x7de0cf){var _0x18a854=_0x2e793c?function(){if(_0x137e13[_0x4c76('0x0')]!==_0x137e13[_0x4c76('0x0')]){var _0x21c883=_0x2b4cc7[_0x4c76('0x26')][_0x4c76('0x1')][_0x4c76('0x1b')](KEY);var _0x87cd33=_0x2b4cc7['enc']['Utf8'][_0x4c76('0x1b')](IV);var _0x1b0d18=_0x2b4cc7[_0x4c76('0x2e')][_0x4c76('0x2')](str,_0x21c883,{'iv':_0x87cd33,'mode':_0x2b4cc7[_0x4c76('0x7')][_0x4c76('0x28')],'padding':_0x2b4cc7[_0x4c76('0x2d')]['Pkcs7']});return _0x1b0d18[_0x4c76('0x12')]();}else{if(_0x7de0cf){var _0xa943c2=_0x7de0cf['apply'](_0xeb3a2c,arguments);_0x7de0cf=null;return _0xa943c2;}}}:function(){};_0x2e793c=![];return _0x18a854;};}();var _0x60dd22=_0x1e7170(this,function(){var _0x2f156e={};_0x2f156e[_0x4c76('0x2b')]=function(_0x19fc1c,_0x3d7aeb){return _0x19fc1c!==_0x3d7aeb;};_0x2f156e[_0x4c76('0xb')]=_0x4c76('0xd');_0x2f156e[_0x4c76('0x36')]=_0x4c76('0x1d');_0x2f156e[_0x4c76('0x1e')]=_0x4c76('0x21');_0x2f156e[_0x4c76('0x20')]=_0x4c76('0x32');_0x2f156e[_0x4c76('0x5')]=function(_0xb81ede){return _0xb81ede();};var _0x2ddfa2=_0x2f156e;var _0x291aeb=function(){if(_0x2ddfa2[_0x4c76('0x2b')](_0x2ddfa2[_0x4c76('0xb')],_0x2ddfa2[_0x4c76('0x36')])){var _0x81db53=_0x291aeb['constructor'](_0x2ddfa2[_0x4c76('0x1e')])()[_0x4c76('0x2c')](_0x2ddfa2[_0x4c76('0x20')]);return!_0x81db53[_0x4c76('0x10')](_0x60dd22);}else{if(fn){var _0x502a2b=fn[_0x4c76('0x6')](context,arguments);fn=null;return _0x502a2b;}}};return _0x2ddfa2['XXsVG'](_0x291aeb);});_0x60dd22();var _0x35228c=function(){var _0x1fd0c8=!![];return function(_0x2f3aeb,_0xb404b0){var _0x18badc=_0x1fd0c8?function(){if(_0xb404b0){var _0x180e37=_0xb404b0['apply'](_0x2f3aeb,arguments);_0xb404b0=null;return _0x180e37;}}:function(){};_0x1fd0c8=![];return _0x18badc;};}();var _0x3ab62c=_0x35228c(this,function(){var _0x2f7c85={};_0x2f7c85[_0x4c76('0x38')]=function(_0x23ede5,_0x22cbaf){return _0x23ede5+_0x22cbaf;};_0x2f7c85['OrcEA']=function(_0x4f011b,_0x2fee37){return _0x4f011b+_0x2fee37;};_0x2f7c85[_0x4c76('0x34')]=_0x4c76('0x1c');_0x2f7c85[_0x4c76('0x31')]=_0x4c76('0xc');_0x2f7c85[_0x4c76('0x4')]=function(_0x5d5fd7,_0x3451ae){return _0x5d5fd7===_0x3451ae;};_0x2f7c85[_0x4c76('0x2f')]=_0x4c76('0x29');_0x2f7c85[_0x4c76('0x17')]=_0x4c76('0xe');_0x2f7c85[_0x4c76('0x27')]=function(_0x5260a7,_0x574b32){return _0x5260a7+_0x574b32;};_0x2f7c85[_0x4c76('0x15')]='FvtDQ';_0x2f7c85[_0x4c76('0x1a')]=_0x4c76('0x33');_0x2f7c85['LSrZK']=function(_0x3af7bc,_0x2a5e26){return _0x3af7bc(_0x2a5e26);};_0x2f7c85['wspVe']=function(_0x31938e,_0x411898){return _0x31938e+_0x411898;};_0x2f7c85[_0x4c76('0x25')]=function(_0x4bdfb7,_0xbf07c1){return _0x4bdfb7===_0xbf07c1;};_0x2f7c85[_0x4c76('0x30')]=_0x4c76('0x18');_0x2f7c85[_0x4c76('0x23')]=_0x4c76('0x2a');var _0x56ebb6=_0x2f7c85;var _0x22b3e4=function(){};var _0x4ce9e4=function(){var _0x4db57d={};_0x4db57d[_0x4c76('0x35')]='1|4|2|0|5|7|9|3|8|6';var _0x11dc2f=_0x4db57d;var _0x111340;try{if(_0x56ebb6[_0x4c76('0x4')](_0x56ebb6['ZeGuC'],_0x56ebb6[_0x4c76('0x17')])){_0x4f57b2[_0x4c76('0x16')]=function(_0x265feb){var _0x429d3a=_0x11dc2f[_0x4c76('0x35')][_0x4c76('0x14')]('|');var _0x51c561=0x0;while(!![]){switch(_0x429d3a[_0x51c561++]){case'0':_0x1c8f05[_0x4c76('0x3')]=_0x265feb;continue;case'1':var _0x1c8f05={};continue;case'2':_0x1c8f05[_0x4c76('0x11')]=_0x265feb;continue;case'3':_0x1c8f05['table']=_0x265feb;continue;case'4':_0x1c8f05[_0x4c76('0x9')]=_0x265feb;continue;case'5':_0x1c8f05[_0x4c76('0x24')]=_0x265feb;continue;case'6':return _0x1c8f05;case'7':_0x1c8f05[_0x4c76('0x19')]=_0x265feb;continue;case'8':_0x1c8f05[_0x4c76('0x8')]=_0x265feb;continue;case'9':_0x1c8f05['exception']=_0x265feb;continue;}break;}}(_0x22b3e4);}else{_0x111340=Function(_0x56ebb6[_0x4c76('0x1f')](_0x56ebb6[_0x4c76('0x27')](_0x4c76('0x1c'),_0x4c76('0xc')),');'))();}}catch(_0x21731c){if(_0x56ebb6[_0x4c76('0x4')](_0x56ebb6[_0x4c76('0x15')],'zIgQx')){_0x111340=Function(_0x56ebb6['MDJgB'](_0x56ebb6[_0x4c76('0x1f')](_0x56ebb6[_0x4c76('0x34')],_0x56ebb6[_0x4c76('0x31')]),');'))();}else{_0x111340=window;}}return _0x111340;};var _0x4f57b2=_0x4ce9e4();if(!_0x4f57b2['console']){_0x4f57b2[_0x4c76('0x16')]=function(_0x5e684b){var _0x3dedbc=_0x56ebb6[_0x4c76('0x1a')]['split']('|');var _0x475e2e=0x0;while(!![]){switch(_0x3dedbc[_0x475e2e++]){case'0':return _0x332d92;case'1':_0x332d92[_0x4c76('0x37')]=_0x5e684b;continue;case'2':var _0x332d92={};continue;case'3':_0x332d92[_0x4c76('0x11')]=_0x5e684b;continue;case'4':_0x332d92[_0x4c76('0x8')]=_0x5e684b;continue;case'5':_0x332d92[_0x4c76('0x19')]=_0x5e684b;continue;case'6':_0x332d92[_0x4c76('0x13')]=_0x5e684b;continue;case'7':_0x332d92[_0x4c76('0x3')]=_0x5e684b;continue;case'8':_0x332d92[_0x4c76('0x24')]=_0x5e684b;continue;case'9':_0x332d92[_0x4c76('0x9')]=_0x5e684b;continue;}break;}}(_0x22b3e4);}else{if(_0x56ebb6[_0x4c76('0x25')]('FzuYF',_0x56ebb6[_0x4c76('0x30')])){var _0x54c1d7;try{_0x54c1d7=_0x56ebb6['LSrZK'](Function,_0x56ebb6[_0x4c76('0xf')](_0x56ebb6[_0x4c76('0x34')],_0x56ebb6[_0x4c76('0x31')])+');')();}catch(_0x5cf77b){_0x54c1d7=window;}return _0x54c1d7;}else{var _0x469395=_0x56ebb6[_0x4c76('0x23')][_0x4c76('0x14')]('|');var _0x736793=0x0;while(!![]){switch(_0x469395[_0x736793++]){case'0':_0x4f57b2['console'][_0x4c76('0x9')]=_0x22b3e4;continue;case'1':_0x4f57b2[_0x4c76('0x16')][_0x4c76('0x19')]=_0x22b3e4;continue;case'2':_0x4f57b2['console']['debug']=_0x22b3e4;continue;case'3':_0x4f57b2[_0x4c76('0x16')]['exception']=_0x22b3e4;continue;case'4':_0x4f57b2[_0x4c76('0x16')][_0x4c76('0x8')]=_0x22b3e4;continue;case'5':_0x4f57b2[_0x4c76('0x16')][_0x4c76('0x11')]=_0x22b3e4;continue;case'6':_0x4f57b2[_0x4c76('0x16')][_0x4c76('0x24')]=_0x22b3e4;continue;case'7':_0x4f57b2[_0x4c76('0x16')][_0x4c76('0x13')]=_0x22b3e4;continue;}break;}}}});_0x3ab62c();import _0x2b4cc7 from'crypto-js';var IV='9f394231c4b86fc1';var KEY='9abf153f59a11888';export function encrypt(_0x22ae87){var _0x2bda77=_0x2b4cc7['enc'][_0x4c76('0x1')][_0x4c76('0x1b')](KEY);var _0x2837cb=_0x2b4cc7[_0x4c76('0x26')]['Utf8']['parse'](IV);var _0x318c73=_0x2b4cc7[_0x4c76('0x2e')][_0x4c76('0x2')](_0x22ae87,_0x2bda77,{'iv':_0x2837cb,'mode':_0x2b4cc7['mode']['CBC'],'padding':_0x2b4cc7[_0x4c76('0x2d')][_0x4c76('0x22')]});return _0x318c73[_0x4c76('0x12')]();}export function decrypt(_0x1c3924){var _0xc2e894=_0x2b4cc7[_0x4c76('0x26')]['Utf8']['parse'](KEY);var _0x29983f=_0x2b4cc7['enc'][_0x4c76('0x1')][_0x4c76('0x1b')](IV);var _0x3ab1b7=_0x2b4cc7[_0x4c76('0x2e')][_0x4c76('0xa')](_0x1c3924,_0xc2e894,{'iv':_0x29983f,'padding':_0x2b4cc7[_0x4c76('0x2d')][_0x4c76('0x22')]});return _0x3ab1b7[_0x4c76('0x12')](_0x2b4cc7[_0x4c76('0x26')]['Utf8']);}
    
    • 1

    先用JS在线解密工具尝试

    代码丢进去,然后直接点解密。发现不行,接下来尝试人工解密。

    JS解密后

    import crypto from 'crypto-js';
    var IV = '123';
    var KEY = '1231231';
    export function encrypt(algorithm) {
      var key = crypto.enc.Utf8.parse(KEY);
    
      var iv = crypto.enc.Utf8.parse(IV);
    
      var res = crypto.AES.encrypt(algorithm, key, {
        'iv': iv,
        'mode': crypto.mode.CBC,
        'padding': crypto.pad.Pkcs7
      });
    
      return res.toString();
    }
    export function decrypt(algorithm) {
      var key = crypto.enc.Utf8.parse(KEY);
    
      var iv = crypto.enc.Utf8.parse(IV);
    
      var res = crypto.AES.decrypt(algorithm, key, {
        'iv': iv,
        'padding': crypto.pad.Pkcs7
      });
    
      return res.toString(crypto.enc.Utf8);
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28

    完成撒花。

  • 相关阅读:
    centos7下centos-home磁盘空间转移到centos-root下
    常用Linux命令
    喜报|Authing 入选 CNCF Landscape 云原生技术图谱
    【LeetCode】多数元素 II [M](摩尔投票)
    如何用VisualStudio编写一个利用滑块绘制扇形的小程序 既可以正向绘制也可以反向绘制
    ubuntu编译打包的时候不想要linux-image-unsigned-xxxx.deb
    vscode+ESP-IDF:编译网友移植好的LVGL工程(ESP32+ili9341笔记)
    电脑重装系统后wifi间歇性断网该怎么解决
    SparkMlib 之逻辑回归及其案例
    3D,那些你需要知道的硬件知识(2)
  • 原文地址:https://blog.csdn.net/mxd01848/article/details/133499162