时间 : 14-05-06 评论 : 0 点击 : 1,049 次
js还原混淆代码方法
被混淆的代码示例:
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1;};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p;}('1 0(){3("2")}',4,4,'a|function|这是被混淆的代码|alert'.split('|'),0,{}))
1、新建一个网页test.html
2、内容如下,把eval函数里面的内容赋值给div的innerText
<html>
<head>
<meta charset='utf-8'/>
</head>
<body>
<div id='test'></div>
<script type='text/javascript'>
document.getElementById('test').innerText = function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1;};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p;}('1 0(){3("2")}',4,4,'a|function|这是被混淆的代码|alert'.split('|'),0,{});
</script>
</body>
</html>
3、打开这个页面,你会看到页面上显示出来的内容是已经解密的js代码
javascript本文标签: js加密