Explorar o código

Added logo, changed debug protection templates

sanex3339 %!s(int64=7) %!d(string=hai) anos
pai
achega
1c3e922e26

+ 1 - 0
.npmignore

@@ -1,2 +1,3 @@
 test/fixtures/compile-performance.js
 coverage
+images

+ 3 - 0
CHANGELOG.md

@@ -4,6 +4,9 @@ v0.12.0
 ---
 * Added ability to disable and enable obfuscation for specific parts of the code by adding conditional comments. 
 * Added obfuscation of `es2015` class names.
+
+v0.11.1
+---
 * Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/94
 
 v0.11.0

+ 2 - 0
README.md

@@ -6,6 +6,8 @@
 
 # JavaScript obfuscator for Node.js
 
+![logo](https://raw.githubusercontent.com/javascript-obfuscator/javascript-obfuscator/master/images/logo_1_300.png)
+
 JavaScript obfuscator is a powerful free obfuscator for JavaScript and Node.js with a wide number of features which provides protection for your source code.
 
 * has no limits or restrictions

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
dist/index.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 33 - 0
images/logo.ai


BIN=BIN
images/logo_1.png


BIN=BIN
images/logo_1_300.png


BIN=BIN
images/logo_2.png


BIN=BIN
images/logo_2_300.png


+ 1 - 1
package.json

@@ -69,7 +69,7 @@
     "tslint-language-service": "^0.9.6",
     "tslint-webpack-plugin": "1.0.0",
     "typescript": "2.5.2",
-    "webpack": "3.5.6",
+    "webpack": "3.6.0",
     "webpack-node-externals": "1.6.0"
   },
   "repository": {

+ 11 - 4
src/custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup.ts

@@ -64,13 +64,20 @@ export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup {
      * @param {IStackTraceData[]} stackTraceData
      */
     public appendCustomNodes (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]): void {
-        // debugProtectionFunctionNode append
-        this.appendCustomNodeIfExist(CustomNode.DebugProtectionFunctionNode, (customNode: ICustomNode) => {
-            NodeAppender.appendNode(blockScopeNode, customNode.getNode());
-        });
+        const randomStackTraceIndex: number = this.getRandomStackTraceIndex(stackTraceData.length);
 
         // debugProtectionFunctionCallNode append
         this.appendCustomNodeIfExist(CustomNode.DebugProtectionFunctionCallNode, (customNode: ICustomNode) => {
+            NodeAppender.appendNodeToOptimalBlockScope(
+                stackTraceData,
+                blockScopeNode,
+                customNode.getNode(),
+                randomStackTraceIndex
+            );
+        });
+
+        // debugProtectionFunctionNode append
+        this.appendCustomNodeIfExist(CustomNode.DebugProtectionFunctionNode, (customNode: ICustomNode) => {
             NodeAppender.appendNode(blockScopeNode, customNode.getNode());
         });
 

+ 3 - 10
src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.ts

@@ -197,16 +197,9 @@ export class DeadCodeInjectionTransformer extends AbstractNodeTransformer {
         const leftString: string = this.randomGenerator.getRandomString(3);
         const rightString: string = random2 ? leftString : this.randomGenerator.getRandomString(3);
 
-        let consequent: ESTree.BlockStatement,
-            alternate: ESTree.BlockStatement;
-
-        if ((random1 && random2) || (!random1 && !random2)) {
-            consequent = blockStatementNode;
-            alternate = randomBlockStatementNode;
-        } else {
-            consequent = randomBlockStatementNode;
-            alternate = blockStatementNode;
-        }
+        const [consequent, alternate]: [ESTree.BlockStatement, ESTree.BlockStatement] = random1 === random2
+            ? [blockStatementNode, randomBlockStatementNode]
+            : [randomBlockStatementNode, blockStatementNode];
 
         let newBlockStatementNode: ESTree.BlockStatement = Nodes.getBlockStatementNode([
             Nodes.getIfStatementNode(

+ 11 - 1
src/templates/custom-nodes/debug-protection-nodes/debug-protection-function-call-node/DebufProtectionFunctionCallTemplate.ts

@@ -2,5 +2,15 @@
  * @returns {string}
  */
 export function DebugProtectionFunctionCallTemplate (): string {
-    return `{debugProtectionFunctionName}();`;
+    return `
+        var regExp1 = new RegExp('function *\\\\( *\\\\)');
+        var regExp2 = new RegExp('_0x([a-f0-9]){4,6} *\\\\(\\\\+\\\\+ *_0x([a-f0-9]){4,6} *\\\\)');
+        var result = {debugProtectionFunctionName}('init');
+        
+        if (!regExp1.test(result + 'chain') || !regExp2.test(result + 'input')) {
+            result('0');
+        } else {
+            {debugProtectionFunctionName}();
+        }
+    `;
 }

+ 16 - 7
src/templates/custom-nodes/debug-protection-nodes/debug-protection-function-node/DebugProtectionFunctionTemplate.ts

@@ -2,21 +2,30 @@
  * @returns {string}
  */
 export function DebugProtectionFunctionTemplate (): string {
-    return `
-        var {debugProtectionFunctionName} = function () {
+    return `     
+        function {debugProtectionFunctionName} (ret) {
             function debuggerProtection (counter) {
-                if (('' + counter / counter)['length'] !== 1 || counter % 20 === 0) {
-                    (function () {}.constructor('debugger')());
+                if (typeof counter === 'string') {
+                    return (function (arg) {}.constructor('while (true) {}').apply('counter'));
                 } else {
-                    (function () {}.constructor('debugger')());
+                    if (('' + counter / counter)['length'] !== 1 || counter % 20 === 0) {
+                        (function () {return true;}.constructor('debu' + 'gger').call('action'));
+                    } else {
+                        (function () {return false;}.constructor('debu' + 'gger').apply('stateObject'));
+                    }
+                    
                 }
                 
                 debuggerProtection(++counter);
             }
             
             try {
-                debuggerProtection(0);
+                if (ret) {
+                    return debuggerProtection;
+                } else {
+                    debuggerProtection(0);
+                }
             } catch (y) {}
-        };
+        }
     `;
 }

+ 3 - 3
yarn.lock

@@ -4033,9 +4033,9 @@ webpack-sources@^1.0.1:
     source-list-map "^2.0.0"
     source-map "~0.5.3"
 
-webpack@3.5.6:
-  version "3.5.6"
-  resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.5.6.tgz#a492fb6c1ed7f573816f90e00c8fbb5a20cc5c36"
[email protected].0:
+  version "3.6.0"
+  resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.6.0.tgz#a89a929fbee205d35a4fa2cc487be9cbec8898bc"
   dependencies:
     acorn "^5.0.0"
     acorn-dynamic-import "^2.0.0"

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio