js-confuser 2.0.0-alpha.5 → 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.
- package/.github/ISSUE_TEMPLATE/bug_report.md +43 -43
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -20
- package/.github/workflows/node.js.yml +28 -28
- package/.prettierrc +4 -4
- package/CHANGELOG.md +1015 -989
- package/CODE_OF_CONDUCT.md +131 -131
- package/CONTRIBUTING.md +52 -52
- package/LICENSE +21 -21
- package/Migration.md +72 -71
- package/README.md +86 -78
- package/dist/constants.js +43 -43
- package/dist/index.js +14 -23
- package/dist/obfuscator.js +31 -25
- package/dist/order.js +4 -4
- package/dist/presets.js +31 -31
- package/dist/templates/integrityTemplate.js +4 -4
- package/dist/templates/template.js +1 -2
- package/dist/transforms/astScrambler.js +1 -2
- package/dist/transforms/calculator.js +1 -2
- package/dist/transforms/controlFlowFlattening.js +93 -63
- package/dist/transforms/deadCode.js +1 -2
- package/dist/transforms/dispatcher.js +4 -5
- package/dist/transforms/extraction/duplicateLiteralsRemoval.js +1 -2
- package/dist/transforms/extraction/objectExtraction.js +1 -2
- package/dist/transforms/finalizer.js +1 -2
- package/dist/transforms/flatten.js +1 -2
- package/dist/transforms/identifier/globalConcealing.js +15 -2
- package/dist/transforms/identifier/movedDeclarations.js +8 -7
- package/dist/transforms/identifier/renameVariables.js +7 -7
- package/dist/transforms/lock/integrity.js +11 -10
- package/dist/transforms/lock/lock.js +2 -3
- package/dist/transforms/minify.js +11 -29
- package/dist/transforms/opaquePredicates.js +1 -2
- package/dist/transforms/pack.js +5 -2
- package/dist/transforms/plugin.js +18 -19
- package/dist/transforms/preparation.js +16 -16
- package/dist/transforms/renameLabels.js +1 -2
- package/dist/transforms/rgf.js +8 -9
- package/dist/transforms/shuffle.js +1 -2
- package/dist/transforms/string/encoding.js +1 -2
- package/dist/transforms/string/stringCompression.js +3 -4
- package/dist/transforms/string/stringConcealing.js +8 -3
- package/dist/transforms/string/stringEncoding.js +1 -2
- package/dist/transforms/variableMasking.js +1 -2
- package/dist/utils/NameGen.js +2 -2
- package/dist/utils/PredicateGen.js +1 -2
- package/dist/utils/ast-utils.js +87 -88
- package/dist/utils/function-utils.js +8 -8
- package/dist/utils/node.js +5 -6
- package/dist/utils/object-utils.js +4 -4
- package/dist/utils/random-utils.js +20 -20
- package/dist/utils/static-utils.js +1 -2
- package/dist/validateOptions.js +4 -7
- package/index.d.ts +17 -17
- package/package.json +61 -59
- package/src/constants.ts +168 -168
- package/src/index.ts +118 -118
- package/src/obfuscationResult.ts +49 -49
- package/src/obfuscator.ts +501 -497
- package/src/options.ts +407 -407
- package/src/order.ts +54 -54
- package/src/presets.ts +125 -125
- package/src/templates/bufferToStringTemplate.ts +57 -57
- package/src/templates/deadCodeTemplates.ts +1185 -1185
- package/src/templates/getGlobalTemplate.ts +76 -76
- package/src/templates/integrityTemplate.ts +64 -64
- package/src/templates/setFunctionLengthTemplate.ts +11 -11
- package/src/templates/stringCompressionTemplate.ts +20 -20
- package/src/templates/tamperProtectionTemplates.ts +120 -120
- package/src/templates/template.ts +224 -224
- package/src/transforms/astScrambler.ts +99 -99
- package/src/transforms/calculator.ts +99 -99
- package/src/transforms/controlFlowFlattening.ts +1716 -1664
- package/src/transforms/deadCode.ts +82 -82
- package/src/transforms/dispatcher.ts +450 -450
- package/src/transforms/extraction/duplicateLiteralsRemoval.ts +156 -158
- package/src/transforms/extraction/objectExtraction.ts +186 -186
- package/src/transforms/finalizer.ts +74 -74
- package/src/transforms/flatten.ts +421 -420
- package/src/transforms/identifier/globalConcealing.ts +315 -295
- package/src/transforms/identifier/movedDeclarations.ts +252 -251
- package/src/transforms/identifier/renameVariables.ts +328 -321
- package/src/transforms/lock/integrity.ts +117 -114
- package/src/transforms/lock/lock.ts +418 -425
- package/src/transforms/minify.ts +615 -629
- package/src/transforms/opaquePredicates.ts +100 -100
- package/src/transforms/pack.ts +239 -231
- package/src/transforms/plugin.ts +173 -173
- package/src/transforms/preparation.ts +349 -347
- package/src/transforms/renameLabels.ts +175 -175
- package/src/transforms/rgf.ts +322 -322
- package/src/transforms/shuffle.ts +82 -82
- package/src/transforms/string/encoding.ts +144 -144
- package/src/transforms/string/stringCompression.ts +128 -128
- package/src/transforms/string/stringConcealing.ts +312 -298
- package/src/transforms/string/stringEncoding.ts +80 -80
- package/src/transforms/string/stringSplitting.ts +77 -77
- package/src/transforms/variableMasking.ts +257 -257
- package/src/utils/IntGen.ts +33 -33
- package/src/utils/NameGen.ts +116 -116
- package/src/utils/PredicateGen.ts +61 -61
- package/src/utils/ast-utils.ts +663 -663
- package/src/utils/function-utils.ts +50 -50
- package/src/utils/gen-utils.ts +48 -48
- package/src/utils/node.ts +78 -78
- package/src/utils/object-utils.ts +21 -21
- package/src/utils/random-utils.ts +93 -93
- package/src/utils/static-utils.ts +66 -66
- package/src/validateOptions.ts +256 -259
- package/tsconfig.json +13 -14
- package/dist/probability.js +0 -1
- package/dist/transforms/functionOutlining.js +0 -230
- package/dist/utils/ControlObject.js +0 -125
package/dist/utils/ast-utils.js
CHANGED
|
@@ -26,8 +26,7 @@ exports.replaceDefiningIdentifierToMemberExpression = replaceDefiningIdentifierT
|
|
|
26
26
|
var t = _interopRequireWildcard(require("@babel/types"));
|
|
27
27
|
var _assert = require("assert");
|
|
28
28
|
var _node = require("./node");
|
|
29
|
-
function
|
|
30
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
29
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
31
30
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
32
31
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
33
32
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
@@ -82,21 +81,21 @@ function getPatternIdentifierNames(path) {
|
|
|
82
81
|
return names;
|
|
83
82
|
}
|
|
84
83
|
|
|
85
|
-
/**
|
|
86
|
-
* Ensures a `String Literal` is 'computed' before replacing it with a more complex expression.
|
|
87
|
-
*
|
|
88
|
-
* ```js
|
|
89
|
-
* // Input
|
|
90
|
-
* {
|
|
91
|
-
* "myToBeEncodedString": "value"
|
|
92
|
-
* }
|
|
93
|
-
*
|
|
94
|
-
* // Output
|
|
95
|
-
* {
|
|
96
|
-
* ["myToBeEncodedString"]: "value"
|
|
97
|
-
* }
|
|
98
|
-
* ```
|
|
99
|
-
* @param path
|
|
84
|
+
/**
|
|
85
|
+
* Ensures a `String Literal` is 'computed' before replacing it with a more complex expression.
|
|
86
|
+
*
|
|
87
|
+
* ```js
|
|
88
|
+
* // Input
|
|
89
|
+
* {
|
|
90
|
+
* "myToBeEncodedString": "value"
|
|
91
|
+
* }
|
|
92
|
+
*
|
|
93
|
+
* // Output
|
|
94
|
+
* {
|
|
95
|
+
* ["myToBeEncodedString"]: "value"
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
* @param path
|
|
100
99
|
*/
|
|
101
100
|
function ensureComputedExpression(path) {
|
|
102
101
|
if ((t.isObjectMember(path.parent) || t.isClassMethod(path.parent) || t.isClassProperty(path.parent)) && path.parent.key === path.node && !path.parent.computed) {
|
|
@@ -104,16 +103,16 @@ function ensureComputedExpression(path) {
|
|
|
104
103
|
}
|
|
105
104
|
}
|
|
106
105
|
|
|
107
|
-
/**
|
|
108
|
-
* Retrieves a function name from debugging purposes.
|
|
109
|
-
* - Function Declaration / Expression
|
|
110
|
-
* - Variable Declaration
|
|
111
|
-
* - Object property / method
|
|
112
|
-
* - Class property / method
|
|
113
|
-
* - Program returns "[Program]"
|
|
114
|
-
* - Default returns "anonymous"
|
|
115
|
-
* @param path
|
|
116
|
-
* @returns
|
|
106
|
+
/**
|
|
107
|
+
* Retrieves a function name from debugging purposes.
|
|
108
|
+
* - Function Declaration / Expression
|
|
109
|
+
* - Variable Declaration
|
|
110
|
+
* - Object property / method
|
|
111
|
+
* - Class property / method
|
|
112
|
+
* - Program returns "[Program]"
|
|
113
|
+
* - Default returns "anonymous"
|
|
114
|
+
* @param path
|
|
115
|
+
* @returns
|
|
117
116
|
*/
|
|
118
117
|
function getFunctionName(path) {
|
|
119
118
|
var _path$parentPath, _path$parentPath2, _path$parentPath3;
|
|
@@ -192,11 +191,11 @@ function getObjectPropertyAsString(property) {
|
|
|
192
191
|
return null;
|
|
193
192
|
}
|
|
194
193
|
|
|
195
|
-
/**
|
|
196
|
-
* Gets the property of a MemberExpression as a string.
|
|
197
|
-
*
|
|
198
|
-
* @param memberPath - The path of the MemberExpression node.
|
|
199
|
-
* @returns The property as a string or null if it cannot be determined.
|
|
194
|
+
/**
|
|
195
|
+
* Gets the property of a MemberExpression as a string.
|
|
196
|
+
*
|
|
197
|
+
* @param memberPath - The path of the MemberExpression node.
|
|
198
|
+
* @returns The property as a string or null if it cannot be determined.
|
|
200
199
|
*/
|
|
201
200
|
function getMemberExpressionPropertyAsString(member) {
|
|
202
201
|
t.assertMemberExpression(member);
|
|
@@ -223,8 +222,8 @@ function nodeListToNodes(nodesIn) {
|
|
|
223
222
|
return nodes;
|
|
224
223
|
}
|
|
225
224
|
|
|
226
|
-
/**
|
|
227
|
-
* Appends to the bottom of a block. Preserving last expression for the top level.
|
|
225
|
+
/**
|
|
226
|
+
* Appends to the bottom of a block. Preserving last expression for the top level.
|
|
228
227
|
*/
|
|
229
228
|
function append(path) {
|
|
230
229
|
for (var _len = arguments.length, nodesIn = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
@@ -260,15 +259,15 @@ function append(path) {
|
|
|
260
259
|
return listParent.pushContainer("body", nodes);
|
|
261
260
|
}
|
|
262
261
|
|
|
263
|
-
/**
|
|
264
|
-
* Prepends and registers a list of nodes to the beginning of a block.
|
|
265
|
-
*
|
|
266
|
-
* - Preserves import declarations by inserting after the last import declaration.
|
|
267
|
-
* - Handles arrow functions
|
|
268
|
-
* - Handles switch cases
|
|
269
|
-
* @param path
|
|
270
|
-
* @param nodes
|
|
271
|
-
* @returns
|
|
262
|
+
/**
|
|
263
|
+
* Prepends and registers a list of nodes to the beginning of a block.
|
|
264
|
+
*
|
|
265
|
+
* - Preserves import declarations by inserting after the last import declaration.
|
|
266
|
+
* - Handles arrow functions
|
|
267
|
+
* - Handles switch cases
|
|
268
|
+
* @param path
|
|
269
|
+
* @param nodes
|
|
270
|
+
* @returns
|
|
272
271
|
*/
|
|
273
272
|
function prepend(path) {
|
|
274
273
|
for (var _len2 = arguments.length, nodesIn = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
@@ -339,13 +338,13 @@ function prependProgram(path) {
|
|
|
339
338
|
return prepend.apply(void 0, [program].concat(nodes));
|
|
340
339
|
}
|
|
341
340
|
|
|
342
|
-
/**
|
|
343
|
-
* A referenced or binding identifier, only names that reflect variables.
|
|
344
|
-
*
|
|
345
|
-
* - Excludes labels
|
|
346
|
-
*
|
|
347
|
-
* @param path
|
|
348
|
-
* @returns
|
|
341
|
+
/**
|
|
342
|
+
* A referenced or binding identifier, only names that reflect variables.
|
|
343
|
+
*
|
|
344
|
+
* - Excludes labels
|
|
345
|
+
*
|
|
346
|
+
* @param path
|
|
347
|
+
* @returns
|
|
349
348
|
*/
|
|
350
349
|
function isVariableIdentifier(path) {
|
|
351
350
|
var _path$parentPath4;
|
|
@@ -356,19 +355,19 @@ function isVariableIdentifier(path) {
|
|
|
356
355
|
return true;
|
|
357
356
|
}
|
|
358
357
|
|
|
359
|
-
/**
|
|
360
|
-
* Subset of BindingIdentifier, excluding non-defined assignment expressions.
|
|
361
|
-
*
|
|
362
|
-
* @example
|
|
363
|
-
* var a = 1; // true
|
|
364
|
-
* var {c} = {} // true
|
|
365
|
-
* function b() {} // true
|
|
366
|
-
* function d([e] = [], ...f) {} // true
|
|
367
|
-
*
|
|
368
|
-
* f = 0; // false
|
|
369
|
-
* f(); // false
|
|
370
|
-
* @param path
|
|
371
|
-
* @returns
|
|
358
|
+
/**
|
|
359
|
+
* Subset of BindingIdentifier, excluding non-defined assignment expressions.
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* var a = 1; // true
|
|
363
|
+
* var {c} = {} // true
|
|
364
|
+
* function b() {} // true
|
|
365
|
+
* function d([e] = [], ...f) {} // true
|
|
366
|
+
*
|
|
367
|
+
* f = 0; // false
|
|
368
|
+
* f(); // false
|
|
369
|
+
* @param path
|
|
370
|
+
* @returns
|
|
372
371
|
*/
|
|
373
372
|
function isDefiningIdentifier(path) {
|
|
374
373
|
if (path.key === "id" && path.parentPath.isFunction()) return true;
|
|
@@ -404,13 +403,13 @@ function isDefiningIdentifier(path) {
|
|
|
404
403
|
return true;
|
|
405
404
|
}
|
|
406
405
|
|
|
407
|
-
/**
|
|
408
|
-
* @example
|
|
409
|
-
* function id() {} // true
|
|
410
|
-
* class id {} // true
|
|
411
|
-
* var id; // false
|
|
412
|
-
* @param path
|
|
413
|
-
* @returns
|
|
406
|
+
/**
|
|
407
|
+
* @example
|
|
408
|
+
* function id() {} // true
|
|
409
|
+
* class id {} // true
|
|
410
|
+
* var id; // false
|
|
411
|
+
* @param path
|
|
412
|
+
* @returns
|
|
414
413
|
*/
|
|
415
414
|
function isStrictIdentifier(path) {
|
|
416
415
|
if (path.key === "id" && (path.parentPath.isFunction() || path.parentPath.isClass())) return true;
|
|
@@ -444,13 +443,13 @@ function isExportedIdentifier(path) {
|
|
|
444
443
|
return false;
|
|
445
444
|
}
|
|
446
445
|
|
|
447
|
-
/**
|
|
448
|
-
* @example
|
|
449
|
-
* function abc() {
|
|
450
|
-
* "use strict";
|
|
451
|
-
* } // true
|
|
452
|
-
* @param path
|
|
453
|
-
* @returns
|
|
446
|
+
/**
|
|
447
|
+
* @example
|
|
448
|
+
* function abc() {
|
|
449
|
+
* "use strict";
|
|
450
|
+
* } // true
|
|
451
|
+
* @param path
|
|
452
|
+
* @returns
|
|
454
453
|
*/
|
|
455
454
|
function isStrictMode(path) {
|
|
456
455
|
// Classes are always in strict mode
|
|
@@ -470,13 +469,13 @@ function isStrictMode(path) {
|
|
|
470
469
|
return false;
|
|
471
470
|
}
|
|
472
471
|
|
|
473
|
-
/**
|
|
474
|
-
* A modified identifier is an identifier that is assigned to or updated.
|
|
475
|
-
*
|
|
476
|
-
* - Assignment Expression
|
|
477
|
-
* - Update Expression
|
|
478
|
-
*
|
|
479
|
-
* @param identifierPath
|
|
472
|
+
/**
|
|
473
|
+
* A modified identifier is an identifier that is assigned to or updated.
|
|
474
|
+
*
|
|
475
|
+
* - Assignment Expression
|
|
476
|
+
* - Update Expression
|
|
477
|
+
*
|
|
478
|
+
* @param identifierPath
|
|
480
479
|
*/
|
|
481
480
|
function isModifiedIdentifier(identifierPath) {
|
|
482
481
|
var isModification = false;
|
|
@@ -541,10 +540,10 @@ function replaceDefiningIdentifierToMemberExpression(path, memberExpression) {
|
|
|
541
540
|
// path.replaceWith(memberExpression);
|
|
542
541
|
}
|
|
543
542
|
|
|
544
|
-
/**
|
|
545
|
-
* @example
|
|
546
|
-
* undefined // true
|
|
547
|
-
* void 0 // true
|
|
543
|
+
/**
|
|
544
|
+
* @example
|
|
545
|
+
* undefined // true
|
|
546
|
+
* void 0 // true
|
|
548
547
|
*/
|
|
549
548
|
function isUndefined(path) {
|
|
550
549
|
if (path.isIdentifier() && path.node.name === "undefined") {
|
|
@@ -9,10 +9,10 @@ var _constants = require("../constants");
|
|
|
9
9
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
10
10
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
11
11
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
12
|
-
/**
|
|
13
|
-
* @example __JS_CONFUSER_VAR__(identifier) // true
|
|
14
|
-
* @param path
|
|
15
|
-
* @returns
|
|
12
|
+
/**
|
|
13
|
+
* @example __JS_CONFUSER_VAR__(identifier) // true
|
|
14
|
+
* @param path
|
|
15
|
+
* @returns
|
|
16
16
|
*/
|
|
17
17
|
function isVariableFunctionIdentifier(path) {
|
|
18
18
|
var _path$parentPath;
|
|
@@ -25,10 +25,10 @@ function isVariableFunctionIdentifier(path) {
|
|
|
25
25
|
return false;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
/**
|
|
29
|
-
* Computes the `function.length` property given the parameter nodes.
|
|
30
|
-
*
|
|
31
|
-
* @example function abc(a, b, c = 1, ...d) {} // abc.length = 2
|
|
28
|
+
/**
|
|
29
|
+
* Computes the `function.length` property given the parameter nodes.
|
|
30
|
+
*
|
|
31
|
+
* @example function abc(a, b, c = 1, ...d) {} // abc.length = 2
|
|
32
32
|
*/
|
|
33
33
|
function computeFunctionLength(fnPath) {
|
|
34
34
|
var savedLength = fnPath.node[_constants.FN_LENGTH];
|
package/dist/utils/node.js
CHANGED
|
@@ -8,8 +8,7 @@ exports.deepClone = deepClone;
|
|
|
8
8
|
exports.numericLiteral = numericLiteral;
|
|
9
9
|
var t = _interopRequireWildcard(require("@babel/types"));
|
|
10
10
|
var _assert = require("assert");
|
|
11
|
-
function
|
|
12
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
13
12
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
14
13
|
var createLiteral = exports.createLiteral = function createLiteral(value) {
|
|
15
14
|
if (value === null) return t.nullLiteral();
|
|
@@ -25,10 +24,10 @@ var createLiteral = exports.createLiteral = function createLiteral(value) {
|
|
|
25
24
|
(0, _assert.ok)(false);
|
|
26
25
|
};
|
|
27
26
|
|
|
28
|
-
/**
|
|
29
|
-
* Handles both positive and negative numeric literals
|
|
30
|
-
* @param value
|
|
31
|
-
* @returns
|
|
27
|
+
/**
|
|
28
|
+
* Handles both positive and negative numeric literals
|
|
29
|
+
* @param value
|
|
30
|
+
* @returns
|
|
32
31
|
*/
|
|
33
32
|
function numericLiteral(value) {
|
|
34
33
|
(0, _assert.ok)(typeof value === "number");
|
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createObject = createObject;
|
|
7
|
-
/**
|
|
8
|
-
* Creates an object from the given keys and values arrays.
|
|
9
|
-
* @param keys
|
|
10
|
-
* @param values
|
|
7
|
+
/**
|
|
8
|
+
* Creates an object from the given keys and values arrays.
|
|
9
|
+
* @param keys
|
|
10
|
+
* @param values
|
|
11
11
|
*/
|
|
12
12
|
function createObject(keys, values) {
|
|
13
13
|
if (keys.length !== values.length) {
|
|
@@ -19,27 +19,27 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
19
19
|
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
20
20
|
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
21
21
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
22
|
-
/**
|
|
23
|
-
* Returns a random element from the given array
|
|
24
|
-
* @param choices Array of items
|
|
25
|
-
* @returns One of the items in the array at random
|
|
22
|
+
/**
|
|
23
|
+
* Returns a random element from the given array
|
|
24
|
+
* @param choices Array of items
|
|
25
|
+
* @returns One of the items in the array at random
|
|
26
26
|
*/
|
|
27
27
|
function choice(choices) {
|
|
28
28
|
var index = Math.floor(Math.random() * choices.length);
|
|
29
29
|
return choices[index];
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
/**
|
|
33
|
-
* Returns a true/false based on the percent chance (0%-100%)
|
|
34
|
-
* @param percentChance AS A PERCENTAGE 0 - 100%
|
|
32
|
+
/**
|
|
33
|
+
* Returns a true/false based on the percent chance (0%-100%)
|
|
34
|
+
* @param percentChance AS A PERCENTAGE 0 - 100%
|
|
35
35
|
*/
|
|
36
36
|
function chance(percentChance) {
|
|
37
37
|
return Math.random() < percentChance / 100;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
/**
|
|
41
|
-
* **Mutates the given array**
|
|
42
|
-
* @param array
|
|
40
|
+
/**
|
|
41
|
+
* **Mutates the given array**
|
|
42
|
+
* @param array
|
|
43
43
|
*/
|
|
44
44
|
function shuffle(array) {
|
|
45
45
|
array.sort(function () {
|
|
@@ -48,12 +48,12 @@ function shuffle(array) {
|
|
|
48
48
|
return array;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
/**
|
|
52
|
-
* Returns a random hexadecimal string.
|
|
53
|
-
*
|
|
54
|
-
* @example getRandomHexString(6) => "CA96BF"
|
|
55
|
-
* @param length
|
|
56
|
-
* @returns
|
|
51
|
+
/**
|
|
52
|
+
* Returns a random hexadecimal string.
|
|
53
|
+
*
|
|
54
|
+
* @example getRandomHexString(6) => "CA96BF"
|
|
55
|
+
* @param length
|
|
56
|
+
* @returns
|
|
57
57
|
*/
|
|
58
58
|
function getRandomHexString(length) {
|
|
59
59
|
return _toConsumableArray(Array(length)).map(function () {
|
|
@@ -61,8 +61,8 @@ function getRandomHexString(length) {
|
|
|
61
61
|
}).join("").toUpperCase();
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
/**
|
|
65
|
-
* @see https://github.com/MichaelXF/js-confuser/issues/150#issuecomment-2466159582
|
|
64
|
+
/**
|
|
65
|
+
* @see https://github.com/MichaelXF/js-confuser/issues/150#issuecomment-2466159582
|
|
66
66
|
*/
|
|
67
67
|
function getRandomChineseString(length) {
|
|
68
68
|
var characters = [];
|
|
@@ -70,8 +70,8 @@ function getRandomChineseString(length) {
|
|
|
70
70
|
return characters.join("");
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
/**
|
|
74
|
-
* Returns a random string.
|
|
73
|
+
/**
|
|
74
|
+
* Returns a random string.
|
|
75
75
|
*/
|
|
76
76
|
function getRandomString(length) {
|
|
77
77
|
var result = "";
|
|
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.isStaticValue = isStaticValue;
|
|
8
8
|
var t = _interopRequireWildcard(require("@babel/types"));
|
|
9
|
-
function
|
|
10
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
9
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
11
10
|
// Function to check if a node is a static value
|
|
12
11
|
function isStaticValue(node) {
|
|
13
12
|
// Check for literals which are considered static
|
package/dist/validateOptions.js
CHANGED
|
@@ -13,8 +13,8 @@ var validProperties = new Set(["preset", "target", "compact", "hexadecimalNumber
|
|
|
13
13
|
var validLockProperties = new Set(["selfDefending", "antiDebug", "tamperProtection", "startDate", "endDate", "domainLock", "integrity", "countermeasures", "customLocks"]);
|
|
14
14
|
function validateOptions(options) {
|
|
15
15
|
if (!options || Object.keys(options).length <= 1) {
|
|
16
|
-
/**
|
|
17
|
-
* Give a welcoming introduction to those who skipped the documentation.
|
|
16
|
+
/**
|
|
17
|
+
* Give a welcoming introduction to those who skipped the documentation.
|
|
18
18
|
*/
|
|
19
19
|
var line = "You provided zero obfuscation options. By default everything is disabled.\nYou can use a preset with:\n\n> {target: '".concat(options.target || "node", "', preset: 'high' | 'medium' | 'low'}.\n\n\nView all settings here:\nhttps://github.com/MichaelXF/js-confuser#options");
|
|
20
20
|
throw new Error("\n\n" + line.split("\n").map(function (x) {
|
|
@@ -59,8 +59,8 @@ function validateOptions(options) {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
/**
|
|
63
|
-
* Sets the default values and validates the configuration.
|
|
62
|
+
/**
|
|
63
|
+
* Sets the default values and validates the configuration.
|
|
64
64
|
*/
|
|
65
65
|
function applyDefaultsToOptions(options) {
|
|
66
66
|
if (options.preset) {
|
|
@@ -73,9 +73,6 @@ function applyDefaultsToOptions(options) {
|
|
|
73
73
|
if (!options.hasOwnProperty("renameGlobals")) {
|
|
74
74
|
options.renameGlobals = true; // RenameGlobals is on by default
|
|
75
75
|
}
|
|
76
|
-
if (!options.hasOwnProperty("preserveFunctionLength")) {
|
|
77
|
-
options.preserveFunctionLength = true; // preserveFunctionLength is on by default
|
|
78
|
-
}
|
|
79
76
|
if (!options.hasOwnProperty("renameLabels")) {
|
|
80
77
|
options.renameLabels = true; // RenameLabels is on by default
|
|
81
78
|
}
|
package/index.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
// Export all the types from the index file
|
|
2
|
-
export * from "./src/index";
|
|
3
|
-
export { default } from "./src/index";
|
|
4
|
-
|
|
5
|
-
// Export useful types
|
|
6
|
-
export type {
|
|
7
|
-
ObfuscateOptions,
|
|
8
|
-
ProbabilityMap,
|
|
9
|
-
CustomLock,
|
|
10
|
-
CustomStringEncoding,
|
|
11
|
-
} from "./src/options";
|
|
12
|
-
export type {
|
|
13
|
-
ObfuscationResult,
|
|
14
|
-
ProfileData,
|
|
15
|
-
ProfilerCallback,
|
|
16
|
-
ProfilerLog,
|
|
17
|
-
} from "./src/obfuscationResult";
|
|
1
|
+
// Export all the types from the index file
|
|
2
|
+
export * from "./src/index";
|
|
3
|
+
export { default } from "./src/index";
|
|
4
|
+
|
|
5
|
+
// Export useful types
|
|
6
|
+
export type {
|
|
7
|
+
ObfuscateOptions,
|
|
8
|
+
ProbabilityMap,
|
|
9
|
+
CustomLock,
|
|
10
|
+
CustomStringEncoding,
|
|
11
|
+
} from "./src/options";
|
|
12
|
+
export type {
|
|
13
|
+
ObfuscationResult,
|
|
14
|
+
ProfileData,
|
|
15
|
+
ProfilerCallback,
|
|
16
|
+
ProfilerLog,
|
|
17
|
+
} from "./src/obfuscationResult";
|
package/package.json
CHANGED
|
@@ -1,59 +1,61 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "js-confuser",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "JavaScript Obfuscation Tool.",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"build": "tsc && babel src --out-dir dist --extensions \".ts,.tsx\"",
|
|
9
|
-
"dev": "node babel.register.js",
|
|
10
|
-
"test": "jest
|
|
11
|
-
"test:coverage": "jest --coverage --coverageReporters=html",
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
"@babel/
|
|
27
|
-
"@babel/
|
|
28
|
-
"@babel/
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"@babel/
|
|
34
|
-
"@babel/plugin-proposal-
|
|
35
|
-
"@babel/plugin-proposal-
|
|
36
|
-
"@babel/
|
|
37
|
-
"@babel/preset-
|
|
38
|
-
"@babel/
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"@types/
|
|
42
|
-
"@types/
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "js-confuser",
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "JavaScript Obfuscation Tool.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc --noEmit && babel src --out-dir dist --extensions \".ts,.tsx\"",
|
|
9
|
+
"dev": "node babel.register.js",
|
|
10
|
+
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
|
|
11
|
+
"test:coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage --coverageReporters=html",
|
|
12
|
+
"typecheck": "tsc --noEmit",
|
|
13
|
+
"prepublishOnly": "npm run typecheck && npm run test && npm run build"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"obfuscator",
|
|
17
|
+
"obfuscation",
|
|
18
|
+
"uglify",
|
|
19
|
+
"code protection",
|
|
20
|
+
"javascript obfuscator",
|
|
21
|
+
"js obfuscator"
|
|
22
|
+
],
|
|
23
|
+
"author": "MichaelXF",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@babel/generator": "^7.28.0",
|
|
27
|
+
"@babel/parser": "^7.28.0",
|
|
28
|
+
"@babel/traverse": "^7.28.0",
|
|
29
|
+
"@babel/types": "^7.28.2",
|
|
30
|
+
"lz-string": "^1.5.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@babel/cli": "^7.24.8",
|
|
34
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
35
|
+
"@babel/plugin-proposal-decorators": "^7.24.7",
|
|
36
|
+
"@babel/plugin-proposal-private-methods": "^7.18.6",
|
|
37
|
+
"@babel/preset-env": "^7.25.3",
|
|
38
|
+
"@babel/preset-typescript": "^7.24.7",
|
|
39
|
+
"@babel/register": "^7.24.6",
|
|
40
|
+
"@eslint/js": "^9.9.0",
|
|
41
|
+
"@types/babel__core": "^7.20.5",
|
|
42
|
+
"@types/jest": "^29.5.12",
|
|
43
|
+
"@types/node": "^22.2.0",
|
|
44
|
+
"cross-env": "^10.1.0",
|
|
45
|
+
"globals": "^15.9.0",
|
|
46
|
+
"jest": "^29.7.0",
|
|
47
|
+
"typescript": "^5.5.4",
|
|
48
|
+
"typescript-eslint": "^8.1.0"
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "https://github.com/MichaelXF/js-confuser"
|
|
53
|
+
},
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "https://github.com/MichaelXF/js-confuser/issues"
|
|
56
|
+
},
|
|
57
|
+
"homepage": "https://js-confuser.com",
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=18.0.0"
|
|
60
|
+
}
|
|
61
|
+
}
|