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