Browse Source

Update readme.md

sanex3339 8 years ago
parent
commit
ef4e579c51
3 changed files with 133 additions and 24 deletions
  1. 1 1
      CHANGELOG.md
  2. 109 0
      README.md
  3. 23 23
      dist/index.js

+ 1 - 1
CHANGELOG.md

@@ -2,7 +2,7 @@ Change Log
 ===
 v0.10.0
 ---
-* **New option:** `deadCodeInjection`. With this option random blocks of code will add to the obfuscated code.
+* **New option:** `deadCodeInjection`. With this option random blocks of dead code will add to the obfuscated code.
 * **New option:** `deadCodeInjectionThreshold` allows to set percentage of nodes that will affected by `deadCodeInjection`.
 * **New option:** `mangle` enables mangling of variable names.
 * `escapeUnicodeSequence` option now disabled by default.

+ 109 - 0
README.md

@@ -306,6 +306,115 @@ This setting is especially useful for large code size because large amounts of c
 
 `controlFlowFlatteningThreshold: 0` equals to `controlFlowFlattening: false`.
 
+### `deadCodeInjection`
+Type: `boolean` Default: `false`
+
+##### :warning: Dramatically increases size of obfuscated code (up to 200%), use only if size of obfuscated code doesn't matter. Use [`deadCodeInjectionThreshold`](#deadcodeinjectionthreshold) to set percentage of nodes that will affected by dead code injection. 
+
+With this option random blocks of dead code will add to the obfuscated code. 
+
+Example:
+```ts
+// input
+(function(){
+    if (true) {
+        var foo = function () {
+            console.log('abc');
+            console.log('cde');
+            console.log('efg');
+            console.log('hij');
+        };
+        
+        var bar = function () {
+            console.log('klm');
+            console.log('nop');
+            console.log('qrs');
+        };
+    
+        var baz = function () {
+            console.log('tuv');
+            console.log('wxy');
+            console.log('z');
+        };
+    
+        foo();
+        bar();
+        baz();
+    }
+})();
+
+// output
+var _0x5024 = [
+    'zaU',
+    'log',
+    'tuv',
+    'wxy',
+    'abc',
+    'cde',
+    'efg',
+    'hij',
+    'QhG',
+    'TeI',
+    'klm',
+    'nop',
+    'qrs',
+    'bZd',
+    'HMx'
+];
+var _0x4502 = function (_0x1254b1, _0x583689) {
+    _0x1254b1 = _0x1254b1 - 0x0;
+    var _0x529b49 = _0x5024[_0x1254b1];
+    return _0x529b49;
+};
+(function () {
+    if (!![]) {
+        var _0x16c18d = function () {
+            if (_0x4502('0x0') !== _0x4502('0x0')) {
+                console[_0x4502('0x1')](_0x4502('0x2'));
+                console[_0x4502('0x1')](_0x4502('0x3'));
+                console[_0x4502('0x1')]('z');
+            } else {
+                console[_0x4502('0x1')](_0x4502('0x4'));
+                console[_0x4502('0x1')](_0x4502('0x5'));
+                console[_0x4502('0x1')](_0x4502('0x6'));
+                console[_0x4502('0x1')](_0x4502('0x7'));
+            }
+        };
+        var _0x1f7292 = function () {
+            if (_0x4502('0x8') === _0x4502('0x9')) {
+                console[_0x4502('0x1')](_0x4502('0xa'));
+                console[_0x4502('0x1')](_0x4502('0xb'));
+                console[_0x4502('0x1')](_0x4502('0xc'));
+            } else {
+                console[_0x4502('0x1')](_0x4502('0xa'));
+                console[_0x4502('0x1')](_0x4502('0xb'));
+                console[_0x4502('0x1')](_0x4502('0xc'));
+            }
+        };
+        var _0x33b212 = function () {
+            if (_0x4502('0xd') !== _0x4502('0xe')) {
+                console[_0x4502('0x1')](_0x4502('0x2'));
+                console[_0x4502('0x1')](_0x4502('0x3'));
+                console[_0x4502('0x1')]('z');
+            } else {
+                console[_0x4502('0x1')](_0x4502('0x4'));
+                console[_0x4502('0x1')](_0x4502('0x5'));
+                console[_0x4502('0x1')](_0x4502('0x6'));
+                console[_0x4502('0x1')](_0x4502('0x7'));
+            }
+        };
+        _0x16c18d();
+        _0x1f7292();
+        _0x33b212();
+    }
+}());
+```
+
+### `deadCodeInjectionThreshold`
+Type: `number` Default: `0.4`
+
+Allows to set percentage of nodes that will affected by `deadCodeInjection`.
+
 ### `debugProtection`
 Type: `boolean` Default: `false`
 

