js-confuser 2.0.0 → 2.0.1

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 (113) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +43 -43
  2. package/.github/ISSUE_TEMPLATE/feature_request.md +20 -20
  3. package/.github/workflows/node.js.yml +28 -28
  4. package/.prettierrc +4 -4
  5. package/CHANGELOG.md +1015 -987
  6. package/CODE_OF_CONDUCT.md +131 -131
  7. package/CONTRIBUTING.md +52 -52
  8. package/LICENSE +21 -21
  9. package/Migration.md +72 -72
  10. package/README.md +86 -86
  11. package/dist/constants.js +43 -43
  12. package/dist/index.js +14 -23
  13. package/dist/obfuscator.js +31 -25
  14. package/dist/order.js +4 -4
  15. package/dist/presets.js +31 -31
  16. package/dist/templates/integrityTemplate.js +4 -4
  17. package/dist/templates/template.js +1 -2
  18. package/dist/transforms/astScrambler.js +1 -2
  19. package/dist/transforms/calculator.js +1 -2
  20. package/dist/transforms/controlFlowFlattening.js +60 -41
  21. package/dist/transforms/deadCode.js +1 -2
  22. package/dist/transforms/dispatcher.js +4 -5
  23. package/dist/transforms/extraction/duplicateLiteralsRemoval.js +1 -2
  24. package/dist/transforms/extraction/objectExtraction.js +1 -2
  25. package/dist/transforms/finalizer.js +1 -2
  26. package/dist/transforms/flatten.js +1 -2
  27. package/dist/transforms/identifier/globalConcealing.js +15 -2
  28. package/dist/transforms/identifier/movedDeclarations.js +8 -7
  29. package/dist/transforms/identifier/renameVariables.js +7 -7
  30. package/dist/transforms/lock/integrity.js +8 -9
  31. package/dist/transforms/lock/lock.js +1 -2
  32. package/dist/transforms/minify.js +11 -29
  33. package/dist/transforms/opaquePredicates.js +1 -2
  34. package/dist/transforms/pack.js +1 -2
  35. package/dist/transforms/plugin.js +18 -19
  36. package/dist/transforms/preparation.js +16 -16
  37. package/dist/transforms/renameLabels.js +1 -2
  38. package/dist/transforms/rgf.js +8 -9
  39. package/dist/transforms/shuffle.js +1 -2
  40. package/dist/transforms/string/encoding.js +1 -2
  41. package/dist/transforms/string/stringCompression.js +3 -4
  42. package/dist/transforms/string/stringConcealing.js +1 -2
  43. package/dist/transforms/string/stringEncoding.js +1 -2
  44. package/dist/transforms/variableMasking.js +1 -2
  45. package/dist/utils/NameGen.js +2 -2
  46. package/dist/utils/PredicateGen.js +1 -2
  47. package/dist/utils/ast-utils.js +87 -88
  48. package/dist/utils/function-utils.js +8 -8
  49. package/dist/utils/node.js +5 -6
  50. package/dist/utils/object-utils.js +4 -4
  51. package/dist/utils/random-utils.js +20 -20
  52. package/dist/utils/static-utils.js +1 -2
  53. package/dist/validateOptions.js +4 -7
  54. package/index.d.ts +17 -17
  55. package/package.json +61 -59
  56. package/src/constants.ts +168 -168
  57. package/src/index.ts +118 -118
  58. package/src/obfuscationResult.ts +49 -49
  59. package/src/obfuscator.ts +501 -497
  60. package/src/options.ts +407 -407
  61. package/src/order.ts +54 -54
  62. package/src/presets.ts +125 -125
  63. package/src/templates/bufferToStringTemplate.ts +57 -57
  64. package/src/templates/deadCodeTemplates.ts +1185 -1185
  65. package/src/templates/getGlobalTemplate.ts +76 -76
  66. package/src/templates/integrityTemplate.ts +64 -64
  67. package/src/templates/setFunctionLengthTemplate.ts +11 -11
  68. package/src/templates/stringCompressionTemplate.ts +20 -20
  69. package/src/templates/tamperProtectionTemplates.ts +120 -120
  70. package/src/templates/template.ts +224 -224
  71. package/src/transforms/astScrambler.ts +99 -99
  72. package/src/transforms/calculator.ts +99 -99
  73. package/src/transforms/controlFlowFlattening.ts +1716 -1680
  74. package/src/transforms/deadCode.ts +82 -82
  75. package/src/transforms/dispatcher.ts +450 -450
  76. package/src/transforms/extraction/duplicateLiteralsRemoval.ts +156 -158
  77. package/src/transforms/extraction/objectExtraction.ts +186 -186
  78. package/src/transforms/finalizer.ts +74 -74
  79. package/src/transforms/flatten.ts +421 -418
  80. package/src/transforms/identifier/globalConcealing.ts +315 -295
  81. package/src/transforms/identifier/movedDeclarations.ts +252 -251
  82. package/src/transforms/identifier/renameVariables.ts +328 -321
  83. package/src/transforms/lock/integrity.ts +117 -117
  84. package/src/transforms/lock/lock.ts +418 -418
  85. package/src/transforms/minify.ts +615 -629
  86. package/src/transforms/opaquePredicates.ts +100 -100
  87. package/src/transforms/pack.ts +239 -239
  88. package/src/transforms/plugin.ts +173 -173
  89. package/src/transforms/preparation.ts +349 -347
  90. package/src/transforms/renameLabels.ts +175 -175
  91. package/src/transforms/rgf.ts +322 -322
  92. package/src/transforms/shuffle.ts +82 -82
  93. package/src/transforms/string/encoding.ts +144 -144
  94. package/src/transforms/string/stringCompression.ts +128 -128
  95. package/src/transforms/string/stringConcealing.ts +312 -312
  96. package/src/transforms/string/stringEncoding.ts +80 -80
  97. package/src/transforms/string/stringSplitting.ts +77 -77
  98. package/src/transforms/variableMasking.ts +257 -257
  99. package/src/utils/IntGen.ts +33 -33
  100. package/src/utils/NameGen.ts +116 -116
  101. package/src/utils/PredicateGen.ts +61 -61
  102. package/src/utils/ast-utils.ts +663 -663
  103. package/src/utils/function-utils.ts +50 -50
  104. package/src/utils/gen-utils.ts +48 -48
  105. package/src/utils/node.ts +78 -78
  106. package/src/utils/object-utils.ts +21 -21
  107. package/src/utils/random-utils.ts +93 -93
  108. package/src/utils/static-utils.ts +66 -66
  109. package/src/validateOptions.ts +256 -259
  110. package/tsconfig.json +13 -14
  111. package/dist/probability.js +0 -1
  112. package/dist/transforms/functionOutlining.js +0 -230
  113. package/dist/utils/ControlObject.js +0 -125
