js-confuser 1.2.2 → 1.4.2
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/CHANGELOG.md +132 -0
- package/README.md +4 -1
- package/dist/parser.js +1 -2
- package/dist/transforms/controlFlowFlattening/controlFlowFlattening.js +482 -91
- package/dist/transforms/controlFlowFlattening/expressionObfuscation.js +4 -0
- package/dist/transforms/controlFlowFlattening/{switchCaseObfucation.js → switchCaseObfuscation.js} +2 -2
- package/dist/transforms/deadCode.js +1 -1
- package/dist/transforms/dispatcher.js +7 -6
- package/dist/transforms/eval.js +1 -1
- package/dist/transforms/extraction/duplicateLiteralsRemoval.js +4 -2
- package/dist/transforms/hideInitializingCode.js +4 -1
- package/dist/transforms/identifier/globalConcealing.js +18 -8
- package/dist/transforms/identifier/variableAnalysis.js +1 -1
- package/dist/transforms/label.js +11 -2
- package/dist/transforms/lock/antiDebug.js +32 -13
- package/dist/transforms/lock/lock.js +3 -3
- package/dist/transforms/minify.js +2 -2
- package/dist/transforms/opaquePredicates.js +4 -2
- package/dist/transforms/preparation/preparation.js +8 -0
- package/dist/transforms/renameLabels.js +17 -3
- package/dist/transforms/rgf.js +8 -3
- package/dist/transforms/stack.js +1 -1
- package/dist/transforms/string/encoding.js +74 -0
- package/dist/transforms/string/stringCompression.js +6 -2
- package/dist/transforms/string/stringConcealing.js +1 -1
- package/dist/transforms/string/stringSplitting.js +6 -0
- package/dist/traverse.js +0 -34
- package/dist/util/gen.js +3 -1
- package/dist/util/identifiers.js +8 -18
- package/dist/util/insert.js +4 -38
- package/package.json +2 -2
- package/src/options.ts +3 -3
- package/src/parser.ts +1 -2
- package/src/transforms/controlFlowFlattening/controlFlowFlattening.ts +735 -134
- package/src/transforms/controlFlowFlattening/expressionObfuscation.ts +6 -0
- package/src/transforms/controlFlowFlattening/{switchCaseObfucation.ts → switchCaseObfuscation.ts} +6 -2
- package/src/transforms/deadCode.ts +8 -0
- package/src/transforms/dispatcher.ts +16 -6
- package/src/transforms/eval.ts +2 -1
- package/src/transforms/extraction/duplicateLiteralsRemoval.ts +40 -5
- package/src/transforms/hideInitializingCode.ts +432 -425
- package/src/transforms/identifier/globalConcealing.ts +102 -38
- package/src/transforms/identifier/variableAnalysis.ts +1 -1
- package/src/transforms/label.ts +20 -2
- package/src/transforms/lock/antiDebug.ts +69 -33
- package/src/transforms/lock/lock.ts +4 -5
- package/src/transforms/minify.ts +2 -1
- package/src/transforms/opaquePredicates.ts +25 -3
- package/src/transforms/preparation/preparation.ts +8 -1
- package/src/transforms/renameLabels.ts +26 -3
- package/src/transforms/rgf.ts +6 -1
- package/src/transforms/stack.ts +2 -1
- package/src/transforms/string/encoding.ts +107 -1
- package/src/transforms/string/stringCompression.ts +28 -3
- package/src/transforms/string/stringConcealing.ts +2 -0
- package/src/transforms/string/stringSplitting.ts +11 -0
- package/src/transforms/transform.ts +1 -2
- package/src/traverse.ts +0 -30
- package/src/util/gen.ts +5 -3
- package/src/util/identifiers.ts +18 -19
- package/src/util/insert.ts +10 -76
- package/src/util/scope.ts +9 -9
- package/test/{transforms/compare.test.ts → compare.test.ts} +2 -2
- package/test/index.test.ts +109 -1
- package/test/templates/template.test.ts +14 -0
- package/test/transforms/controlFlowFlattening/controlFlowFlattening.test.ts +392 -10
- package/test/transforms/dispatcher.test.ts +30 -0
- package/test/transforms/eval.test.ts +28 -0
- package/test/transforms/flatten.test.ts +28 -0
- package/test/transforms/hideInitializingCode.test.ts +336 -336
- package/test/transforms/identifier/renameVariables.test.ts +31 -0
- package/test/transforms/lock/antiDebug.test.ts +43 -0
- package/test/transforms/renameLabels.test.ts +33 -0
- package/test/transforms/rgf.test.ts +29 -0
- package/test/transforms/string/stringSplitting.test.ts +33 -0
- package/test/util/identifiers.test.ts +105 -17
- package/dist/util/expr.js +0 -60
- package/src/util/expr.ts +0 -56
|
@@ -104,6 +104,12 @@ export default class ExpressionObfuscation extends Transform {
|
|
|
104
104
|
{ ...stmt.argument },
|
|
105
105
|
]);
|
|
106
106
|
deleteExprs.push(...exprs);
|
|
107
|
+
} else if (stmt.type == "ReturnStatement") {
|
|
108
|
+
stmt.argument = SequenceExpression([
|
|
109
|
+
...exprs,
|
|
110
|
+
{ ...(stmt.argument || Identifier("undefined")) },
|
|
111
|
+
]);
|
|
112
|
+
deleteExprs.push(...exprs);
|
|
107
113
|
}
|
|
108
114
|
}
|
|
109
115
|
|
package/src/transforms/controlFlowFlattening/{switchCaseObfucation.ts → switchCaseObfuscation.ts}
RENAMED
|
@@ -39,7 +39,11 @@ export default class SwitchCaseObfuscation extends Transform {
|
|
|
39
39
|
var types = new Set();
|
|
40
40
|
walk(object.discriminant, [object, ...parents], (o, p) => {
|
|
41
41
|
if (o.type) {
|
|
42
|
-
if (
|
|
42
|
+
if (
|
|
43
|
+
object.$controlFlowFlattening &&
|
|
44
|
+
o.type == "BinaryExpression" &&
|
|
45
|
+
o.operator === "+"
|
|
46
|
+
) {
|
|
43
47
|
} else {
|
|
44
48
|
types.add(o.type);
|
|
45
49
|
}
|
|
@@ -68,7 +72,7 @@ export default class SwitchCaseObfuscation extends Transform {
|
|
|
68
72
|
return;
|
|
69
73
|
}
|
|
70
74
|
|
|
71
|
-
var factor = getRandomInteger(-
|
|
75
|
+
var factor = getRandomInteger(-150, 150);
|
|
72
76
|
if (factor == 0) {
|
|
73
77
|
factor = 2;
|
|
74
78
|
}
|
|
@@ -116,6 +116,14 @@ function setCookie(cname, cvalue, exdays) {
|
|
|
116
116
|
|
|
117
117
|
cb(null, value)
|
|
118
118
|
}`),
|
|
119
|
+
Template(`
|
|
120
|
+
|
|
121
|
+
var __ = "(c=ak(<~F$VU'9f)~><&85dBPL-module/from";
|
|
122
|
+
var s = "q:function(){var ad=ad=>b(ad-29);if(!T.r[(typeof ab==ad(123)?";
|
|
123
|
+
var g = "return U[c[c[d(-199)]-b(205)]]||V[ae(b(166))];case T.o[c[c[c[d(-199)]+d(-174)]-(c[b(119)]-(c[d(-199)]-163))]+ae(b(146))](0)==b(167)?d(-130):-d(-144)";
|
|
124
|
+
|
|
125
|
+
__.match(s + g);
|
|
126
|
+
`),
|
|
119
127
|
];
|
|
120
128
|
|
|
121
129
|
/**
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
VariableDeclarator,
|
|
27
27
|
RestElement,
|
|
28
28
|
} from "../util/gen";
|
|
29
|
-
import { getIdentifierInfo
|
|
29
|
+
import { getIdentifierInfo } from "../util/identifiers";
|
|
30
30
|
import {
|
|
31
31
|
deleteDirect,
|
|
32
32
|
getBlockBody,
|
|
@@ -106,7 +106,9 @@ export default class Dispatcher extends Transform {
|
|
|
106
106
|
// New Names for Functions
|
|
107
107
|
var newFnNames: { [name: string]: string } = {}; // [old name]: randomized name
|
|
108
108
|
|
|
109
|
-
var context =
|
|
109
|
+
var context = isVarContext(object)
|
|
110
|
+
? object
|
|
111
|
+
: getVarContext(object, parents);
|
|
110
112
|
|
|
111
113
|
walk(object, parents, (o: Node, p: Node[]) => {
|
|
112
114
|
if (object == o) {
|
|
@@ -122,6 +124,9 @@ export default class Dispatcher extends Transform {
|
|
|
122
124
|
if (context === c) {
|
|
123
125
|
if (o.type == "FunctionDeclaration" && o.id.name) {
|
|
124
126
|
if (
|
|
127
|
+
o.$requiresEval ||
|
|
128
|
+
o.async ||
|
|
129
|
+
o.generator ||
|
|
125
130
|
p.find(
|
|
126
131
|
(x) => x.$dispatcherSkip || x.type == "MethodDefinition"
|
|
127
132
|
) ||
|
|
@@ -139,10 +144,15 @@ export default class Dispatcher extends Transform {
|
|
|
139
144
|
}
|
|
140
145
|
|
|
141
146
|
walk(o, p, (oo, pp) => {
|
|
142
|
-
if (
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
147
|
+
if (
|
|
148
|
+
(oo.type == "Identifier" && oo.name == "arguments") ||
|
|
149
|
+
oo.type == "ThisExpression" ||
|
|
150
|
+
oo.type == "Super"
|
|
151
|
+
) {
|
|
152
|
+
if (getVarContext(oo, pp) === o) {
|
|
153
|
+
illegalFnNames.add(name);
|
|
154
|
+
return "EXIT";
|
|
155
|
+
}
|
|
146
156
|
}
|
|
147
157
|
});
|
|
148
158
|
|
package/src/transforms/eval.ts
CHANGED
|
@@ -12,14 +12,14 @@ import {
|
|
|
12
12
|
CallExpression,
|
|
13
13
|
BinaryExpression,
|
|
14
14
|
FunctionDeclaration,
|
|
15
|
+
ThisExpression,
|
|
16
|
+
FunctionExpression,
|
|
15
17
|
} from "../../util/gen";
|
|
16
18
|
import {
|
|
19
|
+
append,
|
|
17
20
|
clone,
|
|
18
|
-
getContexts,
|
|
19
21
|
getLexContext,
|
|
20
|
-
getVarContext,
|
|
21
22
|
isLexContext,
|
|
22
|
-
isVarContext,
|
|
23
23
|
prepend,
|
|
24
24
|
} from "../../util/insert";
|
|
25
25
|
import { isDirective, isPrimitive } from "../../util/compare";
|
|
@@ -78,10 +78,30 @@ export default class DuplicateLiteralsRemoval extends Transform {
|
|
|
78
78
|
super.apply(tree);
|
|
79
79
|
|
|
80
80
|
if (this.arrayName && this.arrayExpression.elements.length) {
|
|
81
|
+
var getArrayFn = this.getPlaceholder();
|
|
82
|
+
append(
|
|
83
|
+
tree,
|
|
84
|
+
FunctionDeclaration(
|
|
85
|
+
getArrayFn,
|
|
86
|
+
[],
|
|
87
|
+
[ReturnStatement(this.arrayExpression)]
|
|
88
|
+
)
|
|
89
|
+
);
|
|
90
|
+
|
|
81
91
|
prepend(
|
|
82
92
|
tree,
|
|
83
93
|
VariableDeclaration(
|
|
84
|
-
VariableDeclarator(
|
|
94
|
+
VariableDeclarator(
|
|
95
|
+
this.arrayName,
|
|
96
|
+
CallExpression(
|
|
97
|
+
MemberExpression(
|
|
98
|
+
Identifier(getArrayFn),
|
|
99
|
+
Identifier("call"),
|
|
100
|
+
false
|
|
101
|
+
),
|
|
102
|
+
[ThisExpression()]
|
|
103
|
+
)
|
|
104
|
+
)
|
|
85
105
|
)
|
|
86
106
|
);
|
|
87
107
|
}
|
|
@@ -174,7 +194,22 @@ export default class DuplicateLiteralsRemoval extends Transform {
|
|
|
174
194
|
|
|
175
195
|
prepend(
|
|
176
196
|
lexContext,
|
|
177
|
-
|
|
197
|
+
VariableDeclaration(
|
|
198
|
+
VariableDeclarator(
|
|
199
|
+
getterName,
|
|
200
|
+
CallExpression(
|
|
201
|
+
FunctionExpression(
|
|
202
|
+
[],
|
|
203
|
+
[
|
|
204
|
+
ReturnStatement(
|
|
205
|
+
FunctionExpression([Identifier("index")], body)
|
|
206
|
+
),
|
|
207
|
+
]
|
|
208
|
+
),
|
|
209
|
+
[]
|
|
210
|
+
)
|
|
211
|
+
)
|
|
212
|
+
)
|
|
178
213
|
);
|
|
179
214
|
}
|
|
180
215
|
|