JS代码混淆了,怎么反混淆回去?

JavaScript08

JS代码混淆了,怎么反混淆回去?,第1张

这不是混淆,只是使用16进制表示的ASCII码~

单独提取出字符串,在后面加上.toString()进行调试即可看到原本字符串。

你的这句转码后如下:

window["document"]["write"]('<sc')

相当于:window.document.write('<sc')

很有可能是输出一个script标签的代码段的开始。

1:利用IE开发人员工具(IE8开始已经自带,IE7以前需要下载安装IE Developer Toolbar)进行反混淆,

2:代码实现

混淆后的测试代码

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-6")2 4(){1("0-5")}8 3=2(){1("0-7")}4()3()',9,9,'忧郁的匹格|alert|function|b|a|反混淆测试2|反混淆测试1|反混淆测试3|var'.split('|'),0,{}))

开始实施:

1.新建一个网页xxx.html

2.加入一个div容器 id="divTest"

3.最关键的一步--赋值执行:(在上面混淆的代码中,将eval()中的内容提取出来赋值(或直接打印)给document.getElementById('divTest').innerText )

document.getElementById('divTest').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-6")2 4(){1("0-5")}8 3=2(){1("0-7")}4()3()',9,9,'忧郁的匹格|alert|function|b|a|反混淆测试2|反混淆测试1|反混淆测试3|var'.split('|'),0,{})

打开xxx.html 显示结果:(反混淆后的代码已经被压缩了,去掉了换行等字符)

alert("忧郁的匹格-反混淆测试1")

function a(){alert("忧郁的匹格-反混淆测试2")}

var b=function(){alert("忧郁的匹格-反混淆测试3")}

a()

b()

PS:使用packed这个混淆过的js都可以使用这个方法还原,找了几个项目里面混淆过的js都可以还原,只是去掉了换行符,