@dacely/toildefender 0.1.0 → 0.1.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/LICENSE +661 -661
- package/NOTICE.md +16 -16
- package/README.md +380 -380
- package/cli.js +168 -168
- package/defendjs.js +6 -6
- package/docs/all-modes-output.demo.js +673 -673
- package/estest.js +49 -49
- package/esutils.js +107 -107
- package/logger.js +28 -28
- package/obfuscator.js +534 -534
- package/package.json +108 -108
- package/processors/deadCode.js +62 -62
- package/processors/flattener.js +808 -808
- package/processors/health.js +55 -55
- package/processors/identifiers.js +256 -256
- package/processors/literalObfuscator.js +40 -40
- package/processors/literals.js +233 -233
- package/processors/methods.js +332 -332
- package/processors/modules.js +231 -231
- package/processors/normalizer.js +490 -490
- package/processors/numericVm.js +950 -950
- package/processors/postprocessing.js +69 -69
- package/processors/preprocessing.js +248 -248
- package/processors/scopes.js +177 -177
- package/processors/uglifier.js +25 -25
- package/processors/variables.js +185 -185
- package/toildefender.js +7 -7
- package/traverser.js +115 -115
- package/utils.js +135 -135
package/package.json
CHANGED
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@dacely/toildefender",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Modern JavaScript code protection, bytecode virtualization, and obfuscation for the Toil tech stack.",
|
|
5
|
-
"author": "Dacely",
|
|
6
|
-
"contributors": [
|
|
7
|
-
{
|
|
8
|
-
"name": "Alexander Horn",
|
|
9
|
-
"url": "https://github.com/alexhorn"
|
|
10
|
-
}
|
|
11
|
-
],
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/dacely-cloud/toildefender.git"
|
|
15
|
-
},
|
|
16
|
-
"bugs": {
|
|
17
|
-
"url": "https://github.com/dacely-cloud/toildefender/issues"
|
|
18
|
-
},
|
|
19
|
-
"homepage": "https://github.com/dacely-cloud/toildefender#readme",
|
|
20
|
-
"keywords": [
|
|
21
|
-
"javascript",
|
|
22
|
-
"obfuscation",
|
|
23
|
-
"bytecode",
|
|
24
|
-
"virtual-machine",
|
|
25
|
-
"code-protection",
|
|
26
|
-
"toiljs",
|
|
27
|
-
"dacely"
|
|
28
|
-
],
|
|
29
|
-
"main": "toildefender.js",
|
|
30
|
-
"exports": {
|
|
31
|
-
".": "./toildefender.js"
|
|
32
|
-
},
|
|
33
|
-
"bin": {
|
|
34
|
-
"toildefender": "toildefender.js"
|
|
35
|
-
},
|
|
36
|
-
"scripts": {
|
|
37
|
-
"test": "node --test test/*.test.js",
|
|
38
|
-
"test:firefox": "node test/firefox-smoke.mjs",
|
|
39
|
-
"pack:dry": "npm pack --dry-run"
|
|
40
|
-
},
|
|
41
|
-
"toildefender": {
|
|
42
|
-
"mainFiles": [
|
|
43
|
-
"toildefender.js"
|
|
44
|
-
]
|
|
45
|
-
},
|
|
46
|
-
"files": [
|
|
47
|
-
"cli.js",
|
|
48
|
-
"defendjs.js",
|
|
49
|
-
"estest.js",
|
|
50
|
-
"esutils.js",
|
|
51
|
-
"logger.js",
|
|
52
|
-
"obfuscator.js",
|
|
53
|
-
"processors",
|
|
54
|
-
"toildefender.js",
|
|
55
|
-
"traverser.js",
|
|
56
|
-
"utils.js",
|
|
57
|
-
"LICENSE",
|
|
58
|
-
"NOTICE.md",
|
|
59
|
-
"README.md",
|
|
60
|
-
"images/toildefender-logo.svg",
|
|
61
|
-
"docs/all-modes-output.demo.js"
|
|
62
|
-
],
|
|
63
|
-
"dependencies": {
|
|
64
|
-
"@babel/core": "^8.0.1",
|
|
65
|
-
"@babel/preset-env": "^8.0.2",
|
|
66
|
-
"babel-core": "6.10.4",
|
|
67
|
-
"babel-plugin-check-es2015-constants": "^6.3.13",
|
|
68
|
-
"babel-plugin-transform-es2015-arrow-functions": "^6.3.13",
|
|
69
|
-
"babel-plugin-transform-es2015-block-scoped-functions": "^6.3.13",
|
|
70
|
-
"babel-plugin-transform-es2015-block-scoping": "^6.9.0",
|
|
71
|
-
"babel-plugin-transform-es2015-classes": "^6.9.0",
|
|
72
|
-
"babel-plugin-transform-es2015-computed-properties": "^6.3.13",
|
|
73
|
-
"babel-plugin-transform-es2015-destructuring": "^6.9.0",
|
|
74
|
-
"babel-plugin-transform-es2015-duplicate-keys": "^6.6.0",
|
|
75
|
-
"babel-plugin-transform-es2015-for-of": "^6.6.0",
|
|
76
|
-
"babel-plugin-transform-es2015-function-name": "^6.9.0",
|
|
77
|
-
"babel-plugin-transform-es2015-literals": "^6.3.13",
|
|
78
|
-
"babel-plugin-transform-es2015-modules-commonjs": "^6.6.0",
|
|
79
|
-
"babel-plugin-transform-es2015-object-super": "^6.3.13",
|
|
80
|
-
"babel-plugin-transform-es2015-parameters": "^6.9.0",
|
|
81
|
-
"babel-plugin-transform-es2015-shorthand-properties": "^6.3.13",
|
|
82
|
-
"babel-plugin-transform-es2015-spread": "^6.3.13",
|
|
83
|
-
"babel-plugin-transform-es2015-sticky-regex": "^6.3.13",
|
|
84
|
-
"babel-plugin-transform-es2015-template-literals": "^6.6.0",
|
|
85
|
-
"babel-plugin-transform-es2015-typeof-symbol": "^6.6.0",
|
|
86
|
-
"babel-plugin-transform-es2015-unicode-regex": "^6.3.13",
|
|
87
|
-
"babel-plugin-transform-regenerator": "^6.9.0",
|
|
88
|
-
"escodegen": "^2.1.0",
|
|
89
|
-
"escope": "3.6.0",
|
|
90
|
-
"esprima": "^4.0.1",
|
|
91
|
-
"esshorten": "1.1.1",
|
|
92
|
-
"estraverse": "4.2.0",
|
|
93
|
-
"expr-eval": "1.0.0",
|
|
94
|
-
"lodash": "4.13.1",
|
|
95
|
-
"minimist": "1.2.0"
|
|
96
|
-
},
|
|
97
|
-
"engines": {
|
|
98
|
-
"node": ">=24.0.0",
|
|
99
|
-
"npm": ">=10.0.0"
|
|
100
|
-
},
|
|
101
|
-
"publishConfig": {
|
|
102
|
-
"access": "public"
|
|
103
|
-
},
|
|
104
|
-
"license": "AGPL-3.0",
|
|
105
|
-
"devDependencies": {
|
|
106
|
-
"playwright": "^1.61.0"
|
|
107
|
-
}
|
|
108
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@dacely/toildefender",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Modern JavaScript code protection, bytecode virtualization, and obfuscation for the Toil tech stack.",
|
|
5
|
+
"author": "Dacely",
|
|
6
|
+
"contributors": [
|
|
7
|
+
{
|
|
8
|
+
"name": "Alexander Horn",
|
|
9
|
+
"url": "https://github.com/alexhorn"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/dacely-cloud/toildefender.git"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/dacely-cloud/toildefender/issues"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/dacely-cloud/toildefender#readme",
|
|
20
|
+
"keywords": [
|
|
21
|
+
"javascript",
|
|
22
|
+
"obfuscation",
|
|
23
|
+
"bytecode",
|
|
24
|
+
"virtual-machine",
|
|
25
|
+
"code-protection",
|
|
26
|
+
"toiljs",
|
|
27
|
+
"dacely"
|
|
28
|
+
],
|
|
29
|
+
"main": "toildefender.js",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": "./toildefender.js"
|
|
32
|
+
},
|
|
33
|
+
"bin": {
|
|
34
|
+
"toildefender": "toildefender.js"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"test": "node --test test/*.test.js",
|
|
38
|
+
"test:firefox": "node test/firefox-smoke.mjs",
|
|
39
|
+
"pack:dry": "npm pack --dry-run"
|
|
40
|
+
},
|
|
41
|
+
"toildefender": {
|
|
42
|
+
"mainFiles": [
|
|
43
|
+
"toildefender.js"
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"cli.js",
|
|
48
|
+
"defendjs.js",
|
|
49
|
+
"estest.js",
|
|
50
|
+
"esutils.js",
|
|
51
|
+
"logger.js",
|
|
52
|
+
"obfuscator.js",
|
|
53
|
+
"processors",
|
|
54
|
+
"toildefender.js",
|
|
55
|
+
"traverser.js",
|
|
56
|
+
"utils.js",
|
|
57
|
+
"LICENSE",
|
|
58
|
+
"NOTICE.md",
|
|
59
|
+
"README.md",
|
|
60
|
+
"images/toildefender-logo.svg",
|
|
61
|
+
"docs/all-modes-output.demo.js"
|
|
62
|
+
],
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@babel/core": "^8.0.1",
|
|
65
|
+
"@babel/preset-env": "^8.0.2",
|
|
66
|
+
"babel-core": "6.10.4",
|
|
67
|
+
"babel-plugin-check-es2015-constants": "^6.3.13",
|
|
68
|
+
"babel-plugin-transform-es2015-arrow-functions": "^6.3.13",
|
|
69
|
+
"babel-plugin-transform-es2015-block-scoped-functions": "^6.3.13",
|
|
70
|
+
"babel-plugin-transform-es2015-block-scoping": "^6.9.0",
|
|
71
|
+
"babel-plugin-transform-es2015-classes": "^6.9.0",
|
|
72
|
+
"babel-plugin-transform-es2015-computed-properties": "^6.3.13",
|
|
73
|
+
"babel-plugin-transform-es2015-destructuring": "^6.9.0",
|
|
74
|
+
"babel-plugin-transform-es2015-duplicate-keys": "^6.6.0",
|
|
75
|
+
"babel-plugin-transform-es2015-for-of": "^6.6.0",
|
|
76
|
+
"babel-plugin-transform-es2015-function-name": "^6.9.0",
|
|
77
|
+
"babel-plugin-transform-es2015-literals": "^6.3.13",
|
|
78
|
+
"babel-plugin-transform-es2015-modules-commonjs": "^6.6.0",
|
|
79
|
+
"babel-plugin-transform-es2015-object-super": "^6.3.13",
|
|
80
|
+
"babel-plugin-transform-es2015-parameters": "^6.9.0",
|
|
81
|
+
"babel-plugin-transform-es2015-shorthand-properties": "^6.3.13",
|
|
82
|
+
"babel-plugin-transform-es2015-spread": "^6.3.13",
|
|
83
|
+
"babel-plugin-transform-es2015-sticky-regex": "^6.3.13",
|
|
84
|
+
"babel-plugin-transform-es2015-template-literals": "^6.6.0",
|
|
85
|
+
"babel-plugin-transform-es2015-typeof-symbol": "^6.6.0",
|
|
86
|
+
"babel-plugin-transform-es2015-unicode-regex": "^6.3.13",
|
|
87
|
+
"babel-plugin-transform-regenerator": "^6.9.0",
|
|
88
|
+
"escodegen": "^2.1.0",
|
|
89
|
+
"escope": "3.6.0",
|
|
90
|
+
"esprima": "^4.0.1",
|
|
91
|
+
"esshorten": "1.1.1",
|
|
92
|
+
"estraverse": "4.2.0",
|
|
93
|
+
"expr-eval": "1.0.0",
|
|
94
|
+
"lodash": "4.13.1",
|
|
95
|
+
"minimist": "1.2.0"
|
|
96
|
+
},
|
|
97
|
+
"engines": {
|
|
98
|
+
"node": ">=24.0.0",
|
|
99
|
+
"npm": ">=10.0.0"
|
|
100
|
+
},
|
|
101
|
+
"publishConfig": {
|
|
102
|
+
"access": "public"
|
|
103
|
+
},
|
|
104
|
+
"license": "AGPL-3.0",
|
|
105
|
+
"devDependencies": {
|
|
106
|
+
"playwright": "^1.61.0"
|
|
107
|
+
}
|
|
108
|
+
}
|
package/processors/deadCode.js
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var assert = require("assert");
|
|
4
|
-
|
|
5
|
-
var _ = require("lodash");
|
|
6
|
-
var estest = require("../estest");
|
|
7
|
-
var traverser = require("../traverser");
|
|
8
|
-
var utils = require("../utils");
|
|
9
|
-
|
|
10
|
-
const KEYWORDS = ["await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","finally","for","function","if","implements","import","in","instanceof","interface","let","new","package","private","protected","public","return","static","super","switch","this","throw","try","typeof","var","void","while","with","yield"];
|
|
11
|
-
|
|
12
|
-
module.exports = class DeadCode {
|
|
13
|
-
|
|
14
|
-
constructor (logger) {
|
|
15
|
-
this.logger = logger;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Insert dead code
|
|
20
|
-
* @param {Node} ast
|
|
21
|
-
* @returns {Node}
|
|
22
|
-
*/
|
|
23
|
-
insert (ast, probability) {
|
|
24
|
-
assert.ok(estest.isNode(ast));
|
|
25
|
-
|
|
26
|
-
var rngAlpha = new utils.UniqueRandomAlpha(3);
|
|
27
|
-
|
|
28
|
-
return traverser.traverse(ast, [], (node, stack) => {
|
|
29
|
-
if (node.type == "BlockStatement") {
|
|
30
|
-
for (var i = 0; i < probability; ++i) {
|
|
31
|
-
if (probability - i < Math.random()) {
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
var pos = utils.random(0, node.body.length - 1);
|
|
36
|
-
var len = utils.random(1, node.body.length - pos);
|
|
37
|
-
|
|
38
|
-
var varValue = _.sample(KEYWORDS);
|
|
39
|
-
|
|
40
|
-
var spliced = node.body.splice(pos, len);
|
|
41
|
-
node.body.splice(pos, 0,
|
|
42
|
-
{
|
|
43
|
-
type: "IfStatement",
|
|
44
|
-
test: {
|
|
45
|
-
type: "BinaryExpression",
|
|
46
|
-
operator: "==",
|
|
47
|
-
left: { type: "Literal", value: varValue },
|
|
48
|
-
right: { type: "Literal", value: varValue }
|
|
49
|
-
},
|
|
50
|
-
consequent: {
|
|
51
|
-
type: "BlockStatement",
|
|
52
|
-
body: spliced
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return node;
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var assert = require("assert");
|
|
4
|
+
|
|
5
|
+
var _ = require("lodash");
|
|
6
|
+
var estest = require("../estest");
|
|
7
|
+
var traverser = require("../traverser");
|
|
8
|
+
var utils = require("../utils");
|
|
9
|
+
|
|
10
|
+
const KEYWORDS = ["await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","finally","for","function","if","implements","import","in","instanceof","interface","let","new","package","private","protected","public","return","static","super","switch","this","throw","try","typeof","var","void","while","with","yield"];
|
|
11
|
+
|
|
12
|
+
module.exports = class DeadCode {
|
|
13
|
+
|
|
14
|
+
constructor (logger) {
|
|
15
|
+
this.logger = logger;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Insert dead code
|
|
20
|
+
* @param {Node} ast
|
|
21
|
+
* @returns {Node}
|
|
22
|
+
*/
|
|
23
|
+
insert (ast, probability) {
|
|
24
|
+
assert.ok(estest.isNode(ast));
|
|
25
|
+
|
|
26
|
+
var rngAlpha = new utils.UniqueRandomAlpha(3);
|
|
27
|
+
|
|
28
|
+
return traverser.traverse(ast, [], (node, stack) => {
|
|
29
|
+
if (node.type == "BlockStatement") {
|
|
30
|
+
for (var i = 0; i < probability; ++i) {
|
|
31
|
+
if (probability - i < Math.random()) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var pos = utils.random(0, node.body.length - 1);
|
|
36
|
+
var len = utils.random(1, node.body.length - pos);
|
|
37
|
+
|
|
38
|
+
var varValue = _.sample(KEYWORDS);
|
|
39
|
+
|
|
40
|
+
var spliced = node.body.splice(pos, len);
|
|
41
|
+
node.body.splice(pos, 0,
|
|
42
|
+
{
|
|
43
|
+
type: "IfStatement",
|
|
44
|
+
test: {
|
|
45
|
+
type: "BinaryExpression",
|
|
46
|
+
operator: "==",
|
|
47
|
+
left: { type: "Literal", value: varValue },
|
|
48
|
+
right: { type: "Literal", value: varValue }
|
|
49
|
+
},
|
|
50
|
+
consequent: {
|
|
51
|
+
type: "BlockStatement",
|
|
52
|
+
body: spliced
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return node;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
};
|