package/CHANGELOG.md CHANGED
@@ -1,988 +1,1016 @@
1
- # `2.0.0`
2
- 2.0 Rewrite 🎉
3
-
4
- ### Complete rewrite of JS-Confuser using Babel! 🎉
5
-
6
- **⚠️ Breaking changes**
7
-
8
- > Check out the [Migration guide](./Migration.md) on how to properly update from 1.X to 2.0. The obfuscation upgrades in 2.0 are worth the small refactoring.
9
-
10
- - Revamped API Interface
11
-
12
- - - JSConfuser.obfuscate() resolves to an object
13
-
14
- | Property | Type | Description |
15
- | --- | --- | --- |
16
- | `code` | `string` | The obfuscated code. |
17
-
18
- - Renamed `Stack` to `Variable Masking`
19
-
20
- - Added configurable limits to options:
21
-
22
- ```js
23
- const options = {
24
- target: "node",
25
-
26
- rgf: {
27
- value: 0.5, // = 50% of eligible functions
28
- limit: 10 // Maximum of 10 changes for performance reasons
29
- },
30
-
31
- // Original format is still valid (No limit applied)
32
- rgf: 0.5
33
- }
34
- ```
35
-
36
- ### 2.0 Changes
37
-
38
- - Added [Custom String Encoding](https://js-confuser.com/docs/options/customStringEncodings) and [Custom Lock Code](https://js-confuser.com/docs/options/customLocks) options
39
-
40
- - Added `Rename Labels` [Learn more here](https://js-confuser.com/docs/options/renamelabels#rename-labels)
41
-
42
- - Added `Pack` [Learn more here](https://js-confuser.com/docs/options/pack#pack)
43
-
44
- - RGF no longers uses `new Function` instead uses `eval`
45
-
46
- - Improved code transforms!
47
-
48
- - Improved `Control Flow Flattening`
49
-
50
- - - Obfuscates the [Call Graph](https://en.wikipedia.org/wiki/Call_graph)
51
-
52
- - - Now supports lexical bindings (`let`, `const`, `class`)
53
-
54
- - - `with () { }` statement obfuscation
55
-
56
- - Improved `Minify`
57
-
58
- - - Removes unused variables and functions
59
-
60
- - Improved `Moved Declaration` ability to move variables as unused function parameters
61
-
62
- - Improved `String` transforms
63
-
64
- - - [Template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) are now obfuscated (First converted into equivalent String Literal)
65
-
66
- - - [Regular expressions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions) are now obfuscated (First converted into equivalent RegExp() constructor calls)
67
-
68
- - - `String Compression` now uses LZ-string compression ([lz-string](https://www.npmjs.com/package/lz-string))
69
-
70
- - New Comment Syntax
71
-
72
- - - `/* @js-confuser-var */ "name"` for improved variable mappings, such as eval() calls
73
-
74
- ```js
75
- // Input
76
- var name = "Internet User";
77
- eval( "console.log(" + /* @js-confuser-var */ "name" + ")" );
78
-
79
- // Output
80
- var zC3PLKu = "Internet User";
81
- eval("console.log(" + "zC3PLKu" + ")");
82
- ```
83
-
84
- Note: The function `__JS_CONFUSER_VAR__` is still supported.
85
-
86
- ### JS-Confuser.com Revamp
87
-
88
- A new UI for [JS-Confuser.com](https://js-confuser.com), featuring an advanced playground and documentation pages.
89
-
90
- The previous version will remain available at [old--confuser.netlify.com](https://old--confuser.netlify.app/).
91
-
92
- **Removed features**
93
-
94
- - Removed `ES5` option - Use Babel Instead
95
-
96
- - Removed `Browser Lock` and `OS Lock` - Use [Custom Locks](https://js-confuser.com/docs/options/customlocks#custom-locks) instead
97
-
98
- - Removed `Shuffle`'s Hash option
99
-
100
- - Removed `Indent` option
101
-
102
-
103
- # `1.7.3`
104
- Tamper Protection
105
-
106
- ### `Tamper Protection`
107
-
108
- Tamper Protection safeguards the runtime behavior from being altered by JavaScript pitfalls.
109
-
110
- [Learn more here.](/docs/TamperProtection.md)
111
-
112
- ---
113
-
114
- - Rename Variables improvements:
115
-
116
- - A new exposed function, `__JS_CONFUSER_VAR__`, can be used to access renamed variables. [Learn more here](/docs/RenameVariables.md).
117
-
118
-
119
- ```js
120
- // Input
121
- var name = "John Doe";
122
- eval("console.log(" + __JS_CONFUSER_VAR__(name) + ")");
123
-
124
- // Output
125
- var CA1HU0 = 'John Doe';
126
- eval('console.log(' + 'CA1HU0' + ')');
127
- ```
128
-
129
- - Improved the `Zero Width` identifier generator (Thanks @doctor8296!)
130
-
131
- - Pad the `String Concealing` array with more fake strings
132
-
133
- - Improve `String Compression`
134
-
135
- - New Web UI sneak peak: https://js-confuser.com/
136
-
137
-
138
- # `1.7.2`
139
- Updates
140
-
141
- - `Anti Tooling` & `Expression Obfuscation` improvements
142
- - - No longer expanded by [webcrack](https://github.com/j4k0xb/webcrack), [synchrony](https://github.com/relative/synchrony) & [REstringer](https://github.com/PerimeterX/restringer)
143
-
144
- - `String Concealing` improvements
145
- - - Randomizes the charset for each obfuscation
146
- - - Place multiple decryption functions throughout the code
147
- - - These changes aim to defeat [JSConfuser-String-Decryptor](https://github.com/0v41n/JSConfuser-String-Decryptor) and any other RegEx-based decoders
148
-
149
- - `Moved Declarations` improvements
150
- - - Now moves some variables as unused parameters on certain functions
151
-
152
- - `RGF` improvements
153
- - - More likely to transform functions containing functions
154
-
155
- - Fixed [#96](https://github.com/MichaelXF/js-confuser/issues/96)
156
- - - Removed hardcoded limits on `String Concealing`, `String Compression`, and `Duplicate Literals Removal`
157
-
158
- - Fixed [#106](https://github.com/MichaelXF/js-confuser/issues/106)
159
- - - Final fix with const variables for `Object Extraction`
160
-
161
- - Fixed [#131](https://github.com/MichaelXF/js-confuser/issues/131)
162
- - - __dirname is no longer changed by `Global Concealing`
163
-
164
- **New Option**
165
-
166
- ### `preserveFunctionLength`
167
- - Modified functions will retain the correct `function.length` property. (`true/false`)
168
- Enabled by default.
169
-
170
- Minor improvements
171
- - Preserve `function.length`
172
- - Preserve Strict Mode behaviors
173
- - Preserve indirect vs. direct [`eval`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) use
174
-
175
-
176
- # `1.7.1`
177
- Updates
178
-
179
- - Fixed [#107](https://github.com/MichaelXF/js-confuser/issues/107)
180
- - - RGF and Integrity clash issue fixed
181
-
182
- - Fixed [#106](https://github.com/MichaelXF/js-confuser/issues/106)
183
- - - Object Extraction to properly handle `const` objects
184
-
185
- - Fixed [#105](https://github.com/MichaelXF/js-confuser/issues/105)
186
- - - Duplicate Literals Removal updated to not cause this error
187
-
188
- - Fixed [#103](https://github.com/MichaelXF/js-confuser/issues/103)
189
- - - Dispatcher will no longer apply to these types of functions to prevent this error
190
-
191
- - Added documentation page for [ES5](https://github.com/MichaelXF/js-confuser/blob/master/docs/ES5.md)
192
-
193
- - Rollup Plugin created: https://github.com/ayecue/rollup-js-confuser (Thanks @ayecue !)
194
-
195
- # `1.7.0`
196
- Updates
197
-
198
- - Fixed [#89](https://github.com/MichaelXF/js-confuser/issues/89)
199
- - - Flatten to not break functions with invalid identifier names
200
-
201
- - Fixed [#88](https://github.com/MichaelXF/js-confuser/issues/88)
202
- - - Stack to not break functions with syncing arguments
203
-
204
- - Fixed [#91](https://github.com/MichaelXF/js-confuser/issues/91)
205
- - - Minify to preserve function.length property
206
-
207
- - Fixed [#95](https://github.com/MichaelXF/js-confuser/issues/95)
208
- - - Rename Variables optimized to obfuscate much faster
209
-
210
- - Added documentation pages for [RGF](https://github.com/MichaelXF/js-confuser/blob/master/docs/RGF.md) and [Control Flow Flattening](https://github.com/MichaelXF/js-confuser/blob/master/docs/ControlFlowFlattening.md)
211
-
212
- - Removed `eval` option in favor of `rgf` option.
213
-
214
- - - Removed the `"all"` option from `rgf`.
215
-
216
- - Removed `nameRecycling` option
217
-
218
- # `1.6.0`
219
- Website Redesign + Updates
220
-
221
- The website is now redesigned and live at [js-confuser.com](https://wwww.js-confuser.com)!
222
-
223
- - Check out the source code for the website here: https://github.com/MichaelXF/js-confuser-website
224
-
225
- #### New feature
226
-
227
- ### `selfDefending`
228
-
229
- Prevents the use of code beautifiers or formatters against your code.
230
-
231
- [Identical to Obfuscator.io's Self Defending](https://github.com/javascript-obfuscator/javascript-obfuscator#selfdefending)
232
-
233
- #### Improvements
234
-
235
- - Fixed [#56](https://github.com/MichaelXF/js-confuser/issues/56)
236
- - - Calculator improved to apply to more operators
237
-
238
- - ES5 to handle destructuring member expressions
239
-
240
- - Improved Control Flow Flattening techniques
241
-
242
- - - Outlining expressions
243
-
244
- - - Control object to store numbers and strings
245
-
246
- - Updated the String concealing encoding algorithm
247
-
248
- - Optimizations / Small fixes
249
-
250
- # `1.5.9`
251
- Big update
252
-
253
- This updates comes with many bug fixes:
254
-
255
- - Fixed [#72](https://github.com/MichaelXF/js-confuser/issues/72)
256
- - - ES5 to handle Class Fields
257
-
258
- Note: The `ES5` option is not meant to replace Babel. It is only intended to undo ES6 features the obfuscator may have added to your code.
259
-
260
- - Fixed [#74](https://github.com/MichaelXF/js-confuser/issues/74)
261
- - - Anti Tooling to not break Symbols
262
-
263
- - Fixed [#75](https://github.com/MichaelXF/js-confuser/issues/75)
264
- - - Minify to properly handle Object constructors
265
-
266
- - Fixed [#76](https://github.com/MichaelXF/js-confuser/issues/76)
267
- - - Minify to not cause syntax errors when objects used `^`, `` ` ``, `[`, `]` as property keys
268
-
269
- - Fixed [#77](https://github.com/MichaelXF/js-confuser/issues/77)
270
- - - Dispatcher to not break code that uses generic names like `toString` and `hasOwnProperty`
271
-
272
- - Fixed [#78](https://github.com/MichaelXF/js-confuser/issues/78)
273
- - - Object Extraction to not error on objects with spread elements
274
-
275
- - Fixed [#79](https://github.com/MichaelXF/js-confuser/issues/79)
276
- - - JsConfuser now supports `BigInt` literals
277
-
278
- - Fixed [#80](https://github.com/MichaelXF/js-confuser/issues/80)
279
- - - Rename Variables to not break code that had `var` and `let` variables in the same scope
280
-
281
- - Fixed [#81](https://github.com/MichaelXF/js-confuser/issues/81)
282
- - - Control Flow Flattening to not break `typeof` expressions
283
-
284
- - Fixed [#82](https://github.com/MichaelXF/js-confuser/issues/82)
285
- - - String Concealing to not break class constructors
286
-
287
- # `1.5.8`
288
- Several fixes
289
-
290
- - Fixed [#46](https://github.com/MichaelXF/js-confuser/issues/46)
291
- - - Updated the validation on `lock` options
292
-
293
- - Fixed [#68](https://github.com/MichaelXF/js-confuser/issues/68)
294
- - - Name Recycling fixed to not break certain function declarations
295
-
296
- - Fixed [#69](https://github.com/MichaelXF/js-confuser/issues/69), [#70](https://github.com/MichaelXF/js-confuser/issues/70) and [#71](https://github.com/MichaelXF/js-confuser/issues/71)
297
- - - Import statements to be properly handled
298
-
299
- - Slight improvements to String Concealing
300
-
301
- # `1.5.7`
302
- Countermeasures function fixes
303
-
304
- This update focuses on fixing Countermeasures bugs
305
-
306
- The `countermeasures` is custom callback function to invoke when a lock is triggered.
307
-
308
- - Fixed [#66](https://github.com/MichaelXF/js-confuser/issues/66)
309
- - - RGF to properly handle the countermeasures function
310
-
311
- - Added additional code to prevent an infinite loop from occurring
312
-
313
- - Slight improvements to RGF
314
-
315
- # `1.5.6`
316
- Website changed and RGF fixes
317
-
318
- The website is back at a different domain now: [https://master--hungry-shannon-c1ce6b.netlify.app/](https://master--hungry-shannon-c1ce6b.netlify.app/)
319
-
320
- This update focuses on fixing RGF bugs
321
-
322
- - Fixed [#64](https://github.com/MichaelXF/js-confuser/issues/64)
323
- - - RGF to properly handle Arrow functions and function expressions
324
-
325
- - RGF will no longer change getter/setter methods
326
-
327
- - RGF will no longer change class methods
328
-
329
- - RGF now works when using `mangled` variable names
330
-
331
- - Minify will remove unreachable code following a Throw statement
332
-
333
- # `1.5.5`
334
- Updates
335
-
336
- - Fixed [#53](https://github.com/MichaelXF/js-confuser/issues/53)
337
- - - Shuffle to not use common variable names like `x`
338
-
339
- - Fixed [#60](https://github.com/MichaelXF/js-confuser/issues/60)
340
- - - Rename Variables to properly handle function parameters
341
-
342
- - Fixed [#62](https://github.com/MichaelXF/js-confuser/issues/62)
343
- - - Rename Variables to properly handle catch-clause parameters
344
-
345
- # `1.5.4`
346
- Small fix
347
-
348
- - Fixed [#45](https://github.com/MichaelXF/js-confuser/issues/45)
349
- - - Opaque predicates fixed to not this cause error
350
-
351
-
352
- # `1.5.3`
353
- Shuffle fix
354
-
355
- - Fixed [#48](https://github.com/MichaelXF/js-confuser/issues/48)
356
- - - Shuffle was re-assigning `const` variables, fixed in this version.
357
-
358
- # `1.5.2`
359
- Mini fixes
360
-
361
- - Fixed [#41](https://github.com/MichaelXF/js-confuser/issues/41)
362
- - - Obfuscator mishandled switch statements with a `default` case
363
-
364
- - Fixed [#43](https://github.com/MichaelXF/js-confuser/issues/43)
365
- - - Obfuscator mishandled variable destructuring in for-loops
366
-
367
- # `1.5.1`
368
- Object Extraction Fix
369
-
370
- - Fixed [#37](https://github.com/MichaelXF/js-confuser/issues/37)
371
- - - Object Extraction was applying to objects with get/set methods, fixed in this version.
372
-
373
- - Slight improvement to `Flatten`
374
-
375
- # `1.5.0`
376
- Hexadecimal Numbers
377
-
378
- - The hexadecimal representation can now be used. [#29](https://github.com/MichaelXF/js-confuser/issues/29)
379
- - New option `hexadecimalNumbers` to control this behavior.
380
-
381
- ### `hexadecimalNumbers`
382
-
383
- Uses the hexadecimal representation (`50` -> `0x32`) for numbers. (`true/false`) -->
384
-
385
- - Slight improvement to `Control Flow Flattening`
386
- - Slight improvement to `Calculator`
387
-
388
- # `1.4.3`
389
- Minify Fix
390
-
391
- - Fixed [#34](https://github.com/MichaelXF/js-confuser/issues/34)
392
- - - Minify was removing `return` statements too aggressively, fixed in this version.
393
-
394
- - Slight improvement to Control Flow Flattening
395
-
396
- # `1.4.2`
397
- Eval Fix
398
-
399
- - Fixed [#31](https://github.com/MichaelXF/js-confuser/issues/31)
400
- - - Eval and Integrity didn't work together, fixed in this version.
401
-
402
- # `1.4.1`
403
- AntiDebug Fix
404
-
405
- - Fixed [#28](https://github.com/MichaelXF/js-confuser/issues/28)
406
- - - AntiDebug was causing syntax errors in some scenarios, fixed in this version.
407
-
408
- # `1.4.0`
409
- Confusing Control Flow
410
-
411
- - `Control Flow Flattening` overhaul, now flattens embedded control structures
412
-
413
- - - `If statements`
414
- - - `For statements`
415
- - - `While statements`
416
- - - `Switch statements`
417
- - - `Do While statements`
418
-
419
- - - Certain functions
420
-
421
- ```js
422
- // Input
423
- console.log(1);
424
- console.log(2);
425
- console.log(Number("3"));
426
-
427
- for (var i = 4; i < 6; i++) {
428
- console.log(i);
429
- }
430
-
431
- var i = 0;
432
- do {
433
- console.log(i + 6);
434
- } while (i++ < 4);
435
-
436
- // Output
437
- var a = -123, b = 414, c = -191;
438
- while (a + b + c != 104) {
439
- var d = (a + b + c) * -28 + 172;
440
- switch (d) {
441
- case -276:
442
- !(a *= 138 > b ? 2 : 158, a -= -5 < c ? -90 : -152, b *= b + 206, b -= a + -539, c += b + -372);
443
- break;
444
- case -2628:
445
- var e = (console['log'](-106 > c ? 1 : 182), console['log'](a + 125), console['log'](Number('3')), -87 < a ? -189 < a ? -133 : 93 : 107 < c ? 227 : 4);
446
- ~(a *= (-114 > c ? -164 : -107) < c ? -164 : 2, a -= 188 > b ? b + -211 : -369, b += -62 > c ? 168 > c ? -539 : 56 : 26, c += (c + 362 > a ? 73 : -157) < b ? 207 : 341);
447
- break;
448
- case -4420:
449
- +(a *= a + (a + 18), a -= 190 > a ? -344 : 71, b *= -206 < b ? c + -173 : -221, b -= b + 94, c += 89 > b ? -311 : 170);
450
- break;
451
- case -3972:
452
- if (e < c + -144) {
453
- !(a *= b + 127, a -= b + (b + 671), b += c + 82, c *= 61 < a ? -139 : 2, c -= b + -35);
454
- break;
455
- }
456
- typeof (a *= c + -148, a -= c + 271, b += c + 184, c += -89 < c ? -42 : -114);
457
- break;
458
- case -3244:
459
- +(a += a + 220, b += b + 317, c += b + -218);
460
- break;
461
- case -4308:
462
- !(a += 134 < b ? -233 : 89, b += -79 < b ? -69 : -241, c *= -107 > a ? -97 : 2, c -= (56 < a ? -27 : -184) > c ? -163 : 231);
463
- break;
464
- case -3664:
465
- ~(a += b + -362, b += -87 < b ? -666 : -172, c += c + 710);
466
- break;
467
- case -5344:
468
- +(a *= c + (-165 < a ? -266 : 182) > c ? 124 : 2, a -= -154 > b ? c + 92 : -388, b += c + -193, c *= c + (c + -30), c -= a + -11);
469
- break;
470
- case -2572:
471
- if (e++ < ((-125 < a ? -62 : 87) < c ? -112 : 4)) {
472
- ~(a += c + -268, b += 215 < b ? 136 : 18 < b ? -233 : 536, c += b + -535);
473
- break;
474
- }
475
- ~(a *= (123 > a ? -105 : 238) < b ? 216 : 2, a -= a + 57, b *= a + 59, b -= a + -369, c *= b + -236, c -= 200 > c ? -288 : -11);
476
- break;
477
- case -4784:
478
- +(console['log'](e), a *= c + -223, a -= 7 > c ? -227 > b ? -4 : 192 : -157, b *= a + (-186 > b ? 211 : 17), b -= -127 > c ? 76 : 280, c *= -63 > c ? a + 264 : 2, c -= (119 < c ? -206 : 85) < a ? 215 : 179);
479
- break;
480
- case -724:
481
- void (console['log'](e + (c + -246)), a *= -177 < c ? 2 : 207, a -= 152 > a ? 122 : -190, b *= c + -250, b -= b + 160, c += -141 < a ? a + 258 : 21);
482
- break;
483
- case -3804:
484
- var e = -143 > a ? 0 : 24;
485
- typeof (a += c + -9, b += c + 125, c += a + -261);
486
- break;
487
- case -1648:
488
- ~(e++, a += a + 3, b *= c + 68, b -= 89 < b ? -173 > b ? -147 : 267 : -228 > c ? -80 : -216 > b ? 93 : 68, c += 65 > a ? b + 156 : 216);
489
- break;
490
- }
491
- }
492
- ```
493
-
494
- - New encoding type `Hex Table`
495
-
496
- ```js
497
- "{0x7E494534,0x688,0x7E6D53,0x401,0x7E584D4B,0x688,0x7E775853,0x688,0x7E5333,0x81}"
498
-
499
- // => "Hello World"
500
- ```
501
-
502
- - Improvements to renaming labels
503
- - Fixed [#24](https://github.com/MichaelXF/js-confuser/issues/24)
504
- - Fixed [#25](https://github.com/MichaelXF/js-confuser/issues/25)
505
- - Fixed [#26](https://github.com/MichaelXF/js-confuser/issues/26)
506
-
507
- # `1.3.0`
508
- String Splitting Improvement
509
-
510
- - `String Splitting` now supports percentages and a custom callback. ([#22](https://github.com/MichaelXF/js-confuser/issues/22))
511
-
512
- ```js
513
- {
514
- // percentage
515
- stringSplitting: 0.75, // = 75%
516
-
517
- // exclude certain strings
518
- stringSplitting: (str)=>{
519
- if ( str == "dont-split-string" ) {
520
- return false;
521
- }
522
-
523
- return true;
524
- },
525
- }
526
- ```
527
-
528
- # `1.2.2`
529
- Global name fix
530
-
531
- - **Bug fix**: `Rename Variables` breaking access to global variables
532
-
533
- ```js
534
- // Say `a` is a global library
535
- // Input
536
- function myFunction(param1){
537
- a(param1);
538
- }
539
-
540
- // Output on 1.2.1
541
- function a(a){
542
- a(a);
543
- }
544
-
545
- // Output on 1.2.2
546
- function b(b){
547
- a(b);
548
- }
549
- ```
550
-
551
- - **Bug fix**: `Flatten` to not accidentally remove function parameters
552
- - **Bug fix**: `Dispatcher` on function calls within classes
553
- - **Bug fix**: `Minify` fixed syntax error
554
-
555
- ```js
556
- // Input
557
- var o = {Infinity: 0};
558
-
559
- // Output on 1.2.1
560
- var o = {1/0: 0};
561
-
562
- // Output on 1.2.2
563
- var o = {[1/0]: 0};
564
- ```
565
-
566
- - Added `base32` encoding to `String Concealing`
567
- - `Minify` improvements
568
- - - `true` -> `!0`
569
- - - `false` -> `!1`
570
- - Subtle changes to `String Compression`
571
- - Updated presets
572
-
573
- # `1.2.1`
574
- Bug fixes
575
-
576
- - **Bug fix**: `Control Flow Flattening` on classes no longer creates syntax errors
577
- - **Bug fix**: `String Concealing` will check for duplicate strings
578
- - **Bug fix**: `String Concealing` now handles class properties
579
- - **Bug fix**: `Stack` and `Control Flow Flattening` no longer modifies floats
580
-
581
- - **New API:**
582
-
583
- ## `obfuscateAST(AST, options)`
584
-
585
- 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).
586
-
587
- **Note:** Mutates the object.
588
-
589
- | Parameter | Type | Description |
590
- | --- | --- | --- |
591
- | `AST` | `object` | The [ESTree](https://github.com/estree/estree) compliant AST. This object will be mutated. |
592
- | `options` | `object` | The obfuscator settings. |
593
-
594
- # `1.2.0`
595
- Bug fixes
596
-
597
- - **Bug fix**: `Eval` moves function declarations to the top of the lexical block
598
- - **Bug fix**: `Stack` no longers changes function declarations
599
- - Improvements to `Stack` rotations
600
-
601
- ```js
602
- // Input
603
- function add3(x,y,z){
604
- ok(typeof x === "number");
605
- ok(typeof y === "number");
606
- ok(typeof z === "number");
607
-
608
- return x + y + z;
609
- }
610
-
611
- console.log(add3(1,2,3))
612
-
613
- // Output on 1.1.9
614
- function _WFZLw(..._WFZLw) {
615
- void (_WFZLw.length = 3, ok(typeof _WFZLw[0] === 'number'), ok(typeof _WFZLw[1] === 'number'), ok(typeof _WFZLw[2] === 'number'));
616
- return _WFZLw[0] + _WFZLw[1] + _WFZLw[2];
617
- }
618
- console['log'](_WFZLw(1, 2, 3));
619
-
620
- // Output on 1.2.0
621
- var KZ6LyAL = (...KZ6LyAL) => {
622
- ~(KZ6LyAL.length = 3, ok(typeof KZ6LyAL[0] === 'number'), KZ6LyAL[186] = KZ6LyAL[0], ok(typeof KZ6LyAL[1] === 'number'), KZ6LyAL[227] = -22, ok(typeof KZ6LyAL[KZ6LyAL[KZ6LyAL[227] + 249] + 24] === 'number'));
623
- return KZ6LyAL[KZ6LyAL[227] - (KZ6LyAL[227] - 186)] + KZ6LyAL[KZ6LyAL[227] + 23] + KZ6LyAL[KZ6LyAL[KZ6LyAL[227] + 249] - (KZ6LyAL[227] - (KZ6LyAL[227] + 24))];
624
- };
625
- console.log(KZ6LyAL(1, 2, 3));
626
- ```
627
-
628
- # `1.1.9`
629
- Browser Lock and OS Lock
630
-
631
- - Added `Browser Lock` and `OS Lock`
632
-
633
- | Mode | Target | Method |
634
- | --- | --- | --- |
635
- | `Browser Lock` | `"browser"` | Checks `window.navigator.userAgent` |
636
- | `Browser Lock` | `"node"` | N/A |
637
- | `OS Lock` | `"browser"` | Checks `window.navigator.userAgent` |
638
- | `OS Lock` | `"node"` | Checks `require('os').platform()` |
639
-
640
- ---
641
-
642
- - #### `Browser Lock`
643
-
644
- - Array of browsers where the script is allowed to run. (`string[]`)
645
-
646
- - - Potency Low
647
- - - Resilience Medium
648
- - - Cost Medium
649
-
650
- - Allowed values: `"firefox"`, `"chrome"`, `"iexplorer"`, `"edge"`, `"safari"`, `"opera"`
651
-
652
- - Example: `["firefox", "chrome"]`
653
-
654
- ---
655
-
656
- - #### `OS Lock`
657
-
658
- - Array of operating-systems where the script is allowed to run. (`string[]`)
659
-
660
- - - Potency Low
661
- - - Resilience Medium
662
- - - Cost Medium
663
-
664
- - Allowed values: `"linux"`, `"windows"`, `"osx"`, `"android"`, `"ios"`
665
-
666
- - Example: `["linux", "windows"]`
667
-
668
- ---
669
-
670
- - **Bug fix**: `Moved Declarations` no longer applies to loops
671
- - - Previously broke Switch statements
672
-
673
- - `String Splitting` use larger chunk sizes to avoid creating too many strings
674
-
675
- Available now on NPM: https://www.npmjs.com/package/js-confuser
676
-
677
- # `1.1.8`
678
- Bug Fixes and Improvements
679
-
680
- - **Bug fix**: Stack no longer replaces identifiers that are in nested contexts
681
-
682
- - `es5` converts
683
- - - `fn(...args)` -> `fn.apply(this, args)`
684
- - - `fn(...arguments)` -> `fn.apply(this, [].concat(Array.prototype.slice.call(arguments)))`
685
-
686
- - Changes to `identifierGenerator`
687
- - - `mangled` Now uses both lowercase and uppercase alphabets
688
-
689
- - Added `antiTooling` to stop [JSNice.org](https://JSNice.org) from expanding sequence expressions
690
-
691
- ```js
692
- // Input
693
- (console.log(1), console.log(2), console.log(3))
694
-
695
- // Output
696
- +(console.log(1), console.log(2), console.log(3))
697
-
698
- // JSNice on Input
699
- console.log(1)
700
- console.log(2)
701
- console.log(3)
702
-
703
- // JSNice on Output
704
- +(console.log(1), console.log(2), console.log(3))
705
- ```
706
-
707
- - Improved `controlFlowFlattening`
708
- - - No longer changes blocks with `const` variables
709
- - - Now obscures order of expressions
710
- ```js
711
- // Input
712
- console.log(1)
713
- console.log(2)
714
- console.log(3)
715
- console.log(4)
716
- var five = 5;
717
- console.log(five);
718
-
719
- // Output
720
- var oI8J9w6 = (console['log'](1), console['log'](2), console['log'](3), console['log'](4), 5);
721
- console['log'](oI8J9w6);
722
- ```
723
-
724
- - - Now entangles number literals with the state variables ex:
725
-
726
- ```js
727
- // Input
728
- console.log(1);
729
- console.log(2);
730
- console.log(3);
731
- console.log(4);
732
- console.log(5);
733
- console.log(6);
734
- console.log(7);
735
- console.log(8);
736
- console.log(9);
737
- console.log(10);
738
-
739
- // Output
740
- var xYPTGP = -164, NYvTJV = -40, eB6EbU = 55, cD8ztD = -73, AnCfc3A = 237, n6wikC = 52;
741
- while (xYPTGP + NYvTJV + eB6EbU + cD8ztD + AnCfc3A + n6wikC != 33) {
742
- var ruVzem = (xYPTGP + NYvTJV + eB6EbU + cD8ztD + AnCfc3A + n6wikC) * -184 - 38;
743
- switch (ruVzem) {
744
- case -3350:
745
- console.log(4), (NYvTJV *= -66 > AnCfc3A ? n6wikC + (134 > xYPTGP ? -190 : 194) : 2, NYvTJV -= 77 < xYPTGP ? 28 : 66), xYPTGP += AnCfc3A - 201, (AnCfc3A *= n6wikC + 109, AnCfc3A -= 16 < NYvTJV ? 661 : -169);
746
- break;
747
- case -26902:
748
- console.log(31 > AnCfc3A ? 39 : -2 > AnCfc3A ? -137 : 3), (NYvTJV *= -174 > n6wikC ? AnCfc3A - 292 : 2, NYvTJV -= n6wikC - 91), (eB6EbU *= 155 > cD8ztD ? 2 : 42, eB6EbU -= 155 > AnCfc3A ? 1 : -227), (cD8ztD *= 183 < eB6EbU ? 222 : 2, cD8ztD -= 214 < AnCfc3A ? 270 : 70);
749
- break;
750
- case -12366:
751
- console.log(196 < eB6EbU ? -5 : 1), eB6EbU += -47 > cD8ztD ? -225 : 57, (xYPTGP *= AnCfc3A - 235, xYPTGP -= -126 < eB6EbU ? 46 : -434);
752
- break;
753
- case -20646:
754
- console.log(2), (n6wikC *= cD8ztD + 75, n6wikC -= ((107 > xYPTGP ? -244 : -80) > cD8ztD ? 65 : 149) > cD8ztD ? -138 > eB6EbU ? cD8ztD + 284 : 159 : 73 < AnCfc3A ? -14 : 83), AnCfc3A += xYPTGP - 95 < n6wikC ? 199 : 147, xYPTGP += 227 < xYPTGP ? -238 : 46;
755
- break;
756
- case -10526:
757
- console.log(10), xYPTGP += n6wikC + 524, n6wikC += cD8ztD + 263, (AnCfc3A *= 67 > xYPTGP ? n6wikC + (xYPTGP - 433 > n6wikC ? -21 : -111) : 2, AnCfc3A -= AnCfc3A + 247);
758
- break;
759
- case -2614:
760
- console.log(5), (n6wikC *= xYPTGP - 333, n6wikC -= (-41 > cD8ztD ? -38 > AnCfc3A ? 96 : -97 : 49) < NYvTJV ? 131 : 112), (cD8ztD *= eB6EbU + 115, cD8ztD -= -216 < AnCfc3A ? -631 : 23), (AnCfc3A *= (NYvTJV + 1 > xYPTGP ? 235 : 206) < n6wikC ? n6wikC + 310 : 2, AnCfc3A -= NYvTJV - 236), (xYPTGP *= 185 > eB6EbU ? -169 < xYPTGP ? 2 : 236 : -19, xYPTGP -= -59 < n6wikC ? 100 : n6wikC + 779);
761
- break;
762
- case -5006:
763
- console.log(6), (cD8ztD *= cD8ztD + (-100 < n6wikC ? -66 : 203), cD8ztD -= -87 < eB6EbU ? -101 : -261);
764
- break;
765
- case -16046:
766
- console.log(240 > AnCfc3A ? -70 : 7), (NYvTJV *= AnCfc3A - 240, NYvTJV -= 240 > AnCfc3A ? -66 : 304), AnCfc3A += eB6EbU - 76, (eB6EbU *= 154 > NYvTJV ? xYPTGP - 234 : 103 > xYPTGP ? -138 : 2, eB6EbU -= AnCfc3A - 409);
767
- break;
768
- case -9974:
769
- console.log(NYvTJV + (-225 > AnCfc3A ? -98 : -103)), xYPTGP += n6wikC + 260, eB6EbU += NYvTJV - 67, (AnCfc3A *= eB6EbU - 173, AnCfc3A -= eB6EbU - 132 < NYvTJV ? 19 : -107 > NYvTJV ? 145 : -44);
770
- break;
771
- case -8318:
772
- console.log(AnCfc3A - 45), (n6wikC *= -126 < xYPTGP ? 2 : 53, n6wikC -= n6wikC + 336);
773
- }
774
- }
775
- ```
776
-
777
- Available now on NPM: https://www.npmjs.com/package/js-confuser
778
-
779
- # `1.1.7`
780
- Website is Live
781
-
782
- - [https://master--hungry-shannon-c1ce6b.netlify.app/](https://master--hungry-shannon-c1ce6b.netlify.app/) is live!
783
- - Check out the [js-confuser-website](https://github.com/MichaelXF/js-confuser-website) repo for more info
784
-
785
- - **⚠️ Breaking change**: `Rename Globals` is now enabled by default
786
- - **Bug fix**: `Dead Code` no longers adds async code when `es5` option is enabled
787
- - Improved `Control Flow Flattening`
788
-
789
- # `1.1.6`
790
- New feature: Name Recycling
791
-
792
- - **New feature:** `nameRecycling`
793
- - - Attempts to reuse released names.
794
- - - Potency Medium
795
- - - Resilience High
796
- - - Cost Low
797
-
798
- ```js
799
- // Input
800
- function percentage(decimal) {
801
- var multiplied = x * 100;
802
- var floored = Math.floor(multiplied);
803
- var output = floored + "%"
804
- return output;
805
- }
806
-
807
- // Output
808
- function percentage(decimal) {
809
- var multiplied = x * 100;
810
- var floored = Math.floor(multiplied);
811
- multiplied = floored + "%";
812
- return multiplied;
813
- }
814
- ```
815
-
816
- - `delete` operator is now properly parsed
817
- - No longers changes `constructor` method on classes
818
- - Added two new Dead Code samples and fixed one
819
- - RGF now skips async and generator functions
820
- - Object Extraction now places the extracted properties in the same position as the declaration
821
- - Name Conflicts disabled to speed up obfuscation times
822
- - Improvements to Minify
823
- (better Variable Grouping)
824
- - The `renameGlobals` option now has affect
825
-
826
- Available now on NPM: https://www.npmjs.com/package/js-confuser
827
-
828
- # `1.1.5`
829
- Performance Improvements
830
-
831
- - **Bug fix**: Object Extraction
832
- - - Improved safety checks (searches further down tree)
833
- - - No longer applies to empty objects
834
-
835
- - String Concealing results are now cached
836
-
837
- - Minification improvements
838
- - - `a += -1` -> `a -= 1`
839
- - - `a -= -1` -> `a += 1`
840
- - - `a + -b` -> `a - b`
841
- - - `a - -b` -> `a + b`
842
-
843
- - Dispatcher no longer applies to redefined functions
844
-
845
- - Ensure `controlFlowFlattening` numbers don't get too large
846
- (hardcoded limit of 100,000)
847
-
848
- - Opaque Predicates now excludes await expressions
849
-
850
- Available now on NPM: https://www.npmjs.com/package/js-confuser
851
-
852
- # `1.1.4`
853
- Improved ES5 Support
854
-
855
- - Full support for transpiling [ES6 template strings](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)
856
- - - Added `.raw` property for Tagged Template Literals
857
-
858
- - Transpiling [ES6 Classes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) down to ES5-compatible code
859
- - Transpiling the [ES6 spread operator in arrays](https://www.samanthaming.com/tidbits/92-6-use-cases-of-spread-with-array/)
860
- - Transpiling the [ES6 spread operator in objects](https://lucybain.com/blog/2018/js-es6-spread-operator/)
861
-
862
- - Improved `controlFlowFlattening` to use multiple state variables
863
- - Added chained-calls to `duplicateLiteralsRemoval`, similar to obfuscator.io's [`stringArrayWrappersChainedCalls`](https://github.com/javascript-obfuscator/javascript-obfuscator) option
864
-
865
- Available now on NPM: https://www.npmjs.com/package/js-confuser
866
-
867
- # `1.1.3`
868
- Minification Changes
869
-
870
- - Fixed minification errors
871
- - - No longer accidentally removes function declarations/class declarations
872
-
873
- - RGF Changes
874
- - - Function cannot rely on `this`
875
- - - Better support with `renameVariables`
876
-
877
- - Opaque Predicate Changes
878
- - - Now correctly applies to switch case tests
879
-
880
- - Fixed Flatten bug causing undefined return values
881
-
882
- - Support for transpiling [ES6 template strings](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)
883
-
884
- Available now on NPM: https://www.npmjs.com/package/js-confuser
885
-
886
- # `1.1.2`
887
- New String Compression feature and Fixed Syntax errors
888
-
889
- - **New feature**: `stringCompression`
890
- - - String Compression uses LZW's compression algorithm to reduce file size. (`true/false/0-1`)
891
- - - `"console"` -> `inflate('replaĕ!ğğuģģ<~@')`
892
- - - Potency High
893
- - - Resilience Medium
894
- - - Cost Medium
895
-
896
- - Fixed error with String encoding
897
-
898
- - Fixed syntax error from obfuscating destructuring with computed keys
899
- - Fixed syntax error when getters/setters were being converted to arrow functions
900
- - Integrity fixes:
901
- - - Better support with Dispatcher
902
- - - Better support with Calculator
903
-
904
- Available now on NPM: https://www.npmjs.com/package/js-confuser
905
-
906
- # `1.1.1`
907
- General fixes
908
- - No longer encodes `"use strict"` and other directives
909
- - No longer encodes `require("str")` or `import("str")` strings
910
-
911
- - Fixed several `controlFlowFlattening` bugs:
912
- Fixed rare code corruption when nested
913
- Fixed obfuscation on `for` and `while` loops
914
-
915
- - Fixed `stack` from creating syntax errors
916
- (No longer applies to for-loop initializers)
917
-
918
- - Fixed renaming identifiers in object destructing
919
- - Better support for `let` variables
920
-
921
- - Checks for invalid options
922
- - Increased test coverage to 90%
923
-
924
- - `debugTransformations`, `Obfuscator` and `Transform` objects exposed.
925
-
926
- Available now on NPM: https://www.npmjs.com/package/js-confuser
927
-
928
- # `1.1.0`
929
- New feature: Stack, and various improvements
930
- - **New feature:** `stack`
931
- Local variables are consolidated into a rotating array. (`true/false/0-1`)
932
- [Similar to Jscrambler's Variable Masking](https://docs.jscrambler.com/code-integrity/documentation/transformations/variable-masking)
933
- - Potency Medium
934
- - Resilience Medium
935
- - Cost Low
936
-
937
- ```js
938
- // input
939
- function add3(x, y, z){
940
- return x + y + z;
941
- }
942
-
943
- // output
944
- function add3(...AxaSQr){AxaSQr.length=3;return AxaSQr.shift()+AxaSQr.shift()+AxaSQr.shift()}
945
- ```
946
-
947
- - Improvements to `flatten`
948
- - Properly renames `let` variables now
949
- - Improvements to `dispatcher`
950
-
951
- Available now on NPM: https://www.npmjs.com/package/js-confuser
952
-
953
- # `1.0.9`
954
- Support for lower versions of NodeJS
955
-
956
- - Adjusted babel config to be more forgiving to the older versions of NodeJS.
957
-
958
-
959
- # `1.0.8`
960
- New shuffle feature and improvements
961
- - New feature for shuffle:
962
- `hash` - Shift based on the hash of the array contents
963
- If the hash changes, the order of the array will be messed up causing your program to brick.
964
-
965
- - Lock improvements
966
- Fixed issue with `nativeFunctions`
967
- Now errors when `countermeasures` callback can't be found.
968
- Countermeasures callback works with `Integrity`.
969
- New rules for `countermeasures` callback:
970
- Must be top-level,
971
- No references to locked code (otherwise infinite loop)
972
-
973
- - General improvements
974
- Updated presets and documentation
975
- Added `index.d.ts` for type-intellisense
976
-
977
- Available now on NPM: https://www.npmjs.com/package/js-confuser
978
-
979
-
980
-
981
- # `1.0.7`
982
- Integrity fixed
983
- - Integrity Improvements
984
- - - Countermeasures function works with Integrity
985
- - - Fixed hashing issues
986
- - - - Wrote more tests for integrity
987
- - Documentation Update
1
+ # `2.0.1`
2
+ Fixes
3
+
4
+ - Fixed [#167](https://github.com/MichaelXF/js-confuser/issues/167)
5
+ - Fixed [#190](https://github.com/MichaelXF/js-confuser/issues/190)
6
+
7
+ - Improved `Control Flow Flattening`
8
+ - - Fixed implicit return bug causing incorrect return values
9
+ - - The switch-case transitions now are computed by other state variables
10
+ - - No longer lifted by [nullableVoidPtr's deobfuscator](https://github.com/nullableVoidPtr/deobf) - a complete CFF-in-CFF solver
11
+
12
+ ```js
13
+ // Input code:
14
+ console.log(1)
15
+
16
+ // 2.0.0
17
+ case 245:
18
+ console["log"](1);
19
+ ((c += -311), (d += 251), (e += 346));
20
+ break;
21
+
22
+ // 2.0.1
23
+ case 245:
24
+ console["log"](1);
25
+ ((c += e - -174), (d += e - -114), (e += c - 329));
26
+ break;
27
+ ```
28
+
29
+ # `2.0.0`
30
+ 2.0 Rewrite 🎉
31
+
32
+ ### Complete rewrite of JS-Confuser using Babel! 🎉
33
+
34
+ **⚠️ Breaking changes**
35
+
36
+ > Check out the [Migration guide](./Migration.md) on how to properly update from 1.X to 2.0. The obfuscation upgrades in 2.0 are worth the small refactoring.
37
+
38
+ - Revamped API Interface
39
+
40
+ - - JSConfuser.obfuscate() resolves to an object
41
+
42
+ | Property | Type | Description |
43
+ | --- | --- | --- |
44
+ | `code` | `string` | The obfuscated code. |
45
+
46
+ - Renamed `Stack` to `Variable Masking`
47
+
48
+ - Added configurable limits to options:
49
+
50
+ ```js
51
+ const options = {
52
+ target: "node",
53
+
54
+ rgf: {
55
+ value: 0.5, // = 50% of eligible functions
56
+ limit: 10 // Maximum of 10 changes for performance reasons
57
+ },
58
+
59
+ // Original format is still valid (No limit applied)
60
+ rgf: 0.5
61
+ }
62
+ ```
63
+
64
+ ### 2.0 Changes
65
+
66
+ - Added [Custom String Encoding](https://js-confuser.com/docs/options/customStringEncodings) and [Custom Lock Code](https://js-confuser.com/docs/options/customLocks) options
67
+
68
+ - Added `Rename Labels` [Learn more here](https://js-confuser.com/docs/options/renamelabels#rename-labels)
69
+
70
+ - Added `Pack` [Learn more here](https://js-confuser.com/docs/options/pack#pack)
71
+
72
+ - RGF no longers uses `new Function` instead uses `eval`
73
+
74
+ - Improved code transforms!
75
+
76
+ - Improved `Control Flow Flattening`
77
+
78
+ - - Obfuscates the [Call Graph](https://en.wikipedia.org/wiki/Call_graph)
79
+
80
+ - - Now supports lexical bindings (`let`, `const`, `class`)
81
+
82
+ - - `with () { }` statement obfuscation
83
+
84
+ - Improved `Minify`
85
+
86
+ - - Removes unused variables and functions
87
+
88
+ - Improved `Moved Declaration` ability to move variables as unused function parameters
89
+
90
+ - Improved `String` transforms
91
+
92
+ - - [Template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) are now obfuscated (First converted into equivalent String Literal)
93
+
94
+ - - [Regular expressions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions) are now obfuscated (First converted into equivalent RegExp() constructor calls)
95
+
96
+ - - `String Compression` now uses LZ-string compression ([lz-string](https://www.npmjs.com/package/lz-string))
97
+
98
+ - New Comment Syntax
99
+
100
+ - - `/* @js-confuser-var */ "name"` for improved variable mappings, such as eval() calls
101
+
102
+ ```js
103
+ // Input
104
+ var name = "Internet User";
105
+ eval( "console.log(" + /* @js-confuser-var */ "name" + ")" );
106
+
107
+ // Output
108
+ var zC3PLKu = "Internet User";
109
+ eval("console.log(" + "zC3PLKu" + ")");
110
+ ```
111
+
112
+ Note: The function `__JS_CONFUSER_VAR__` is still supported.
113
+
114
+ ### JS-Confuser.com Revamp
115
+
116
+ A new UI for [JS-Confuser.com](https://js-confuser.com), featuring an advanced playground and documentation pages.
117
+
118
+ The previous version will remain available at [old--confuser.netlify.com](https://old--confuser.netlify.app/).
119
+
120
+ **Removed features**
121
+
122
+ - Removed `ES5` option - Use Babel Instead
123
+
124
+ - Removed `Browser Lock` and `OS Lock` - Use [Custom Locks](https://js-confuser.com/docs/options/customlocks#custom-locks) instead
125
+
126
+ - Removed `Shuffle`'s Hash option
127
+
128
+ - Removed `Indent` option
129
+
130
+
131
+ # `1.7.3`
132
+ Tamper Protection
133
+
134
+ ### `Tamper Protection`
135
+
136
+ Tamper Protection safeguards the runtime behavior from being altered by JavaScript pitfalls.
137
+
138
+ [Learn more here.](/docs/TamperProtection.md)
139
+
140
+ ---
141
+
142
+ - Rename Variables improvements:
143
+
144
+ - A new exposed function, `__JS_CONFUSER_VAR__`, can be used to access renamed variables. [Learn more here](/docs/RenameVariables.md).
145
+
146
+
147
+ ```js
148
+ // Input
149
+ var name = "John Doe";
150
+ eval("console.log(" + __JS_CONFUSER_VAR__(name) + ")");
151
+
152
+ // Output
153
+ var CA1HU0 = 'John Doe';
154
+ eval('console.log(' + 'CA1HU0' + ')');
155
+ ```
156
+
157
+ - Improved the `Zero Width` identifier generator (Thanks @doctor8296!)
158
+
159
+ - Pad the `String Concealing` array with more fake strings
160
+
161
+ - Improve `String Compression`
162
+
163
+ - New Web UI sneak peak: https://js-confuser.com/
164
+
165
+
166
+ # `1.7.2`
167
+ Updates
168
+
169
+ - `Anti Tooling` & `Expression Obfuscation` improvements
170
+ - - No longer expanded by [webcrack](https://github.com/j4k0xb/webcrack), [synchrony](https://github.com/relative/synchrony) & [REstringer](https://github.com/PerimeterX/restringer)
171
+
172
+ - `String Concealing` improvements
173
+ - - Randomizes the charset for each obfuscation
174
+ - - Place multiple decryption functions throughout the code
175
+ - - These changes aim to defeat [JSConfuser-String-Decryptor](https://github.com/0v41n/JSConfuser-String-Decryptor) and any other RegEx-based decoders
176
+
177
+ - `Moved Declarations` improvements
178
+ - - Now moves some variables as unused parameters on certain functions
179
+
180
+ - `RGF` improvements
181
+ - - More likely to transform functions containing functions
182
+
183
+ - Fixed [#96](https://github.com/MichaelXF/js-confuser/issues/96)
184
+ - - Removed hardcoded limits on `String Concealing`, `String Compression`, and `Duplicate Literals Removal`
185
+
186
+ - Fixed [#106](https://github.com/MichaelXF/js-confuser/issues/106)
187
+ - - Final fix with const variables for `Object Extraction`
188
+
189
+ - Fixed [#131](https://github.com/MichaelXF/js-confuser/issues/131)
190
+ - - __dirname is no longer changed by `Global Concealing`
191
+
192
+ **New Option**
193
+
194
+ ### `preserveFunctionLength`
195
+ - Modified functions will retain the correct `function.length` property. (`true/false`)
196
+ Enabled by default.
197
+
198
+ Minor improvements
199
+ - Preserve `function.length`
200
+ - Preserve Strict Mode behaviors
201
+ - Preserve indirect vs. direct [`eval`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) use
202
+
203
+
204
+ # `1.7.1`
205
+ Updates
206
+
207
+ - Fixed [#107](https://github.com/MichaelXF/js-confuser/issues/107)
208
+ - - RGF and Integrity clash issue fixed
209
+
210
+ - Fixed [#106](https://github.com/MichaelXF/js-confuser/issues/106)
211
+ - - Object Extraction to properly handle `const` objects
212
+
213
+ - Fixed [#105](https://github.com/MichaelXF/js-confuser/issues/105)
214
+ - - Duplicate Literals Removal updated to not cause this error
215
+
216
+ - Fixed [#103](https://github.com/MichaelXF/js-confuser/issues/103)
217
+ - - Dispatcher will no longer apply to these types of functions to prevent this error
218
+
219
+ - Added documentation page for [ES5](https://github.com/MichaelXF/js-confuser/blob/master/docs/ES5.md)
220
+
221
+ - Rollup Plugin created: https://github.com/ayecue/rollup-js-confuser (Thanks @ayecue !)
222
+
223
+ # `1.7.0`
224
+ Updates
225
+
226
+ - Fixed [#89](https://github.com/MichaelXF/js-confuser/issues/89)
227
+ - - Flatten to not break functions with invalid identifier names
228
+
229
+ - Fixed [#88](https://github.com/MichaelXF/js-confuser/issues/88)
230
+ - - Stack to not break functions with syncing arguments
231
+
232
+ - Fixed [#91](https://github.com/MichaelXF/js-confuser/issues/91)
233
+ - - Minify to preserve function.length property
234
+
235
+ - Fixed [#95](https://github.com/MichaelXF/js-confuser/issues/95)
236
+ - - Rename Variables optimized to obfuscate much faster
237
+
238
+ - Added documentation pages for [RGF](https://github.com/MichaelXF/js-confuser/blob/master/docs/RGF.md) and [Control Flow Flattening](https://github.com/MichaelXF/js-confuser/blob/master/docs/ControlFlowFlattening.md)
239
+
240
+ - Removed `eval` option in favor of `rgf` option.
241
+
242
+ - - Removed the `"all"` option from `rgf`.
243
+
244
+ - Removed `nameRecycling` option
245
+
246
+ # `1.6.0`
247
+ Website Redesign + Updates
248
+
249
+ The website is now redesigned and live at [js-confuser.com](https://wwww.js-confuser.com)!
250
+
251
+ - Check out the source code for the website here: https://github.com/MichaelXF/js-confuser-website
252
+
253
+ #### New feature
254
+
255
+ ### `selfDefending`
256
+
257
+ Prevents the use of code beautifiers or formatters against your code.
258
+
259
+ [Identical to Obfuscator.io's Self Defending](https://github.com/javascript-obfuscator/javascript-obfuscator#selfdefending)
260
+
261
+ #### Improvements
262
+
263
+ - Fixed [#56](https://github.com/MichaelXF/js-confuser/issues/56)
264
+ - - Calculator improved to apply to more operators
265
+
266
+ - ES5 to handle destructuring member expressions
267
+
268
+ - Improved Control Flow Flattening techniques
269
+
270
+ - - Outlining expressions
271
+
272
+ - - Control object to store numbers and strings
273
+
274
+ - Updated the String concealing encoding algorithm
275
+
276
+ - Optimizations / Small fixes
277
+
278
+ # `1.5.9`
279
+ Big update
280
+
281
+ This updates comes with many bug fixes:
282
+
283
+ - Fixed [#72](https://github.com/MichaelXF/js-confuser/issues/72)
284
+ - - ES5 to handle Class Fields
285
+
286
+ Note: The `ES5` option is not meant to replace Babel. It is only intended to undo ES6 features the obfuscator may have added to your code.
287
+
288
+ - Fixed [#74](https://github.com/MichaelXF/js-confuser/issues/74)
289
+ - - Anti Tooling to not break Symbols
290
+
291
+ - Fixed [#75](https://github.com/MichaelXF/js-confuser/issues/75)
292
+ - - Minify to properly handle Object constructors
293
+
294
+ - Fixed [#76](https://github.com/MichaelXF/js-confuser/issues/76)
295
+ - - Minify to not cause syntax errors when objects used `^`, `` ` ``, `[`, `]` as property keys
296
+
297
+ - Fixed [#77](https://github.com/MichaelXF/js-confuser/issues/77)
298
+ - - Dispatcher to not break code that uses generic names like `toString` and `hasOwnProperty`
299
+
300
+ - Fixed [#78](https://github.com/MichaelXF/js-confuser/issues/78)
301
+ - - Object Extraction to not error on objects with spread elements
302
+
303
+ - Fixed [#79](https://github.com/MichaelXF/js-confuser/issues/79)
304
+ - - JsConfuser now supports `BigInt` literals
305
+
306
+ - Fixed [#80](https://github.com/MichaelXF/js-confuser/issues/80)
307
+ - - Rename Variables to not break code that had `var` and `let` variables in the same scope
308
+
309
+ - Fixed [#81](https://github.com/MichaelXF/js-confuser/issues/81)
310
+ - - Control Flow Flattening to not break `typeof` expressions
311
+
312
+ - Fixed [#82](https://github.com/MichaelXF/js-confuser/issues/82)
313
+ - - String Concealing to not break class constructors
314
+
315
+ # `1.5.8`
316
+ Several fixes
317
+
318
+ - Fixed [#46](https://github.com/MichaelXF/js-confuser/issues/46)
319
+ - - Updated the validation on `lock` options
320
+
321
+ - Fixed [#68](https://github.com/MichaelXF/js-confuser/issues/68)
322
+ - - Name Recycling fixed to not break certain function declarations
323
+
324
+ - Fixed [#69](https://github.com/MichaelXF/js-confuser/issues/69), [#70](https://github.com/MichaelXF/js-confuser/issues/70) and [#71](https://github.com/MichaelXF/js-confuser/issues/71)
325
+ - - Import statements to be properly handled
326
+
327
+ - Slight improvements to String Concealing
328
+
329
+ # `1.5.7`
330
+ Countermeasures function fixes
331
+
332
+ This update focuses on fixing Countermeasures bugs
333
+
334
+ The `countermeasures` is custom callback function to invoke when a lock is triggered.
335
+
336
+ - Fixed [#66](https://github.com/MichaelXF/js-confuser/issues/66)
337
+ - - RGF to properly handle the countermeasures function
338
+
339
+ - Added additional code to prevent an infinite loop from occurring
340
+
341
+ - Slight improvements to RGF
342
+
343
+ # `1.5.6`
344
+ Website changed and RGF fixes
345
+
346
+ The website is back at a different domain now: [https://master--hungry-shannon-c1ce6b.netlify.app/](https://master--hungry-shannon-c1ce6b.netlify.app/)
347
+
348
+ This update focuses on fixing RGF bugs
349
+
350
+ - Fixed [#64](https://github.com/MichaelXF/js-confuser/issues/64)
351
+ - - RGF to properly handle Arrow functions and function expressions
352
+
353
+ - RGF will no longer change getter/setter methods
354
+
355
+ - RGF will no longer change class methods
356
+
357
+ - RGF now works when using `mangled` variable names
358
+
359
+ - Minify will remove unreachable code following a Throw statement
360
+
361
+ # `1.5.5`
362
+ Updates
363
+
364
+ - Fixed [#53](https://github.com/MichaelXF/js-confuser/issues/53)
365
+ - - Shuffle to not use common variable names like `x`
366
+
367
+ - Fixed [#60](https://github.com/MichaelXF/js-confuser/issues/60)
368
+ - - Rename Variables to properly handle function parameters
369
+
370
+ - Fixed [#62](https://github.com/MichaelXF/js-confuser/issues/62)
371
+ - - Rename Variables to properly handle catch-clause parameters
372
+
373
+ # `1.5.4`
374
+ Small fix
375
+
376
+ - Fixed [#45](https://github.com/MichaelXF/js-confuser/issues/45)
377
+ - - Opaque predicates fixed to not this cause error
378
+
379
+
380
+ # `1.5.3`
381
+ Shuffle fix
382
+
383
+ - Fixed [#48](https://github.com/MichaelXF/js-confuser/issues/48)
384
+ - - Shuffle was re-assigning `const` variables, fixed in this version.
385
+
386
+ # `1.5.2`
387
+ Mini fixes
388
+
389
+ - Fixed [#41](https://github.com/MichaelXF/js-confuser/issues/41)
390
+ - - Obfuscator mishandled switch statements with a `default` case
391
+
392
+ - Fixed [#43](https://github.com/MichaelXF/js-confuser/issues/43)
393
+ - - Obfuscator mishandled variable destructuring in for-loops
394
+
395
+ # `1.5.1`
396
+ Object Extraction Fix
397
+
398
+ - Fixed [#37](https://github.com/MichaelXF/js-confuser/issues/37)
399
+ - - Object Extraction was applying to objects with get/set methods, fixed in this version.
400
+
401
+ - Slight improvement to `Flatten`
402
+
403
+ # `1.5.0`
404
+ Hexadecimal Numbers
405
+
406
+ - The hexadecimal representation can now be used. [#29](https://github.com/MichaelXF/js-confuser/issues/29)
407
+ - New option `hexadecimalNumbers` to control this behavior.
408
+
409
+ ### `hexadecimalNumbers`
410
+
411
+ Uses the hexadecimal representation (`50` -> `0x32`) for numbers. (`true/false`) -->
412
+
413
+ - Slight improvement to `Control Flow Flattening`
414
+ - Slight improvement to `Calculator`
415
+
416
+ # `1.4.3`
417
+ Minify Fix
418
+
419
+ - Fixed [#34](https://github.com/MichaelXF/js-confuser/issues/34)
420
+ - - Minify was removing `return` statements too aggressively, fixed in this version.
421
+
422
+ - Slight improvement to Control Flow Flattening
423
+
424
+ # `1.4.2`
425
+ Eval Fix
426
+
427
+ - Fixed [#31](https://github.com/MichaelXF/js-confuser/issues/31)
428
+ - - Eval and Integrity didn't work together, fixed in this version.
429
+
430
+ # `1.4.1`
431
+ AntiDebug Fix
432
+
433
+ - Fixed [#28](https://github.com/MichaelXF/js-confuser/issues/28)
434
+ - - AntiDebug was causing syntax errors in some scenarios, fixed in this version.
435
+
436
+ # `1.4.0`
437
+ Confusing Control Flow
438
+
439
+ - `Control Flow Flattening` overhaul, now flattens embedded control structures
440
+
441
+ - - `If statements`
442
+ - - `For statements`
443
+ - - `While statements`
444
+ - - `Switch statements`
445
+ - - `Do While statements`
446
+
447
+ - - Certain functions
448
+
449
+ ```js
450
+ // Input
451
+ console.log(1);
452
+ console.log(2);
453
+ console.log(Number("3"));
454
+
455
+ for (var i = 4; i < 6; i++) {
456
+ console.log(i);
457
+ }
458
+
459
+ var i = 0;
460
+ do {
461
+ console.log(i + 6);
462
+ } while (i++ < 4);
463
+
464
+ // Output
465
+ var a = -123, b = 414, c = -191;
466
+ while (a + b + c != 104) {
467
+ var d = (a + b + c) * -28 + 172;
468
+ switch (d) {
469
+ case -276:
470
+ !(a *= 138 > b ? 2 : 158, a -= -5 < c ? -90 : -152, b *= b + 206, b -= a + -539, c += b + -372);
471
+ break;
472
+ case -2628:
473
+ var e = (console['log'](-106 > c ? 1 : 182), console['log'](a + 125), console['log'](Number('3')), -87 < a ? -189 < a ? -133 : 93 : 107 < c ? 227 : 4);
474
+ ~(a *= (-114 > c ? -164 : -107) < c ? -164 : 2, a -= 188 > b ? b + -211 : -369, b += -62 > c ? 168 > c ? -539 : 56 : 26, c += (c + 362 > a ? 73 : -157) < b ? 207 : 341);
475
+ break;
476
+ case -4420:
477
+ +(a *= a + (a + 18), a -= 190 > a ? -344 : 71, b *= -206 < b ? c + -173 : -221, b -= b + 94, c += 89 > b ? -311 : 170);
478
+ break;
479
+ case -3972:
480
+ if (e < c + -144) {
481
+ !(a *= b + 127, a -= b + (b + 671), b += c + 82, c *= 61 < a ? -139 : 2, c -= b + -35);
482
+ break;
483
+ }
484
+ typeof (a *= c + -148, a -= c + 271, b += c + 184, c += -89 < c ? -42 : -114);
485
+ break;
486
+ case -3244:
487
+ +(a += a + 220, b += b + 317, c += b + -218);
488
+ break;
489
+ case -4308:
490
+ !(a += 134 < b ? -233 : 89, b += -79 < b ? -69 : -241, c *= -107 > a ? -97 : 2, c -= (56 < a ? -27 : -184) > c ? -163 : 231);
491
+ break;
492
+ case -3664:
493
+ ~(a += b + -362, b += -87 < b ? -666 : -172, c += c + 710);
494
+ break;
495
+ case -5344:
496
+ +(a *= c + (-165 < a ? -266 : 182) > c ? 124 : 2, a -= -154 > b ? c + 92 : -388, b += c + -193, c *= c + (c + -30), c -= a + -11);
497
+ break;
498
+ case -2572:
499
+ if (e++ < ((-125 < a ? -62 : 87) < c ? -112 : 4)) {
500
+ ~(a += c + -268, b += 215 < b ? 136 : 18 < b ? -233 : 536, c += b + -535);
501
+ break;
502
+ }
503
+ ~(a *= (123 > a ? -105 : 238) < b ? 216 : 2, a -= a + 57, b *= a + 59, b -= a + -369, c *= b + -236, c -= 200 > c ? -288 : -11);
504
+ break;
505
+ case -4784:
506
+ +(console['log'](e), a *= c + -223, a -= 7 > c ? -227 > b ? -4 : 192 : -157, b *= a + (-186 > b ? 211 : 17), b -= -127 > c ? 76 : 280, c *= -63 > c ? a + 264 : 2, c -= (119 < c ? -206 : 85) < a ? 215 : 179);
507
+ break;
508
+ case -724:
509
+ void (console['log'](e + (c + -246)), a *= -177 < c ? 2 : 207, a -= 152 > a ? 122 : -190, b *= c + -250, b -= b + 160, c += -141 < a ? a + 258 : 21);
510
+ break;
511
+ case -3804:
512
+ var e = -143 > a ? 0 : 24;
513
+ typeof (a += c + -9, b += c + 125, c += a + -261);
514
+ break;
515
+ case -1648:
516
+ ~(e++, a += a + 3, b *= c + 68, b -= 89 < b ? -173 > b ? -147 : 267 : -228 > c ? -80 : -216 > b ? 93 : 68, c += 65 > a ? b + 156 : 216);
517
+ break;
518
+ }
519
+ }
520
+ ```
521
+
522
+ - New encoding type `Hex Table`
523
+
524
+ ```js
525
+ "{0x7E494534,0x688,0x7E6D53,0x401,0x7E584D4B,0x688,0x7E775853,0x688,0x7E5333,0x81}"
526
+
527
+ // => "Hello World"
528
+ ```
529
+
530
+ - Improvements to renaming labels
531
+ - Fixed [#24](https://github.com/MichaelXF/js-confuser/issues/24)
532
+ - Fixed [#25](https://github.com/MichaelXF/js-confuser/issues/25)
533
+ - Fixed [#26](https://github.com/MichaelXF/js-confuser/issues/26)
534
+
535
+ # `1.3.0`
536
+ String Splitting Improvement
537
+
538
+ - `String Splitting` now supports percentages and a custom callback. ([#22](https://github.com/MichaelXF/js-confuser/issues/22))
539
+
540
+ ```js
541
+ {
542
+ // percentage
543
+ stringSplitting: 0.75, // = 75%
544
+
545
+ // exclude certain strings
546
+ stringSplitting: (str)=>{
547
+ if ( str == "dont-split-string" ) {
548
+ return false;
549
+ }
550
+
551
+ return true;
552
+ },
553
+ }
554
+ ```
555
+
556
+ # `1.2.2`
557
+ Global name fix
558
+
559
+ - **Bug fix**: `Rename Variables` breaking access to global variables
560
+
561
+ ```js
562
+ // Say `a` is a global library
563
+ // Input
564
+ function myFunction(param1){
565
+ a(param1);
566
+ }
567
+
568
+ // Output on 1.2.1
569
+ function a(a){
570
+ a(a);
571
+ }
572
+
573
+ // Output on 1.2.2
574
+ function b(b){
575
+ a(b);
576
+ }
577
+ ```
578
+
579
+ - **Bug fix**: `Flatten` to not accidentally remove function parameters
580
+ - **Bug fix**: `Dispatcher` on function calls within classes
581
+ - **Bug fix**: `Minify` fixed syntax error
582
+
583
+ ```js
584
+ // Input
585
+ var o = {Infinity: 0};
586
+
587
+ // Output on 1.2.1
588
+ var o = {1/0: 0};
589
+
590
+ // Output on 1.2.2
591
+ var o = {[1/0]: 0};
592
+ ```
593
+
594
+ - Added `base32` encoding to `String Concealing`
595
+ - `Minify` improvements
596
+ - - `true` -> `!0`
597
+ - - `false` -> `!1`
598
+ - Subtle changes to `String Compression`
599
+ - Updated presets
600
+
601
+ # `1.2.1`
602
+ Bug fixes
603
+
604
+ - **Bug fix**: `Control Flow Flattening` on classes no longer creates syntax errors
605
+ - **Bug fix**: `String Concealing` will check for duplicate strings
606
+ - **Bug fix**: `String Concealing` now handles class properties
607
+ - **Bug fix**: `Stack` and `Control Flow Flattening` no longer modifies floats
608
+
609
+ - **New API:**
610
+
611
+ ## `obfuscateAST(AST, options)`
612
+
613
+ 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).
614
+
615
+ **Note:** Mutates the object.
616
+
617
+ | Parameter | Type | Description |
618
+ | --- | --- | --- |
619
+ | `AST` | `object` | The [ESTree](https://github.com/estree/estree) compliant AST. This object will be mutated. |
620
+ | `options` | `object` | The obfuscator settings. |
621
+
622
+ # `1.2.0`
623
+ Bug fixes
624
+
625
+ - **Bug fix**: `Eval` moves function declarations to the top of the lexical block
626
+ - **Bug fix**: `Stack` no longers changes function declarations
627
+ - Improvements to `Stack` rotations
628
+
629
+ ```js
630
+ // Input
631
+ function add3(x,y,z){
632
+ ok(typeof x === "number");
633
+ ok(typeof y === "number");
634
+ ok(typeof z === "number");
635
+
636
+ return x + y + z;
637
+ }
638
+
639
+ console.log(add3(1,2,3))
640
+
641
+ // Output on 1.1.9
642
+ function _WFZLw(..._WFZLw) {
643
+ void (_WFZLw.length = 3, ok(typeof _WFZLw[0] === 'number'), ok(typeof _WFZLw[1] === 'number'), ok(typeof _WFZLw[2] === 'number'));
644
+ return _WFZLw[0] + _WFZLw[1] + _WFZLw[2];
645
+ }
646
+ console['log'](_WFZLw(1, 2, 3));
647
+
648
+ // Output on 1.2.0
649
+ var KZ6LyAL = (...KZ6LyAL) => {
650
+ ~(KZ6LyAL.length = 3, ok(typeof KZ6LyAL[0] === 'number'), KZ6LyAL[186] = KZ6LyAL[0], ok(typeof KZ6LyAL[1] === 'number'), KZ6LyAL[227] = -22, ok(typeof KZ6LyAL[KZ6LyAL[KZ6LyAL[227] + 249] + 24] === 'number'));
651
+ return KZ6LyAL[KZ6LyAL[227] - (KZ6LyAL[227] - 186)] + KZ6LyAL[KZ6LyAL[227] + 23] + KZ6LyAL[KZ6LyAL[KZ6LyAL[227] + 249] - (KZ6LyAL[227] - (KZ6LyAL[227] + 24))];
652
+ };
653
+ console.log(KZ6LyAL(1, 2, 3));
654
+ ```
655
+
656
+ # `1.1.9`
657
+ Browser Lock and OS Lock
658
+
659
+ - Added `Browser Lock` and `OS Lock`
660
+
661
+ | Mode | Target | Method |
662
+ | --- | --- | --- |
663
+ | `Browser Lock` | `"browser"` | Checks `window.navigator.userAgent` |
664
+ | `Browser Lock` | `"node"` | N/A |
665
+ | `OS Lock` | `"browser"` | Checks `window.navigator.userAgent` |
666
+ | `OS Lock` | `"node"` | Checks `require('os').platform()` |
667
+
668
+ ---
669
+
670
+ - #### `Browser Lock`
671
+
672
+ - Array of browsers where the script is allowed to run. (`string[]`)
673
+
674
+ - - Potency Low
675
+ - - Resilience Medium
676
+ - - Cost Medium
677
+
678
+ - Allowed values: `"firefox"`, `"chrome"`, `"iexplorer"`, `"edge"`, `"safari"`, `"opera"`
679
+
680
+ - Example: `["firefox", "chrome"]`
681
+
682
+ ---
683
+
684
+ - #### `OS Lock`
685
+
686
+ - Array of operating-systems where the script is allowed to run. (`string[]`)
687
+
688
+ - - Potency Low
689
+ - - Resilience Medium
690
+ - - Cost Medium
691
+
692
+ - Allowed values: `"linux"`, `"windows"`, `"osx"`, `"android"`, `"ios"`
693
+
694
+ - Example: `["linux", "windows"]`
695
+
696
+ ---
697
+
698
+ - **Bug fix**: `Moved Declarations` no longer applies to loops
699
+ - - Previously broke Switch statements
700
+
701
+ - `String Splitting` use larger chunk sizes to avoid creating too many strings
702
+
703
+ Available now on NPM: https://www.npmjs.com/package/js-confuser
704
+
705
+ # `1.1.8`
706
+ Bug Fixes and Improvements
707
+
708
+ - **Bug fix**: Stack no longer replaces identifiers that are in nested contexts
709
+
710
+ - `es5` converts
711
+ - - `fn(...args)` -> `fn.apply(this, args)`
712
+ - - `fn(...arguments)` -> `fn.apply(this, [].concat(Array.prototype.slice.call(arguments)))`
713
+
714
+ - Changes to `identifierGenerator`
715
+ - - `mangled` Now uses both lowercase and uppercase alphabets
716
+
717
+ - Added `antiTooling` to stop [JSNice.org](https://JSNice.org) from expanding sequence expressions
718
+
719
+ ```js
720
+ // Input
721
+ (console.log(1), console.log(2), console.log(3))
722
+
723
+ // Output
724
+ +(console.log(1), console.log(2), console.log(3))
725
+
726
+ // JSNice on Input
727
+ console.log(1)
728
+ console.log(2)
729
+ console.log(3)
730
+
731
+ // JSNice on Output
732
+ +(console.log(1), console.log(2), console.log(3))
733
+ ```
734
+
735
+ - Improved `controlFlowFlattening`
736
+ - - No longer changes blocks with `const` variables
737
+ - - Now obscures order of expressions
738
+ ```js
739
+ // Input
740
+ console.log(1)
741
+ console.log(2)
742
+ console.log(3)
743
+ console.log(4)
744
+ var five = 5;
745
+ console.log(five);
746
+
747
+ // Output
748
+ var oI8J9w6 = (console['log'](1), console['log'](2), console['log'](3), console['log'](4), 5);
749
+ console['log'](oI8J9w6);
750
+ ```
751
+
752
+ - - Now entangles number literals with the state variables ex:
753
+
754
+ ```js
755
+ // Input
756
+ console.log(1);
757
+ console.log(2);
758
+ console.log(3);
759
+ console.log(4);
760
+ console.log(5);
761
+ console.log(6);
762
+ console.log(7);
763
+ console.log(8);
764
+ console.log(9);
765
+ console.log(10);
766
+
767
+ // Output
768
+ var xYPTGP = -164, NYvTJV = -40, eB6EbU = 55, cD8ztD = -73, AnCfc3A = 237, n6wikC = 52;
769
+ while (xYPTGP + NYvTJV + eB6EbU + cD8ztD + AnCfc3A + n6wikC != 33) {
770
+ var ruVzem = (xYPTGP + NYvTJV + eB6EbU + cD8ztD + AnCfc3A + n6wikC) * -184 - 38;
771
+ switch (ruVzem) {
772
+ case -3350:
773
+ console.log(4), (NYvTJV *= -66 > AnCfc3A ? n6wikC + (134 > xYPTGP ? -190 : 194) : 2, NYvTJV -= 77 < xYPTGP ? 28 : 66), xYPTGP += AnCfc3A - 201, (AnCfc3A *= n6wikC + 109, AnCfc3A -= 16 < NYvTJV ? 661 : -169);
774
+ break;
775
+ case -26902:
776
+ console.log(31 > AnCfc3A ? 39 : -2 > AnCfc3A ? -137 : 3), (NYvTJV *= -174 > n6wikC ? AnCfc3A - 292 : 2, NYvTJV -= n6wikC - 91), (eB6EbU *= 155 > cD8ztD ? 2 : 42, eB6EbU -= 155 > AnCfc3A ? 1 : -227), (cD8ztD *= 183 < eB6EbU ? 222 : 2, cD8ztD -= 214 < AnCfc3A ? 270 : 70);
777
+ break;
778
+ case -12366:
779
+ console.log(196 < eB6EbU ? -5 : 1), eB6EbU += -47 > cD8ztD ? -225 : 57, (xYPTGP *= AnCfc3A - 235, xYPTGP -= -126 < eB6EbU ? 46 : -434);
780
+ break;
781
+ case -20646:
782
+ console.log(2), (n6wikC *= cD8ztD + 75, n6wikC -= ((107 > xYPTGP ? -244 : -80) > cD8ztD ? 65 : 149) > cD8ztD ? -138 > eB6EbU ? cD8ztD + 284 : 159 : 73 < AnCfc3A ? -14 : 83), AnCfc3A += xYPTGP - 95 < n6wikC ? 199 : 147, xYPTGP += 227 < xYPTGP ? -238 : 46;
783
+ break;
784
+ case -10526:
785
+ console.log(10), xYPTGP += n6wikC + 524, n6wikC += cD8ztD + 263, (AnCfc3A *= 67 > xYPTGP ? n6wikC + (xYPTGP - 433 > n6wikC ? -21 : -111) : 2, AnCfc3A -= AnCfc3A + 247);
786
+ break;
787
+ case -2614:
788
+ console.log(5), (n6wikC *= xYPTGP - 333, n6wikC -= (-41 > cD8ztD ? -38 > AnCfc3A ? 96 : -97 : 49) < NYvTJV ? 131 : 112), (cD8ztD *= eB6EbU + 115, cD8ztD -= -216 < AnCfc3A ? -631 : 23), (AnCfc3A *= (NYvTJV + 1 > xYPTGP ? 235 : 206) < n6wikC ? n6wikC + 310 : 2, AnCfc3A -= NYvTJV - 236), (xYPTGP *= 185 > eB6EbU ? -169 < xYPTGP ? 2 : 236 : -19, xYPTGP -= -59 < n6wikC ? 100 : n6wikC + 779);
789
+ break;
790
+ case -5006:
791
+ console.log(6), (cD8ztD *= cD8ztD + (-100 < n6wikC ? -66 : 203), cD8ztD -= -87 < eB6EbU ? -101 : -261);
792
+ break;
793
+ case -16046:
794
+ console.log(240 > AnCfc3A ? -70 : 7), (NYvTJV *= AnCfc3A - 240, NYvTJV -= 240 > AnCfc3A ? -66 : 304), AnCfc3A += eB6EbU - 76, (eB6EbU *= 154 > NYvTJV ? xYPTGP - 234 : 103 > xYPTGP ? -138 : 2, eB6EbU -= AnCfc3A - 409);
795
+ break;
796
+ case -9974:
797
+ console.log(NYvTJV + (-225 > AnCfc3A ? -98 : -103)), xYPTGP += n6wikC + 260, eB6EbU += NYvTJV - 67, (AnCfc3A *= eB6EbU - 173, AnCfc3A -= eB6EbU - 132 < NYvTJV ? 19 : -107 > NYvTJV ? 145 : -44);
798
+ break;
799
+ case -8318:
800
+ console.log(AnCfc3A - 45), (n6wikC *= -126 < xYPTGP ? 2 : 53, n6wikC -= n6wikC + 336);
801
+ }
802
+ }
803
+ ```
804
+
805
+ Available now on NPM: https://www.npmjs.com/package/js-confuser
806
+
807
+ # `1.1.7`
808
+ Website is Live
809
+
810
+ - [https://master--hungry-shannon-c1ce6b.netlify.app/](https://master--hungry-shannon-c1ce6b.netlify.app/) is live!
811
+ - Check out the [js-confuser-website](https://github.com/MichaelXF/js-confuser-website) repo for more info
812
+
813
+ - **⚠️ Breaking change**: `Rename Globals` is now enabled by default
814
+ - **Bug fix**: `Dead Code` no longers adds async code when `es5` option is enabled
815
+ - Improved `Control Flow Flattening`
816
+
817
+ # `1.1.6`
818
+ New feature: Name Recycling
819
+
820
+ - **New feature:** `nameRecycling`
821
+ - - Attempts to reuse released names.
822
+ - - Potency Medium
823
+ - - Resilience High
824
+ - - Cost Low
825
+
826
+ ```js
827
+ // Input
828
+ function percentage(decimal) {
829
+ var multiplied = x * 100;
830
+ var floored = Math.floor(multiplied);
831
+ var output = floored + "%"
832
+ return output;
833
+ }
834
+
835
+ // Output
836
+ function percentage(decimal) {
837
+ var multiplied = x * 100;
838
+ var floored = Math.floor(multiplied);
839
+ multiplied = floored + "%";
840
+ return multiplied;
841
+ }
842
+ ```
843
+
844
+ - `delete` operator is now properly parsed
845
+ - No longers changes `constructor` method on classes
846
+ - Added two new Dead Code samples and fixed one
847
+ - RGF now skips async and generator functions
848
+ - Object Extraction now places the extracted properties in the same position as the declaration
849
+ - Name Conflicts disabled to speed up obfuscation times
850
+ - Improvements to Minify
851
+ (better Variable Grouping)
852
+ - The `renameGlobals` option now has affect
853
+
854
+ Available now on NPM: https://www.npmjs.com/package/js-confuser
855
+
856
+ # `1.1.5`
857
+ Performance Improvements
858
+
859
+ - **Bug fix**: Object Extraction
860
+ - - Improved safety checks (searches further down tree)
861
+ - - No longer applies to empty objects
862
+
863
+ - String Concealing results are now cached
864
+
865
+ - Minification improvements
866
+ - - `a += -1` -> `a -= 1`
867
+ - - `a -= -1` -> `a += 1`
868
+ - - `a + -b` -> `a - b`
869
+ - - `a - -b` -> `a + b`
870
+
871
+ - Dispatcher no longer applies to redefined functions
872
+
873
+ - Ensure `controlFlowFlattening` numbers don't get too large
874
+ (hardcoded limit of 100,000)
875
+
876
+ - Opaque Predicates now excludes await expressions
877
+
878
+ Available now on NPM: https://www.npmjs.com/package/js-confuser
879
+
880
+ # `1.1.4`
881
+ Improved ES5 Support
882
+
883
+ - Full support for transpiling [ES6 template strings](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)
884
+ - - Added `.raw` property for Tagged Template Literals
885
+
886
+ - Transpiling [ES6 Classes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) down to ES5-compatible code
887
+ - Transpiling the [ES6 spread operator in arrays](https://www.samanthaming.com/tidbits/92-6-use-cases-of-spread-with-array/)
888
+ - Transpiling the [ES6 spread operator in objects](https://lucybain.com/blog/2018/js-es6-spread-operator/)
889
+
890
+ - Improved `controlFlowFlattening` to use multiple state variables
891
+ - Added chained-calls to `duplicateLiteralsRemoval`, similar to obfuscator.io's [`stringArrayWrappersChainedCalls`](https://github.com/javascript-obfuscator/javascript-obfuscator) option
892
+
893
+ Available now on NPM: https://www.npmjs.com/package/js-confuser
894
+
895
+ # `1.1.3`
896
+ Minification Changes
897
+
898
+ - Fixed minification errors
899
+ - - No longer accidentally removes function declarations/class declarations
900
+
901
+ - RGF Changes
902
+ - - Function cannot rely on `this`
903
+ - - Better support with `renameVariables`
904
+
905
+ - Opaque Predicate Changes
906
+ - - Now correctly applies to switch case tests
907
+
908
+ - Fixed Flatten bug causing undefined return values
909
+
910
+ - Support for transpiling [ES6 template strings](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)
911
+
912
+ Available now on NPM: https://www.npmjs.com/package/js-confuser
913
+
914
+ # `1.1.2`
915
+ New String Compression feature and Fixed Syntax errors
916
+
917
+ - **New feature**: `stringCompression`
918
+ - - String Compression uses LZW's compression algorithm to reduce file size. (`true/false/0-1`)
919
+ - - `"console"` -> `inflate('replaĕ!ğğuģģ<~@')`
920
+ - - Potency High
921
+ - - Resilience Medium
922
+ - - Cost Medium
923
+
924
+ - Fixed error with String encoding
925
+
926
+ - Fixed syntax error from obfuscating destructuring with computed keys
927
+ - Fixed syntax error when getters/setters were being converted to arrow functions
928
+ - Integrity fixes:
929
+ - - Better support with Dispatcher
930
+ - - Better support with Calculator
931
+
932
+ Available now on NPM: https://www.npmjs.com/package/js-confuser
933
+
934
+ # `1.1.1`
935
+ General fixes
936
+ - No longer encodes `"use strict"` and other directives
937
+ - No longer encodes `require("str")` or `import("str")` strings
938
+
939
+ - Fixed several `controlFlowFlattening` bugs:
940
+ Fixed rare code corruption when nested
941
+ Fixed obfuscation on `for` and `while` loops
942
+
943
+ - Fixed `stack` from creating syntax errors
944
+ (No longer applies to for-loop initializers)
945
+
946
+ - Fixed renaming identifiers in object destructing
947
+ - Better support for `let` variables
948
+
949
+ - Checks for invalid options
950
+ - Increased test coverage to 90%
951
+
952
+ - `debugTransformations`, `Obfuscator` and `Transform` objects exposed.
953
+
954
+ Available now on NPM: https://www.npmjs.com/package/js-confuser
955
+
956
+ # `1.1.0`
957
+ New feature: Stack, and various improvements
958
+ - **New feature:** `stack`
959
+ Local variables are consolidated into a rotating array. (`true/false/0-1`)
960
+ [Similar to Jscrambler's Variable Masking](https://docs.jscrambler.com/code-integrity/documentation/transformations/variable-masking)
961
+ - Potency Medium
962
+ - Resilience Medium
963
+ - Cost Low
964
+
965
+ ```js
966
+ // input
967
+ function add3(x, y, z){
968
+ return x + y + z;
969
+ }
970
+
971
+ // output
972
+ function add3(...AxaSQr){AxaSQr.length=3;return AxaSQr.shift()+AxaSQr.shift()+AxaSQr.shift()}
973
+ ```
974
+
975
+ - Improvements to `flatten`
976
+ - Properly renames `let` variables now
977
+ - Improvements to `dispatcher`
978
+
979
+ Available now on NPM: https://www.npmjs.com/package/js-confuser
980
+
981
+ # `1.0.9`
982
+ Support for lower versions of NodeJS
983
+
984
+ - Adjusted babel config to be more forgiving to the older versions of NodeJS.
985
+
986
+
987
+ # `1.0.8`
988
+ New shuffle feature and improvements
989
+ - New feature for shuffle:
990
+ `hash` - Shift based on the hash of the array contents
991
+ If the hash changes, the order of the array will be messed up causing your program to brick.
992
+
993
+ - Lock improvements
994
+ Fixed issue with `nativeFunctions`
995
+ Now errors when `countermeasures` callback can't be found.
996
+ Countermeasures callback works with `Integrity`.
997
+ New rules for `countermeasures` callback:
998
+ Must be top-level,
999
+ No references to locked code (otherwise infinite loop)
1000
+
1001
+ - General improvements
1002
+ Updated presets and documentation
1003
+ Added `index.d.ts` for type-intellisense
1004
+
1005
+ Available now on NPM: https://www.npmjs.com/package/js-confuser
1006
+
1007
+
1008
+
1009
+ # `1.0.7`
1010
+ Integrity fixed
1011
+ - Integrity Improvements
1012
+ - - Countermeasures function works with Integrity
1013
+ - - Fixed hashing issues
1014
+ - - - Wrote more tests for integrity
1015
+ - Documentation Update
988
1016
  - - Fixed errors in examples