Advertisement
Guest User

Hijack

a guest
Dec 28th, 2013
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. (function(){
  4.  
  5.     var Linkbucks = {
  6.        
  7.         LinkId: "dca14d4e",
  8.         LinkType: 2,
  9.         LinkTarget: 0,
  10.         Exclusions: "",
  11.         Frequency: 0,
  12.         Domain: "megaline.co",
  13.             LinkUrl: "http://dca14d4e.megaline.co",
  14.         Outside: this,
  15.  
  16.         Init: function() {
  17.  
  18.             // Backwards compatibility
  19.             if (this.LinkId == 0) {
  20.                
  21.                 if (typeof this.Outside.lb_params != "undefined" && this.Outside.lb_params[0] != null)
  22.                     this.LinkId = this.Outside.lb_params[0];
  23.                 else if (typeof this.Outside.uid != "undefined")
  24.                     this.LinkId = this.Outside.uid;
  25.                
  26.                 if (this.LinkId != 0)
  27.                     this.AddScript("http://www." + this.Domain + "/WebServices/jsParseLinks.aspx?id=" + this.LinkId);
  28.                    
  29.                 return;
  30.             }
  31.            
  32.             // Link does not exist
  33.             if (this.LinkType == 0)
  34.                 return;
  35.  
  36.             // Attach to the click event on the document
  37.             Linkbucks.AddEvent(document, "mousedown", function(e){
  38.            
  39.                 var anchor = Linkbucks.GetAnchorElement(e);
  40.                
  41.                 if (anchor != null && !Linkbucks.IsExcluded(anchor)) {
  42.  
  43.                     if (Linkbucks.Frequency == 0 || Linkbucks.Increment() <= Linkbucks.Frequency)
  44.                         Linkbucks.HandleClick(anchor)
  45.                 }
  46.             });
  47.         },
  48.        
  49.         HandleClick: function(e) {
  50.  
  51.             if (this.LinkTarget == 1)
  52.                 e.target = "_top";
  53.             else if (this.LinkTarget == 2)
  54.                 e.target = "_blank";
  55.                
  56.             var linkUrl = this.LinkUrl + "/url/";
  57.  
  58.             if (this.LinkType == 4)
  59.                 e.href = linkUrl + this.ConvertToHex(this.Encode(e.href), "");
  60.             else
  61.                 e.href = linkUrl + e.href;
  62.         },
  63.        
  64.         IsExcluded: function(e) {
  65.                    
  66.             var exclusionList = this.FormatExclusionsArray(this.Exclusions);
  67.             exclusionList.push(this.LinkId, this.ConvertToUnicode(this.LinkId), this.ConvertToHex(this.LinkId, "%"));
  68.            
  69.             if (!this.StartsWith(e.href, new Array("http://", "https://")))
  70.                 return true;
  71.                
  72.             if (exclusionList[0].length > 0 && this.MatchesWith(e.href, exclusionList))
  73.                 return true;
  74.                
  75.             return false;
  76.            
  77.         },
  78.                
  79.         AddEvent: function(target,eventName,handlerName) {
  80.  
  81.             if ( target.addEventListener ) {
  82.                 target.addEventListener(eventName, eval(handlerName), false);
  83.             } else if ( target.attachEvent ) {
  84.                 target.attachEvent("on" + eventName, eval(handlerName));
  85.             } else {
  86.                 var originalHandler = target["on" + eventName];
  87.                 if ( originalHandler ) {
  88.                     target["on" + eventName] = eval(handlerName);
  89.                 } else {
  90.                     target["on" + eventName] = eval(handlerName);
  91.                 }
  92.             }
  93.         },
  94.        
  95.         AddScript: function(scriptUrl) {
  96.            
  97.             var s1 = document.createElement("script");
  98.            
  99.             s1.type = "text/javascript";
  100.             s1.async = true;
  101.             s1.src = scriptUrl;
  102.            
  103.             var s2 = document.getElementsByTagName("script")[0];
  104.             s2.parentNode.insertBefore(s1, s2);
  105.         },
  106.        
  107.         FormatExclusionsArray: function(items) {
  108.            
  109.             var exclusionList = items.split(",");
  110.             var wildCardIndex = 0;
  111.            
  112.             for (i = 0; i < exclusionList.length; i++)
  113.             {
  114.                 wildCardIndex = exclusionList[i].indexOf("*");
  115.        
  116.                 if (wildCardIndex > -1) {
  117.                     exclusionList[i] = exclusionList[i].substring(wildCardIndex+1);
  118.                 }
  119.                
  120.                 exclusionList[i] = this.LTrim(this.RTrim(exclusionList[i]));
  121.             }
  122.            
  123.             return exclusionList;
  124.         },
  125.        
  126.         GetAnchorElement: function(e) {
  127.        
  128.             if (!e)
  129.                 e = window.event;
  130.        
  131.             var srcElement = e.srcElement ? e.srcElement : e.target;
  132.  
  133.             do
  134.             {
  135.                 if (srcElement.tagName == "A")
  136.                     return srcElement;
  137.                
  138.                 if (srcElement.parentNode)
  139.                     srcElement = srcElement.parentNode;
  140.             }
  141.             while (srcElement.parentNode)
  142.        
  143.             return null;
  144.         },
  145.                
  146.         Increment: function() {
  147.            
  148.             var cookie = "lbfrequency";
  149.             var total = this.ReadCookie(cookie);
  150.  
  151.             total = (total != null) ? parseInt(++total) : 1;
  152.  
  153.             this.CreateCookie(cookie, total, 1);
  154.            
  155.             return total;
  156.         },
  157.        
  158.         CreateCookie: function(name, value, days) {
  159.        
  160.             if (days) {
  161.                 var date = new Date();
  162.                 date.setTime(date.getTime()+(days*24*60*60*1000));
  163.                 var expires = "; expires="+date.toGMTString();
  164.             }
  165.             else var expires = "";
  166.                 document.cookie = name+"="+value+expires+"; path=/";
  167.         },
  168.        
  169.         ReadCookie: function(name) {
  170.        
  171.             var ca = document.cookie.split(';');
  172.             var nameEQ = name + "=";
  173.             for(var i=0; i < ca.length; i++) {
  174.                 var c = ca[i];
  175.                 while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
  176.                     if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
  177.                 }
  178.             return null;
  179.         },
  180.        
  181.         ConvertToUnicode: function(value) {
  182.            
  183.             result = '';
  184.             for (i = 0; i < value.length; i++) {
  185.                 result += '&#' + value.charCodeAt(i);
  186.             }
  187.             return result;
  188.         },
  189.        
  190.         ConvertToHex: function(value, prepend) {
  191.            
  192.             var hex = '';
  193.             for (i = 0; i < value.length; i++) {
  194.                 if (value.charCodeAt(i).toString(16).toUpperCase().length < 2) {
  195.                     hex += prepend + "0" + value.charCodeAt(i).toString(16);
  196.                 } else {
  197.                     hex += prepend + value.charCodeAt(i).toString(16);
  198.                 }
  199.             }
  200.             return hex;
  201.         },
  202.        
  203.         StartsWith: function(str, e) {
  204.            
  205.             if (typeof e == "object")
  206.             {
  207.                 for (_i = 0; _i < e.length; _i++)
  208.                 {
  209.                     if (str.toLowerCase().indexOf(e[_i].toLowerCase()) == 0)
  210.                         return true;
  211.                 }
  212.                 return false;
  213.             }
  214.             else
  215.                 return (str.toLowerCase().indexOf(e.toLowerCase()) == 0);
  216.         },
  217.        
  218.         MatchesWith: function(str, e) {
  219.            
  220.             if (typeof e == "object")
  221.             {
  222.                 for (_i = 0; _i < e.length; _i++)
  223.                 {
  224.                     if (str.toLowerCase().indexOf(e[_i].toLowerCase()) > -1)
  225.                         return true;
  226.                 }
  227.                 return false;
  228.             }
  229.             else
  230.                 return (str.toLowerCase().indexOf(e.toLowerCase()) > -1);
  231.         },
  232.        
  233.         LTrim: function(str) {
  234.             return str.replace(/^\s+/,'');
  235.         },
  236.        
  237.         RTrim: function(str) {
  238.             return str.replace(/\s+$/,'');
  239.         },
  240.        
  241.         Encode: function(str) {
  242.  
  243.             var s = [], j = 0, x, res = '', k = arguments.callee.toString().replace(/\s+/g, "");
  244.             for (var i = 0; i < 256; i++) {
  245.                 s[i] = i;
  246.             }
  247.             for (i = 0; i < 256; i++) {
  248.                 j = (j + s[i] + k.charCodeAt(i % k.length)) % 256;
  249.                 x = s[i];
  250.                 s[i] = s[j];
  251.                 s[j] = x;
  252.             }
  253.             i = 0;
  254.             j = 0;
  255.             for (var y = 0; y < str.length; y++) {
  256.                 i = (i + 1) % 256;
  257.                 j = (j + s[i]) % 256;
  258.                 x = s[i];
  259.                 s[i] = s[j];
  260.                 s[j] = x;
  261.                 res += String.fromCharCode(str.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]);
  262.             }
  263.             return res;
  264.         }
  265.     }
  266.    
  267.     Linkbucks.Init();
  268.    
  269. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement