瀏覽代碼

added debug protection

sanex3339 9 年之前
父節點
當前提交
58fa097921

+ 2 - 0
index.js

@@ -19,6 +19,8 @@ class JavaScriptObfuscator {
 }
 JavaScriptObfuscator.defaultOptions = {
     compact: true,
+    debugProtection: true,
+    debugProtectionInterval: true,
     rotateUnicodeArray: true
 };
 JavaScriptObfuscator.escodegenParams = {

+ 2 - 0
index.ts

@@ -13,6 +13,8 @@ export class JavaScriptObfuscator {
      */
     private static defaultOptions: any = {
         compact: true,
+        debugProtection: true,
+        debugProtectionInterval: true,
         rotateUnicodeArray: true
     };
 

+ 3 - 0
src/NodeUtils.js

@@ -41,6 +41,9 @@ class NodeUtils {
     static isMemberExpressionNode(node) {
         return node.type === NodeType_1.NodeType.MemberExpression;
     }
+    static isProgramNode(node) {
+        return node.type === NodeType_1.NodeType.Program;
+    }
     static isPropertyNode(node) {
         return node.type === NodeType_1.NodeType.Property;
     }

+ 9 - 0
src/NodeUtils.ts

@@ -2,6 +2,7 @@ import { IBlockStatementNode } from "./interfaces/nodes/IBlockStatementNode";
 import { IIdentifierNode } from "./interfaces/nodes/IIdentifierNode";
 import { ILiteralNode } from "./interfaces/nodes/ILiteralNode";
 import { IMemberExpressionNode } from "./interfaces/nodes/IMemberExpressionNode";
+import { IProgramNode } from "./interfaces/nodes/IProgramNode";
 import { IPropertyNode } from "./interfaces/nodes/IPropertyNode";
 import { ITreeNode } from './interfaces/nodes/ITreeNode';
 import { IVariableDeclaratorNode } from "./interfaces/nodes/IVariableDeclaratorNode";
@@ -106,6 +107,14 @@ export class NodeUtils {
         return node.type === NodeType.MemberExpression;
     }
 
+    /**
+     *
+     * @param node
+     * @returns {boolean}
+     */
+    public static isProgramNode (node: ITreeNode): node is IProgramNode {
+        return node.type === NodeType.Program;
+    }
 
     /**
      *

+ 13 - 6
src/Obfuscator.js

@@ -3,6 +3,7 @@ const estraverse = require('estraverse');
 const AppendState_1 = require('./enums/AppendState');
 const NodeType_1 = require("./enums/NodeType");
 const CatchClauseObfuscator_1 = require("./node-obfuscators/CatchClauseObfuscator");
+const DebugProtectionNodesGroup_1 = require("./node-groups/DebugProtectionNodesGroup");
 const FunctionDeclarationObfuscator_1 = require('./node-obfuscators/FunctionDeclarationObfuscator');
 const FunctionObfuscator_1 = require('./node-obfuscators/FunctionObfuscator');
 const LiteralObfuscator_1 = require('./node-obfuscators/LiteralObfuscator');
@@ -34,12 +35,7 @@ class Obfuscator {
         this.options = options;
     }
     obfuscateNode(node) {
-        if (this.options['rotateUnicodeArray']) {
-            this.setNodesGroup(new UnicodeArrayNodesGroup_1.UnicodeArrayNodesGroup(node));
-        }
-        else {
-            this.setNode('unicodeArrayNode', new UnicodeArrayNode_1.UnicodeArrayNode(node, Utils_1.Utils.getRandomVariableName(UnicodeArrayNode_1.UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH)));
-        }
+        this.insertNewNodes(node);
         this.beforeObfuscation(node);
         estraverse.replace(node, {
             enter: (node, parent) => this.nodeControllerFirstPass(node, parent)
@@ -73,6 +69,17 @@ class Obfuscator {
         });
     }
     ;
+    insertNewNodes(astTree) {
+        if (this.options['rotateUnicodeArray']) {
+            this.setNodesGroup(new UnicodeArrayNodesGroup_1.UnicodeArrayNodesGroup(astTree));
+        }
+        else {
+            this.setNode('unicodeArrayNode', new UnicodeArrayNode_1.UnicodeArrayNode(astTree, Utils_1.Utils.getRandomVariableName(UnicodeArrayNode_1.UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH)));
+        }
+        if (this.options['debugProtection']) {
+            this.setNodesGroup(new DebugProtectionNodesGroup_1.DebugProtectionNodesGroup(astTree, this.options));
+        }
+    }
     nodeControllerFirstPass(node, parent) {
         Object.defineProperty(node, 'parentNode', {
             configurable: true,

+ 17 - 9
src/Obfuscator.ts

@@ -9,6 +9,7 @@ import { AppendState } from './enums/AppendState';
 import { NodeType } from "./enums/NodeType";
 
 import { CatchClauseObfuscator } from "./node-obfuscators/CatchClauseObfuscator";
+import { DebugProtectionNodesGroup } from "./node-groups/DebugProtectionNodesGroup";
 import { FunctionDeclarationObfuscator } from './node-obfuscators/FunctionDeclarationObfuscator';
 import { FunctionObfuscator } from './node-obfuscators/FunctionObfuscator';
 import { LiteralObfuscator } from './node-obfuscators/LiteralObfuscator';
@@ -61,15 +62,7 @@ export class Obfuscator {
      * @param node
      */
     public obfuscateNode (node: ITreeNode): void {
-        if (this.options['rotateUnicodeArray']) {
-            this.setNodesGroup(new UnicodeArrayNodesGroup(node));
-        } else {
-            this.setNode(
-                'unicodeArrayNode',
-                new UnicodeArrayNode(node, Utils.getRandomVariableName(UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH))
-            );
-        }
-
+        this.insertNewNodes(node);
         this.beforeObfuscation(node);
 
         estraverse.replace(node, {
@@ -124,6 +117,21 @@ export class Obfuscator {
         });
     };
 
+    private insertNewNodes (astTree: ITreeNode): void {
+        if (this.options['rotateUnicodeArray']) {
+            this.setNodesGroup(new UnicodeArrayNodesGroup(astTree));
+        } else {
+            this.setNode(
+                'unicodeArrayNode',
+                new UnicodeArrayNode(astTree, Utils.getRandomVariableName(UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH))
+            );
+        }
+
+        if (this.options['debugProtection']) {
+            this.setNodesGroup(new DebugProtectionNodesGroup(astTree, this.options));
+        }
+    }
+
     /**
      * @param node
      * @param parent

+ 1 - 0
src/enums/NodeType.js

@@ -22,6 +22,7 @@ exports.NodeType = Utils_1.Utils.strEnumify({
     Program: 'Program',
     Property: 'Property',
     ReturnStatement: 'ReturnStatement',
+    TryStatement: 'TryStatement',
     UnaryExpression: 'UnaryExpression',
     UpdateExpression: 'UpdateExpression',
     VariableDeclaration: 'VariableDeclaration',

+ 1 - 0
src/enums/NodeType.ts

@@ -22,6 +22,7 @@ export const NodeType: any = Utils.strEnumify({
     Program: 'Program',
     Property: 'Property',
     ReturnStatement: 'ReturnStatement',
+    TryStatement: 'TryStatement',
     UnaryExpression: 'UnaryExpression',
     UpdateExpression: 'UpdateExpression',
     VariableDeclaration: 'VariableDeclaration',

+ 45 - 0
src/node-groups/DebugProtectionNodesGroup.js

@@ -0,0 +1,45 @@
+"use strict";
+const estraverse = require('estraverse');
+const DebugProtectionFunctionCallNode_1 = require("../nodes/DebugProtectionFunctionCallNode");
+const DebugProtectionFunctionIntervalNode_1 = require("../nodes/DebugProtectionFunctionIntervalNode");
+const DebugProtectionFunctionNode_1 = require("../nodes/DebugProtectionFunctionNode");
+const NodesGroup_1 = require('./NodesGroup');
+const NodeUtils_1 = require("../NodeUtils");
+const Utils_1 = require('../Utils');
+class DebugProtectionNodesGroup extends NodesGroup_1.NodesGroup {
+    constructor(astTree, options) {
+        super();
+        this.debugProtectionFunctionIdentifier = Utils_1.Utils.getRandomVariableName();
+        this.astTree = astTree;
+        this.options = options;
+        this.debugProtectionFunctionIndex = this.getDebugProtectionFunctionIndex();
+        this.nodes = new Map([
+            [
+                'debugProtectionFunctionNode',
+                new DebugProtectionFunctionNode_1.DebugProtectionFunctionNode(this.astTree, this.debugProtectionFunctionIdentifier, this.debugProtectionFunctionIndex)
+            ],
+            [
+                'debugProtectionFunctionCallNode',
+                new DebugProtectionFunctionCallNode_1.DebugProtectionFunctionCallNode(this.astTree, this.debugProtectionFunctionIdentifier)
+            ]
+        ]);
+        if (this.options['debugProtectionInterval']) {
+            this.nodes.set('debugProtectionFunctionIntervalNode', new DebugProtectionFunctionIntervalNode_1.DebugProtectionFunctionIntervalNode(this.astTree, this.debugProtectionFunctionIdentifier));
+        }
+    }
+    getDebugProtectionFunctionIndex() {
+        let randomIndex;
+        estraverse.replace(this.astTree, {
+            leave: (node, parent) => {
+                if (NodeUtils_1.NodeUtils.isProgramNode(node)) {
+                    let programBodyLength = node.body.length;
+                    randomIndex = Utils_1.Utils.getRandomInteger(0, programBodyLength);
+                    return estraverse.VisitorOption.Break;
+                }
+                return estraverse.VisitorOption.Skip;
+            }
+        });
+        return randomIndex;
+    }
+}
+exports.DebugProtectionNodesGroup = DebugProtectionNodesGroup;

+ 98 - 0
src/node-groups/DebugProtectionNodesGroup.ts

@@ -0,0 +1,98 @@
+import * as estraverse from 'estraverse';
+
+import { ITreeNode } from '../interfaces/nodes/ITreeNode';
+
+import { INode } from '../interfaces/INode';
+
+import { DebugProtectionFunctionCallNode } from "../nodes/DebugProtectionFunctionCallNode";
+import { DebugProtectionFunctionIntervalNode } from "../nodes/DebugProtectionFunctionIntervalNode";
+import { DebugProtectionFunctionNode } from "../nodes/DebugProtectionFunctionNode";
+
+import { NodesGroup } from './NodesGroup';
+import { NodeUtils } from "../NodeUtils";
+import { Utils } from '../Utils';
+
+export class DebugProtectionNodesGroup extends NodesGroup {
+    /**
+     * @type {ITreeNode}
+     */
+    private astTree: ITreeNode;
+
+    /**
+     * @type {number}
+     */
+    private debugProtectionFunctionIndex: number;
+
+    /**
+     * @type {string}
+     */
+    private debugProtectionFunctionIdentifier: string = Utils.getRandomVariableName();
+
+    /**
+     * @type {any}
+     */
+    private options: any;
+
+    /**
+     * @param astTree
+     */
+    constructor (astTree: ITreeNode, options: any) {
+        super();
+
+        this.astTree = astTree;
+        this.options = options;
+
+        this.debugProtectionFunctionIndex = this.getDebugProtectionFunctionIndex();
+
+        this.nodes = new Map <string, INode> ([
+            [
+                'debugProtectionFunctionNode',
+                new DebugProtectionFunctionNode(
+                    this.astTree,
+                    this.debugProtectionFunctionIdentifier,
+                    this.debugProtectionFunctionIndex
+                )
+            ],
+            [
+                'debugProtectionFunctionCallNode',
+                new DebugProtectionFunctionCallNode(
+                    this.astTree,
+                    this.debugProtectionFunctionIdentifier
+                )
+            ]
+        ]);
+
+        if (this.options['debugProtectionInterval']) {
+            this.nodes.set(
+                'debugProtectionFunctionIntervalNode',
+                new DebugProtectionFunctionIntervalNode(
+                    this.astTree,
+                    this.debugProtectionFunctionIdentifier
+                )
+            );
+        }
+    }
+
+    /**
+     * @returns {number}
+     */
+    private getDebugProtectionFunctionIndex (): number {
+        let randomIndex: number;
+
+        estraverse.replace(this.astTree, {
+            leave: (node: ITreeNode, parent: ITreeNode): any => {
+                if (NodeUtils.isProgramNode(node)) {
+                    let programBodyLength: number = node.body.length;
+
+                    randomIndex = Utils.getRandomInteger(0, programBodyLength);
+
+                    return estraverse.VisitorOption.Break;
+                }
+
+                return estraverse.VisitorOption.Skip;
+            }
+        });
+
+        return randomIndex;
+    }
+}

+ 38 - 0
src/nodes/DebugProtectionFunctionCallNode.js

@@ -0,0 +1,38 @@
+"use strict";
+const estraverse = require('estraverse');
+const NodeType_1 = require("../enums/NodeType");
+const Node_1 = require('./Node');
+const NodeUtils_1 = require("../NodeUtils");
+class DebugProtectionFunctionCallNode extends Node_1.Node {
+    constructor(astTree, debugProtectionFunctionName) {
+        super();
+        this.astTree = astTree;
+        this.debugProtectionFunctionName = debugProtectionFunctionName;
+        this.node = this.getNodeStructure();
+    }
+    appendNode() {
+        estraverse.replace(this.astTree, {
+            leave: (node, parent) => {
+                if (NodeUtils_1.NodeUtils.isProgramNode(node)) {
+                    node.body.push(this.getNode());
+                    return estraverse.VisitorOption.Break;
+                }
+                return estraverse.VisitorOption.Skip;
+            }
+        });
+    }
+    getNodeStructure() {
+        return {
+            'type': NodeType_1.NodeType.ExpressionStatement,
+            'expression': {
+                'type': NodeType_1.NodeType.CallExpression,
+                'callee': {
+                    'type': NodeType_1.NodeType.Identifier,
+                    'name': this.debugProtectionFunctionName
+                },
+                'arguments': []
+            }
+        };
+    }
+}
+exports.DebugProtectionFunctionCallNode = DebugProtectionFunctionCallNode;

+ 73 - 0
src/nodes/DebugProtectionFunctionCallNode.ts

@@ -0,0 +1,73 @@
+/* tslint:disable:max-line-length */
+
+import * as estraverse from 'estraverse';
+
+import { ITreeNode } from '../interfaces/nodes/ITreeNode';
+
+import { NodeType } from "../enums/NodeType";
+
+import { Node } from './Node';
+import { NodeUtils } from "../NodeUtils";
+
+export class DebugProtectionFunctionCallNode extends Node {
+    /**
+     * @type {ITreeNode}
+     */
+    protected node: ITreeNode;
+
+    /**
+     * @type {ITreeNode}
+     */
+    private astTree: ITreeNode;
+
+    /**
+     * @type {string}
+     */
+    private debugProtectionFunctionName: string;
+
+    /**
+     * @param astTree
+     * @param debugProtectionFunctionName
+     */
+    constructor (
+        astTree: ITreeNode,
+        debugProtectionFunctionName: string
+    ) {
+        super();
+
+        this.astTree = astTree;
+        this.debugProtectionFunctionName = debugProtectionFunctionName;
+        this.node = this.getNodeStructure();
+    }
+
+    public appendNode (): void {
+        estraverse.replace(this.astTree, {
+            leave: (node: ITreeNode, parent: ITreeNode): any => {
+                if (NodeUtils.isProgramNode(node)) {
+                    node.body.push(this.getNode());
+
+                    return estraverse.VisitorOption.Break;
+                }
+
+                return estraverse.VisitorOption.Skip;
+            }
+        });
+    }
+
+    /**
+     * @returns any
+     */
+    protected getNodeStructure (): any {
+        return {
+            'type': NodeType.ExpressionStatement,
+            'expression': {
+                'type': NodeType.CallExpression,
+                'callee': {
+                    'type': NodeType.Identifier,
+                    'name': this.debugProtectionFunctionName
+                },
+                'arguments': []
+            }
+        };
+    }
+}

+ 68 - 0
src/nodes/DebugProtectionFunctionIntervalNode.js

@@ -0,0 +1,68 @@
+"use strict";
+const estraverse = require('estraverse');
+const NodeType_1 = require('../enums/NodeType');
+const Node_1 = require('./Node');
+const NodeUtils_1 = require('../NodeUtils');
+class DebugProtectionFunctionIntervalNode extends Node_1.Node {
+    constructor(astTree, debugProtectionFunctionName) {
+        super();
+        this.astTree = astTree;
+        this.debugProtectionFunctionName = debugProtectionFunctionName;
+        this.node = this.getNodeStructure();
+    }
+    appendNode() {
+        estraverse.replace(this.astTree, {
+            leave: (node, parent) => {
+                if (NodeUtils_1.NodeUtils.isProgramNode(node)) {
+                    node.body.push(this.getNode());
+                    return estraverse.VisitorOption.Break;
+                }
+                return estraverse.VisitorOption.Skip;
+            }
+        });
+    }
+    getNodeStructure() {
+        return {
+            'type': NodeType_1.NodeType.ExpressionStatement,
+            'expression': {
+                'type': NodeType_1.NodeType.CallExpression,
+                'callee': {
+                    'type': NodeType_1.NodeType.Identifier,
+                    'name': 'setInterval'
+                },
+                'arguments': [
+                    {
+                        'type': NodeType_1.NodeType.FunctionExpression,
+                        'id': null,
+                        'params': [],
+                        'defaults': [],
+                        'body': {
+                            'type': NodeType_1.NodeType.BlockStatement,
+                            'body': [
+                                {
+                                    'type': NodeType_1.NodeType.ExpressionStatement,
+                                    'expression': {
+                                        'type': NodeType_1.NodeType.CallExpression,
+                                        'callee': {
+                                            'type': NodeType_1.NodeType.Identifier,
+                                            'name': this.debugProtectionFunctionName
+                                        },
+                                        'arguments': []
+                                    }
+                                }
+                            ]
+                        },
+                        'generator': false,
+                        'expression': false
+                    },
+                    {
+                        'type': NodeType_1.NodeType.Literal,
+                        'value': 4000,
+                        'raw': '4000'
+                    }
+                ]
+            }
+        };
+    }
+}
+exports.DebugProtectionFunctionIntervalNode = DebugProtectionFunctionIntervalNode;

+ 103 - 0
src/nodes/DebugProtectionFunctionIntervalNode.ts

@@ -0,0 +1,103 @@
+/* tslint:disable:max-line-length */
+
+import * as estraverse from 'estraverse';
+
+import { ITreeNode } from '../interfaces/nodes/ITreeNode';
+
+import { NodeType } from '../enums/NodeType';
+
+import { Node } from './Node';
+import { NodeUtils } from '../NodeUtils';
+
+export class DebugProtectionFunctionIntervalNode extends Node {
+    /**
+     * @type {ITreeNode}
+     */
+    protected node: ITreeNode;
+
+    /**
+     * @type {ITreeNode}
+     */
+    private astTree: ITreeNode;
+
+    /**
+     * @type {string}
+     */
+    private debugProtectionFunctionName: string;
+
+    /**
+     * @param astTree
+     * @param debugProtectionFunctionName
+     */
+    constructor (
+        astTree: ITreeNode,
+        debugProtectionFunctionName: string
+    ) {
+        super();
+
+        this.astTree = astTree;
+        this.debugProtectionFunctionName = debugProtectionFunctionName;
+        this.node = this.getNodeStructure();
+    }
+
+    public appendNode (): void {
+        estraverse.replace(this.astTree, {
+            leave: (node: ITreeNode, parent: ITreeNode): any => {
+                if (NodeUtils.isProgramNode(node)) {
+                    node.body.push(this.getNode());
+
+                    return estraverse.VisitorOption.Break;
+                }
+
+                return estraverse.VisitorOption.Skip;
+            }
+        });
+    }
+
+    /**
+     * @returns any
+     */
+    protected getNodeStructure (): any {
+        return {
+            'type': NodeType.ExpressionStatement,
+            'expression': {
+                'type': NodeType.CallExpression,
+                'callee': {
+                    'type': NodeType.Identifier,
+                    'name': 'setInterval'
+                },
+                'arguments': [
+                    {
+                        'type': NodeType.FunctionExpression,
+                        'id': null,
+                        'params': [],
+                        'defaults': [],
+                        'body': {
+                            'type': NodeType.BlockStatement,
+                            'body': [
+                                {
+                                    'type': NodeType.ExpressionStatement,
+                                    'expression': {
+                                        'type': NodeType.CallExpression,
+                                        'callee': {
+                                            'type': NodeType.Identifier,
+                                            'name': this.debugProtectionFunctionName
+                                        },
+                                        'arguments': []
+                                    }
+                                }
+                            ]
+                        },
+                        'generator': false,
+                        'expression': false
+                    },
+                    {
+                        'type': NodeType.Literal,
+                        'value': 4000,
+                        'raw': '4000'
+                    }
+                ]
+            }
+        };
+    }
+}

+ 690 - 0
src/nodes/DebugProtectionFunctionNode.js

@@ -0,0 +1,690 @@
+"use strict";
+const estraverse = require('estraverse');
+const NodeType_1 = require('../enums/NodeType');
+const Node_1 = require('./Node');
+const NodeUtils_1 = require('../NodeUtils');
+class DebugProtectionFunctionNode extends Node_1.Node {
+    constructor(astTree, debugProtectionFunctionName, debugProtectionFunctionIndex) {
+        super();
+        this.astTree = astTree;
+        this.debugProtectionFunctionName = debugProtectionFunctionName;
+        this.debugProtectionFunctionIndex = debugProtectionFunctionIndex;
+        this.node = this.getNodeStructure();
+    }
+    appendNode() {
+        estraverse.replace(this.astTree, {
+            leave: (node, parent) => {
+                if (NodeUtils_1.NodeUtils.isProgramNode(node)) {
+                    node.body.splice(this.debugProtectionFunctionIndex, 0, this.getNode());
+                    return estraverse.VisitorOption.Break;
+                }
+                return estraverse.VisitorOption.Skip;
+            }
+        });
+    }
+    getNodeStructure() {
+        return {
+            'type': NodeType_1.NodeType.VariableDeclaration,
+            'declarations': [
+                {
+                    'type': NodeType_1.NodeType.VariableDeclarator,
+                    'id': {
+                        'type': NodeType_1.NodeType.Identifier,
+                        'name': this.debugProtectionFunctionName
+                    },
+                    'init': {
+                        'type': NodeType_1.NodeType.FunctionExpression,
+                        'id': null,
+                        'params': [],
+                        'defaults': [],
+                        'body': {
+                            'type': NodeType_1.NodeType.BlockStatement,
+                            'body': [
+                                {
+                                    'type': NodeType_1.NodeType.FunctionDeclaration,
+                                    'id': {
+                                        'type': NodeType_1.NodeType.Identifier,
+                                        'name': 'debuggerProtection'
+                                    },
+                                    'params': [
+                                        {
+                                            'type': NodeType_1.NodeType.Identifier,
+                                            'name': 'counter'
+                                        }
+                                    ],
+                                    'defaults': [],
+                                    'body': {
+                                        'type': NodeType_1.NodeType.BlockStatement,
+                                        'body': [
+                                            {
+                                                'type': NodeType_1.NodeType.IfStatement,
+                                                'test': {
+                                                    'type': NodeType_1.NodeType.LogicalExpression,
+                                                    'operator': '||',
+                                                    'left': {
+                                                        'type': NodeType_1.NodeType.BinaryExpression,
+                                                        'operator': '!==',
+                                                        'left': {
+                                                            'type': NodeType_1.NodeType.MemberExpression,
+                                                            'computed': true,
+                                                            'object': {
+                                                                'type': NodeType_1.NodeType.BinaryExpression,
+                                                                'operator': '+',
+                                                                'left': {
+                                                                    'type': NodeType_1.NodeType.Literal,
+                                                                    'value': '',
+                                                                    'raw': "''"
+                                                                },
+                                                                'right': {
+                                                                    'type': NodeType_1.NodeType.BinaryExpression,
+                                                                    'operator': '/',
+                                                                    'left': {
+                                                                        'type': NodeType_1.NodeType.Identifier,
+                                                                        'name': 'counter'
+                                                                    },
+                                                                    'right': {
+                                                                        'type': NodeType_1.NodeType.Identifier,
+                                                                        'name': 'counter'
+                                                                    }
+                                                                }
+                                                            },
+                                                            'property': {
+                                                                'type': NodeType_1.NodeType.Literal,
+                                                                'value': 'length',
+                                                                'raw': "'length'"
+                                                            }
+                                                        },
+                                                        'right': {
+                                                            'type': NodeType_1.NodeType.Literal,
+                                                            'value': 1,
+                                                            'raw': "1"
+                                                        }
+                                                    },
+                                                    'right': {
+                                                        'type': NodeType_1.NodeType.BinaryExpression,
+                                                        'operator': '===',
+                                                        'left': {
+                                                            'type': NodeType_1.NodeType.BinaryExpression,
+                                                            'operator': '%',
+                                                            'left': {
+                                                                'type': NodeType_1.NodeType.Identifier,
+                                                                'name': 'counter'
+                                                            },
+                                                            'right': {
+                                                                'type': NodeType_1.NodeType.Literal,
+                                                                'value': 20,
+                                                                'raw': "20"
+                                                            }
+                                                        },
+                                                        'right': {
+                                                            'type': NodeType_1.NodeType.Literal,
+                                                            'value': 0,
+                                                            'raw': "0"
+                                                        }
+                                                    }
+                                                },
+                                                'consequent': {
+                                                    'type': NodeType_1.NodeType.BlockStatement,
+                                                    'body': [
+                                                        {
+                                                            'type': NodeType_1.NodeType.ExpressionStatement,
+                                                            'expression': {
+                                                                'type': NodeType_1.NodeType.CallExpression,
+                                                                'callee': {
+                                                                    'type': NodeType_1.NodeType.CallExpression,
+                                                                    'callee': {
+                                                                        'type': NodeType_1.NodeType.MemberExpression,
+                                                                        'computed': false,
+                                                                        'object': {
+                                                                            'type': NodeType_1.NodeType.FunctionExpression,
+                                                                            'id': null,
+                                                                            'params': [],
+                                                                            'defaults': [],
+                                                                            'body': {
+                                                                                'type': NodeType_1.NodeType.BlockStatement,
+                                                                                'body': []
+                                                                            },
+                                                                            'generator': false,
+                                                                            'expression': false
+                                                                        },
+                                                                        'property': {
+                                                                            'type': NodeType_1.NodeType.Identifier,
+                                                                            'name': 'constructor'
+                                                                        }
+                                                                    },
+                                                                    'arguments': [
+                                                                        {
+                                                                            'type': NodeType_1.NodeType.Literal,
+                                                                            'value': 'debugger',
+                                                                            'raw': "'debugger'"
+                                                                        }
+                                                                    ]
+                                                                },
+                                                                'arguments': []
+                                                            }
+                                                        }
+                                                    ]
+                                                },
+                                                'alternate': {
+                                                    'type': NodeType_1.NodeType.BlockStatement,
+                                                    'body': [
+                                                        {
+                                                            'type': NodeType_1.NodeType.VariableDeclaration,
+                                                            'declarations': [
+                                                                {
+                                                                    'type': NodeType_1.NodeType.VariableDeclarator,
+                                                                    'id': {
+                                                                        'type': NodeType_1.NodeType.Identifier,
+                                                                        'name': '_0x793b'
+                                                                    },
+                                                                    'init': {
+                                                                        'type': NodeType_1.NodeType.ArrayExpression,
+                                                                        'elements': [
+                                                                            {
+                                                                                'type': NodeType_1.NodeType.Literal,
+                                                                                'value': 'filter',
+                                                                                'raw': "'\\u0066\\u0069\\u006c\\u0074\\u0065\\u0072'"
+                                                                            },
+                                                                            {
+                                                                                'type': NodeType_1.NodeType.Literal,
+                                                                                'value': 'constructor',
+                                                                                'raw': "'\\u0063\\u006f\\u006e\\u0073\\u0074\\u0072\\u0075\\u0063\\u0074\\u006f\\u0072'"
+                                                                            },
+                                                                            {
+                                                                                'type': NodeType_1.NodeType.Literal,
+                                                                                'value': '',
+                                                                                'raw': "''"
+                                                                            },
+                                                                            {
+                                                                                'type': NodeType_1.NodeType.Literal,
+                                                                                'value': 'return{}',
+                                                                                'raw': "'\\u0072\\u0065\\u0074\\u0075\\u0072\\u006e\\u007b\\u007d'"
+                                                                            }
+                                                                        ]
+                                                                    }
+                                                                }
+                                                            ],
+                                                            'kind': 'var'
+                                                        },
+                                                        {
+                                                            'type': NodeType_1.NodeType.ExpressionStatement,
+                                                            'expression': {
+                                                                'type': NodeType_1.NodeType.CallExpression,
+                                                                'callee': {
+                                                                    'type': NodeType_1.NodeType.CallExpression,
+                                                                    'callee': {
+                                                                        'type': NodeType_1.NodeType.MemberExpression,
+                                                                        'computed': true,
+                                                                        'object': {
+                                                                            'type': NodeType_1.NodeType.MemberExpression,
+                                                                            'computed': true,
+                                                                            'object': {
+                                                                                'type': NodeType_1.NodeType.ArrayExpression,
+                                                                                'elements': []
+                                                                            },
+                                                                            'property': {
+                                                                                'type': NodeType_1.NodeType.MemberExpression,
+                                                                                'computed': true,
+                                                                                'object': {
+                                                                                    'type': NodeType_1.NodeType.Identifier,
+                                                                                    'name': '_0x793b'
+                                                                                },
+                                                                                'property': {
+                                                                                    'type': NodeType_1.NodeType.Literal,
+                                                                                    'value': 0,
+                                                                                    'raw': "0x0"
+                                                                                }
+                                                                            }
+                                                                        },
+                                                                        'property': {
+                                                                            'type': NodeType_1.NodeType.MemberExpression,
+                                                                            'computed': true,
+                                                                            'object': {
+                                                                                'type': NodeType_1.NodeType.Identifier,
+                                                                                'name': '_0x793b'
+                                                                            },
+                                                                            'property': {
+                                                                                'type': NodeType_1.NodeType.Literal,
+                                                                                'value': 1,
+                                                                                'raw': "0x1"
+                                                                            }
+                                                                        }
+                                                                    },
+                                                                    'arguments': [
+                                                                        {
+                                                                            'type': NodeType_1.NodeType.BinaryExpression,
+                                                                            'operator': '+',
+                                                                            'left': {
+                                                                                'type': NodeType_1.NodeType.BinaryExpression,
+                                                                                'operator': '+',
+                                                                                'left': {
+                                                                                    'type': NodeType_1.NodeType.BinaryExpression,
+                                                                                    'operator': '+',
+                                                                                    'left': {
+                                                                                        'type': NodeType_1.NodeType.BinaryExpression,
+                                                                                        'operator': '+',
+                                                                                        'left': {
+                                                                                            'type': NodeType_1.NodeType.BinaryExpression,
+                                                                                            'operator': '+',
+                                                                                            'left': {
+                                                                                                'type': NodeType_1.NodeType.BinaryExpression,
+                                                                                                'operator': '+',
+                                                                                                'left': {
+                                                                                                    'type': NodeType_1.NodeType.BinaryExpression,
+                                                                                                    'operator': '+',
+                                                                                                    'left': {
+                                                                                                        'type': NodeType_1.NodeType.MemberExpression,
+                                                                                                        'computed': true,
+                                                                                                        'object': {
+                                                                                                            'type': NodeType_1.NodeType.BinaryExpression,
+                                                                                                            'operator': '+',
+                                                                                                            'left': {
+                                                                                                                'type': NodeType_1.NodeType.Identifier,
+                                                                                                                'name': 'undefined'
+                                                                                                            },
+                                                                                                            'right': {
+                                                                                                                'type': NodeType_1.NodeType.MemberExpression,
+                                                                                                                'computed': true,
+                                                                                                                'object': {
+                                                                                                                    'type': NodeType_1.NodeType.Identifier,
+                                                                                                                    'name': '_0x793b'
+                                                                                                                },
+                                                                                                                'property': {
+                                                                                                                    'type': NodeType_1.NodeType.Literal,
+                                                                                                                    'value': 2,
+                                                                                                                    'raw': "0x2"
+                                                                                                                }
+                                                                                                            }
+                                                                                                        },
+                                                                                                        'property': {
+                                                                                                            'type': NodeType_1.NodeType.Literal,
+                                                                                                            'value': 2,
+                                                                                                            'raw': "0x2"
+                                                                                                        }
+                                                                                                    },
+                                                                                                    'right': {
+                                                                                                        'type': NodeType_1.NodeType.MemberExpression,
+                                                                                                        'computed': true,
+                                                                                                        'object': {
+                                                                                                            'type': NodeType_1.NodeType.BinaryExpression,
+                                                                                                            'operator': '+',
+                                                                                                            'left': {
+                                                                                                                'type': NodeType_1.NodeType.UnaryExpression,
+                                                                                                                'operator': '!',
+                                                                                                                'argument': {
+                                                                                                                    'type': NodeType_1.NodeType.UnaryExpression,
+                                                                                                                    'operator': '!',
+                                                                                                                    'argument': {
+                                                                                                                        'type': NodeType_1.NodeType.ArrayExpression,
+                                                                                                                        'elements': []
+                                                                                                                    },
+                                                                                                                    'prefix': true
+                                                                                                                },
+                                                                                                                'prefix': true
+                                                                                                            },
+                                                                                                            'right': {
+                                                                                                                'type': NodeType_1.NodeType.MemberExpression,
+                                                                                                                'computed': true,
+                                                                                                                'object': {
+                                                                                                                    'type': NodeType_1.NodeType.Identifier,
+                                                                                                                    'name': '_0x793b'
+                                                                                                                },
+                                                                                                                'property': {
+                                                                                                                    'type': NodeType_1.NodeType.Literal,
+                                                                                                                    'value': 2,
+                                                                                                                    'raw': "0x2"
+                                                                                                                }
+                                                                                                            }
+                                                                                                        },
+                                                                                                        'property': {
+                                                                                                            'type': NodeType_1.NodeType.Literal,
+                                                                                                            'value': 3,
+                                                                                                            'raw': "0x3"
+                                                                                                        }
+                                                                                                    }
+                                                                                                },
+                                                                                                'right': {
+                                                                                                    'type': NodeType_1.NodeType.MemberExpression,
+                                                                                                    'computed': true,
+                                                                                                    'object': {
+                                                                                                        'type': NodeType_1.NodeType.BinaryExpression,
+                                                                                                        'operator': '+',
+                                                                                                        'left': {
+                                                                                                            'type': NodeType_1.NodeType.CallExpression,
+                                                                                                            'callee': {
+                                                                                                                'type': NodeType_1.NodeType.CallExpression,
+                                                                                                                'callee': {
+                                                                                                                    'type': NodeType_1.NodeType.Identifier,
+                                                                                                                    'name': 'Function'
+                                                                                                                },
+                                                                                                                'arguments': [
+                                                                                                                    {
+                                                                                                                        'type': NodeType_1.NodeType.MemberExpression,
+                                                                                                                        'computed': true,
+                                                                                                                        'object': {
+                                                                                                                            'type': NodeType_1.NodeType.Identifier,
+                                                                                                                            'name': '_0x793b'
+                                                                                                                        },
+                                                                                                                        'property': {
+                                                                                                                            'type': NodeType_1.NodeType.Literal,
+                                                                                                                            'value': 3,
+                                                                                                                            'raw': "0x3"
+                                                                                                                        }
+                                                                                                                    }
+                                                                                                                ]
+                                                                                                            },
+                                                                                                            'arguments': []
+                                                                                                        },
+                                                                                                        'right': {
+                                                                                                            'type': NodeType_1.NodeType.MemberExpression,
+                                                                                                            'computed': true,
+                                                                                                            'object': {
+                                                                                                                'type': NodeType_1.NodeType.Identifier,
+                                                                                                                'name': '_0x793b'
+                                                                                                            },
+                                                                                                            'property': {
+                                                                                                                'type': NodeType_1.NodeType.Literal,
+                                                                                                                'value': 2,
+                                                                                                                'raw': "0x2"
+                                                                                                            }
+                                                                                                        }
+                                                                                                    },
+                                                                                                    'property': {
+                                                                                                        'type': NodeType_1.NodeType.Literal,
+                                                                                                        'value': 2,
+                                                                                                        'raw': "0x2"
+                                                                                                    }
+                                                                                                }
+                                                                                            },
+                                                                                            'right': {
+                                                                                                'type': NodeType_1.NodeType.MemberExpression,
+                                                                                                'computed': true,
+                                                                                                'object': {
+                                                                                                    'type': NodeType_1.NodeType.BinaryExpression,
+                                                                                                    'operator': '+',
+                                                                                                    'left': {
+                                                                                                        'type': NodeType_1.NodeType.Identifier,
+                                                                                                        'name': 'undefined'
+                                                                                                    },
+                                                                                                    'right': {
+                                                                                                        'type': NodeType_1.NodeType.MemberExpression,
+                                                                                                        'computed': true,
+                                                                                                        'object': {
+                                                                                                            'type': NodeType_1.NodeType.Identifier,
+                                                                                                            'name': '_0x793b'
+                                                                                                        },
+                                                                                                        'property': {
+                                                                                                            'type': NodeType_1.NodeType.Literal,
+                                                                                                            'value': 2,
+                                                                                                            'raw': "0x2"
+                                                                                                        }
+                                                                                                    }
+                                                                                                },
+                                                                                                'property': {
+                                                                                                    'type': NodeType_1.NodeType.Literal,
+                                                                                                    'value': 0,
+                                                                                                    'raw': "0x0"
+                                                                                                }
+                                                                                            }
+                                                                                        },
+                                                                                        'right': {
+                                                                                            'type': NodeType_1.NodeType.MemberExpression,
+                                                                                            'computed': true,
+                                                                                            'object': {
+                                                                                                'type': NodeType_1.NodeType.BinaryExpression,
+                                                                                                'operator': '+',
+                                                                                                'left': {
+                                                                                                    'type': NodeType_1.NodeType.BinaryExpression,
+                                                                                                    'operator': '+',
+                                                                                                    'left': {
+                                                                                                        'type': NodeType_1.NodeType.UnaryExpression,
+                                                                                                        'operator': '!',
+                                                                                                        'argument': {
+                                                                                                            'type': NodeType_1.NodeType.ArrayExpression,
+                                                                                                            'elements': []
+                                                                                                        },
+                                                                                                        'prefix': true
+                                                                                                    },
+                                                                                                    'right': {
+                                                                                                        'type': NodeType_1.NodeType.ArrayExpression,
+                                                                                                        'elements': [
+                                                                                                            {
+                                                                                                                'type': NodeType_1.NodeType.Literal,
+                                                                                                                'value': 0,
+                                                                                                                'raw': "0x0"
+                                                                                                            }
+                                                                                                        ]
+                                                                                                    }
+                                                                                                },
+                                                                                                'right': {
+                                                                                                    'type': NodeType_1.NodeType.Identifier,
+                                                                                                    'name': 'String'
+                                                                                                }
+                                                                                            },
+                                                                                            'property': {
+                                                                                                'type': NodeType_1.NodeType.Literal,
+                                                                                                'value': 20,
+                                                                                                'raw': "0x14"
+                                                                                            }
+                                                                                        }
+                                                                                    },
+                                                                                    'right': {
+                                                                                        'type': NodeType_1.NodeType.MemberExpression,
+                                                                                        'computed': true,
+                                                                                        'object': {
+                                                                                            'type': NodeType_1.NodeType.BinaryExpression,
+                                                                                            'operator': '+',
+                                                                                            'left': {
+                                                                                                'type': NodeType_1.NodeType.BinaryExpression,
+                                                                                                'operator': '+',
+                                                                                                'left': {
+                                                                                                    'type': NodeType_1.NodeType.UnaryExpression,
+                                                                                                    'operator': '!',
+                                                                                                    'argument': {
+                                                                                                        'type': NodeType_1.NodeType.ArrayExpression,
+                                                                                                        'elements': []
+                                                                                                    },
+                                                                                                    'prefix': true
+                                                                                                },
+                                                                                                'right': {
+                                                                                                    'type': NodeType_1.NodeType.ArrayExpression,
+                                                                                                    'elements': [
+                                                                                                        {
+                                                                                                            'type': NodeType_1.NodeType.Literal,
+                                                                                                            'value': 0,
+                                                                                                            'raw': "0x0"
+                                                                                                        }
+                                                                                                    ]
+                                                                                                }
+                                                                                            },
+                                                                                            'right': {
+                                                                                                'type': NodeType_1.NodeType.Identifier,
+                                                                                                'name': 'String'
+                                                                                            }
+                                                                                        },
+                                                                                        'property': {
+                                                                                            'type': NodeType_1.NodeType.Literal,
+                                                                                            'value': 20,
+                                                                                            'raw': "0x14"
+                                                                                        }
+                                                                                    }
+                                                                                },
+                                                                                'right': {
+                                                                                    'type': NodeType_1.NodeType.MemberExpression,
+                                                                                    'computed': true,
+                                                                                    'object': {
+                                                                                        'type': NodeType_1.NodeType.BinaryExpression,
+                                                                                        'operator': '+',
+                                                                                        'left': {
+                                                                                            'type': NodeType_1.NodeType.UnaryExpression,
+                                                                                            'operator': '!',
+                                                                                            'argument': {
+                                                                                                'type': NodeType_1.NodeType.UnaryExpression,
+                                                                                                'operator': '!',
+                                                                                                'argument': {
+                                                                                                    'type': NodeType_1.NodeType.ArrayExpression,
+                                                                                                    'elements': []
+                                                                                                },
+                                                                                                'prefix': true
+                                                                                            },
+                                                                                            'prefix': true
+                                                                                        },
+                                                                                        'right': {
+                                                                                            'type': NodeType_1.NodeType.MemberExpression,
+                                                                                            'computed': true,
+                                                                                            'object': {
+                                                                                                'type': NodeType_1.NodeType.Identifier,
+                                                                                                'name': '_0x793b'
+                                                                                            },
+                                                                                            'property': {
+                                                                                                'type': NodeType_1.NodeType.Literal,
+                                                                                                'value': 2,
+                                                                                                'raw': "0x2"
+                                                                                            }
+                                                                                        }
+                                                                                    },
+                                                                                    'property': {
+                                                                                        'type': NodeType_1.NodeType.Literal,
+                                                                                        'value': 3,
+                                                                                        'raw': "0x3"
+                                                                                    }
+                                                                                }
+                                                                            },
+                                                                            'right': {
+                                                                                'type': NodeType_1.NodeType.MemberExpression,
+                                                                                'computed': true,
+                                                                                'object': {
+                                                                                    'type': NodeType_1.NodeType.BinaryExpression,
+                                                                                    'operator': '+',
+                                                                                    'left': {
+                                                                                        'type': NodeType_1.NodeType.UnaryExpression,
+                                                                                        'operator': '!',
+                                                                                        'argument': {
+                                                                                            'type': NodeType_1.NodeType.UnaryExpression,
+                                                                                            'operator': '!',
+                                                                                            'argument': {
+                                                                                                'type': NodeType_1.NodeType.ArrayExpression,
+                                                                                                'elements': []
+                                                                                            },
+                                                                                            'prefix': true
+                                                                                        },
+                                                                                        'prefix': true
+                                                                                    },
+                                                                                    'right': {
+                                                                                        'type': NodeType_1.NodeType.MemberExpression,
+                                                                                        'computed': true,
+                                                                                        'object': {
+                                                                                            'type': NodeType_1.NodeType.Identifier,
+                                                                                            'name': '_0x793b'
+                                                                                        },
+                                                                                        'property': {
+                                                                                            'type': NodeType_1.NodeType.Literal,
+                                                                                            'value': 2,
+                                                                                            'raw': "0x2"
+                                                                                        }
+                                                                                    }
+                                                                                },
+                                                                                'property': {
+                                                                                    'type': NodeType_1.NodeType.Literal,
+                                                                                    'value': 1,
+                                                                                    'raw': "0x1"
+                                                                                }
+                                                                            }
+                                                                        }
+                                                                    ]
+                                                                },
+                                                                'arguments': []
+                                                            }
+                                                        }
+                                                    ]
+                                                }
+                                            },
+                                            {
+                                                'type': NodeType_1.NodeType.ExpressionStatement,
+                                                'expression': {
+                                                    'type': NodeType_1.NodeType.CallExpression,
+                                                    'callee': {
+                                                        'type': NodeType_1.NodeType.Identifier,
+                                                        'name': 'debuggerProtection'
+                                                    },
+                                                    'arguments': [
+                                                        {
+                                                            'type': NodeType_1.NodeType.UpdateExpression,
+                                                            'operator': '++',
+                                                            'argument': {
+                                                                'type': NodeType_1.NodeType.Identifier,
+                                                                'name': 'counter'
+                                                            },
+                                                            'prefix': true
+                                                        }
+                                                    ]
+                                                }
+                                            }
+                                        ]
+                                    },
+                                    'generator': false,
+                                    'expression': false
+                                },
+                                {
+                                    'type': NodeType_1.NodeType.TryStatement,
+                                    'block': {
+                                        'type': NodeType_1.NodeType.BlockStatement,
+                                        'body': [
+                                            {
+                                                'type': NodeType_1.NodeType.ExpressionStatement,
+                                                'expression': {
+                                                    'type': NodeType_1.NodeType.CallExpression,
+                                                    'callee': {
+                                                        'type': NodeType_1.NodeType.Identifier,
+                                                        'name': 'debuggerProtection'
+                                                    },
+                                                    'arguments': [
+                                                        {
+                                                            'type': NodeType_1.NodeType.Literal,
+                                                            'value': 0,
+                                                            'raw': "0"
+                                                        }
+                                                    ]
+                                                }
+                                            }
+                                        ]
+                                    },
+                                    'guardedHandlers': [],
+                                    'handlers': [
+                                        {
+                                            'type': NodeType_1.NodeType.CatchClause,
+                                            'param': {
+                                                'type': NodeType_1.NodeType.Identifier,
+                                                'name': 'y'
+                                            },
+                                            'body': {
+                                                'type': NodeType_1.NodeType.BlockStatement,
+                                                'body': []
+                                            }
+                                        }
+                                    ],
+                                    'handler': {
+                                        'type': NodeType_1.NodeType.CatchClause,
+                                        'param': {
+                                            'type': NodeType_1.NodeType.Identifier,
+                                            'name': 'y'
+                                        },
+                                        'body': {
+                                            'type': NodeType_1.NodeType.BlockStatement,
+                                            'body': []
+                                        }
+                                    },
+                                    'finalizer': null
+                                }
+                            ]
+                        },
+                        'generator': false,
+                        'expression': false
+                    }
+                }
+            ],
+            'kind': 'var'
+        };
+    }
+}
+exports.DebugProtectionFunctionNode = DebugProtectionFunctionNode;

+ 732 - 0
src/nodes/DebugProtectionFunctionNode.ts

@@ -0,0 +1,732 @@
+/* tslint:disable:max-line-length */
+
+import * as estraverse from 'estraverse';
+
+import { ITreeNode } from '../interfaces/nodes/ITreeNode';
+
+import { NodeType } from '../enums/NodeType';
+
+import { Node } from './Node';
+import { NodeUtils } from '../NodeUtils';
+
+export class DebugProtectionFunctionNode extends Node {
+    /**
+     * @type {ITreeNode}
+     */
+    protected node: ITreeNode;
+
+    /**
+     * @type {ITreeNode}
+     */
+    private astTree: ITreeNode;
+
+    /**
+     * @type {string}
+     */
+    private debugProtectionFunctionName: string;
+
+    /**
+     * @type {number}
+     */
+    private debugProtectionFunctionIndex: number;
+
+    /**
+     * @param astTree
+     * @param debugProtectionFunctionName
+     * @param debugProtectionFunctionIndex
+     */
+    constructor (
+        astTree: ITreeNode,
+        debugProtectionFunctionName: string,
+        debugProtectionFunctionIndex: number
+    ) {
+        super();
+
+        this.astTree = astTree;
+        this.debugProtectionFunctionName = debugProtectionFunctionName;
+        this.debugProtectionFunctionIndex = debugProtectionFunctionIndex;
+        this.node = this.getNodeStructure();
+    }
+
+    public appendNode (): void {
+        estraverse.replace(this.astTree, {
+            leave: (node: ITreeNode, parent: ITreeNode): any => {
+                if (NodeUtils.isProgramNode(node)) {
+                    node.body.splice(this.debugProtectionFunctionIndex, 0, this.getNode());
+
+                    return estraverse.VisitorOption.Break;
+                }
+
+                return estraverse.VisitorOption.Skip;
+            }
+        });
+    }
+
+    /**
+     * @returns any
+     */
+    protected getNodeStructure (): any {
+        return {
+            'type': NodeType.VariableDeclaration,
+            'declarations': [
+                {
+                    'type': NodeType.VariableDeclarator,
+                    'id': {
+                        'type': NodeType.Identifier,
+                        'name': this.debugProtectionFunctionName
+                    },
+                    'init': {
+                        'type': NodeType.FunctionExpression,
+                        'id': null,
+                        'params': [],
+                        'defaults': [],
+                        'body': {
+                            'type': NodeType.BlockStatement,
+                            'body': [
+                                {
+                                    'type': NodeType.FunctionDeclaration,
+                                    'id': {
+                                        'type': NodeType.Identifier,
+                                        'name': 'debuggerProtection'
+                                    },
+                                    'params': [
+                                        {
+                                            'type': NodeType.Identifier,
+                                            'name': 'counter'
+                                        }
+                                    ],
+                                    'defaults': [],
+                                    'body': {
+                                        'type': NodeType.BlockStatement,
+                                        'body': [
+                                            {
+                                                'type': NodeType.IfStatement,
+                                                'test': {
+                                                    'type': NodeType.LogicalExpression,
+                                                    'operator': '||',
+                                                    'left': {
+                                                        'type': NodeType.BinaryExpression,
+                                                        'operator': '!==',
+                                                        'left': {
+                                                            'type': NodeType.MemberExpression,
+                                                            'computed': true,
+                                                            'object': {
+                                                                'type': NodeType.BinaryExpression,
+                                                                'operator': '+',
+                                                                'left': {
+                                                                    'type': NodeType.Literal,
+                                                                    'value': '',
+                                                                    'raw': "''"
+                                                                },
+                                                                'right': {
+                                                                    'type': NodeType.BinaryExpression,
+                                                                    'operator': '/',
+                                                                    'left': {
+                                                                        'type': NodeType.Identifier,
+                                                                        'name': 'counter'
+                                                                    },
+                                                                    'right': {
+                                                                        'type': NodeType.Identifier,
+                                                                        'name': 'counter'
+                                                                    }
+                                                                }
+                                                            },
+                                                            'property': {
+                                                                'type': NodeType.Literal,
+                                                                'value': 'length',
+                                                                'raw': "'length'"
+                                                            }
+                                                        },
+                                                        'right': {
+                                                            'type': NodeType.Literal,
+                                                            'value': 1,
+                                                            'raw': "1"
+                                                        }
+                                                    },
+                                                    'right': {
+                                                        'type': NodeType.BinaryExpression,
+                                                        'operator': '===',
+                                                        'left': {
+                                                            'type': NodeType.BinaryExpression,
+                                                            'operator': '%',
+                                                            'left': {
+                                                                'type': NodeType.Identifier,
+                                                                'name': 'counter'
+                                                            },
+                                                            'right': {
+                                                                'type': NodeType.Literal,
+                                                                'value': 20,
+                                                                'raw': "20"
+                                                            }
+                                                        },
+                                                        'right': {
+                                                            'type': NodeType.Literal,
+                                                            'value': 0,
+                                                            'raw': "0"
+                                                        }
+                                                    }
+                                                },
+                                                'consequent': {
+                                                    'type': NodeType.BlockStatement,
+                                                    'body': [
+                                                        {
+                                                            'type': NodeType.ExpressionStatement,
+                                                            'expression': {
+                                                                'type': NodeType.CallExpression,
+                                                                'callee': {
+                                                                    'type': NodeType.CallExpression,
+                                                                    'callee': {
+                                                                        'type': NodeType.MemberExpression,
+                                                                        'computed': false,
+                                                                        'object': {
+                                                                            'type': NodeType.FunctionExpression,
+                                                                            'id': null,
+                                                                            'params': [],
+                                                                            'defaults': [],
+                                                                            'body': {
+                                                                                'type': NodeType.BlockStatement,
+                                                                                'body': []
+                                                                            },
+                                                                            'generator': false,
+                                                                            'expression': false
+                                                                        },
+                                                                        'property': {
+                                                                            'type': NodeType.Identifier,
+                                                                            'name': 'constructor'
+                                                                        }
+                                                                    },
+                                                                    'arguments': [
+                                                                        {
+                                                                            'type': NodeType.Literal,
+                                                                            'value': 'debugger',
+                                                                            'raw': "'debugger'"
+                                                                        }
+                                                                    ]
+                                                                },
+                                                                'arguments': []
+                                                            }
+                                                        }
+                                                    ]
+                                                },
+                                                'alternate': {
+                                                    'type': NodeType.BlockStatement,
+                                                    'body': [
+                                                        {
+                                                            'type': NodeType.VariableDeclaration,
+                                                            'declarations': [
+                                                                {
+                                                                    'type': NodeType.VariableDeclarator,
+                                                                    'id': {
+                                                                        'type': NodeType.Identifier,
+                                                                        'name': '_0x793b'
+                                                                    },
+                                                                    'init': {
+                                                                        'type': NodeType.ArrayExpression,
+                                                                        'elements': [
+                                                                            {
+                                                                                'type': NodeType.Literal,
+                                                                                'value': 'filter',
+                                                                                'raw': "'\\u0066\\u0069\\u006c\\u0074\\u0065\\u0072'"
+                                                                            },
+                                                                            {
+                                                                                'type': NodeType.Literal,
+                                                                                'value': 'constructor',
+                                                                                'raw': "'\\u0063\\u006f\\u006e\\u0073\\u0074\\u0072\\u0075\\u0063\\u0074\\u006f\\u0072'"
+                                                                            },
+                                                                            {
+                                                                                'type': NodeType.Literal,
+                                                                                'value': '',
+                                                                                'raw': "''"
+                                                                            },
+                                                                            {
+                                                                                'type': NodeType.Literal,
+                                                                                'value': 'return{}',
+                                                                                'raw': "'\\u0072\\u0065\\u0074\\u0075\\u0072\\u006e\\u007b\\u007d'"
+                                                                            }
+                                                                        ]
+                                                                    }
+                                                                }
+                                                            ],
+                                                            'kind': 'var'
+                                                        },
+                                                        {
+                                                            'type': NodeType.ExpressionStatement,
+                                                            'expression': {
+                                                                'type': NodeType.CallExpression,
+                                                                'callee': {
+                                                                    'type': NodeType.CallExpression,
+                                                                    'callee': {
+                                                                        'type': NodeType.MemberExpression,
+                                                                        'computed': true,
+                                                                        'object': {
+                                                                            'type': NodeType.MemberExpression,
+                                                                            'computed': true,
+                                                                            'object': {
+                                                                                'type': NodeType.ArrayExpression,
+                                                                                'elements': []
+                                                                            },
+                                                                            'property': {
+                                                                                'type': NodeType.MemberExpression,
+                                                                                'computed': true,
+                                                                                'object': {
+                                                                                    'type': NodeType.Identifier,
+                                                                                    'name': '_0x793b'
+                                                                                },
+                                                                                'property': {
+                                                                                    'type': NodeType.Literal,
+                                                                                    'value': 0,
+                                                                                    'raw': "0x0"
+                                                                                }
+                                                                            }
+                                                                        },
+                                                                        'property': {
+                                                                            'type': NodeType.MemberExpression,
+                                                                            'computed': true,
+                                                                            'object': {
+                                                                                'type': NodeType.Identifier,
+                                                                                'name': '_0x793b'
+                                                                            },
+                                                                            'property': {
+                                                                                'type': NodeType.Literal,
+                                                                                'value': 1,
+                                                                                'raw': "0x1"
+                                                                            }
+                                                                        }
+                                                                    },
+                                                                    'arguments': [
+                                                                        {
+                                                                            'type': NodeType.BinaryExpression,
+                                                                            'operator': '+',
+                                                                            'left': {
+                                                                                'type': NodeType.BinaryExpression,
+                                                                                'operator': '+',
+                                                                                'left': {
+                                                                                    'type': NodeType.BinaryExpression,
+                                                                                    'operator': '+',
+                                                                                    'left': {
+                                                                                        'type': NodeType.BinaryExpression,
+                                                                                        'operator': '+',
+                                                                                        'left': {
+                                                                                            'type': NodeType.BinaryExpression,
+                                                                                            'operator': '+',
+                                                                                            'left': {
+                                                                                                'type': NodeType.BinaryExpression,
+                                                                                                'operator': '+',
+                                                                                                'left': {
+                                                                                                    'type': NodeType.BinaryExpression,
+                                                                                                    'operator': '+',
+                                                                                                    'left': {
+                                                                                                        'type': NodeType.MemberExpression,
+                                                                                                        'computed': true,
+                                                                                                        'object': {
+                                                                                                            'type': NodeType.BinaryExpression,
+                                                                                                            'operator': '+',
+                                                                                                            'left': {
+                                                                                                                'type': NodeType.Identifier,
+                                                                                                                'name': 'undefined'
+                                                                                                            },
+                                                                                                            'right': {
+                                                                                                                'type': NodeType.MemberExpression,
+                                                                                                                'computed': true,
+                                                                                                                'object': {
+                                                                                                                    'type': NodeType.Identifier,
+                                                                                                                    'name': '_0x793b'
+                                                                                                                },
+                                                                                                                'property': {
+                                                                                                                    'type': NodeType.Literal,
+                                                                                                                    'value': 2,
+                                                                                                                    'raw': "0x2"
+                                                                                                                }
+                                                                                                            }
+                                                                                                        },
+                                                                                                        'property': {
+                                                                                                            'type': NodeType.Literal,
+                                                                                                            'value': 2,
+                                                                                                            'raw': "0x2"
+                                                                                                        }
+                                                                                                    },
+                                                                                                    'right': {
+                                                                                                        'type': NodeType.MemberExpression,
+                                                                                                        'computed': true,
+                                                                                                        'object': {
+                                                                                                            'type': NodeType.BinaryExpression,
+                                                                                                            'operator': '+',
+                                                                                                            'left': {
+                                                                                                                'type': NodeType.UnaryExpression,
+                                                                                                                'operator': '!',
+                                                                                                                'argument': {
+                                                                                                                    'type': NodeType.UnaryExpression,
+                                                                                                                    'operator': '!',
+                                                                                                                    'argument': {
+                                                                                                                        'type': NodeType.ArrayExpression,
+                                                                                                                        'elements': []
+                                                                                                                    },
+                                                                                                                    'prefix': true
+                                                                                                                },
+                                                                                                                'prefix': true
+                                                                                                            },
+                                                                                                            'right': {
+                                                                                                                'type': NodeType.MemberExpression,
+                                                                                                                'computed': true,
+                                                                                                                'object': {
+                                                                                                                    'type': NodeType.Identifier,
+                                                                                                                    'name': '_0x793b'
+                                                                                                                },
+                                                                                                                'property': {
+                                                                                                                    'type': NodeType.Literal,
+                                                                                                                    'value': 2,
+                                                                                                                    'raw': "0x2"
+                                                                                                                }
+                                                                                                            }
+                                                                                                        },
+                                                                                                        'property': {
+                                                                                                            'type': NodeType.Literal,
+                                                                                                            'value': 3,
+                                                                                                            'raw': "0x3"
+                                                                                                        }
+                                                                                                    }
+                                                                                                },
+                                                                                                'right': {
+                                                                                                    'type': NodeType.MemberExpression,
+                                                                                                    'computed': true,
+                                                                                                    'object': {
+                                                                                                        'type': NodeType.BinaryExpression,
+                                                                                                        'operator': '+',
+                                                                                                        'left': {
+                                                                                                            'type': NodeType.CallExpression,
+                                                                                                            'callee': {
+                                                                                                                'type': NodeType.CallExpression,
+                                                                                                                'callee': {
+                                                                                                                    'type': NodeType.Identifier,
+                                                                                                                    'name': 'Function'
+                                                                                                                },
+                                                                                                                'arguments': [
+                                                                                                                    {
+                                                                                                                        'type': NodeType.MemberExpression,
+                                                                                                                        'computed': true,
+                                                                                                                        'object': {
+                                                                                                                            'type': NodeType.Identifier,
+                                                                                                                            'name': '_0x793b'
+                                                                                                                        },
+                                                                                                                        'property': {
+                                                                                                                            'type': NodeType.Literal,
+                                                                                                                            'value': 3,
+                                                                                                                            'raw': "0x3"
+                                                                                                                        }
+                                                                                                                    }
+                                                                                                                ]
+                                                                                                            },
+                                                                                                            'arguments': []
+                                                                                                        },
+                                                                                                        'right': {
+                                                                                                            'type': NodeType.MemberExpression,
+                                                                                                            'computed': true,
+                                                                                                            'object': {
+                                                                                                                'type': NodeType.Identifier,
+                                                                                                                'name': '_0x793b'
+                                                                                                            },
+                                                                                                            'property': {
+                                                                                                                'type': NodeType.Literal,
+                                                                                                                'value': 2,
+                                                                                                                'raw': "0x2"
+                                                                                                            }
+                                                                                                        }
+                                                                                                    },
+                                                                                                    'property': {
+                                                                                                        'type': NodeType.Literal,
+                                                                                                        'value': 2,
+                                                                                                        'raw': "0x2"
+                                                                                                    }
+                                                                                                }
+                                                                                            },
+                                                                                            'right': {
+                                                                                                'type': NodeType.MemberExpression,
+                                                                                                'computed': true,
+                                                                                                'object': {
+                                                                                                    'type': NodeType.BinaryExpression,
+                                                                                                    'operator': '+',
+                                                                                                    'left': {
+                                                                                                        'type': NodeType.Identifier,
+                                                                                                        'name': 'undefined'
+                                                                                                    },
+                                                                                                    'right': {
+                                                                                                        'type': NodeType.MemberExpression,
+                                                                                                        'computed': true,
+                                                                                                        'object': {
+                                                                                                            'type': NodeType.Identifier,
+                                                                                                            'name': '_0x793b'
+                                                                                                        },
+                                                                                                        'property': {
+                                                                                                            'type': NodeType.Literal,
+                                                                                                            'value': 2,
+                                                                                                            'raw': "0x2"
+                                                                                                        }
+                                                                                                    }
+                                                                                                },
+                                                                                                'property': {
+                                                                                                    'type': NodeType.Literal,
+                                                                                                    'value': 0,
+                                                                                                    'raw': "0x0"
+                                                                                                }
+                                                                                            }
+                                                                                        },
+                                                                                        'right': {
+                                                                                            'type': NodeType.MemberExpression,
+                                                                                            'computed': true,
+                                                                                            'object': {
+                                                                                                'type': NodeType.BinaryExpression,
+                                                                                                'operator': '+',
+                                                                                                'left': {
+                                                                                                    'type': NodeType.BinaryExpression,
+                                                                                                    'operator': '+',
+                                                                                                    'left': {
+                                                                                                        'type': NodeType.UnaryExpression,
+                                                                                                        'operator': '!',
+                                                                                                        'argument': {
+                                                                                                            'type': NodeType.ArrayExpression,
+                                                                                                            'elements': []
+                                                                                                        },
+                                                                                                        'prefix': true
+                                                                                                    },
+                                                                                                    'right': {
+                                                                                                        'type': NodeType.ArrayExpression,
+                                                                                                        'elements': [
+                                                                                                            {
+                                                                                                                'type': NodeType.Literal,
+                                                                                                                'value': 0,
+                                                                                                                'raw': "0x0"
+                                                                                                            }
+                                                                                                        ]
+                                                                                                    }
+                                                                                                },
+                                                                                                'right': {
+                                                                                                    'type': NodeType.Identifier,
+                                                                                                    'name': 'String'
+                                                                                                }
+                                                                                            },
+                                                                                            'property': {
+                                                                                                'type': NodeType.Literal,
+                                                                                                'value': 20,
+                                                                                                'raw': "0x14"
+                                                                                            }
+                                                                                        }
+                                                                                    },
+                                                                                    'right': {
+                                                                                        'type': NodeType.MemberExpression,
+                                                                                        'computed': true,
+                                                                                        'object': {
+                                                                                            'type': NodeType.BinaryExpression,
+                                                                                            'operator': '+',
+                                                                                            'left': {
+                                                                                                'type': NodeType.BinaryExpression,
+                                                                                                'operator': '+',
+                                                                                                'left': {
+                                                                                                    'type': NodeType.UnaryExpression,
+                                                                                                    'operator': '!',
+                                                                                                    'argument': {
+                                                                                                        'type': NodeType.ArrayExpression,
+                                                                                                        'elements': []
+                                                                                                    },
+                                                                                                    'prefix': true
+                                                                                                },
+                                                                                                'right': {
+                                                                                                    'type': NodeType.ArrayExpression,
+                                                                                                    'elements': [
+                                                                                                        {
+                                                                                                            'type': NodeType.Literal,
+                                                                                                            'value': 0,
+                                                                                                            'raw': "0x0"
+                                                                                                        }
+                                                                                                    ]
+                                                                                                }
+                                                                                            },
+                                                                                            'right': {
+                                                                                                'type': NodeType.Identifier,
+                                                                                                'name': 'String'
+                                                                                            }
+                                                                                        },
+                                                                                        'property': {
+                                                                                            'type': NodeType.Literal,
+                                                                                            'value': 20,
+                                                                                            'raw': "0x14"
+                                                                                        }
+                                                                                    }
+                                                                                },
+                                                                                'right': {
+                                                                                    'type': NodeType.MemberExpression,
+                                                                                    'computed': true,
+                                                                                    'object': {
+                                                                                        'type': NodeType.BinaryExpression,
+                                                                                        'operator': '+',
+                                                                                        'left': {
+                                                                                            'type': NodeType.UnaryExpression,
+                                                                                            'operator': '!',
+                                                                                            'argument': {
+                                                                                                'type': NodeType.UnaryExpression,
+                                                                                                'operator': '!',
+                                                                                                'argument': {
+                                                                                                    'type': NodeType.ArrayExpression,
+                                                                                                    'elements': []
+                                                                                                },
+                                                                                                'prefix': true
+                                                                                            },
+                                                                                            'prefix': true
+                                                                                        },
+                                                                                        'right': {
+                                                                                            'type': NodeType.MemberExpression,
+                                                                                            'computed': true,
+                                                                                            'object': {
+                                                                                                'type': NodeType.Identifier,
+                                                                                                'name': '_0x793b'
+                                                                                            },
+                                                                                            'property': {
+                                                                                                'type': NodeType.Literal,
+                                                                                                'value': 2,
+                                                                                                'raw': "0x2"
+                                                                                            }
+                                                                                        }
+                                                                                    },
+                                                                                    'property': {
+                                                                                        'type': NodeType.Literal,
+                                                                                        'value': 3,
+                                                                                        'raw': "0x3"
+                                                                                    }
+                                                                                }
+                                                                            },
+                                                                            'right': {
+                                                                                'type': NodeType.MemberExpression,
+                                                                                'computed': true,
+                                                                                'object': {
+                                                                                    'type': NodeType.BinaryExpression,
+                                                                                    'operator': '+',
+                                                                                    'left': {
+                                                                                        'type': NodeType.UnaryExpression,
+                                                                                        'operator': '!',
+                                                                                        'argument': {
+                                                                                            'type': NodeType.UnaryExpression,
+                                                                                            'operator': '!',
+                                                                                            'argument': {
+                                                                                                'type': NodeType.ArrayExpression,
+                                                                                                'elements': []
+                                                                                            },
+                                                                                            'prefix': true
+                                                                                        },
+                                                                                        'prefix': true
+                                                                                    },
+                                                                                    'right': {
+                                                                                        'type': NodeType.MemberExpression,
+                                                                                        'computed': true,
+                                                                                        'object': {
+                                                                                            'type': NodeType.Identifier,
+                                                                                            'name': '_0x793b'
+                                                                                        },
+                                                                                        'property': {
+                                                                                            'type': NodeType.Literal,
+                                                                                            'value': 2,
+                                                                                            'raw': "0x2"
+                                                                                        }
+                                                                                    }
+                                                                                },
+                                                                                'property': {
+                                                                                    'type': NodeType.Literal,
+                                                                                    'value': 1,
+                                                                                    'raw': "0x1"
+                                                                                }
+                                                                            }
+                                                                        }
+                                                                    ]
+                                                                },
+                                                                'arguments': []
+                                                            }
+                                                        }
+                                                    ]
+                                                }
+                                            },
+                                            {
+                                                'type': NodeType.ExpressionStatement,
+                                                'expression': {
+                                                    'type': NodeType.CallExpression,
+                                                    'callee': {
+                                                        'type': NodeType.Identifier,
+                                                        'name': 'debuggerProtection'
+                                                    },
+                                                    'arguments': [
+                                                        {
+                                                            'type': NodeType.UpdateExpression,
+                                                            'operator': '++',
+                                                            'argument': {
+                                                                'type': NodeType.Identifier,
+                                                                'name': 'counter'
+                                                            },
+                                                            'prefix': true
+                                                        }
+                                                    ]
+                                                }
+                                            }
+                                        ]
+                                    },
+                                    'generator': false,
+                                    'expression': false
+                                },
+                                {
+                                    'type': NodeType.TryStatement,
+                                    'block': {
+                                        'type': NodeType.BlockStatement,
+                                        'body': [
+                                            {
+                                                'type': NodeType.ExpressionStatement,
+                                                'expression': {
+                                                    'type': NodeType.CallExpression,
+                                                    'callee': {
+                                                        'type': NodeType.Identifier,
+                                                        'name': 'debuggerProtection'
+                                                    },
+                                                    'arguments': [
+                                                        {
+                                                            'type': NodeType.Literal,
+                                                            'value': 0,
+                                                            'raw': "0"
+                                                        }
+                                                    ]
+                                                }
+                                            }
+                                        ]
+                                    },
+                                    'guardedHandlers': [],
+                                    'handlers': [
+                                        {
+                                            'type': NodeType.CatchClause,
+                                            'param': {
+                                                'type': NodeType.Identifier,
+                                                'name': 'y'
+                                            },
+                                            'body': {
+                                                'type': NodeType.BlockStatement,
+                                                'body': []
+                                            }
+                                        }
+                                    ],
+                                    'handler': {
+                                        'type': NodeType.CatchClause,
+                                        'param': {
+                                            'type': NodeType.Identifier,
+                                            'name': 'y'
+                                        },
+                                        'body': {
+                                            'type': NodeType.BlockStatement,
+                                            'body': []
+                                        }
+                                    },
+                                    'finalizer': null
+                                }
+                            ]
+                        },
+                        'generator': false,
+                        'expression': false
+                    }
+                }
+            ],
+            'kind': 'var'
+        };
+    }
+}

+ 1 - 0
src/nodes/UnicodeArrayRotateFunctionNode.ts

@@ -18,6 +18,7 @@ export class UnicodeArrayRotateFunctionNode extends Node {
      * @type {ITreeNode}
      */
     private astTree: ITreeNode;
+
     /**
      * @type {string}
      */

+ 1 - 0
tests/dev-test.js

@@ -47,6 +47,7 @@ let obfuscatedCode = index_1.JavaScriptObfuscator.obfuscate(`
         console.log(true, false);
     })();
     `, {
+    debugProtectionInterval: false,
     rotateUnicodeArray: false
 });
 console.log(obfuscatedCode);

+ 1 - 0
tests/dev-test.ts

@@ -49,6 +49,7 @@ let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
     })();
     `,
     {
+        debugProtectionInterval: false,
         rotateUnicodeArray: false
     }
 );