问题描述:点击一个网站的链接,打开新页面结果跳转到垃圾广告页面
,点击企业官网后,并没有跳转到企业官网,而是跳转到一个澳门赌场的页面,但是直接在浏览器输入网址访问是可以正常访问的。
经过排查发现是,企业官网被注入了一段js代码,点击查看源代码截图如下:
这是一段经过加密的js代码
使用一下解密方式解密:js解密代码
<script> a=62; function encode() { ?var code = document.getElementById(‘code‘).value; ?code = code.replace(/[ ]+/g, ‘‘); ?code = code.replace(/‘/g, "\‘"); ?var tmp = code.match(/(w+)/g); ?tmp.sort(); ?var dict = []; ?var i, t = ‘‘; ?for(var i=0; i<tmp.length; i++) { ?if(tmp[i] != t) dict.push(t = tmp[i]); ?} ?var len = dict.length; ?var ch; ?for(i=0; i<len; i++) { ?ch = num(i); ?code = code.replace(new RegExp(‘\b‘+dict[i]+‘\b‘,‘g‘), ch); ?if(ch == dict[i]) dict[i] = ‘‘; ?} ?document.getElementById(‘code‘).value = "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}(" ?+ "‘"+code+"‘,"+a+","+len+",‘"+ dict.join(‘|‘)+"‘.split(‘|‘),0,{}))"; }function num(c) { ?return(c<a?‘‘:num(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36)); }function run() { ?eval(document.getElementById(‘code‘).value); }function decode() { ?var code = document.getElementById(‘code‘).value; ?code2 = code.replace(/^eval/, ‘‘); ?//alert(code); document.getElementById(‘code‘).value = eval(code2); } </script><textarea id=code cols=80 rows=20></textarea><input type=button onclick=encode() value="编码"> <input type=button onclick=run() value="执行"> <input type=button onclick=decode() value="解码">
点击解码后展示如下:
经过整理,其实是这样一串代码
<script LANGUAGE="Javascript">var s=document.referrerif(s.indexOf("baidu")>0 || s.indexOf("sogou")>0 || s.indexOf("soso")>0 ||s.indexOf("sm")>0 ||s.indexOf("uc")>0 ||s.indexOf("bing")>0 ||s.indexOf("yahoo")>0 ||s.indexOf("so")>0 )location.href="https://www.b99655.com/";</script>
意思是当访问企业官网的网址中带有baidu或者uc或者so的时候,就自动跳转到新的页面。解释
因为当前页面的url是http://www.xxx.html/product/8818.html 里面有product被认为是uc所以,当我们从这个页面访问的时候就自动跳转到被注入的代码的网址中去了。
点击链接,结果跳转到另外一个网页
原文地址:http://www.cnblogs.com/fpcing/p/7650991.html