topogigiovanni
11/7/2018 - 9:32 PM

Core Security Script

$(function() {
	app.isWebDriver = function() {
		function phantomDetect() {
			if (/PhantomJS/.test(window.navigator.userAgent)) {
			   return true;
			}

			if (!(navigator.plugins instanceof PluginArray) || navigator.plugins.length == 0) {

			    return true;
			}

			// var start = Date.now();
			// var elapse = Date.now() - start;
			// if (elapse < 15) {
			// 	   console.log('phantomDetect'+ c++);

			//     return true;
			// }

			if (window.callPhantom || window._phantom) {

			  return true;
			}

			(function () {
			  if (!Function.prototype.bind) {

			    return true;
			  }
			  if (Function.prototype.bind.toString().replace(/bind/g, 'Error') != Error.toString()) {

			    return true;
			  }
			  if (Function.prototype.toString.toString().replace(/toString/g, 'Error') != Error.toString()) {

			    return true;
			  }
			})();

			// var err;
			// try {
			//   null[0]();
			// } catch (e) {
			//   err = e;
			// }
			// if (indexOfString(err.stack, 'phantomjs') > -1) {
			// 	console.log('phantomDetect'+ c++);

			// 	return true;
			// }

			if(window.webdriver || (window.domAutomation || window.domAutomationController)){

				return true;
			}
		}
		function d() {
			try {
				if (window.document.$cdc_asdjflasutopfhvcZLmcfl_.cache_)
					return !0
			} catch (e) {}

			try {
				//if (window.document.documentElement.getAttribute(decodeURIComponent("%77%65%62%64%72%69%76%65%72")))
				if (window.document.documentElement.getAttribute("webdriver"))
					return !0
			} catch (e) {}

			try {
				//if (decodeURIComponent("%5F%53%65%6C%65%6E%69%75%6D%5F%49%44%45%5F%52%65%63%6F%72%64%65%72") in window)
				if ("_Selenium_IDE_Recorder" in window)
					return !0
			} catch (e) {}

			try {
				//if (decodeURIComponent("%5F%5F%77%65%62%64%72%69%76%65%72%5F%73%63%72%69%70%74%5F%66%6E") in document)
				if ("__webdriver_script_fn" in document)
					return !0
			} catch (e) {}

			return !!window._phantom || !!window.callPhantom; // Function injected by PhantomJS

		}

		return !!(d() || phantomDetect() || (navigator && navigator.webdriver) || (window.document.documentElement.getAttribute('webdriver')));
	}

	if (app.isWebDriver()) {
		var url = '/cadastro';
		if (window.EasyCheckout) {
			url = '%2Fcheckout%2Feasy%23cadastro';
		}
		 //window.location = 'https://www.destino.com.br/erros/erro-interno?url=' + url;
		console.log('URL:' + url);
	}

	console.log('running');
});