使用VBA进行JS加密的反混淆,还原JS代码。

时间:2023-02-06 05:57:28

本文地址:http://www.cnblogs.com/Charltsing/p/JSEval.html

联系QQ:564955427

类似下面的代码是登陆 全国企业信用信息公示系统(安徽)(网址:http://www.ahcredit.gov.cn/search.jspx)时得到的,需要反混淆。

eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>32?String.fromCharCode(c+32):c.toString(33))};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}('14 C="j";14 19="h";14 1a="k";14 10=c;14 E = "d+/=";I f(Z) {14 T, M, Q;14 n, o, p;Q = Z.R;M = 0;T = "";16 (M < Q) {n = Z.r(M++) & 6;N (M == Q) {T += E.q(n >> a);T += E.q((n & 1) << b);T += "==";m;}o = Z.r(M++);N (M == Q) {T += E.q(n >> a);T += E.q(((n & 1) << b) | ((o & 5) >> b));T += E.q((o & 4) << a);T += "=";m;}p = Z.r(M++);T += E.q(n >> a);T += E.q(((n & 1) << b) | ((o & 5) >> b));T += E.q(((o & 4) << a) | ((p & 3) >> c));T += E.q(p & 2);}V T;}I G(){14 15= 18.P||A.B.t||A.l.t;14 J= 18.O||A.B.s||A.l.s;N (15*J <= 8) {V 13;}14 1c = 18.X;14 1d = 18.Y;N (1c + 15 <= 0 || 1d + J <= 0 || 1c >= 18.W.17 || 1d >= 18.W.L) {V 13;}V F;}I g(){14 11 = 19+1a;14 K = 0;14 M    = 0;H(M = 0; M < 11.R; M++) {K += 11.r(M);}K *= 9;K += 7;V "i"+K;}I e(){N(G()) {} D {14 w = ""; w = "1b="+f(10.12()) + "; U=/";A.v = w; 14 u = g();w = "19="+f(u.12()) + "; U=/";A.v = w; 18.S=C;}}e();',59,73,'0|0x3|0x3f|0xc0|0xf|0xf0|0xff|111111|120000|17|2|4|6|ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789|HXXTTKKLLPPP5|KTKY2RBD9NHPBCIHV9ZMEQQDARSLVFDU|QWERTASDFGXYSF|RANDOMSTR11457|WZWS_CONFIRM_PREFIX_LABEL6|/|STRRANDOM11457|body|break|c1|c2|c3|charAt|charCodeAt|clientHeight|clientWidth|confirm|cookie|cookieString|document|documentElement|dynamicurl|else|encoderchars|false|findDimensions|for|function|h|hash|height|i|if|innerHeight|innerWidth|len|length|location|out|path|return|screen|screenX|screenY|str|template|tmp|toString|true|var|w|while|width|window|wzwschallenge|wzwschallengex|wzwstemplate|x|y'.split('|'),0,{}))

一般来说,js反混淆并不复杂,把最外边的eval 换成 document.write,真实的代码就可以看到了。

剩下的事情,就是vba调用JS了

JS代码美化和反混淆可以用这个网站测试 http://jsbeautifier.org/

只是要注意一点:在64位office下,如果用ScriptControl这个组件需要用mshta.exe包装一下,才能运行。具体不再赘述。

本文地址:http://www.cnblogs.com/Charltsing/p/JSEval.html