瀏覽代碼

Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/65

sanex3339 7 年之前
父節點
當前提交
2114064665

+ 3 - 1
CHANGELOG.md

@@ -9,10 +9,12 @@ v0.10.0
 * `controlFlowFlattening` now affects string literal nodes.
 * increased runtime performance with `rc4` `stringArrayEncoding`.
 * added support for async functions
-* fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/54
+* fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/65
 * fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/60
+* fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/54
 * fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/57
 * fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/58
+* fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/58
 
 v0.9.3
 ---

File diff suppressed because it is too large
+ 0 - 0
dist/index.js


+ 2 - 2
package.json

@@ -1,6 +1,6 @@
 {
   "name": "javascript-obfuscator",
-  "version": "0.10.0-beta.7",
+  "version": "0.10.0-beta.8",
   "description": "JavaScript obfuscator",
   "keywords": [
     "obfuscator",
@@ -46,7 +46,7 @@
     "@types/md5": "2.1.32",
     "@types/mkdirp": "0.3.29",
     "@types/mocha": "2.2.41",
-    "@types/node": "8.0.8",
+    "@types/node": "8.0.9",
     "@types/sinon": "2.3.2",
     "@types/string-template": "1.0.2",
     "awesome-typescript-loader": "3.2.1",

+ 10 - 3
src/templates/custom-nodes/AtobTemplate.ts

@@ -4,9 +4,16 @@
 export function AtobTemplate (): string {
     return `
         (function () {
-            var getGlobal = Function('return (function () ' + '{}.constructor("return this")()' + ');');
-
-            var object = getGlobal();
+            var object;
+            
+            try { 
+                var getGlobal = Function('return (function() ' + '{}.constructor("return this")( )' + ');');
+                
+                object = getGlobal(); 
+            } catch (e) { 
+                object = window; 
+            }
+            
             var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
 
             object.atob || (

+ 10 - 4
src/templates/custom-nodes/console-output-nodes/console-output-disable-expression-node/ConsoleOutputDisableExpressionTemplate.ts

@@ -3,11 +3,17 @@
  */
 export function ConsoleOutputDisableExpressionTemplate (): string {
     return `
-        var {consoleLogDisableFunctionName} = {singleNodeCallControllerFunctionName}(this, function () {
-            var getGlobal = Function('return (function() ' + '{}.constructor("return this")( )' + ');');
-            
+        var {consoleLogDisableFunctionName} = {singleNodeCallControllerFunctionName}(this, function () {            
             var func = function () {};
-            var that = getGlobal();
+            var that;
+            
+            try { 
+                var getGlobal = Function('return (function() ' + '{}.constructor("return this")( )' + ');');
+                
+                that = getGlobal(); 
+            } catch (e) { 
+                that = window; 
+            }
                         
             if (!that.console) {
                 that.console = (function (func){ 

+ 26 - 9
src/templates/custom-nodes/domain-lock-nodes/domain-lock-node/DomainLockNodeTemplate.ts

@@ -4,26 +4,43 @@
 export function DomainLockNodeTemplate (): string {
     return `
         var {domainLockFunctionName} = {singleNodeCallControllerFunctionName}(this, function () {
-            var getGlobal = Function('return (function () ' + '{}.constructor("return this")()' + ');');
-
+            var getGlobal = function () {
+                var globalObject;
+            
+                try {                     
+                    globalObject = Function('return (function() ' + '{}.constructor("return this")( )' + ');')(); 
+                } catch (e) { 
+                    globalObject = window; 
+                }
+                
+                return globalObject;
+            };
+            var that = getGlobal();
             var func = function () { 
                 return {
                     key: 'item',
                     value: 'attribute',
                     getAttribute: function () {
-                        getGlobal()['eval']('while(true){}')();
+                        for (var i = 0; i < 1000; i--) {
+                            var isPositive = i > 0;
+                            
+                            switch (isPositive) {
+                                case true:
+                                    return this.item + '_' + this.value + '_' + i;
+                                default:
+                                    this.item + '_' + this.value;
+                            }
+                        }
                     }()
                 };
             };
                         
             var regExp = new RegExp("[{diff}]", "g");
             var domains = "{domains}".replace(regExp, "").split(";");
-            var eval = []["forEach"]["constructor"];
-            var windowObject = eval("return this")();
             var document;
             var domain;
                         
-            for (var d in windowObject) {
+            for (var d in that) {
                 if (d.length == 8 && d.charCodeAt(7) == 116 && d.charCodeAt(5) == 101 && d.charCodeAt(3) == 117 && d.charCodeAt(0) == 100) {
                     document = d;
                 
@@ -31,7 +48,7 @@ export function DomainLockNodeTemplate (): string {
                 }
             }
 
-            for (var d1 in windowObject[document]) {
+            for (var d1 in that[document]) {
                 if (d1.length == 6 && d1.charCodeAt(5) == 110 && d1.charCodeAt(0) == 100) {
                     domain = d1;
                     
@@ -39,11 +56,11 @@ export function DomainLockNodeTemplate (): string {
                 }
             }
             
-            if ((!document && !domain) || (!windowObject[document] && !windowObject[document][domain])) {
+            if ((!document && !domain) || (!that[document] && !that[document][domain])) {
                 return;
             }
             
-            var currentDomain = windowObject[document][domain];
+            var currentDomain = that[document][domain];
 
             var ok = false;
                         

+ 31 - 12
yarn.lock

@@ -54,9 +54,9 @@
   version "8.0.7"
   resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.7.tgz#fb0ad04b5b6f6eabe0372a32a8f1fbba5c130cae"
 
-"@types/[email protected].8":
-  version "8.0.8"
-  resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.8.tgz#0dc4ca2c6f6fc69baee16c5e928c4a627f517ada"
+"@types/[email protected].9":
+  version "8.0.9"
+  resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.9.tgz#19f44c3b6cb8a70d261d366f73650e3e3891ab2d"
 
 "@types/[email protected]":
   version "2.3.2"
@@ -1308,7 +1308,7 @@ encoding@^0.1.11:
   dependencies:
     iconv-lite "~0.4.13"
 
-enhanced-resolve@^3.0.0, enhanced-resolve@^3.1.0:
+enhanced-resolve@^3.1.0:
   version "3.1.0"
   resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-3.1.0.tgz#9f4b626f577245edcf4b2ad83d86e17f4f421dec"
   dependencies:
@@ -1317,6 +1317,15 @@ enhanced-resolve@^3.0.0, enhanced-resolve@^3.1.0:
     object-assign "^4.0.1"
     tapable "^0.2.5"
 
+enhanced-resolve@^3.3.0:
+  version "3.3.0"
+  resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-3.3.0.tgz#950964ecc7f0332a42321b673b38dc8ff15535b3"
+  dependencies:
+    graceful-fs "^4.1.2"
+    memory-fs "^0.4.0"
+    object-assign "^4.0.1"
+    tapable "^0.2.5"
+
 errno@^0.1.3:
   version "0.1.4"
   resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.4.tgz#b896e23a9e5e8ba33871fc996abd3635fc9a1c7d"
@@ -3795,15 +3804,25 @@ uglify-js@^2.6:
   optionalDependencies:
     uglify-to-browserify "~1.0.0"
 
+uglify-js@^2.8.29:
+  version "2.8.29"
+  resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd"
+  dependencies:
+    source-map "~0.5.1"
+    yargs "~3.10.0"
+  optionalDependencies:
+    uglify-to-browserify "~1.0.0"
+
 uglify-to-browserify@~1.0.0:
   version "1.0.2"
   resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7"
 
-uglifyjs-webpack-plugin@^0.4.4:
-  version "0.4.4"
-  resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-0.4.4.tgz#7829c50ee5a5b755969d4458357ed5a2dd36fbbd"
+uglifyjs-webpack-plugin@^0.4.6:
+  version "0.4.6"
+  resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-0.4.6.tgz#b951f4abb6bd617e66f63eb891498e391763e309"
   dependencies:
     source-map "^0.5.6"
+    uglify-js "^2.8.29"
     webpack-sources "^1.0.1"
 
 uid-number@^0.0.6:
@@ -3911,16 +3930,16 @@ webpack-sources@^1.0.1:
     source-list-map "^2.0.0"
     source-map "~0.5.3"
 
-webpack@3.0.0:
-  version "3.0.0"
-  resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.0.0.tgz#ee9bcebf21247f7153cb410168cab45e3a59d4d7"
+webpack@3.1.0:
+  version "3.1.0"
+  resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.1.0.tgz#ac0675e500db835f9ab2369d29ba096f51ad0731"
   dependencies:
     acorn "^5.0.0"
     acorn-dynamic-import "^2.0.0"
     ajv "^5.1.5"
     ajv-keywords "^2.0.0"
     async "^2.1.2"
-    enhanced-resolve "^3.0.0"
+    enhanced-resolve "^3.3.0"
     escope "^3.6.0"
     interpret "^1.0.0"
     json-loader "^0.5.4"
@@ -3933,7 +3952,7 @@ [email protected]:
     source-map "^0.5.3"
     supports-color "^3.1.0"
     tapable "~0.2.5"
-    uglifyjs-webpack-plugin "^0.4.4"
+    uglifyjs-webpack-plugin "^0.4.6"
     watchpack "^1.3.1"
     webpack-sources "^1.0.1"
     yargs "^6.0.0"

Some files were not shown because too many files changed in this diff