javascript另类混淆加密
源代码:<textarea id="ta" style="width:100%;height:300px">alert('大家好,我是showbo!双字节测试')</textarea> <input type="button" value="加密" onclick=" taEncrypt.value = encrypSource(ta.value);" /> <input type="button" value="执行加密代码" onclick="eval(taEncrypt.value)" /><br /> 加密后代码:<textarea id="taEncrypt" style="width:100%;height:300px"> </textarea> <script> var kv = { "0": "___", "1": "__$", "2": "_$_", "3": "_$$", "4": "$__", "5": "$_$", "6": "$$_", "7": "$$$", "8": "$___", "9": "$__$", "f": "$$$$", "a": "$_$_", "b": "$_$$", "d": "$$_$", "e": "$$$_", "c": "$$__", "o": "_$", "t": "__", "u": "_" }; function getOctalStr(c) { var s = '+"\\\\"'; var sOctal = c.charCodeAt(0).toString(8); for (var i = 0; i < sOctal.length; i++) s += '+$.' + kv[sOctal.charAt(i)]; return s; } function padding(s, l, c) { if (s.length < l) for (var i = l - s.length; i > 0; i--) s = c + s; return s;} function encrypSource(s) { //////处理大于255 ASCII字符为16进制编码 s = s.replace(/[\u0100-\uFFFF]+/g, function (s) { var r = ''; for (var i = 0; i < s.length; i++) r += '\\u' + padding(s.charCodeAt(i).toString(16), 4, 0); return r; }); //////// var r = ''; //将s转为8进制表示 for (var i = 0, l = s.length; i < l; i++) { var c = s.charAt(i); if (kv[c]) {//不需要转8进制的字符 r += '+$.' + kv[c]; } else {//字符转8进制 r += getOctalStr(c); } } //加上原文网站解码程序 return '$=~[];$={___:++$,$$$$:(![]+"")[$],__$:++$,$_$_:(![]+"")[$],_$_:++$,$_$$:({}+"")[$],$$_$:($[$]+"")[$],_$$:++$,$$$_:(!""+"")[$],$__:++$,$_$:++$,$$__:({}+"")[$],$$_:++$,$$$:++$,$___:++$,$__$:++$};$.$_=($.$_=$+"")' + '[$.$_$]+($._$=$.$_[$.__$])+($.$$=($.$+"")[$.__$])+((!$)+"")[$._$$]+($.__=$.$_[$.$$_])+($.$=(!""+"")[$.__$])+($._=(!""+"")[$._$_])+$.$_[$.$_$]+$.__' + '+$._$+$.$;$.$$=$.$+(!""+"")[$._$$]+$.__+$._+$.$+$.$$;$.$=($.___)[$.$_][$.$_];$.$($.$(' + '$.$$+"\\""' + r + '+"\\""'//这串是加密后的 + ')())();' ; } </script>
原创文章,转载请注明出处:
2017-8-12Web开发网