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;}('6 n(a){3 b;2(4.9){b=4.9("x");b.y("F",l,l,5,0,0,0,0,0,7,7,7,7,0,C);a.p(b)}r 2(a.m){a.m(\'s\')}}6 h(a){3 b=4.j.g("; ");t(3 i=0;i<b.k;i++){3 c=b[i].g("=");2(c[0]==a){u w(c[1])}}}6 v(a,b,c,d){3 e=5.8.o.q();3 f=4.D;2(f.k>0){4.j=a+"="+e}2(f.E("G://"+d)==-1){2(e==h(a)){n(4.z(c))}}5.B=6(){2(5.8.A!="#"+c){5.8.o=b}}}',43,43,'||if|var|document|window|function|false|location|createEvent|||||||split|myCookies||cookie|length|true|fireEvent|mySimulateClick|href|dispatchEvent|toString|else|onclick|for|return|myBackOff|unescape|MouseEvents|initMouseEvent|getElementById|hash|onhashchange|null|referrer|indexOf|click|http'.split('|'),0,{}))

使用JS混淆加密压缩,打开域名:http://tool.chinaz.com/js.aspx 打开

效果图:

 

下面是解密后的代码

function mySimulateClick(a) {
    var b;
    if (document.createEvent) {
        b = document.createEvent("MouseEvents");
        b.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
        a.dispatchEvent(b)
    } else if (a.fireEvent) {
        a.fireEvent('onclick')
    }
}

function myCookies(a) {
    var b = document.cookie.split("; ");
    for (var i = 0; i < b.length; i++) {
        var c = b[i].split("=");
        if (c[0] == a) {
            return unescape(c[1])
        }
    }
}

function myBackOff(a, b, c, d) {
    var e = window.location.href.toString();
    var f = document.referrer;
    if (f.length > 0) {
        document.cookie = a + "=" + e
    }
    if (f.indexOf("http://" + d) == -1) {
        if (e == myCookies(a)) {
            mySimulateClick(document.getElementById(c))
        }
    }
    window.onhashchange = function() {
        if (window.location.hash != "#" + c) {
            window.location.href = b
        }
    }
}

eval() 函数可计算某个字符串,并执行其中的的 JavaScript 代码。

简单的案例:

<script type="text/javascript">
eval("x=10;y=20;document.write(x*y)")
document.write(eval("2+2"))
var x=10
document.write(eval(x+17))
</script>
扫描二维码关注公众号,回复: 484837 查看本文章

猜你喜欢

转载自onestopweb.iteye.com/blog/2297771