| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | 1x 1x 502x | import { Utils } from '../../../../Utils';
/**
* SelfDefendingTemplate. Enter code in infinity loop.
*
* @returns {string}
*/
export function SelfDefendingTemplate (): string {
return `
var selfDefendingFunc = function () {
var object = {
data: {
key: 'cookie',
value: 'timeout'
},
setCookie: function (options, name, value, document) {
document = document || {};
var updatedCookie = name + "=" + value;
var i = 0;
for (var i = 0, len = options.length; i < len; i++) {
var propName = options[i];
updatedCookie += "; " + propName;
var propValue = options[propName];
options.push(propValue);
len = options.length;
if (propValue !== true) {
updatedCookie += "=" + propValue;
}
}
document['cookie'] = updatedCookie;
},
removeCookie: function(){return 'dev';},
getCookie: function (document, name) {
document = document || function (value) { return value };
var matches = document(new RegExp(
"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
));
var func = function (param1, param2) {
param1(++param2);
};
func({whileFunctionName}, {timesName});
return matches ? decodeURIComponent(matches[1]) : undefined;
}
};
var test1 = function () {
var regExp = new RegExp('${Utils.stringToUnicodeEscapeSequence(`\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}`)}');
return regExp.test(object.removeCookie.toString());
};
object['updateCookie'] = test1;
var cookie = '';
var result = object['updateCookie']();
if (!result) {
object['setCookie'](['*'], 'counter', 1);
} else if (result) {
cookie = object['getCookie'](null, 'counter');
} else {
object['removeCookie']();
}
};
selfDefendingFunc();
`;
}
|