js-confuser-vm 0.1.0 → 0.1.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/README.md +281 -147
- package/dist/build-runtime.js +41 -15
- package/dist/compiler.js +714 -265
- package/dist/disassembler.js +367 -0
- package/dist/index.js +7 -2
- package/dist/runtime.js +160 -119
- package/dist/template.js +163 -42
- package/dist/transforms/bytecode/aliasedOpcodes.js +4 -1
- package/dist/transforms/bytecode/concealConstants.js +2 -2
- package/dist/transforms/bytecode/controlFlowFlattening.js +569 -0
- package/dist/transforms/bytecode/dispatcher.js +15 -111
- package/dist/transforms/bytecode/macroOpcodes.js +2 -2
- package/{src/transforms/bytecode/resolveContants.ts → dist/transforms/bytecode/resolveConstants.js} +30 -56
- package/dist/transforms/bytecode/resolveRegisters.js +23 -4
- package/dist/transforms/bytecode/selfModifying.js +88 -21
- package/dist/transforms/bytecode/semanticOpcodes.js +162 -0
- package/dist/transforms/bytecode/specializedOpcodes.js +23 -12
- package/dist/transforms/bytecode/stringConcealing.js +288 -0
- package/dist/transforms/runtime/classObfuscation.js +43 -0
- package/dist/transforms/runtime/handlerTable.js +91 -0
- package/dist/transforms/runtime/semanticOpcodes.js +35 -0
- package/dist/transforms/runtime/specializedOpcodes.js +11 -5
- package/dist/types.js +1 -1
- package/dist/utils/ast-utils.js +75 -0
- package/dist/utils/op-utils.js +1 -2
- package/dist/utils/pass-utils.js +100 -0
- package/dist/utils/profile-utils.js +3 -0
- package/package.json +8 -1
- package/.gitmodules +0 -4
- package/.prettierignore +0 -1
- package/CHANGELOG.md +0 -335
- package/babel-plugin-inline-runtime.cjs +0 -34
- package/babel.config.json +0 -23
- package/index.ts +0 -38
- package/jest-strip-types.js +0 -10
- package/jest.config.js +0 -52
- package/src/build-runtime.ts +0 -78
- package/src/compiler.ts +0 -2593
- package/src/index.ts +0 -14
- package/src/minify.ts +0 -21
- package/src/options.ts +0 -18
- package/src/runtime.ts +0 -923
- package/src/template.ts +0 -141
- package/src/transforms/bytecode/aliasedOpcodes.ts +0 -148
- package/src/transforms/bytecode/concealConstants.ts +0 -52
- package/src/transforms/bytecode/dispatcher.ts +0 -398
- package/src/transforms/bytecode/macroOpcodes.ts +0 -193
- package/src/transforms/bytecode/microOpcodes.ts +0 -291
- package/src/transforms/bytecode/resolveLabels.ts +0 -112
- package/src/transforms/bytecode/resolveRegisters.ts +0 -221
- package/src/transforms/bytecode/selfModifying.ts +0 -121
- package/src/transforms/bytecode/specializedOpcodes.ts +0 -153
- package/src/transforms/runtime/aliasedOpcodes.ts +0 -191
- package/src/transforms/runtime/internalVariables.ts +0 -270
- package/src/transforms/runtime/macroOpcodes.ts +0 -138
- package/src/transforms/runtime/microOpcodes.ts +0 -93
- package/src/transforms/runtime/minify.ts +0 -1
- package/src/transforms/runtime/shuffleOpcodes.ts +0 -24
- package/src/transforms/runtime/specializedOpcodes.ts +0 -156
- package/src/types.ts +0 -93
- package/src/utils/op-utils.ts +0 -48
- package/src/utils/random-utils.ts +0 -31
- package/tsconfig.json +0 -12
package/src/index.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { compileAndSerialize } from "./compiler.ts";
|
|
2
|
-
import type { Options } from "./options.ts";
|
|
3
|
-
import { DEFAULT_OPTIONS } from "./options.ts";
|
|
4
|
-
|
|
5
|
-
async function obfuscate(source, options: Options = DEFAULT_OPTIONS) {
|
|
6
|
-
const result = compileAndSerialize(source, options);
|
|
7
|
-
|
|
8
|
-
return result;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const JsConfuserVM = {
|
|
12
|
-
obfuscate,
|
|
13
|
-
};
|
|
14
|
-
export default JsConfuserVM;
|
package/src/minify.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import ClosureCompiler from "google-closure-compiler";
|
|
2
|
-
|
|
3
|
-
export function minify(sourceCode: string): Promise<string> {
|
|
4
|
-
return new Promise((resolve, reject) => {
|
|
5
|
-
const compiler = new ClosureCompiler({
|
|
6
|
-
compilation_level: "ADVANCED",
|
|
7
|
-
warning_level: "QUIET",
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
const compilerProcess = compiler.run((exitCode: number, stdOut: string, stdErr: string) => {
|
|
11
|
-
if (exitCode !== 0) {
|
|
12
|
-
reject(new Error(stdErr || `Closure Compiler exited with code ${exitCode}`));
|
|
13
|
-
} else {
|
|
14
|
-
resolve(stdOut);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
compilerProcess.stdin.write(sourceCode);
|
|
19
|
-
compilerProcess.stdin.end();
|
|
20
|
-
});
|
|
21
|
-
}
|
package/src/options.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface Options {
|
|
2
|
-
target?: "node" | "browser";
|
|
3
|
-
|
|
4
|
-
randomizeOpcodes?: boolean; // randomize the opcode numbers?
|
|
5
|
-
shuffleOpcodes?: boolean; // shuffle order of opcode handlers in the runtime?
|
|
6
|
-
encodeBytecode?: boolean; // encode bytecode? when off, comments for instructions are added
|
|
7
|
-
selfModifying?: boolean; // do self-modifying bytecode for function bodies?
|
|
8
|
-
dispatcher?: boolean; // create middleman blocks to process jumps?
|
|
9
|
-
macroOpcodes?: boolean; // create combined opcodes for repeated instruction sequences?
|
|
10
|
-
microOpcodes?: boolean; // break opcodes into sub-opcodes?
|
|
11
|
-
specializedOpcodes?: boolean; // create specialized opcodes for commonly used opcode+operand pairs?
|
|
12
|
-
aliasedOpcodes?: boolean; // create duplicate opcodes for commonly used opcodes?
|
|
13
|
-
timingChecks?: boolean; // add timing checks to detect debuggers?
|
|
14
|
-
concealConstants?: boolean; // conceal strings and integers in the constant pool?
|
|
15
|
-
minify?: boolean; // pass final output through Google Closure Compiler? (Renames VM class properties)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const DEFAULT_OPTIONS = {};
|