+ 23 - 23
dist/index.js

@@ -153,7 +153,6 @@ var _createClass = (function () { function defineProperties(target, props) { for
 
 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 
-Object.defineProperty(exports, "__esModule", { value: true });
 var escodegen = __webpack_require__(23);
 var esprima = __webpack_require__(36);
 var estraverse = __webpack_require__(11);
@@ -442,6 +441,7 @@ exports.RandomGeneratorUtils = RandomGeneratorUtils;
 "use strict";
 
 
+var tslib_1 = __webpack_require__(1);
 function initializable() {
     var initializeMethodKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'initialize';
 
@@ -453,21 +453,21 @@ function initializable() {
         };
         var initializeMethod = target[initializeMethodKey];
         if (!initializeMethod || typeof initializeMethod !== 'function') {
-            throw new Error('`' + initializeMethodKey + '` method with initialization logic not found. `@' + decoratorName + '` decorator requires `' + initializeMethodKey + '` method');
+            throw new Error("`" + initializeMethodKey + "` method with initialization logic not found. `@" + decoratorName + "` decorator requires `" + initializeMethodKey + "` method");
         }
-        var metadataPropertyKey = '_' + propertyKey;
+        var metadataPropertyKey = "_" + propertyKey;
         var propertyDescriptor = Object.getOwnPropertyDescriptor(target, metadataPropertyKey) || descriptor;
         var methodDescriptor = Object.getOwnPropertyDescriptor(target, initializeMethodKey) || descriptor;
         var originalMethod = methodDescriptor.value;
-        Object.defineProperty(target, propertyKey, Object.assign({}, propertyDescriptor, { get: function get() {
+        Object.defineProperty(target, propertyKey, tslib_1.__assign({}, propertyDescriptor, { get: function get() {
                 if (this[metadataPropertyKey] === undefined) {
-                    throw new Error('Property `' + propertyKey + '` is not initialized! Initialize it first!');
+                    throw new Error("Property `" + propertyKey + "` is not initialized! Initialize it first!");
                 }
                 return this[metadataPropertyKey];
             }, set: function set(newVal) {
                 this[metadataPropertyKey] = newVal;
             } }));
-        Object.defineProperty(target, initializeMethodKey, Object.assign({}, methodDescriptor, { value: function value() {
+        Object.defineProperty(target, initializeMethodKey, tslib_1.__assign({}, methodDescriptor, { value: function value() {
                 originalMethod.apply(this, arguments);
                 if (this[propertyKey]) {}
             } }));
@@ -1531,7 +1531,6 @@ exports.AbstractReplacer = AbstractReplacer;
 "use strict";
 
 
-Object.defineProperty(exports, "__esModule", { value: true });
 var SourceMapMode_1 = __webpack_require__(20);
 exports.NO_CUSTOM_NODES_PRESET = Object.freeze({
     compact: true,
@@ -1648,7 +1647,6 @@ var AbstractControlFlowReplacer_1;
 "use strict";
 
 
-Object.defineProperty(exports, "__esModule", { value: true });
 var SourceMapMode_1 = __webpack_require__(20);
 exports.DEFAULT_PRESET = Object.freeze({
     compact: true,
@@ -2122,7 +2120,6 @@ var _createClass = (function () { function defineProperties(target, props) { for
 
 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 
-Object.defineProperty(exports, "__esModule", { value: true });
 var tslib_1 = __webpack_require__(1);
 var inversify_1 = __webpack_require__(0);
 var ServiceIdentifiers_1 = __webpack_require__(2);
@@ -2242,7 +2239,6 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
 
 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 
-Object.defineProperty(exports, "__esModule", { value: true });
 var tslib_1 = __webpack_require__(1);
 var inversify_1 = __webpack_require__(0);
 var ServiceIdentifiers_1 = __webpack_require__(2);
@@ -2358,7 +2354,6 @@ var _createClass = (function () { function defineProperties(target, props) { for
 
 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 
-Object.defineProperty(exports, "__esModule", { value: true });
 var tslib_1 = __webpack_require__(1);
 var inversify_1 = __webpack_require__(0);
 var ServiceIdentifiers_1 = __webpack_require__(2);
@@ -2508,7 +2503,6 @@ var _createClass = (function () { function defineProperties(target, props) { for
 
 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 
-Object.defineProperty(exports, "__esModule", { value: true });
 var commander = __webpack_require__(138);
 var path = __webpack_require__(37);
 var SourceMapMode_1 = __webpack_require__(20);
@@ -4059,7 +4053,7 @@ var NodeCallsControllerFunctionNode = function (_AbstractCustomNode_) {
             if (this.appendEvent === ObfuscationEvents_1.ObfuscationEvents.AfterObfuscation) {
                 return JavaScriptObfuscator_1.JavaScriptObfuscator.obfuscate(format(SingleNodeCallControllerTemplate_1.SingleNodeCallControllerTemplate(), {
                     singleNodeCallControllerFunctionName: this.callsControllerFunctionName
-                }), Object.assign({}, NoCustomNodes_1.NO_CUSTOM_NODES_PRESET, { seed: this.options.seed })).getObfuscatedCode();
+                }), tslib_1.__assign({}, NoCustomNodes_1.NO_CUSTOM_NODES_PRESET, { seed: this.options.seed })).getObfuscatedCode();
             }
             return format(SingleNodeCallControllerTemplate_1.SingleNodeCallControllerTemplate(), {
                 singleNodeCallControllerFunctionName: this.callsControllerFunctionName
@@ -4273,7 +4267,7 @@ var StringArrayCallsWrapper = function (_AbstractCustomNode_) {
                 decodeNodeTemplate: decodeNodeTemplate,
                 stringArrayCallsWrapperName: this.stringArrayCallsWrapperName,
                 stringArrayName: this.stringArrayName
-            }), Object.assign({}, NoCustomNodes_1.NO_CUSTOM_NODES_PRESET, { seed: this.options.seed })).getObfuscatedCode();
+            }), tslib_1.__assign({}, NoCustomNodes_1.NO_CUSTOM_NODES_PRESET, { seed: this.options.seed })).getObfuscatedCode();
         }
     }, {
         key: "getDecodeStringArrayTemplate",
@@ -4454,7 +4448,7 @@ var StringArrayRotateFunctionNode = function (_AbstractCustomNode_) {
                 stringArrayName: this.stringArrayName,
                 stringArrayRotateValue: Utils_1.Utils.decToHex(this.stringArrayRotateValue),
                 whileFunctionName: whileFunctionName
-            }), Object.assign({}, NoCustomNodes_1.NO_CUSTOM_NODES_PRESET, { seed: this.options.seed })).getObfuscatedCode();
+            }), tslib_1.__assign({}, NoCustomNodes_1.NO_CUSTOM_NODES_PRESET, { seed: this.options.seed })).getObfuscatedCode();
         }
     }]);
 
@@ -5213,6 +5207,8 @@ var MethodDefinitionTransformer_1;
 "use strict";
 
 
+var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
+
 var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
 
 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -5269,11 +5265,17 @@ var TemplateLiteralTransformer = TemplateLiteralTransformer_1 = function (_Abstr
                 nodes.unshift(Nodes_1.Nodes.getLiteralNode(''));
             }
             if (nodes.length > 1) {
-                var root = Nodes_1.Nodes.getBinaryExpressionNode('+', nodes.shift(), nodes.shift());
-                nodes.forEach(function (node) {
-                    root = Nodes_1.Nodes.getBinaryExpressionNode('+', root, node);
-                });
-                return root;
+                var _ret = function () {
+                    var root = Nodes_1.Nodes.getBinaryExpressionNode('+', nodes.shift(), nodes.shift());
+                    nodes.forEach(function (node) {
+                        root = Nodes_1.Nodes.getBinaryExpressionNode('+', root, node);
+                    });
+                    return {
+                        v: root
+                    };
+                }();
+
+                if ((typeof _ret === "undefined" ? "undefined" : _typeof(_ret)) === "object") return _ret.v;
             }
             return nodes[0];
         }
@@ -5305,7 +5307,6 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
 
 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
 
-Object.defineProperty(exports, "__esModule", { value: true });
 var tslib_1 = __webpack_require__(1);
 var inversify_1 = __webpack_require__(0);
 var ServiceIdentifiers_1 = __webpack_require__(2);
@@ -6369,7 +6370,6 @@ var StringLiteralReplacer_1;
 
 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 
-Object.defineProperty(exports, "__esModule", { value: true });
 var tslib_1 = __webpack_require__(1);
 var inversify_1 = __webpack_require__(0);
 var class_validator_1 = __webpack_require__(137);
@@ -6861,7 +6861,7 @@ var StackTraceAnalyzer = StackTraceAnalyzer_1 = function () {
                 if (!calleeData) {
                     return;
                 }
-                stackTraceData.push(Object.assign({}, calleeData, { stackTrace: _this2.analyzeRecursive(calleeData.callee.body) }));
+                stackTraceData.push(tslib_1.__assign({}, calleeData, { stackTrace: _this2.analyzeRecursive(calleeData.callee.body) }));
             });
         }
     }], [{