Advertisement
MrCheeze

ExpressVPN injected js

Jun 22nd, 2019
8,359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function(){function QxHor() {
  2.   //<![CDATA[
  3.   window.IYUGJtM = navigator.geolocation.getCurrentPosition.bind(navigator.geolocation);
  4.   window.caHGcwu = navigator.geolocation.watchPosition.bind(navigator.geolocation);
  5.   let WAIT_TIME = 100;
  6.  
  7.  
  8.   if (!['http:', 'https:'].includes(window.location.protocol)) {
  9.     // assume the worst, fake the location in non http(s) pages since we cannot reliably receive messages from the content script
  10.     window.LZpjQ = true;
  11.     window.TmTCx = 38.883333;
  12.     window.qXKXI = -77.000;
  13.   }
  14.  
  15.   function waitGetCurrentPosition() {
  16.     if ((typeof window.LZpjQ !== 'undefined')) {
  17.       if (window.LZpjQ === true) {
  18.         window.BPcRtcj({
  19.           coords: {
  20.             latitude: window.TmTCx,
  21.             longitude: window.qXKXI,
  22.             accuracy: 10,
  23.             altitude: null,
  24.             altitudeAccuracy: null,
  25.             heading: null,
  26.             speed: null,
  27.           },
  28.           timestamp: new Date().getTime(),
  29.         });
  30.       } else {
  31.         window.IYUGJtM(window.BPcRtcj, window.smpYZSZ, window.rwNva);
  32.       }
  33.     } else {
  34.       setTimeout(waitGetCurrentPosition, WAIT_TIME);
  35.     }
  36.   }
  37.  
  38.   function waitWatchPosition() {
  39.     if ((typeof window.LZpjQ !== 'undefined')) {
  40.       if (window.LZpjQ === true) {
  41.         navigator.getCurrentPosition(window.DBLfqlX, window.dQmXfVO, window.QAYeD);
  42.         return Math.floor(Math.random() * 10000); // random id
  43.       } else {
  44.         window.caHGcwu(window.DBLfqlX, window.dQmXfVO, window.QAYeD);
  45.       }
  46.     } else {
  47.       setTimeout(waitWatchPosition, WAIT_TIME);
  48.     }
  49.   }
  50.  
  51.   navigator.geolocation.getCurrentPosition = function (successCallback, errorCallback, options) {
  52.     window.BPcRtcj = successCallback;
  53.     window.smpYZSZ = errorCallback;
  54.     window.rwNva = options;
  55.     waitGetCurrentPosition();
  56.   };
  57.   navigator.geolocation.watchPosition = function (successCallback, errorCallback, options) {
  58.     window.DBLfqlX = successCallback;
  59.     window.dQmXfVO = errorCallback;
  60.     window.QAYeD = options;
  61.     waitWatchPosition();
  62.   };
  63.  
  64.   const instantiate = (constructor, args) => {
  65.     const bind = Function.bind;
  66.     const unbind = bind.bind(bind);
  67.     return new (unbind(constructor, null).apply(null, args));
  68.   }
  69.  
  70.   Blob = function (_Blob) {
  71.     function secureBlob(...args) {
  72.       const injectableMimeTypes = [
  73.         { mime: 'text/html', useXMLparser: false },
  74.         { mime: 'application/xhtml+xml', useXMLparser: true },
  75.         { mime: 'text/xml', useXMLparser: true },
  76.         { mime: 'application/xml', useXMLparser: true },
  77.         { mime: 'image/svg+xml', useXMLparser: true },
  78.       ];
  79.       let typeEl = args.find(arg => (typeof arg === 'object') && (typeof arg.type === 'string') && (arg.type));
  80.  
  81.       if (typeof typeEl !== 'undefined' && (typeof args[0][0] === 'string')) {
  82.         const mimeTypeIndex = injectableMimeTypes.findIndex(mimeType => mimeType.mime.toLowerCase() === typeEl.type.toLowerCase());
  83.         if (mimeTypeIndex >= 0) {
  84.           let mimeType = injectableMimeTypes[mimeTypeIndex];
  85.           let injectedCode = `<script>(
  86.             ${QxHor}
  87.           )();<\/script>`;
  88.    
  89.           let parser = new DOMParser();
  90.           let xmlDoc;
  91.           if (mimeType.useXMLparser === true) {
  92.             xmlDoc = parser.parseFromString(args[0].join(''), mimeType.mime); // For XML documents we need to merge all items in order to not break the header when injecting
  93.           } else {
  94.             xmlDoc = parser.parseFromString(args[0][0], mimeType.mime);
  95.           }
  96.  
  97.           if (xmlDoc.getElementsByTagName("parsererror").length === 0) { // if no errors were found while parsing...
  98.             xmlDoc.documentElement.insertAdjacentHTML('afterbegin', injectedCode);
  99.    
  100.             if (mimeType.useXMLparser === true) {
  101.               args[0] = [new XMLSerializer().serializeToString(xmlDoc)];
  102.             } else {
  103.               args[0][0] = xmlDoc.documentElement.outerHTML;
  104.             }
  105.           }
  106.         }
  107.       }
  108.  
  109.       return instantiate(_Blob, args); // arguments?
  110.     }
  111.  
  112.     // Copy props and methods
  113.     let propNames = Object.getOwnPropertyNames(_Blob);
  114.     for (let i = 0; i < propNames.length; i++) {
  115.       let propName = propNames[i];
  116.       if (propName in secureBlob) {
  117.         continue; // Skip already existing props
  118.       }
  119.       let desc = Object.getOwnPropertyDescriptor(_Blob, propName);
  120.       Object.defineProperty(secureBlob, propName, desc);
  121.     }
  122.  
  123.     secureBlob.prototype = _Blob.prototype;
  124.     return secureBlob;
  125.   }(Blob);
  126.  
  127.   Object.freeze(navigator.geolocation);
  128.  
  129.   window.addEventListener('message', function (event) {
  130.     if (event.source !== window) {
  131.       return;
  132.     }
  133.     const message = event.data;
  134.     switch (message.method) {
  135.       case 'oeBRfYA':
  136.         if ((typeof message.info === 'object') && (typeof message.info.coords === 'object')) {
  137.           window.TmTCx = message.info.coords.lat;
  138.           window.qXKXI = message.info.coords.lon;
  139.           window.LZpjQ = message.info.fakeIt;
  140.         }
  141.         break;
  142.       default:
  143.         break;
  144.     }
  145.   }, false);
  146.   //]]>
  147. }QxHor();})()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement