js-confuser 1.7.2 → 2.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (263) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +6 -4
  2. package/.github/workflows/node.js.yml +1 -1
  3. package/CHANGELOG.md +105 -0
  4. package/Migration.md +57 -0
  5. package/README.md +23 -913
  6. package/dist/constants.js +69 -13
  7. package/dist/index.js +108 -152
  8. package/dist/obfuscator.js +316 -118
  9. package/dist/options.js +1 -109
  10. package/dist/order.js +30 -30
  11. package/dist/presets.js +47 -45
  12. package/dist/probability.js +25 -32
  13. package/dist/templates/bufferToStringTemplate.js +9 -0
  14. package/dist/templates/deadCodeTemplates.js +9 -0
  15. package/dist/templates/getGlobalTemplate.js +19 -0
  16. package/dist/templates/integrityTemplate.js +30 -0
  17. package/dist/templates/setFunctionLengthTemplate.js +9 -0
  18. package/dist/templates/stringCompressionTemplate.js +10 -0
  19. package/dist/templates/tamperProtectionTemplates.js +21 -0
  20. package/dist/templates/template.js +213 -93
  21. package/dist/transforms/astScrambler.js +100 -0
  22. package/dist/transforms/calculator.js +70 -127
  23. package/dist/transforms/controlFlowFlattening.js +1182 -0
  24. package/dist/transforms/deadCode.js +62 -577
  25. package/dist/transforms/dispatcher.js +300 -309
  26. package/dist/transforms/extraction/duplicateLiteralsRemoval.js +88 -189
  27. package/dist/transforms/extraction/objectExtraction.js +131 -215
  28. package/dist/transforms/finalizer.js +56 -59
  29. package/dist/transforms/flatten.js +275 -276
  30. package/dist/transforms/functionOutlining.js +230 -0
  31. package/dist/transforms/identifier/globalConcealing.js +217 -103
  32. package/dist/transforms/identifier/movedDeclarations.js +167 -91
  33. package/dist/transforms/identifier/renameVariables.js +240 -187
  34. package/dist/transforms/lock/integrity.js +61 -184
  35. package/dist/transforms/lock/lock.js +263 -303
  36. package/dist/transforms/minify.js +431 -436
  37. package/dist/transforms/opaquePredicates.js +65 -118
  38. package/dist/transforms/pack.js +160 -0
  39. package/dist/transforms/plugin.js +179 -0
  40. package/dist/transforms/preparation.js +263 -163
  41. package/dist/transforms/renameLabels.js +132 -56
  42. package/dist/transforms/rgf.js +142 -240
  43. package/dist/transforms/shuffle.js +52 -145
  44. package/dist/transforms/string/encoding.js +45 -173
  45. package/dist/transforms/string/stringCompression.js +81 -126
  46. package/dist/transforms/string/stringConcealing.js +189 -224
  47. package/dist/transforms/string/stringEncoding.js +32 -40
  48. package/dist/transforms/string/stringSplitting.js +54 -55
  49. package/dist/transforms/variableMasking.js +232 -0
  50. package/dist/utils/ControlObject.js +125 -0
  51. package/dist/utils/IntGen.js +46 -0
  52. package/dist/utils/NameGen.js +106 -0
  53. package/dist/utils/ast-utils.js +560 -0
  54. package/dist/utils/function-utils.js +56 -0
  55. package/dist/utils/gen-utils.js +48 -0
  56. package/dist/utils/node.js +77 -0
  57. package/dist/utils/object-utils.js +21 -0
  58. package/dist/utils/random-utils.js +91 -0
  59. package/dist/utils/static-utils.js +64 -0
  60. package/dist/validateOptions.js +122 -0
  61. package/index.d.ts +1 -17
  62. package/package.json +27 -22
  63. package/src/constants.ts +139 -77
  64. package/src/index.ts +70 -163
  65. package/src/obfuscationResult.ts +43 -0
  66. package/src/obfuscator.ts +328 -135
  67. package/src/options.ts +154 -623
  68. package/src/order.ts +14 -14
  69. package/src/presets.ts +39 -34
  70. package/src/probability.ts +21 -36
  71. package/src/templates/{bufferToString.ts → bufferToStringTemplate.ts} +5 -54
  72. package/src/templates/deadCodeTemplates.ts +1185 -0
  73. package/src/templates/getGlobalTemplate.ts +72 -0
  74. package/src/templates/integrityTemplate.ts +69 -0
  75. package/src/templates/setFunctionLengthTemplate.ts +11 -0
  76. package/src/templates/stringCompressionTemplate.ts +42 -0
  77. package/src/templates/tamperProtectionTemplates.ts +116 -0
  78. package/src/templates/template.ts +183 -92
  79. package/src/transforms/astScrambler.ts +99 -0
  80. package/src/transforms/calculator.ts +96 -224
  81. package/src/transforms/controlFlowFlattening.ts +1594 -0
  82. package/src/transforms/deadCode.ts +85 -628
  83. package/src/transforms/dispatcher.ts +431 -636
  84. package/src/transforms/extraction/duplicateLiteralsRemoval.ts +147 -299
  85. package/src/transforms/extraction/objectExtraction.ts +160 -333
  86. package/src/transforms/finalizer.ts +63 -64
  87. package/src/transforms/flatten.ts +439 -557
  88. package/src/transforms/functionOutlining.ts +225 -0
  89. package/src/transforms/identifier/globalConcealing.ts +261 -189
  90. package/src/transforms/identifier/movedDeclarations.ts +228 -142
  91. package/src/transforms/identifier/renameVariables.ts +252 -258
  92. package/src/transforms/lock/integrity.ts +84 -260
  93. package/src/transforms/lock/lock.ts +342 -491
  94. package/src/transforms/minify.ts +523 -663
  95. package/src/transforms/opaquePredicates.ts +90 -229
  96. package/src/transforms/pack.ts +195 -0
  97. package/src/transforms/plugin.ts +185 -0
  98. package/src/transforms/preparation.ts +337 -215
  99. package/src/transforms/renameLabels.ts +176 -77
  100. package/src/transforms/rgf.ts +293 -386
  101. package/src/transforms/shuffle.ts +80 -254
  102. package/src/transforms/string/encoding.ts +26 -129
  103. package/src/transforms/string/stringCompression.ts +118 -236
  104. package/src/transforms/string/stringConcealing.ts +255 -339
  105. package/src/transforms/string/stringEncoding.ts +28 -47
  106. package/src/transforms/string/stringSplitting.ts +61 -75
  107. package/src/transforms/variableMasking.ts +257 -0
  108. package/src/utils/ControlObject.ts +141 -0
  109. package/src/utils/IntGen.ts +33 -0
  110. package/src/utils/NameGen.ts +106 -0
  111. package/src/utils/ast-utils.ts +667 -0
  112. package/src/utils/function-utils.ts +50 -0
  113. package/src/utils/gen-utils.ts +48 -0
  114. package/src/utils/node.ts +78 -0
  115. package/src/utils/object-utils.ts +21 -0
  116. package/src/utils/random-utils.ts +79 -0
  117. package/src/utils/static-utils.ts +66 -0
  118. package/src/validateOptions.ts +256 -0
  119. package/tsconfig.json +13 -8
  120. package/babel.config.js +0 -12
  121. package/dev.js +0 -8
  122. package/dist/compiler.js +0 -34
  123. package/dist/parser.js +0 -59
  124. package/dist/precedence.js +0 -66
  125. package/dist/templates/bufferToString.js +0 -108
  126. package/dist/templates/crash.js +0 -59
  127. package/dist/templates/es5.js +0 -137
  128. package/dist/templates/functionLength.js +0 -34
  129. package/dist/templates/globals.js +0 -9
  130. package/dist/transforms/antiTooling.js +0 -88
  131. package/dist/transforms/controlFlowFlattening/controlFlowFlattening.js +0 -1281
  132. package/dist/transforms/controlFlowFlattening/expressionObfuscation.js +0 -131
  133. package/dist/transforms/es5/antiClass.js +0 -164
  134. package/dist/transforms/es5/antiDestructuring.js +0 -193
  135. package/dist/transforms/es5/antiES6Object.js +0 -185
  136. package/dist/transforms/es5/antiSpreadOperator.js +0 -35
  137. package/dist/transforms/es5/antiTemplate.js +0 -66
  138. package/dist/transforms/es5/es5.js +0 -123
  139. package/dist/transforms/extraction/classExtraction.js +0 -83
  140. package/dist/transforms/identifier/globalAnalysis.js +0 -70
  141. package/dist/transforms/identifier/variableAnalysis.js +0 -104
  142. package/dist/transforms/lock/antiDebug.js +0 -76
  143. package/dist/transforms/stack.js +0 -343
  144. package/dist/transforms/transform.js +0 -350
  145. package/dist/traverse.js +0 -110
  146. package/dist/util/compare.js +0 -145
  147. package/dist/util/gen.js +0 -564
  148. package/dist/util/guard.js +0 -9
  149. package/dist/util/identifiers.js +0 -355
  150. package/dist/util/insert.js +0 -362
  151. package/dist/util/math.js +0 -19
  152. package/dist/util/object.js +0 -40
  153. package/dist/util/random.js +0 -130
  154. package/dist/util/scope.js +0 -20
  155. package/docs/ControlFlowFlattening.md +0 -595
  156. package/docs/Countermeasures.md +0 -63
  157. package/docs/ES5.md +0 -197
  158. package/docs/Integrity.md +0 -75
  159. package/docs/RGF.md +0 -419
  160. package/samples/example.js +0 -15
  161. package/samples/high.js +0 -1
  162. package/samples/input.js +0 -3
  163. package/samples/javascriptobfuscator.com.js +0 -8
  164. package/samples/jscrambler_advanced.js +0 -1894
  165. package/samples/jscrambler_light.js +0 -1134
  166. package/samples/low.js +0 -1
  167. package/samples/medium.js +0 -1
  168. package/samples/obfuscator.io.js +0 -1686
  169. package/samples/preemptive.com.js +0 -16
  170. package/src/compiler.ts +0 -35
  171. package/src/parser.ts +0 -49
  172. package/src/precedence.ts +0 -61
  173. package/src/templates/crash.ts +0 -55
  174. package/src/templates/es5.ts +0 -131
  175. package/src/templates/functionLength.ts +0 -32
  176. package/src/templates/globals.ts +0 -3
  177. package/src/transforms/antiTooling.ts +0 -102
  178. package/src/transforms/controlFlowFlattening/controlFlowFlattening.ts +0 -2146
  179. package/src/transforms/controlFlowFlattening/expressionObfuscation.ts +0 -179
  180. package/src/transforms/es5/antiClass.ts +0 -272
  181. package/src/transforms/es5/antiDestructuring.ts +0 -294
  182. package/src/transforms/es5/antiES6Object.ts +0 -267
  183. package/src/transforms/es5/antiSpreadOperator.ts +0 -56
  184. package/src/transforms/es5/antiTemplate.ts +0 -98
  185. package/src/transforms/es5/es5.ts +0 -149
  186. package/src/transforms/extraction/classExtraction.ts +0 -168
  187. package/src/transforms/identifier/globalAnalysis.ts +0 -85
  188. package/src/transforms/identifier/variableAnalysis.ts +0 -118
  189. package/src/transforms/lock/antiDebug.ts +0 -112
  190. package/src/transforms/stack.ts +0 -551
  191. package/src/transforms/transform.ts +0 -453
  192. package/src/traverse.ts +0 -120
  193. package/src/types.ts +0 -131
  194. package/src/util/compare.ts +0 -181
  195. package/src/util/gen.ts +0 -651
  196. package/src/util/guard.ts +0 -7
  197. package/src/util/identifiers.ts +0 -494
  198. package/src/util/insert.ts +0 -419
  199. package/src/util/math.ts +0 -15
  200. package/src/util/object.ts +0 -39
  201. package/src/util/random.ts +0 -141
  202. package/src/util/scope.ts +0 -21
  203. package/test/code/Cash.src.js +0 -1011
  204. package/test/code/Cash.test.ts +0 -49
  205. package/test/code/Dynamic.src.js +0 -118
  206. package/test/code/Dynamic.test.ts +0 -49
  207. package/test/code/ES6.src.js +0 -235
  208. package/test/code/ES6.test.ts +0 -42
  209. package/test/code/NewFeatures.test.ts +0 -19
  210. package/test/code/StrictMode.src.js +0 -65
  211. package/test/code/StrictMode.test.js +0 -37
  212. package/test/compare.test.ts +0 -104
  213. package/test/index.test.ts +0 -249
  214. package/test/options.test.ts +0 -132
  215. package/test/presets.test.ts +0 -22
  216. package/test/probability.test.ts +0 -44
  217. package/test/templates/template.test.ts +0 -14
  218. package/test/transforms/antiTooling.test.ts +0 -52
  219. package/test/transforms/calculator.test.ts +0 -78
  220. package/test/transforms/controlFlowFlattening/controlFlowFlattening.test.ts +0 -1274
  221. package/test/transforms/controlFlowFlattening/expressionObfuscation.test.ts +0 -192
  222. package/test/transforms/deadCode.test.ts +0 -85
  223. package/test/transforms/dispatcher.test.ts +0 -457
  224. package/test/transforms/es5/antiClass.test.ts +0 -427
  225. package/test/transforms/es5/antiDestructuring.test.ts +0 -157
  226. package/test/transforms/es5/antiES6Object.test.ts +0 -245
  227. package/test/transforms/es5/antiTemplate.test.ts +0 -116
  228. package/test/transforms/es5/es5.test.ts +0 -110
  229. package/test/transforms/extraction/classExtraction.test.ts +0 -86
  230. package/test/transforms/extraction/duplicateLiteralsRemoval.test.ts +0 -200
  231. package/test/transforms/extraction/objectExtraction.test.ts +0 -491
  232. package/test/transforms/flatten.test.ts +0 -721
  233. package/test/transforms/hexadecimalNumbers.test.ts +0 -62
  234. package/test/transforms/identifier/globalConcealing.test.ts +0 -72
  235. package/test/transforms/identifier/movedDeclarations.test.ts +0 -275
  236. package/test/transforms/identifier/renameVariables.test.ts +0 -621
  237. package/test/transforms/lock/antiDebug.test.ts +0 -66
  238. package/test/transforms/lock/browserLock.test.ts +0 -129
  239. package/test/transforms/lock/countermeasures.test.ts +0 -100
  240. package/test/transforms/lock/integrity.test.ts +0 -161
  241. package/test/transforms/lock/lock.test.ts +0 -204
  242. package/test/transforms/lock/osLock.test.ts +0 -312
  243. package/test/transforms/lock/selfDefending.test.ts +0 -68
  244. package/test/transforms/minify.test.ts +0 -575
  245. package/test/transforms/opaquePredicates.test.ts +0 -43
  246. package/test/transforms/preparation.test.ts +0 -157
  247. package/test/transforms/renameLabels.test.ts +0 -95
  248. package/test/transforms/rgf.test.ts +0 -378
  249. package/test/transforms/shuffle.test.ts +0 -135
  250. package/test/transforms/stack.test.ts +0 -573
  251. package/test/transforms/string/stringCompression.test.ts +0 -120
  252. package/test/transforms/string/stringConcealing.test.ts +0 -299
  253. package/test/transforms/string/stringEncoding.test.ts +0 -95
  254. package/test/transforms/string/stringSplitting.test.ts +0 -135
  255. package/test/transforms/transform.test.ts +0 -66
  256. package/test/traverse.test.ts +0 -139
  257. package/test/util/compare.test.ts +0 -34
  258. package/test/util/gen.test.ts +0 -121
  259. package/test/util/identifiers.test.ts +0 -253
  260. package/test/util/insert.test.ts +0 -142
  261. package/test/util/math.test.ts +0 -5
  262. package/test/util/random.test.ts +0 -71
  263. /package/dist/{types.js → obfuscationResult.js} +0 -0
package/README.md CHANGED
@@ -1,37 +1,39 @@
1
1
  # JS Confuser
2
2
 
3
+ **⚠️ Warning: This an alpha release. This version is not stable and the likelihood of encountering bugs is significantly higher.**
4
+
3
5
  JS-Confuser is a JavaScript obfuscation tool to make your programs _impossible_ to read. [Try the web version](https://js-confuser.com).
4
6
 
5
7
  [![NPM](https://img.shields.io/badge/NPM-%23000000.svg?style=for-the-badge&logo=npm&logoColor=white)](https://npmjs.com/package/js-confuser) [![GitHub](https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white)](https://github.com/MichaelXF/js-confuser) [![Netlify](https://img.shields.io/badge/netlify-%23000000.svg?style=for-the-badge&logo=netlify&logoColor=#00C7B7)](https://js-confuser.com)
6
8
 
7
- ## Key features
8
9
 
9
- - Variable renaming
10
- - Control Flow obfuscation
11
- - String concealing
12
- - Function obfuscation
13
- - Locks (domainLock, date)
14
- - [Detect changes to source code](https://github.com/MichaelXF/js-confuser/blob/master/docs/Integrity.md)
10
+ **The official documentation for this project has moved to [`JS-Confuser.com`](https://js-confuser.com)**:
11
+
12
+ - [Getting Started](https://new--confuser.netlify.app/docs)
13
+
14
+ - - [What is Obfuscation?](https://new--confuser.netlify.app/docs/getting-started/what-is-obfuscation)
15
+
16
+ - - [Playground](https://new--confuser.netlify.app/docs/getting-started/playground)
17
+
18
+ - - [Installation](https://new--confuser.netlify.app/docs/getting-started/installation)
15
19
 
16
- ## Presets
20
+ - - [Usage](https://new--confuser.netlify.app/docs/getting-started/usage)
17
21
 
18
- JS-Confuser comes with three presets built into the obfuscator.
22
+ - - [FAQ](https://new--confuser.netlify.app/docs/getting-started/faq)
19
23
 
20
- | Preset | Transforms | Performance Reduction | Sample |
21
- | --- | --- | --- | --- |
22
- | High | 22/25 | 98% | [Sample](https://github.com/MichaelXF/js-confuser/blob/master/samples/high.js) |
23
- | Medium | 19/25 | 52% | [Sample](https://github.com/MichaelXF/js-confuser/blob/master/samples/medium.js) |
24
- | Low | 15/25 | 30% | [Sample](https://github.com/MichaelXF/js-confuser/blob/master/samples/low.js) |
24
+ - [Options](https://new--confuser.netlify.app/docs)
25
25
 
26
- You can extend each preset or all go without them entirely.
26
+ - [Presets](https://new--confuser.netlify.app/docs)
27
27
 
28
- ## Installation
28
+ ## API Usage
29
+
30
+ ### Installation
29
31
 
30
32
  ```bash
31
33
  $ npm install js-confuser
32
34
  ```
33
35
 
34
- ## Usage
36
+ ### Usage
35
37
 
36
38
  ```js
37
39
  var JsConfuser = require("js-confuser");
@@ -54,8 +56,8 @@ JsConfuser.obfuscate(`
54
56
  target: "node",
55
57
  preset: "high",
56
58
  stringEncoding: false, // <- Normally enabled
57
- }).then(obfuscated => {
58
- console.log(obfuscated)
59
+ }).then(result => {
60
+ console.log(result.code)
59
61
  })
60
62
 
61
63
  /*
@@ -63,866 +65,6 @@ var AF59rI,ZgbbeaU,WDgj3I,gpR2qG,Ox61sk,pTNPNpX;AF59rI=[60,17,25,416,22,23,83,26
63
65
  */
64
66
  ```
65
67
 
66
- ## CLI Usage
67
-
68
- ```shell
69
- <coming soon>
70
- ```
71
-
72
- ## `obfuscate(sourceCode, options)`
73
-
74
- Obfuscates the `sourceCode`. Returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that resolves to a string of the obfuscated code.
75
-
76
- | Parameter | Type | Description |
77
- | --- | --- | --- |
78
- | `sourceCode` | `string` | The JavaScript code to be obfuscated. |
79
- | `options` | `object` | The obfuscator settings. |
80
-
81
- ## `obfuscateAST(AST, options)`
82
-
83
- Obfuscates an [ESTree](https://github.com/estree/estree) compliant AST. Returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
84
-
85
- **Note:** Mutates the object.
86
-
87
- | Parameter | Type | Description |
88
- | --- | --- | --- |
89
- | `AST` | `object` | The [ESTree](https://github.com/estree/estree) compliant AST. This object will be mutated. |
90
- | `options` | `object` | The obfuscator settings. |
91
-
92
- ## Options
93
-
94
- ### `target`
95
-
96
- The execution context for your output. _Required_.
97
-
98
- 1. `"node"`
99
- 2. `"browser"`
100
-
101
- ### `preset`
102
-
103
- [JS-Confuser comes with three presets built into the obfuscator](https://github.com/MichaelXF/js-confuser#presets). _Optional_. (`"high"/"medium"/"low"`)
104
-
105
- ```js
106
- var JsConfuser = require('js-confuser');
107
-
108
- JsConfuser.obfuscate(`<source code>`, {
109
- target: "node",
110
- preset: "high" // | "medium" | "low"
111
- }).then(obfuscated=>{
112
- console.log(obfuscated); // obfuscated is a string
113
- })
114
- ```
115
-
116
- ### `compact`
117
-
118
- Remove's whitespace from the final output. Enabled by default. (`true/false`)
119
-
120
- ### `hexadecimalNumbers`
121
-
122
- Uses the hexadecimal representation for numbers. (`true/false`)
123
-
124
- ### `minify`
125
-
126
- Minifies redundant code. (`true/false`)
127
-
128
- ### `es5`
129
-
130
- Converts output to ES5-compatible code. (`true/false`)
131
-
132
- Does not cover all cases such as Promises or Generator functions. Use [Babel](https://babel.dev/).
133
-
134
- [Learn more here.](https://github.com/MichaelXF/js-confuser/blob/master/docs/ES5.md)
135
-
136
- ### `renameVariables`
137
-
138
- Determines if variables should be renamed. (`true/false`)
139
-
140
- ```js
141
- // Input
142
- var twoSum = function (nums, target) {
143
- var hash = {};
144
- var len = nums.length;
145
- for (var i = 0; i < len; i++) {
146
- if (nums[i] in hash) return [hash[nums[i]], i];
147
- hash[target - nums[i]] = i;
148
- }
149
- return [-1, -1];
150
- };
151
-
152
- var test = function () {
153
- var inputNums = [2, 7, 11, 15];
154
- var inputTarget = 9;
155
- var expectedResult = [0, 1];
156
-
157
- var actualResult = twoSum(inputNums, inputTarget);
158
- ok(actualResult[0] === expectedResult[0]);
159
- ok(actualResult[1] === expectedResult[1]);
160
- };
161
-
162
- test();
163
-
164
- // Output
165
- var _O2mOcF = function (kB4uXM, w_07HXS) {
166
- var ZLTJcx = {};
167
- var sXQOaUx = kB4uXM["length"];
168
- for (var JYYxEk = 0; JYYxEk < sXQOaUx; JYYxEk++) {
169
- if (kB4uXM[JYYxEk] in ZLTJcx) {
170
- return [ZLTJcx[kB4uXM[JYYxEk]], JYYxEk];
171
- }
172
- ZLTJcx[w_07HXS - kB4uXM[JYYxEk]] = JYYxEk;
173
- }
174
- return [-1, -1];
175
- };
176
- var qFaI6S = function () {
177
- var fZpeOw = [2, 7, 11, 15];
178
- var UJ62R2c = 9;
179
- var dG6R0cV = [0, 1];
180
- var WgYXwn = _O2mOcF(fZpeOw, UJ62R2c);
181
- void (ok(WgYXwn[0] === dG6R0cV[0]), ok(WgYXwn[1] === dG6R0cV[1]));
182
- };
183
- qFaI6S();
184
- ```
185
-
186
- ### `renameGlobals`
187
-
188
- Renames top-level variables, turn this off for web-related scripts. Enabled by default. (`true/false`)
189
-
190
- ### `identifierGenerator`
191
-
192
- Determines how variables are renamed.
193
-
194
- | Mode | Description | Example |
195
- | --- | --- | --- |
196
- | `"hexadecimal"` | Random hex strings | \_0xa8db5 |
197
- | `"randomized"` | Random characters | w$Tsu4G |
198
- | `"zeroWidth"` | Invisible characters | U+200D |
199
- | `"mangled"` | Alphabet sequence | a, b, c |
200
- | `"number"` | Numbered sequence | var_1, var_2 |
201
- | `<function>` | Write a custom name generator | See Below |
202
-
203
- ```js
204
- // Custom implementation
205
- JsConfuser.obfuscate(code, {
206
- target: "node",
207
- renameVariables: true,
208
- identifierGenerator: function () {
209
- return "$" + Math.random().toString(36).substring(7);
210
- },
211
- });
212
-
213
- // Numbered variables
214
- var counter = 0;
215
- JsConfuser.obfuscate(code, {
216
- target: "node",
217
- renameVariables: true,
218
- identifierGenerator: function () {
219
- return "var_" + (counter++);
220
- },
221
- });
222
- ```
223
-
224
- JSConfuser tries to reuse names when possible, creating very potent code.
225
-
226
- ### `controlFlowFlattening`
227
-
228
- **⚠️ Significantly impacts performance, use sparingly!**
229
-
230
- Control-flow Flattening hinders program comprehension by creating convoluted switch statements. (`true/false/0-1`)
231
-
232
- Use a number to control the percentage from 0 to 1.
233
-
234
- [Learn more here.](https://github.com/MichaelXF/js-confuser/blob/master/docs/ControlFlowFlattening.md)
235
-
236
- ```js
237
- // Input
238
- function countTo(num){
239
- for ( var i = 1; i <= num; i++ ) {
240
- console.log(i);
241
- }
242
- }
243
-
244
- var number = 10;
245
- countTo(number); // 1,2,3,4,5,6,7,8,9,10
246
-
247
- // Output
248
- var n2DUka,
249
- O7yZ0oU,
250
- mJMdMhJ = -337,
251
- A1Nyvv = -94,
252
- xDwpOk6 = 495,
253
- uKcJl2 = {
254
- TGCpW6t: "log",
255
- qUrjFe: function () {
256
- return xDwpOk6 == (126 > mJMdMhJ ? -16 : 34);
257
- },
258
- YN20IBx: function () {
259
- return (A1Nyvv -= 53);
260
- },
261
- CTW4vwx: -73,
262
- PLzWYDx: function () {
263
- return (O7yZ0oU = [[385, -94, -282], [10]]);
264
- },
265
- bW2FK2: function () {
266
- return (mJMdMhJ *= 2), (mJMdMhJ += 366);
267
- },
268
- AfOoRT: function () {
269
- return xDwpOk6 == xDwpOk6 + 867;
270
- },
271
- KTNMdj: function () {
272
- if (uKcJl2.AfOoRT()) {
273
- typeof ((mJMdMhJ += 0), uKcJl2.Q0I6e4f(), (xDwpOk6 += 0));
274
- return "cobTe8G";
275
- }
276
- typeof (uKcJl2.htRXYx(),
277
- (mJMdMhJ += 59),
278
- (A1Nyvv -= 537),
279
- (xDwpOk6 += uKcJl2.mLuSzZ < mJMdMhJ ? 449 : -33));
280
- return "cobTe8G";
281
- },
282
- };
283
- while (mJMdMhJ + A1Nyvv + xDwpOk6 != 83) {
284
- var yQNDJh = (mJMdMhJ + A1Nyvv + xDwpOk6) * 58 + 54;
285
- switch (yQNDJh) {
286
- case 750:
287
- if (A1Nyvv == 24) {
288
- uKcJl2.FxREGd6();
289
- break;
290
- }
291
- case 1214:
292
- if (uKcJl2.qUrjFe()) {
293
- typeof ((mJMdMhJ *= -8 > xDwpOk6 ? -109 : 2),
294
- (mJMdMhJ += 1168),
295
- (xDwpOk6 += xDwpOk6 - 1290));
296
- break;
297
- }
298
- function _VSsIw() {
299
- var [yQNDJh, _VSsIw] = O7yZ0oU,
300
- [L9B14E] = _VSsIw,
301
- uTyFFb = 322;
302
- while (uTyFFb != 23) {
303
- var cBx3ysg = uTyFFb * 48 - 77;
304
- switch (cBx3ysg) {
305
- case 15379:
306
- var IOoqIZ = 1;
307
- uTyFFb -= 306;
308
- break;
309
- case 691:
310
- uTyFFb += IOoqIZ <= L9B14E ? 976 : 7;
311
- break;
312
- case 47539:
313
- typeof (console[uKcJl2.TGCpW6t](IOoqIZ), (uTyFFb -= 795));
314
- break;
315
- case 9379:
316
- !(IOoqIZ++, (uTyFFb -= 181));
317
- }
318
- }
319
- return ([mJMdMhJ, A1Nyvv, xDwpOk6] = yQNDJh), (n2DUka = void 0);
320
- }
321
- (xDwpOk6 == -73 ? parseInt : _VSsIw)();
322
- break;
323
- case 576:
324
- typeof (mJMdMhJ == -4 ? clearImmediate : void 0,
325
- uKcJl2.bky8kL(),
326
- (xDwpOk6 -= 463));
327
- break;
328
- case 4172:
329
- var L9B14E = 10;
330
- void ((O7yZ0oU = [[385, -94, -282], [10]]),
331
- (mJMdMhJ -= 187),
332
- uKcJl2.YN20IBx(),
333
- (xDwpOk6 += 189));
334
- break;
335
- case 3766:
336
- !((uKcJl2.Fpp8x5 = -167),
337
- (uKcJl2.mLuSzZ = 144),
338
- (uKcJl2.FxREGd6 = function () {
339
- return (mJMdMhJ += uKcJl2.Fpp8x5), (xDwpOk6 += 164);
340
- }),
341
- (uKcJl2.bky8kL = function () {
342
- return (A1Nyvv += 537);
343
- }),
344
- (uKcJl2.Q0I6e4f = function () {
345
- return (A1Nyvv += 0);
346
- }),
347
- (uKcJl2.htRXYx = function () {
348
- return (xDwpOk6 = -82);
349
- }));
350
- var L9B14E = 10;
351
- void (uKcJl2.PLzWYDx(), uKcJl2.bW2FK2(), (xDwpOk6 += uKcJl2.CTW4vwx));
352
- break;
353
- default:
354
- if (uKcJl2.KTNMdj() == "cobTe8G") {
355
- break;
356
- }
357
- }
358
- }
359
- ```
360
-
361
- ### `globalConcealing`
362
-
363
- Global Concealing hides global variables being accessed. (`true/false`)
364
-
365
- ```js
366
- // Input
367
- console.log("Hello World");
368
-
369
- // Output
370
- yAt1T_y(-93)["log"]("Hello World");
371
- ```
372
-
373
- ### `stringCompression`
374
-
375
- String Compression uses LZW's compression algorithm to compress strings. (`true/false/0-1`)
376
-
377
- Use a number to control the percentage of strings.
378
-
379
- `"console"` -> `inflate('replaĕ!ğğuģģ<~@')`
380
-
381
- ### `stringConcealing`
382
-
383
- String Concealing involves encoding strings to conceal plain-text values. (`true/false/0-1`)
384
-
385
- Use a number to control the percentage of strings.
386
-
387
- `"console"` -> `decrypt('<~@rH7+Dert~>')`
388
-
389
- ### `stringEncoding`
390
-
391
- String Encoding transforms a string into an encoded representation. (`true/false/0-1`)
392
-
393
- Use a number to control the percentage of strings.
394
-
395
- `"console"` -> `'\x63\x6f\x6e\x73\x6f\x6c\x65'`
396
-
397
- ### `stringSplitting`
398
-
399
- String Splitting splits your strings into multiple expressions. (`true/false/0-1`)
400
-
401
- Use a number to control the percentage of strings.
402
-
403
- `"console"` -> `String.fromCharCode(99) + 'ons' + 'ole'`
404
-
405
- ### `duplicateLiteralsRemoval`
406
-
407
- Duplicate Literals Removal replaces duplicate literals with a single variable name. (`true/false`)
408
-
409
- ### `dispatcher`
410
-
411
- Creates a middleman function to process function calls. (`true/false/0-1`)
412
-
413
- ```js
414
- // Input
415
- function print(x){
416
- console.log(x);
417
- }
418
-
419
- print("Hello World"); // "Hello World"
420
-
421
- // Output
422
- var RfN5Yz = Object.create(null),
423
- GEMxMoq = [];
424
- typeof ((GEMxMoq = ["Hello World"]), yT9GzM("jlg2V0"));
425
- function yT9GzM(yT9GzM, ChVrLK, b8q2HVZ) {
426
- var RuH38a = {
427
- jlg2V0: function (_x5bmV, fslYszl, YbdYYlj) {
428
- if (!_x5bmV) {
429
- return fslYszl(this, YbdYYlj);
430
- }
431
- var [yT9GzM] = GEMxMoq;
432
- console.log(yT9GzM);
433
- },
434
- },
435
- JwN3oMY;
436
- if (ChVrLK == "smHux1f") {
437
- GEMxMoq = [];
438
- }
439
- JwN3oMY =
440
- ChVrLK == "DiwMvrE"
441
- ? RfN5Yz[yT9GzM] ||
442
- (RfN5Yz[yT9GzM] = function (...fslYszl) {
443
- GEMxMoq = fslYszl;
444
- return RuH38a[yT9GzM].call(this, "vZWlke7");
445
- })
446
- : RuH38a[yT9GzM]("EuVJE6");
447
- return b8q2HVZ == "ePsy9W" ? { occYQrC: JwN3oMY } : JwN3oMY;
448
- }
449
- ```
450
-
451
- ### `rgf`
452
-
453
- RGF (Runtime-Generated-Functions) uses the [`new Function(code...)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/Function) syntax to construct executable code from strings. (`true/false/0-1`)
454
-
455
- - **This can break your code.**
456
- - **Due to the security concerns of arbitrary code execution, you must enable this yourself.**
457
- - The arbitrary code is also obfuscated.
458
-
459
- Note: RGF will only apply to functions that do not rely on any outside-scoped variables. Enable `flatten` along with `rgf` to apply to these functions.
460
-
461
- Note: Does not apply to arrow, async, or generator functions.
462
-
463
- Use a number to control the percentage of functions changed.
464
-
465
- [Learn more here.](https://github.com/MichaelXF/js-confuser/blob/master/docs/RGF.md)
466
-
467
- ```js
468
- // Input
469
- function printToConsole(message){
470
- console.log(message);
471
- }
472
-
473
- printToConsole("Hello World"); // "Hello World"
474
-
475
- // Output
476
- var Ricvq8s = [new Function('function HIGRHaD(ANVivo_){console[\'log\'](ANVivo_)}return HIGRHaD[\'apply\'](this,arguments)')];
477
- function uhj6obs() {
478
- return Ricvq8s[0]['apply'](this, arguments);
479
- }
480
- uhj6obs('Hello World'); // "Hello World"
481
- ```
482
-
483
-
484
- ### `flatten`
485
-
486
- Brings independent declarations to the highest scope. (`true/false/0-1`)
487
-
488
- This transformation makes functions eligible for the RGF transformation.
489
-
490
- Use a number to control the percentage of functions changed.
491
-
492
- ```js
493
- // Input
494
- (function(){
495
- var stringToPrint = "Hello World";
496
- var timesPrinted = 0;
497
-
498
- function printString(){
499
- timesPrinted++;
500
- console.log(stringToPrint);
501
- }
502
-
503
- printString(); // "Hello World"
504
- })();
505
-
506
- // Output
507
- var XKlik0N = lP2p9dc(([], pgswImq) => {
508
- void (pgswImq.rGFfJKd++, console.log(pgswImq.I6NTID));
509
- });
510
- function M5IeIO([], mu63vsS) {
511
- var p_hOdnM = "Hello World",
512
- X_bU9rL = 0;
513
- function Iwe3cJW(...nuTwoiz) {
514
- var aNxnp94 = {
515
- set rGFfJKd(C9XSMeD) {
516
- X_bU9rL = C9XSMeD;
517
- },
518
- get I6NTID() {
519
- return p_hOdnM;
520
- },
521
- get rGFfJKd() {
522
- return X_bU9rL;
523
- },
524
- };
525
- return mu63vsS.PbELcOw(nuTwoiz, aNxnp94);
526
- }
527
- Iwe3cJW();
528
- }
529
- lP2p9dc((...AvydL3) => {
530
- var B6ymQf = {
531
- get PbELcOw() {
532
- return XKlik0N;
533
- },
534
- };
535
- return M5IeIO(AvydL3, B6ymQf);
536
- })();
537
- function lP2p9dc(fJxfZW) {
538
- return function () {
539
- return fJxfZW(...arguments);
540
- };
541
- }
542
- ```
543
-
544
- ### `objectExtraction`
545
-
546
- Extracts object properties into separate variables. (`true/false`)
547
-
548
- ```js
549
- // Input
550
- var utils = {
551
- isString: x=>typeof x === "string",
552
- isBoolean: x=>typeof x === "boolean"
553
- }
554
- if ( utils.isString("Hello") ) {
555
- // ...
556
- }
557
-
558
- // Output
559
- var utils_isString = x=>typeof x === "string";
560
- var utils_isBoolean = x=>typeof x === "boolean";
561
- if ( utils_isString("Hello") ) {
562
- // ...
563
- }
564
- ```
565
-
566
- ### `deadCode`
567
-
568
- Randomly injects dead code. (`true/false/0-1`)
569
-
570
- Use a number to control the percentage from 0 to 1.
571
-
572
- ### `calculator`
573
-
574
- Creates a calculator function to handle arithmetic and logical expressions. (`true/false/0-1`)
575
-
576
- ### `lock.antiDebug`
577
-
578
- Adds `debugger` statements throughout the code. Additionally adds a background function for DevTools detection. (`true/false/0-1`)
579
-
580
- ### `lock.context`
581
-
582
- Properties that must be present on the `window` object (or `global` for NodeJS). (`string[]`)
583
-
584
- ### `lock.startDate`
585
-
586
- When the program is first able to be used. (`number` or `Date`)
587
-
588
- Number should be in milliseconds.
589
-
590
- ### `lock.endDate`
591
-
592
- When the program is no longer able to be used. (`number` or `Date`)
593
-
594
- Number should be in milliseconds.
595
-
596
- ### `lock.domainLock`
597
-
598
- Array of regex strings that the `window.location.href` must follow. (`Regex[]` or `string[]`)
599
-
600
- ### `lock.osLock`
601
-
602
- Array of operating-systems where the script is allowed to run. (`string[]`)
603
-
604
- Allowed values: `"linux"`, `"windows"`, `"osx"`, `"android"`, `"ios"`
605
-
606
- Example: `["linux", "windows"]`
607
-
608
- ### `lock.browserLock`
609
-
610
- Array of browsers where the script is allowed to run. (`string[]`)
611
-
612
- Allowed values: `"firefox"`, `"chrome"`, `"iexplorer"`, `"edge"`, `"safari"`, `"opera"`
613
-
614
- Example: `["firefox", "chrome"]`
615
-
616
- ### `lock.selfDefending`
617
-
618
- Prevents the use of code beautifiers or formatters against your code.
619
-
620
- [Identical to Obfuscator.io's Self Defending](https://github.com/javascript-obfuscator/javascript-obfuscator#selfdefending)
621
-
622
- ### `lock.integrity`
623
-
624
- Integrity ensures the source code is unchanged. (`true/false/0-1`)
625
-
626
- [Learn more here](https://github.com/MichaelXF/js-confuser/blob/master/docs/Integrity.md).
627
-
628
- ### `lock.countermeasures`
629
-
630
- A custom callback function to invoke when a lock is triggered. (`string/false`)
631
-
632
- [Learn more about the countermeasures function](https://github.com/MichaelXF/js-confuser/blob/master/docs/Countermeasures.md).
633
-
634
- Otherwise, the obfuscator falls back to crashing the process.
635
-
636
- ### `movedDeclarations`
637
-
638
- Moves variable declarations to the top of the context. (`true/false`)
639
-
640
- ```js
641
- // Input
642
- function getAreaOfCircle(radius) {
643
- var pi = Math.PI;
644
- var radiusSquared = Math.pow(radius, 2);
645
- var area = pi * radiusSquared;
646
-
647
- return area;
648
- }
649
-
650
- // Output
651
- function getAreaOfCircle(yLu5YB1, eUf7Wle, XVYH4D, F8QuPL) {
652
- F8QuPL = Math["PI"];
653
- typeof ((eUf7Wle = Math["pow"](yLu5YB1, 2)), (XVYH4D = F8QuPL * eUf7Wle));
654
- return XVYH4D;
655
- }
656
- ```
657
-
658
- ### `opaquePredicates`
659
-
660
- An Opaque Predicate that is evaluated at runtime, this can confuse reverse engineers from understanding your code. (`true/false/0-1`)
661
-
662
- ### `shuffle`
663
-
664
- Shuffles the initial order of arrays. The order is brought back to the original during runtime. (`"hash"/true/false/0-1`)
665
-
666
- | Mode | Description |
667
- | --- | --- |
668
- | `"hash"`| Array is shifted based on hash of the elements |
669
- | `true`| Arrays are shifted *n* elements, unshifted at runtime |
670
- | `false` | Feature disabled |
671
-
672
- ### `stack`
673
-
674
- Local variables are consolidated into a rotating array. (`true/false/0-1`)
675
-
676
- [Similar to Jscrambler's Variable Masking](https://docs.jscrambler.com/code-integrity/documentation/transformations/variable-masking)
677
-
678
- ```js
679
- // Input
680
- function add3(x, y, z){
681
- return x + y + z;
682
- }
683
-
684
- // Output
685
- function iVQoGQD(...iVQoGQD){
686
- ~(iVQoGQD.length = 3, iVQoGQD[215] = iVQoGQD[2], iVQoGQD[75] = 227, iVQoGQD[iVQoGQD[75] - (iVQoGQD[75] - 75)] = iVQoGQD[75] - (iVQoGQD[75] - 239), iVQoGQD[iVQoGQD[iVQoGQD[75] - 164] - 127] = iVQoGQD[iVQoGQD[75] - 238], iVQoGQD[iVQoGQD[75] - 104] = iVQoGQD[75] - 482, iVQoGQD[iVQoGQD[135] + 378] = iVQoGQD[iVQoGQD[135] + 318] - 335, iVQoGQD[21] = iVQoGQD[iVQoGQD[135] + 96], iVQoGQD[iVQoGQD[iVQoGQD[75] - 104] - (iVQoGQD[75] - 502)] = iVQoGQD[iVQoGQD[75] - 164] - 440);
687
- return iVQoGQD[75] > iVQoGQD[75] + 90 ? iVQoGQD[iVQoGQD[135] - (iVQoGQD[135] + 54)] : iVQoGQD[iVQoGQD[135] + 117] + iVQoGQD[iVQoGQD[iVQoGQD[75] - (iVQoGQD[75] - (iVQoGQD[75] - 104))] - (iVQoGQD[135] - 112)] + iVQoGQD[215];
688
- };
689
- ```
690
-
691
- ## High preset
692
- ```js
693
- {
694
- target: "node",
695
- preset: "high",
696
-
697
- calculator: true,
698
- compact: true,
699
- hexadecimalNumbers: true,
700
- controlFlowFlattening: 0.75,
701
- deadCode: 0.2,
702
- dispatcher: true,
703
- duplicateLiteralsRemoval: 0.75,
704
- flatten: true,
705
- globalConcealing: true,
706
- identifierGenerator: "randomized",
707
- minify: true,
708
- movedDeclarations: true,
709
- objectExtraction: true,
710
- opaquePredicates: 0.75,
711
- renameVariables: true,
712
- renameGlobals: true,
713
- shuffle: { hash: 0.5, true: 0.5 },
714
- stack: true,
715
- stringConcealing: true,
716
- stringCompression: true,
717
- stringEncoding: true,
718
- stringSplitting: 0.75,
719
-
720
- // Use at own risk
721
- rgf: false
722
- }
723
- ```
724
-
725
- ## Medium preset
726
- ```js
727
- {
728
- target: "node",
729
- preset: "medium",
730
-
731
- calculator: true,
732
- compact: true,
733
- hexadecimalNumbers: true,
734
- controlFlowFlattening: 0.5,
735
- deadCode: 0.025,
736
- dispatcher: 0.75,
737
- duplicateLiteralsRemoval: 0.5,
738
- globalConcealing: true,
739
- identifierGenerator: "randomized",
740
- minify: true,
741
- movedDeclarations: true,
742
- objectExtraction: true,
743
- opaquePredicates: 0.5,
744
- renameVariables: true,
745
- renameGlobals: true,
746
- shuffle: true,
747
- stack: 0.5,
748
- stringConcealing: true,
749
- stringSplitting: 0.25
750
- }
751
- ```
752
-
753
- ## Low Preset
754
-
755
- ```js
756
- {
757
- target: "node",
758
- preset: "low",
759
-
760
- calculator: true,
761
- compact: true,
762
- hexadecimalNumbers: true,
763
- controlFlowFlattening: 0.25,
764
- deadCode: 0.01,
765
- dispatcher: 0.5,
766
- duplicateLiteralsRemoval: true,
767
- identifierGenerator: "randomized",
768
- minify: true,
769
- movedDeclarations: true,
770
- objectExtraction: true,
771
- opaquePredicates: 0.1,
772
- renameVariables: true,
773
- renameGlobals: true,
774
- stringConcealing: true
775
- }
776
- ```
777
-
778
- ## Locks
779
-
780
- You must enable locks yourself, and configure them to your needs.
781
-
782
- ```js
783
- {
784
- target: "node",
785
- lock: {
786
- integrity: true,
787
- selfDefending: true,
788
- domainLock: ["mywebsite.com"],
789
- osLock: ["windows", "linux"],
790
- browserLock: ["firefox"],
791
- startDate: new Date("Feb 1 2021"),
792
- endDate: new Date("Mar 1 2021"),
793
- antiDebug: true,
794
-
795
- // crashes browser
796
- countermeasures: true,
797
-
798
- // or custom callback (pre-obfuscated name)
799
- countermeasures: "onLockDetected"
800
- }
801
- }
802
- ```
803
-
804
- ## Optional features
805
-
806
- These features are experimental or a security concern.
807
-
808
- ```js
809
- {
810
- target: "node",
811
- rgf: true, // (security concern)
812
-
813
- // set to false for web-related scripts
814
- renameGlobals: false,
815
-
816
- // experimental
817
- identifierGenerator: function(){
818
- return "myvar_" + (counter++);
819
- },
820
-
821
- // Modified functions will retain the correct `function.length` property.
822
- // Enabled by default.
823
- preserveFunctionLength: false
824
- }
825
- ```
826
-
827
- ## Percentages
828
-
829
- Most settings allow percentages to control the frequency of the transformation. Fine-tune the percentages to keep file size down, and performance high.
830
-
831
- ```js
832
- {
833
- target: "node",
834
- controlFlowFlattening: true, // equal to 1, which is 100% (slow)
835
-
836
- controlFlowFlattening: 0.5, // 50%
837
- controlFlowFlattening: 0.01 // 1%
838
- }
839
- ```
840
-
841
- ## Probabilities
842
-
843
- Mix modes using an object with key-value pairs to represent each mode's percentage.
844
-
845
- ```js
846
- {
847
- target: "node",
848
- identifierGenerator: {
849
- "hexadecimal": 0.25, // 25% each
850
- "randomized": 0.25,
851
- "mangled": 0.25,
852
- "number": 0.25
853
- },
854
-
855
- shuffle: {hash: 0.5, true: 0.5} // 50% hash, 50% normal
856
- }
857
- ```
858
-
859
- ## Custom Implementations
860
-
861
- ```js
862
- {
863
- target: "node",
864
-
865
- // avoid renaming a certain variable
866
- renameVariables: name=>name!="jQuery",
867
-
868
- // custom variable names
869
- identifierGenerator: ()=>{
870
- return "_0x" + Math.random().toString(16).slice(2, 8);
871
- },
872
-
873
- // force encoding on a string
874
- stringConcealing: (str)=>{
875
- if (str=="https://mywebsite.com/my-secret-api"){
876
- return true;
877
- }
878
-
879
- // 60%
880
- return Math.random() < 0.6;
881
- },
882
-
883
- // set limits
884
- deadCode: ()=>{
885
- dead++;
886
-
887
- return dead < 50;
888
- }
889
- }
890
- ```
891
-
892
- ## Potential Issues
893
-
894
- 1. String Encoding can corrupt files. Disable `stringEncoding` if this happens.
895
- 2. Dead Code can bloat file size. Reduce or disable `deadCode`.
896
- 3. Rename Globals can break web-scripts.
897
- i. Disable `renameGlobals` or
898
- ii. Refactor your code
899
- ```js
900
- // Avoid doing this
901
- var myGlobalFunction = ()=>console.log("Called");
902
-
903
- // Do this instead
904
- window.myGlobalFunction = ()=>console.log("Called");
905
- ```
906
-
907
- ## File size and Performance
908
-
909
- Obfuscation can bloat file size and negatively impact performance. Avoid using the following:
910
-
911
- | Option | Description |
912
- | --- | --- |
913
- | `deadCode` | Bloats file size. Use low percentages. |
914
- | `stringSplitting`, `stringEncoding` | Bloats file size. Avoid using these altogether. |
915
- | `controlFlowFlattening` | Significant performance impact. Use very low percentage when source code is large. |
916
- | `dispatcher` | Slow performance. Use low percentage. |
917
-
918
- ## "The obfuscator broke my code!"
919
-
920
- Try disabling features in the following order:
921
- 1. `flatten`
922
- 2. `stack`
923
- 3. `dispatcher`
924
-
925
- If the error continues then [open an issue](https://github.com/MichaelXF/js-confuser/issues).
926
68
 
927
69
  ## Bug report
928
70
 
@@ -932,38 +74,6 @@ Please [open an issue](https://github.com/MichaelXF/js-confuser/issues) with the
932
74
 
933
75
  Please [open an issue](https://github.com/MichaelXF/js-confuser/issues) and be descriptive. Don't submit any PRs until approved.
934
76
 
935
- ## JsConfuser vs. Javascript-obfuscator
936
-
937
- Javascript-obfuscator ([https://obfuscator.io](https://obfuscator.io)) is the popular choice for JS obfuscation. This means more attackers are aware of their strategies. JSConfuser provides unique features and is lesser-known.
938
-
939
- Automated deobfuscators are aware of [https://obfuscator.io](https://obfuscator.io)'s techniques:
940
-
941
- https://www.youtube.com/watch?v=_UIqhaYyCMI
942
-
943
- However, the dev is [quick to fix these](https://github.com/LostMyCode/javascript-deobfuscator/issues/12). The one above no longer works.
944
-
945
- Alternatively, you could go the paid-route with [Jscrambler.com (enterprise only)](https://jscrambler.com/) or [PreEmptive.com](https://www.preemptive.com/products/jsdefender/online-javascript-obfuscator-demo)
946
-
947
- I've included several alternative obfuscators in the [`samples/`](https://github.com/MichaelXF/js-confuser/tree/master/samples) folder. They are all derived from the `input.js` file.
948
-
949
- ## Debugging
950
-
951
- Enable logs to view the obfuscator's state.
952
-
953
- ```js
954
- {
955
- target: "node",
956
- verbose: true
957
- }
958
- ```
959
-
960
- ## About the internals
961
-
962
- This obfuscator depends on two libraries to work: `acorn` and `escodegen`
963
-
964
- - `acorn` is responsible for parsing source code into an AST.
965
- - `escodegen` is responsible for generating source from modified AST.
77
+ ## License
966
78
 
967
- The tree is modified by transformations, which each traverse the entire tree.
968
- Properties starting with `$` are for saving information (typically circular data),
969
- these properties are deleted before output.
79
+ MIT License