Browse Source

First draw of control flow change. Right now for binary expressions.

sanex3339 8 years ago
parent
commit
8e5c127226

+ 4 - 4
dist/index.js

@@ -1564,12 +1564,12 @@ var Obfuscator = function () {
             NodeUtils_1.NodeUtils.parentize(node);
             var stackTraceData = new StackTraceAnalyzer_1.StackTraceAnalyzer(node.body).analyze();
             this.initializeCustomNodes(stackTraceData);
-            this.beforeObfuscation(node);
-            this.obfuscate(node);
-            this.afterObfuscation(node);
             if (this.options.controlFlow) {
                 this.changeControlFlow(node);
             }
+            this.beforeObfuscation(node);
+            this.obfuscate(node);
+            this.afterObfuscation(node);
             return node;
         }
     }, {
@@ -3151,7 +3151,7 @@ var AbstractControlFlowReplacer = function () {
         key: 'getStorageKey',
         value: function getStorageKey() {
             return Utils_1.Utils.getRandomGenerator().string({
-                length: 4,
+                length: 3,
                 pool: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
             });
         }

+ 4 - 4
src/Obfuscator.ts

@@ -104,14 +104,14 @@ export class Obfuscator implements IObfuscator {
 
         this.initializeCustomNodes(stackTraceData);
 
-        this.beforeObfuscation(node);
-        this.obfuscate(node);
-        this.afterObfuscation(node);
-
         if (this.options.controlFlow) {
             this.changeControlFlow(node);
         }
 
+        this.beforeObfuscation(node);
+        this.obfuscate(node);
+        this.afterObfuscation(node);
+
         return node;
     }
 

+ 1 - 1
src/node-control-flow-changers/control-flow-replacers/AbstractControlFlowReplacer.ts

@@ -32,7 +32,7 @@ export abstract class AbstractControlFlowReplacer implements IControlFlowReplace
      */
     protected static getStorageKey (): string {
         return Utils.getRandomGenerator().string({
-            length: 4,
+            length: 3,
             pool: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
         });
     }

+ 6 - 4
test/dev/dev.ts

@@ -1,5 +1,4 @@
 'use strict';
-import { NO_CUSTOM_NODES_PRESET } from '../../src/preset-options/NoCustomNodesPreset';
 
 if (!(<any>global)._babelPolyfill) {
     require('babel-polyfill');
@@ -50,9 +49,12 @@ if (!(<any>global)._babelPolyfill) {
         console.log(n);
     })();
     `,
-        Object.assign({}, NO_CUSTOM_NODES_PRESET, {
-            controlFlow: true
-        })
+        {
+            controlFlow: true,
+            disableConsoleOutput: false,
+            selfDefending: true,
+            stringArrayEncoding: 'rc4'
+        }
     ).getObfuscatedCode();
 
     console.log(obfuscatedCode);