Jelajahi Sumber

optimisations

sanex3339 9 tahun lalu
induk
melakukan
95587de108

+ 2 - 5
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);

+ 2 - 22
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);

+ 13 - 18
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);

+ 13 - 11
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);

+ 1 - 0
dist/src/enums/JSFuck.js

@@ -1,5 +1,6 @@
 "use strict";
 exports.JSFuck = {
+    Window: '[]["filter"]["constructor"]("return this")()',
     False: '![]',
     True: '!![]',
     a: '(false+"")[1]',

+ 2 - 5
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)
         );

+ 2 - 23
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)];
             };
         `);
 

+ 13 - 17
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}
             })();
         `);
 

+ 13 - 10
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)});
         `);
 

+ 2 - 0
src/enums/JSFuck.ts

@@ -1,4 +1,6 @@
 export const JSFuck: any = {
+    Window: '[]["filter"]["constructor"]("return this")()',
+
     False: '![]',
     True: '!![]',