diff --git a/dist/src/custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode.js b/dist/src/custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode.js index e31352fe..ccb7d00d 100644 --- a/dist/src/custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode.js +++ b/dist/src/custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode.js @@ -1,6 +1,7 @@ "use strict"; const esprima = require('esprima'); const AppendState_1 = require("../../enums/AppendState"); +const JSFuck_1 = require("../../enums/JSFuck"); const NoCustomNodesPreset_1 = require("../../preset-options/NoCustomNodesPreset"); const JavaScriptObfuscator_1 = require("../../JavaScriptObfuscator"); const Node_1 = require('../Node'); @@ -26,11 +27,7 @@ class SelfDefendingUnicodeNode extends Node_1.Node { return 'window'; }; - if ( - !Function(${Utils_1.Utils.stringToUnicode(`return/(\\\\[x|u](\\w){2,4})+/`)})().test(func.toString()) - ) { - []['filter']['constructor'](${Utils_1.Utils.stringToJSFuck('while')} + '(true){}')(); - } + !Function(${Utils_1.Utils.stringToUnicode(`return/(\\\\[x|u](\\w){2,4})+/`)})().test(func.toString()) ? []['filter']['constructor'](${Utils_1.Utils.stringToJSFuck('while')} + '(${JSFuck_1.JSFuck.True}){}')() : !!!!!![] ? []['filter']['constructor'](${Utils_1.Utils.stringToJSFuck('while')} + '(${JSFuck_1.JSFuck.False}){}')() : []['filter']['constructor'](${Utils_1.Utils.stringToJSFuck('while')} + '(${JSFuck_1.JSFuck.False}){}')(); })(); `, NoCustomNodesPreset_1.NO_CUSTOM_NODES_PRESET)); NodeUtils_1.NodeUtils.addXVerbatimPropertyToLiterals(node); diff --git a/dist/src/custom-nodes/unicode-array-nodes/UnicodeArrayCallsWrapper.js b/dist/src/custom-nodes/unicode-array-nodes/UnicodeArrayCallsWrapper.js index 74b340e3..dfc1acb8 100644 --- a/dist/src/custom-nodes/unicode-array-nodes/UnicodeArrayCallsWrapper.js +++ b/dist/src/custom-nodes/unicode-array-nodes/UnicodeArrayCallsWrapper.js @@ -1,7 +1,6 @@ "use strict"; const esprima = require('esprima'); const AppendState_1 = require("../../enums/AppendState"); -const JSFuck_1 = require("../../enums/JSFuck"); const Node_1 = require('../Node'); const NodeUtils_1 = require("../../NodeUtils"); const Utils_1 = require("../../Utils"); @@ -29,29 +28,10 @@ class UnicodeArrayCallsWrapper extends Node_1.Node { return super.getNode(); } getNodeStructure() { - let code = '', environmentName = Utils_1.Utils.getRandomVariableName(), keyName = Utils_1.Utils.getRandomVariableName(), node; - if (this.options['selfDefending']) { - code = ` - var ${environmentName} = function(){return ${Utils_1.Utils.stringToUnicode('production')};}; - - if ( - ${keyName} % ${Utils_1.Utils.getRandomInteger(this.unicodeArray.length / 8, this.unicodeArray.length / 2)} === 0x0 && - ( - Function(${Utils_1.Utils.stringToUnicode(`return/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/`)})()[${Utils_1.Utils.stringToUnicode('test')}]( - ${environmentName}[${Utils_1.Utils.stringToUnicode('toString')}]() - ) === ${JSFuck_1.JSFuck.True} || ${keyName}++ - ) - ); - - return ${this.unicodeArrayName}[parseInt(${keyName}, 0x010)]; - `; - } - else { - code = `return ${this.unicodeArrayName}[parseInt(${keyName}, 0x010)]`; - } + let keyName = Utils_1.Utils.getRandomVariableName(), node; node = esprima.parse(` var ${this.unicodeArrayCallsWrapperName} = function (${keyName}) { - ${code} + return ${this.unicodeArrayName}[parseInt(${keyName}, 0x010)]; }; `); NodeUtils_1.NodeUtils.addXVerbatimPropertyToLiterals(node); diff --git a/dist/src/custom-nodes/unicode-array-nodes/UnicodeArrayDecodeNode.js b/dist/src/custom-nodes/unicode-array-nodes/UnicodeArrayDecodeNode.js index aefcd076..6df09069 100644 --- a/dist/src/custom-nodes/unicode-array-nodes/UnicodeArrayDecodeNode.js +++ b/dist/src/custom-nodes/unicode-array-nodes/UnicodeArrayDecodeNode.js @@ -26,20 +26,13 @@ class UnicodeArrayDecodeNode extends Node_1.Node { return super.getNode(); } getNodeStructure() { - const environmentName = Utils_1.Utils.getRandomVariableName(), indexVariableName = Utils_1.Utils.getRandomVariableName(), tempArrayName = Utils_1.Utils.getRandomVariableName(); + const environmentName = Utils_1.Utils.getRandomVariableName(), forLoopFunctionName = Utils_1.Utils.getRandomVariableName(), indexVariableName = Utils_1.Utils.getRandomVariableName(), tempArrayName = Utils_1.Utils.getRandomVariableName(); let code = '', node; if (this.options['selfDefending']) { code = ` var ${environmentName} = function(){return ${Utils_1.Utils.stringToUnicode('dev')};}; - - if ( - ${indexVariableName} % ${Utils_1.Utils.getRandomInteger(this.unicodeArray.length / 8, this.unicodeArray.length / 2)} === 0 && - Function(${Utils_1.Utils.stringToUnicode(`return/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/`)})()[${Utils_1.Utils.stringToUnicode('test')}]( - ${environmentName}[${Utils_1.Utils.stringToUnicode('toString')}]() - ) !== ${JSFuck_1.JSFuck.True} && ${indexVariableName}++ - ) { - continue; - } + + Function(${Utils_1.Utils.stringToUnicode(`return/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/`)})()[${Utils_1.Utils.stringToUnicode('test')}](${environmentName}[${Utils_1.Utils.stringToUnicode('toString')}]()) !== ${JSFuck_1.JSFuck.True} && !${this.unicodeArrayName}++ ? []['filter']['constructor'](${Utils_1.Utils.stringToJSFuck('while')} + '(${JSFuck_1.JSFuck.True}){}')() : ${JSFuck_1.JSFuck.Window}.eval(${forLoopFunctionName}()) ? []['filter']['constructor'](${Utils_1.Utils.stringToJSFuck('while')} + '(${JSFuck_1.JSFuck.False}){}')() : []['filter']['constructor'](${Utils_1.Utils.stringToJSFuck('while')} + '(${JSFuck_1.JSFuck.False}){}')(); `; } node = esprima.parse(` @@ -65,15 +58,17 @@ class UnicodeArrayDecodeNode extends Node_1.Node { })(); `, NoCustomNodesPreset_1.NO_CUSTOM_NODES_PRESET)} - var ${tempArrayName} = []; + var ${forLoopFunctionName} = function () { + var ${tempArrayName} = []; + + for (var ${indexVariableName} in ${this.unicodeArrayName}) { + ${tempArrayName}[${Utils_1.Utils.stringToUnicode('push')}](decodeURI(atob(${this.unicodeArrayName}[${indexVariableName}]))); + } + + ${this.unicodeArrayName} = ${tempArrayName}; + }; - for (var ${indexVariableName} in ${this.unicodeArrayName}) { - ${code} - - ${tempArrayName}[${Utils_1.Utils.stringToUnicode('push')}](decodeURI(atob(${this.unicodeArrayName}[${indexVariableName}]))); - } - - ${this.unicodeArrayName} = ${tempArrayName}; + ${code} })(); `); NodeUtils_1.NodeUtils.addXVerbatimPropertyToLiterals(node); diff --git a/dist/src/custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode.js b/dist/src/custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode.js index a886e1f1..d14f0b82 100644 --- a/dist/src/custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode.js +++ b/dist/src/custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode.js @@ -26,7 +26,7 @@ class UnicodeArrayRotateFunctionNode extends Node_1.Node { return super.getNode(); } getNodeStructure() { - let arrayName = Utils_1.Utils.getRandomVariableName(), code = '', timesName = Utils_1.Utils.getRandomVariableName(), tempArrayName = Utils_1.Utils.getRandomVariableName(), node; + let arrayName = Utils_1.Utils.getRandomVariableName(), code = '', timesName = Utils_1.Utils.getRandomVariableName(), timesArgumentName = Utils_1.Utils.getRandomVariableName(), tempArrayName = Utils_1.Utils.getRandomVariableName(), whileFunctionName = Utils_1.Utils.getRandomVariableName(), node; if (this.options['selfDefending']) { code = JavaScriptObfuscator_1.JavaScriptObfuscator.obfuscate(` (function () { @@ -34,14 +34,13 @@ class UnicodeArrayRotateFunctionNode extends Node_1.Node { return 'window'; }; - if ( - !Function(${Utils_1.Utils.stringToUnicode(`return/(\\\\[x|u](\\w){2,4})+/`)})().test(func.toString()) - ) { - []['filter']['constructor'](${Utils_1.Utils.stringToJSFuck('while')} + '(${JSFuck_1.JSFuck.True}){}')(); - } + !Function(${Utils_1.Utils.stringToUnicode(`return/(\\\\[x|u](\\w){2,4})+/`)})().test(func.toString()) ? []['filter']['constructor'](${Utils_1.Utils.stringToJSFuck('while')} + '(${JSFuck_1.JSFuck.True}){}')() : ${JSFuck_1.JSFuck.Window}.eval(${whileFunctionName}(${timesName})) ? []['filter']['constructor'](${Utils_1.Utils.stringToJSFuck('while')} + '(${JSFuck_1.JSFuck.False}){}')() : []['filter']['constructor'](${Utils_1.Utils.stringToJSFuck('while')} + '(${JSFuck_1.JSFuck.False}){}')(); })(); `, NoCustomNodesPreset_1.NO_CUSTOM_NODES_PRESET); } + else { + code = `${whileFunctionName}(${timesName})`; + } node = esprima.parse(` (function (${arrayName}, ${timesName}) { if (${timesName} < 0x${Utils_1.Utils.decToHex(0)}) { @@ -50,11 +49,14 @@ class UnicodeArrayRotateFunctionNode extends Node_1.Node { var ${tempArrayName}; - while (${timesName}--) { - ${code} - ${tempArrayName} = ${arrayName}[${Utils_1.Utils.stringToUnicode('shift')}](); - ${arrayName}[${Utils_1.Utils.stringToUnicode('push')}](${tempArrayName}); - } + var ${whileFunctionName} = function (${timesArgumentName}) { + while (${timesArgumentName}--) { + ${tempArrayName} = ${arrayName}[${Utils_1.Utils.stringToUnicode('shift')}](); + ${arrayName}[${Utils_1.Utils.stringToUnicode('push')}](${tempArrayName}); + } + }; + + ${code} })(${this.unicodeArrayName}, 0x${Utils_1.Utils.decToHex(this.unicodeArrayRotateValue)}); `); NodeUtils_1.NodeUtils.addXVerbatimPropertyToLiterals(node); diff --git a/dist/src/enums/JSFuck.js b/dist/src/enums/JSFuck.js index fc5ee9c0..e850e5c6 100644 --- a/dist/src/enums/JSFuck.js +++ b/dist/src/enums/JSFuck.js @@ -1,5 +1,6 @@ "use strict"; exports.JSFuck = { + Window: '[]["filter"]["constructor"]("return this")()', False: '![]', True: '!![]', a: '(false+"")[1]', diff --git a/src/custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode.ts b/src/custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode.ts index 91169e95..05a80daa 100644 --- a/src/custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode.ts +++ b/src/custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode.ts @@ -6,6 +6,7 @@ import { IOptions } from "../../interfaces/IOptions"; import { TBlockScopeNode } from "../../types/TBlockScopeNode"; import { AppendState } from "../../enums/AppendState"; +import { JSFuck } from "../../enums/JSFuck"; import { NO_CUSTOM_NODES_PRESET } from "../../preset-options/NoCustomNodesPreset"; @@ -54,11 +55,7 @@ export class SelfDefendingUnicodeNode extends Node { return 'window'; }; - if ( - !Function(${Utils.stringToUnicode(`return/(\\\\[x|u](\\w){2,4})+/`)})().test(func.toString()) - ) { - []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(true){}')(); - } + !Function(${Utils.stringToUnicode(`return/(\\\\[x|u](\\w){2,4})+/`)})().test(func.toString()) ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.True}){}')() : !!!!!![] ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.False}){}')() : []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.False}){}')(); })(); `, NO_CUSTOM_NODES_PRESET) ); diff --git a/src/custom-nodes/unicode-array-nodes/UnicodeArrayCallsWrapper.ts b/src/custom-nodes/unicode-array-nodes/UnicodeArrayCallsWrapper.ts index 628bafd6..526f146b 100644 --- a/src/custom-nodes/unicode-array-nodes/UnicodeArrayCallsWrapper.ts +++ b/src/custom-nodes/unicode-array-nodes/UnicodeArrayCallsWrapper.ts @@ -85,33 +85,12 @@ export class UnicodeArrayCallsWrapper extends Node { * @returns {INode} */ protected getNodeStructure (): INode { - let code: string = '', - environmentName: string = Utils.getRandomVariableName(), - keyName: string = Utils.getRandomVariableName(), + let keyName: string = Utils.getRandomVariableName(), node: INode; - if (this.options['selfDefending']) { - code = ` - var ${environmentName} = function(){return ${Utils.stringToUnicode('production')};}; - - if ( - ${keyName} % ${Utils.getRandomInteger(this.unicodeArray.length / 8, this.unicodeArray.length / 2)} === 0x0 && - ( - Function(${Utils.stringToUnicode(`return/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/`)})()[${Utils.stringToUnicode('test')}]( - ${environmentName}[${Utils.stringToUnicode('toString')}]() - ) === ${JSFuck.True} || ${keyName}++ - ) - ); - - return ${this.unicodeArrayName}[parseInt(${keyName}, 0x010)]; - `; - } else { - code = `return ${this.unicodeArrayName}[parseInt(${keyName}, 0x010)]`; - } - node = esprima.parse(` var ${this.unicodeArrayCallsWrapperName} = function (${keyName}) { - ${code} + return ${this.unicodeArrayName}[parseInt(${keyName}, 0x010)]; }; `); diff --git a/src/custom-nodes/unicode-array-nodes/UnicodeArrayDecodeNode.ts b/src/custom-nodes/unicode-array-nodes/UnicodeArrayDecodeNode.ts index 352d58a6..227cf666 100644 --- a/src/custom-nodes/unicode-array-nodes/UnicodeArrayDecodeNode.ts +++ b/src/custom-nodes/unicode-array-nodes/UnicodeArrayDecodeNode.ts @@ -74,6 +74,7 @@ export class UnicodeArrayDecodeNode extends Node { */ protected getNodeStructure (): INode { const environmentName: string = Utils.getRandomVariableName(), + forLoopFunctionName: string = Utils.getRandomVariableName(), indexVariableName: string = Utils.getRandomVariableName(), tempArrayName: string = Utils.getRandomVariableName(); @@ -83,15 +84,8 @@ export class UnicodeArrayDecodeNode extends Node { if (this.options['selfDefending']) { code = ` var ${environmentName} = function(){return ${Utils.stringToUnicode('dev')};}; - - if ( - ${indexVariableName} % ${Utils.getRandomInteger(this.unicodeArray.length / 8, this.unicodeArray.length / 2)} === 0 && - Function(${Utils.stringToUnicode(`return/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/`)})()[${Utils.stringToUnicode('test')}]( - ${environmentName}[${Utils.stringToUnicode('toString')}]() - ) !== ${JSFuck.True} && ${indexVariableName}++ - ) { - continue; - } + + Function(${Utils.stringToUnicode(`return/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/`)})()[${Utils.stringToUnicode('test')}](${environmentName}[${Utils.stringToUnicode('toString')}]()) !== ${JSFuck.True} && !${this.unicodeArrayName}++ ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.True}){}')() : ${JSFuck.Window}.eval(${forLoopFunctionName}()) ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.False}){}')() : []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.False}){}')(); `; } @@ -118,15 +112,17 @@ export class UnicodeArrayDecodeNode extends Node { })(); `, NO_CUSTOM_NODES_PRESET)} - var ${tempArrayName} = []; + var ${forLoopFunctionName} = function () { + var ${tempArrayName} = []; + + for (var ${indexVariableName} in ${this.unicodeArrayName}) { + ${tempArrayName}[${Utils.stringToUnicode('push')}](decodeURI(atob(${this.unicodeArrayName}[${indexVariableName}]))); + } + + ${this.unicodeArrayName} = ${tempArrayName}; + }; - for (var ${indexVariableName} in ${this.unicodeArrayName}) { - ${code} - - ${tempArrayName}[${Utils.stringToUnicode('push')}](decodeURI(atob(${this.unicodeArrayName}[${indexVariableName}]))); - } - - ${this.unicodeArrayName} = ${tempArrayName}; + ${code} })(); `); diff --git a/src/custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode.ts b/src/custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode.ts index cc610b59..9aa18f27 100644 --- a/src/custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode.ts +++ b/src/custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode.ts @@ -82,7 +82,9 @@ export class UnicodeArrayRotateFunctionNode extends Node { let arrayName: string = Utils.getRandomVariableName(), code: string = '', timesName: string = Utils.getRandomVariableName(), + timesArgumentName: string = Utils.getRandomVariableName(), tempArrayName: string = Utils.getRandomVariableName(), + whileFunctionName: string = Utils.getRandomVariableName(), node: INode; if (this.options['selfDefending']) { @@ -92,13 +94,11 @@ export class UnicodeArrayRotateFunctionNode extends Node { return 'window'; }; - if ( - !Function(${Utils.stringToUnicode(`return/(\\\\[x|u](\\w){2,4})+/`)})().test(func.toString()) - ) { - []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.True}){}')(); - } + !Function(${Utils.stringToUnicode(`return/(\\\\[x|u](\\w){2,4})+/`)})().test(func.toString()) ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.True}){}')() : ${JSFuck.Window}.eval(${whileFunctionName}(${timesName})) ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.False}){}')() : []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.False}){}')(); })(); `, NO_CUSTOM_NODES_PRESET); + } else { + code = `${whileFunctionName}(${timesName})`; } node = esprima.parse(` @@ -109,11 +109,14 @@ export class UnicodeArrayRotateFunctionNode extends Node { var ${tempArrayName}; - while (${timesName}--) { - ${code} - ${tempArrayName} = ${arrayName}[${Utils.stringToUnicode('shift')}](); - ${arrayName}[${Utils.stringToUnicode('push')}](${tempArrayName}); - } + var ${whileFunctionName} = function (${timesArgumentName}) { + while (${timesArgumentName}--) { + ${tempArrayName} = ${arrayName}[${Utils.stringToUnicode('shift')}](); + ${arrayName}[${Utils.stringToUnicode('push')}](${tempArrayName}); + } + }; + + ${code} })(${this.unicodeArrayName}, 0x${Utils.decToHex(this.unicodeArrayRotateValue)}); `); diff --git a/src/enums/JSFuck.ts b/src/enums/JSFuck.ts index 365a12c3..4a0f52d7 100644 --- a/src/enums/JSFuck.ts +++ b/src/enums/JSFuck.ts @@ -1,4 +1,6 @@ export const JSFuck: any = { + Window: '[]["filter"]["constructor"]("return this")()', + False: '![]', True: '!![]',