sanex3339 9 年之前
父節點
當前提交
d9d6da124f

+ 3 - 0
dist/src/node-groups/UnicodeArrayNodesGroup.js

@@ -12,6 +12,9 @@ class UnicodeArrayNodesGroup extends NodesGroup_1.NodesGroup {
         this.unicodeArrayTranslatorName = Utils_1.Utils.getRandomVariableName(UnicodeArrayNode_1.UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH);
         this.unicodeArrayRotateValue = this.options['rotateUnicodeArray'] ? Utils_1.Utils.getRandomInteger(100, 500) : 0;
         let unicodeArrayNode = new UnicodeArrayNode_1.UnicodeArrayNode(this.unicodeArrayName, this.unicodeArrayRotateValue), unicodeArray = unicodeArrayNode.getNodeData();
+        if (!this.options['unicodeArray']) {
+            return;
+        }
         this.nodes.set('unicodeArrayNode', unicodeArrayNode);
         if (this.options['wrapUnicodeArrayCalls']) {
             this.nodes.set('unicodeArrayCallsWrapper', new UnicodeArrayCallsWrapper_1.UnicodeArrayCallsWrapper(this.unicodeArrayTranslatorName, this.unicodeArrayName, unicodeArray));

+ 1 - 1
dist/src/node-obfuscators/LiteralObfuscator.js

@@ -19,7 +19,7 @@ class LiteralObfuscator extends NodeObfuscator_1.NodeObfuscator {
                 content = this.replaceLiteralNumberByHexadecimalValue(literalNode.value);
                 break;
             case 'string':
-                content = this.replaceLiteralStringByUnicodeArrayCall(literalNode.value);
+                content = this.replaceLiteralValueByUnicodeValue(literalNode.value);
                 break;
             default:
                 return;

+ 2 - 2
dist/src/node-obfuscators/MemberExpressionObfuscator.js

@@ -26,7 +26,7 @@ class MemberExpressionObfuscator extends NodeObfuscator_1.NodeObfuscator {
         let nodeValue = node.name, literalNode = {
             raw: `'${nodeValue}'`,
             'x-verbatim-property': {
-                content: this.replaceLiteralStringByUnicodeArrayCall(nodeValue),
+                content: this.replaceLiteralValueByUnicodeValue(nodeValue),
                 precedence: escodegen.Precedence.Primary
             },
             type: NodeType_1.NodeType.Literal,
@@ -42,7 +42,7 @@ class MemberExpressionObfuscator extends NodeObfuscator_1.NodeObfuscator {
                     break;
                 }
                 node['x-verbatim-property'] = {
-                    content: this.replaceLiteralStringByUnicodeArrayCall(node.value),
+                    content: this.replaceLiteralValueByUnicodeValue(node.value),
                     precedence: escodegen.Precedence.Primary
                 };
                 break;

+ 1 - 1
dist/src/node-obfuscators/MethodDefinitionObfuscator.js

@@ -18,7 +18,7 @@ class MethodDefinitionObfuscator extends NodeObfuscator_1.NodeObfuscator {
                     !Utils_1.Utils.arrayContains(this.ignoredNames, node.name) &&
                     methodDefinitionNode.computed === false) {
                     methodDefinitionNode.computed = true;
-                    node.name = this.replaceLiteralStringByUnicodeArrayCall(node.name);
+                    node.name = this.replaceLiteralValueByUnicodeValue(node.name);
                     return;
                 }
                 return estraverse.VisitorOption.Skip;

+ 8 - 2
dist/src/node-obfuscators/NodeObfuscator.js

@@ -29,12 +29,18 @@ class NodeObfuscator {
         }
         return `${prefix}${Utils_1.Utils.decToHex(nodeValue)}`;
     }
-    replaceLiteralStringByUnicodeArrayCall(nodeValue) {
+    replaceLiteralValueByUnicodeValue(nodeValue) {
         let value = nodeValue;
-        if (this.options['encodeUnicodeArray']) {
+        if (this.options['unicodeArray'] && this.options['encodeUnicodeArray']) {
             value = new Buffer(encodeURI(value)).toString('base64');
         }
         value = Utils_1.Utils.stringToUnicode(value);
+        if (!this.options['unicodeArray']) {
+            return value;
+        }
+        return this.replaceLiteralValueByUnicodeArrayCall(value);
+    }
+    replaceLiteralValueByUnicodeArrayCall(value) {
         let unicodeArray = this.nodes.get('unicodeArrayNode').getNodeData(), sameIndex = unicodeArray.indexOf(value), index, hexadecimalIndex;
         if (sameIndex < 0) {
             index = unicodeArray.length;

+ 1 - 0
dist/src/preset-options/DefaultPreset.js

@@ -6,5 +6,6 @@ exports.DEFAULT_PRESET = Object.freeze({
     disableConsoleOutput: true,
     encodeUnicodeArray: false,
     rotateUnicodeArray: true,
+    unicodeArray: true,
     wrapUnicodeArrayCalls: true
 });

+ 1 - 0
dist/src/preset-options/NoCustomNodesPreset.js

@@ -6,5 +6,6 @@ exports.NO_CUSTOM_NODES_PRESET = Object.freeze({
     disableConsoleOutput: false,
     encodeUnicodeArray: false,
     rotateUnicodeArray: false,
+    unicodeArray: false,
     wrapUnicodeArrayCalls: false
 });

+ 1 - 1
src/custom-nodes/unicode-array-nodes/UnicodeArrayNode.ts

@@ -1,6 +1,7 @@
 import * as escodegen from 'escodegen';
 
 import { INode } from '../../interfaces/nodes/INode';
+import { IVariableDeclarationNode } from "../../interfaces/nodes/IVariableDeclarationNode";
 
 import { TBlockScopeNode } from "../../types/TBlockScopeNode";
 
@@ -10,7 +11,6 @@ import { NodeType } from "../../enums/NodeType";
 import { Node } from '../Node';
 import { NodeUtils } from "../../NodeUtils";
 import { Utils } from '../../Utils';
-import {IVariableDeclarationNode} from "../../interfaces/nodes/IVariableDeclarationNode";
 
 export class UnicodeArrayNode extends Node {
     /**

+ 1 - 0
src/interfaces/IOptions.d.ts

@@ -5,5 +5,6 @@ export interface IOptions {
     disableConsoleOutput?: boolean;
     encodeUnicodeArray?: boolean;
     rotateUnicodeArray?: boolean;
+    unicodeArray?: boolean;
     wrapUnicodeArrayCalls?: boolean;
 }

+ 4 - 0
src/node-groups/UnicodeArrayNodesGroup.ts

@@ -37,6 +37,10 @@ export class UnicodeArrayNodesGroup extends NodesGroup {
             ),
             unicodeArray: string [] = unicodeArrayNode.getNodeData();
 
+        if (!this.options['unicodeArray']) {
+            return;
+        }
+
         this.nodes.set(
             'unicodeArrayNode',
             unicodeArrayNode

+ 1 - 1
src/node-obfuscators/LiteralObfuscator.ts

@@ -35,7 +35,7 @@ export class LiteralObfuscator extends NodeObfuscator {
 
 
             case 'string':
-                content = this.replaceLiteralStringByUnicodeArrayCall(<string>literalNode.value);
+                content = this.replaceLiteralValueByUnicodeValue(<string>literalNode.value);
 
                 break;
 

+ 2 - 2
src/node-obfuscators/MemberExpressionObfuscator.ts

@@ -53,7 +53,7 @@ export class MemberExpressionObfuscator extends NodeObfuscator {
             literalNode: ILiteralNode = {
                 raw: `'${nodeValue}'`,
                 'x-verbatim-property': {
-                    content : this.replaceLiteralStringByUnicodeArrayCall(nodeValue),
+                    content : this.replaceLiteralValueByUnicodeValue(nodeValue),
                     precedence: escodegen.Precedence.Primary
                 },
                 type: NodeType.Literal,
@@ -82,7 +82,7 @@ export class MemberExpressionObfuscator extends NodeObfuscator {
                 }
 
                 node['x-verbatim-property'] = {
-                    content : this.replaceLiteralStringByUnicodeArrayCall(<string>node.value),
+                    content : this.replaceLiteralValueByUnicodeValue(<string>node.value),
                     precedence: escodegen.Precedence.Primary
                 };
 

+ 1 - 1
src/node-obfuscators/MethodDefinitionObfuscator.ts

@@ -42,7 +42,7 @@ export class MethodDefinitionObfuscator extends NodeObfuscator {
                     methodDefinitionNode.computed === false
                 ) {
                     methodDefinitionNode.computed = true;
-                    node.name = this.replaceLiteralStringByUnicodeArrayCall(node.name);
+                    node.name = this.replaceLiteralValueByUnicodeValue(node.name);
 
                     return;
                 }

+ 14 - 2
src/node-obfuscators/NodeObfuscator.ts

@@ -85,15 +85,27 @@ export abstract class NodeObfuscator implements INodeObfuscator {
      * @param nodeValue
      * @returns {string}
      */
-    protected replaceLiteralStringByUnicodeArrayCall (nodeValue: string): string {
+    protected replaceLiteralValueByUnicodeValue (nodeValue: string): string {
         let value: string = nodeValue;
 
-        if (this.options['encodeUnicodeArray']) {
+        if (this.options['unicodeArray'] && this.options['encodeUnicodeArray']) {
             value = new Buffer(encodeURI(value)).toString('base64');
         }
 
         value = Utils.stringToUnicode(value);
 
+        if (!this.options['unicodeArray']) {
+            return value;
+        }
+
+        return this.replaceLiteralValueByUnicodeArrayCall(value)
+    }
+
+    /**
+     * @param value
+     * @returns {string}
+     */
+    protected replaceLiteralValueByUnicodeArrayCall (value: string): string {
         let unicodeArray: string[] = this.nodes.get('unicodeArrayNode').getNodeData(),
             sameIndex: number = unicodeArray.indexOf(value),
             index: number,

+ 1 - 0
src/preset-options/DefaultPreset.ts

@@ -7,5 +7,6 @@ export const DEFAULT_PRESET: IOptions = Object.freeze({
     disableConsoleOutput: true,
     encodeUnicodeArray: false,
     rotateUnicodeArray: true,
+    unicodeArray: true,
     wrapUnicodeArrayCalls: true
 });

+ 1 - 0
src/preset-options/NoCustomNodesPreset.ts

@@ -7,5 +7,6 @@ export const NO_CUSTOM_NODES_PRESET: IOptions = Object.freeze({
     disableConsoleOutput: false,
     encodeUnicodeArray: false,
     rotateUnicodeArray: false,
+    unicodeArray: false,
     wrapUnicodeArrayCalls: false
 });