js-confuser-vm 0.0.4 → 0.0.6
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 +58 -3
- package/README.MD +186 -107
- package/dist/build-runtime.js +59 -0
- package/dist/compiler.js +1777 -0
- package/dist/index.js +10 -0
- package/dist/minify.js +18 -0
- package/dist/options.js +1 -0
- package/dist/runtime.js +826 -0
- package/dist/transforms/bytecode/aliasedOpcodes.js +140 -0
- package/dist/transforms/bytecode/concealConstants.js +31 -0
- package/dist/transforms/bytecode/macroOpcodes.js +164 -0
- package/dist/transforms/bytecode/resolveContants.js +106 -0
- package/dist/transforms/bytecode/resolveLabels.js +80 -0
- package/dist/transforms/bytecode/selfModifying.js +108 -0
- package/dist/transforms/bytecode/specializedOpcodes.js +113 -0
- package/dist/transforms/runtime/aliasedOpcodes.js +134 -0
- package/dist/transforms/runtime/macroOpcodes.js +88 -0
- package/dist/transforms/runtime/minify.js +1 -0
- package/dist/transforms/runtime/shuffleOpcodes.js +20 -0
- package/dist/transforms/runtime/specializedOpcodes.js +107 -0
- package/{src/transforms/utils/op-utils.ts → dist/transforms/utils/op-utils.js} +25 -26
- package/dist/transforms/utils/random-utils.js +27 -0
- package/dist/types.js +15 -0
- package/dist/utils/op-utils.js +29 -0
- package/dist/utils/random-utils.js +27 -0
- package/dist/utilts.js +3 -0
- package/index.ts +10 -8
- package/jest.config.js +10 -0
- package/package.json +3 -4
- package/src/build-runtime.ts +7 -1
- package/src/compiler.ts +2395 -2069
- package/src/options.ts +2 -0
- package/src/runtime.ts +838 -771
- package/src/transforms/bytecode/aliasedOpcodes.ts +158 -0
- package/src/transforms/bytecode/concealConstants.ts +52 -0
- package/src/transforms/bytecode/macroOpcodes.ts +32 -15
- package/src/transforms/bytecode/resolveContants.ts +87 -16
- package/src/transforms/bytecode/selfModifying.ts +3 -3
- package/src/transforms/bytecode/specializedOpcodes.ts +58 -29
- package/src/transforms/runtime/aliasedOpcodes.ts +191 -0
- package/src/transforms/runtime/shuffleOpcodes.ts +1 -1
- package/src/transforms/runtime/specializedOpcodes.ts +39 -24
- package/src/utils/op-utils.ts +33 -0
- /package/src/{transforms/utils → utils}/random-utils.ts +0 -0
package/jest.config.js
CHANGED
|
@@ -10,6 +10,14 @@ const OPTIONS_MATRIX = [
|
|
|
10
10
|
displayName: "specializedOpcodes",
|
|
11
11
|
VM_OPTIONS: { specializedOpcodes: true },
|
|
12
12
|
},
|
|
13
|
+
{
|
|
14
|
+
displayName: "aliasedOpcodes",
|
|
15
|
+
VM_OPTIONS: { aliasedOpcodes: true },
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
displayName: "concealConstants",
|
|
19
|
+
VM_OPTIONS: { concealConstants: true },
|
|
20
|
+
},
|
|
13
21
|
{
|
|
14
22
|
displayName: "all",
|
|
15
23
|
VM_OPTIONS: {
|
|
@@ -20,6 +28,8 @@ const OPTIONS_MATRIX = [
|
|
|
20
28
|
timingChecks: true,
|
|
21
29
|
macroOpcodes: true,
|
|
22
30
|
specializedOpcodes: true,
|
|
31
|
+
aliasedOpcodes: true,
|
|
32
|
+
concealConstants: true,
|
|
23
33
|
},
|
|
24
34
|
},
|
|
25
35
|
];
|
package/package.json
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js-confuser-vm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "babel src --out-dir dist --extensions
|
|
6
|
+
"build": "babel src --out-dir dist --extensions \".ts,.js\"",
|
|
7
7
|
"index": "cross-env NODE_OPTIONS=\"--disable-warning=ExperimentalWarning\" node index.ts",
|
|
8
8
|
"test": "cross-env NODE_OPTIONS=\"--experimental-vm-modules --experimental-strip-types --disable-warning=ExperimentalWarning\" jest --coverage --coverageReporters=html --selectProjects default",
|
|
9
9
|
"test-all": "cross-env NODE_OPTIONS=\"--experimental-vm-modules --experimental-strip-types --disable-warning=ExperimentalWarning\" jest --coverage --coverageReporters=html",
|
|
10
10
|
"test262": "cross-env NODE_OPTIONS=\"--experimental-vm-modules --experimental-strip-types --disable-warning=ExperimentalWarning\" node test262-scripts/run-test262.ts",
|
|
11
|
-
"prepublishOnly": "npm run build && npm run test"
|
|
12
|
-
"set-env": ""
|
|
11
|
+
"prepublishOnly": "npm run build && npm run test"
|
|
13
12
|
},
|
|
14
13
|
"type": "module",
|
|
15
14
|
"keywords": [
|
package/src/build-runtime.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { applyShuffleOpcodes } from "./transforms/runtime/shuffleOpcodes.ts";
|
|
|
7
7
|
import { applyMinify } from "./transforms/runtime/minify.ts";
|
|
8
8
|
import { Compiler } from "./compiler.ts";
|
|
9
9
|
import { applySpecializedOpcodes } from "./transforms/runtime/specializedOpcodes.ts";
|
|
10
|
+
import { applyAliasedOpcodes } from "./transforms/runtime/aliasedOpcodes.ts";
|
|
10
11
|
import type * as b from "./types.ts";
|
|
11
12
|
|
|
12
13
|
export async function obfuscateRuntime(
|
|
@@ -22,7 +23,7 @@ export async function obfuscateRuntime(
|
|
|
22
23
|
throw new Error("VM-Runtime final parsing failed", { cause: error });
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
//
|
|
26
|
+
// Specialized opcode cases must be applied BEFORE shuffleOpcodes
|
|
26
27
|
if (options.specializedOpcodes) {
|
|
27
28
|
applySpecializedOpcodes(ast, bytecode, compiler);
|
|
28
29
|
}
|
|
@@ -32,6 +33,11 @@ export async function obfuscateRuntime(
|
|
|
32
33
|
applyMacroOpcodes(ast, compiler);
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
// Aliased opcode cases must be applied BEFORE shuffleOpcodes
|
|
37
|
+
if (options.aliasedOpcodes) {
|
|
38
|
+
applyAliasedOpcodes(ast, compiler);
|
|
39
|
+
}
|
|
40
|
+
|
|
35
41
|
// Shuffle opcode handle order
|
|
36
42
|
if (options.shuffleOpcodes) {
|
|
37
43
|
applyShuffleOpcodes(ast);
|