Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0 #158

Merged
merged 103 commits into from
Dec 1, 2024
Merged

2.0 #158

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
dd408e8
Initial 2.0 Rewrite
MichaelXF Aug 24, 2024
3508099
AST Scrambler, Order, Test refactoring
MichaelXF Aug 24, 2024
31ed956
Finish calculator
MichaelXF Aug 24, 2024
0171f2b
Finish Dispatcher
MichaelXF Aug 25, 2024
2b646b9
Finish `Moved Declarations`
MichaelXF Aug 25, 2024
cfc8d22
Rename Labels, RGF improvements, Refactor
MichaelXF Aug 25, 2024
bc84dd5
Finish `obfuscateWithProfiler`, Generic templates, __JS_CONFUSER_VAR__
MichaelXF Aug 25, 2024
4e26a82
`Stack` renamed to -> `Variable Masking`, Single quote to double quotes
MichaelXF Aug 25, 2024
b0adc3a
Improve Flatten
MichaelXF Aug 26, 2024
c1b98fe
Single Quote Refactoring
MichaelXF Aug 26, 2024
5108312
Add `undefined` and `null` to Duplicate Literals Removal
MichaelXF Aug 26, 2024
76419f1
Improve String Concealing, Variable Masking, Remove ES5/Unused Locks
MichaelXF Aug 26, 2024
13ec3ee
Improve `Shuffle`
MichaelXF Aug 26, 2024
b24fdf3
`Object Extraction` Complete tests (16/16)
MichaelXF Aug 27, 2024
a43309e
`Variable Masking` Tests (18/19)
MichaelXF Aug 27, 2024
59d54e5
Improve Obfuscator Internals
MichaelXF Aug 27, 2024
379e2e3
Control Flow Flattening, Lock, Variable Concealing
MichaelXF Aug 30, 2024
8cf640b
Improved Rename Variables, Scope Integrity checking
MichaelXF Aug 30, 2024
a3077c1
Improve `Rename Variables`, Modified globals
MichaelXF Aug 31, 2024
9fbfa38
Integrity, Custom String Encodings, Opaque Predicates, Improvements
MichaelXF Sep 1, 2024
7a194c7
Improve Rename Labels
MichaelXF Sep 1, 2024
353693b
Preserve Function Length, Identifier Generator Modes, Improvements
MichaelXF Sep 2, 2024
cf2d683
Improve Function Length, RGF Infinite recursion, Variable renaming
MichaelXF Sep 3, 2024
558f0d2
Add `Minify`
MichaelXF Sep 3, 2024
6d0e5b1
Improve API Interface **Breaking change**
MichaelXF Sep 5, 2024
7ce788c
Add `Function Outlining`
MichaelXF Sep 5, 2024
f2198d9
Clean package.json
MichaelXF Sep 5, 2024
6729c98
Scope fixes, improve coverage
MichaelXF Sep 5, 2024
42a4531
Global concealing re-declared global
MichaelXF Sep 5, 2024
53de4d0
Improve function outlining / tests
MichaelXF Sep 7, 2024
2a6eb26
Improve Moved Declarations, Control Object
MichaelXF Sep 7, 2024
c1542d4
Control Flow Flattening, `numericLiteral` fix
MichaelXF Sep 10, 2024
594c9cc
Improve Control Flow Flattening, String Compression, Identifier Track…
MichaelXF Sep 12, 2024
c166a10
Improve test coverage
MichaelXF Sep 18, 2024
679d519
Test refactoring
MichaelXF Sep 18, 2024
3550cd4
Code refactoring
MichaelXF Sep 18, 2024
6a1074d
Improve templates
MichaelXF Sep 18, 2024
7bdc81b
Improve Plugin API, Change Data, Transform improvements
MichaelXF Sep 18, 2024
469236d
Decrease NPM bundle size
MichaelXF Sep 18, 2024
82e77f6
Repo update
MichaelXF Sep 18, 2024
87fb1f4
Prepare for 2.0, All Tests Passing
MichaelXF Sep 18, 2024
3121c28
Exclude dev files
MichaelXF Sep 18, 2024
5ce602b
Improve Control Flow Flattening
MichaelXF Sep 18, 2024
9a56954
Opaque Predicates & Control Flow Flattening fixes
MichaelXF Sep 18, 2024
8fa02ea
Dispatcher redefined/reassigned fix
MichaelXF Sep 18, 2024
524e91a
Update available features
MichaelXF Sep 19, 2024
79c0adb
Add tests, increase code coverage
MichaelXF Sep 19, 2024
6311c71
2.0.0-alpha
MichaelXF Sep 19, 2024
846d23b
Tweak package.json
MichaelXF Sep 19, 2024
78fc46c
Remove `@babel/core`
MichaelXF Sep 19, 2024
853137c
2.0.0-alpha.1
MichaelXF Sep 19, 2024
3c99c89
2.0.0-alpha.2
MichaelXF Sep 19, 2024
a5af6b9
Minify concatenate strings, don't remove String Encoding functions
MichaelXF Sep 22, 2024
70e0cc8
Control Flow Flattening scoping fix
MichaelXF Sep 23, 2024
cc1f1da
Add Date Lock warning, edit comments
MichaelXF Sep 28, 2024
94b6213
Use prepend instead
MichaelXF Oct 28, 2024
5b98237
Small pack fix
MichaelXF Oct 28, 2024
764d285
Improve prepend function for Import Declarations
MichaelXF Oct 28, 2024
5ef2252
Preserve module import strings
MichaelXF Oct 28, 2024
db7e0a7
Code refactoring
MichaelXF Oct 28, 2024
5909309
Fix small Pack error
MichaelXF Oct 28, 2024
19d74dd
Remove Control Objects, Unused features
MichaelXF Nov 10, 2024
1b055aa
Add user defined limits to Probability Maps
MichaelXF Nov 10, 2024
0b36917
Switch String Compression library to lz-string
MichaelXF Nov 10, 2024
df60ade
Use placeholder prefix
MichaelXF Nov 10, 2024
fbe3449
Add Predicate Gen for Dead Code and Opaque Predicates
MichaelXF Nov 10, 2024
dc488c7
Improve RGF selection to improve Obfuscation times, other improvements
MichaelXF Nov 10, 2024
455f75e
Fix small bugs, improve test coverage
MichaelXF Nov 10, 2024
355a8ec
Update to `NumericLiteral`
MichaelXF Nov 10, 2024
610fde7
2.0.0-alpha.3
MichaelXF Nov 10, 2024
07fd7fb
Add option `chinese` for identifier generator
MichaelXF Nov 11, 2024
5158613
Variable Masking bug fix
MichaelXF Nov 12, 2024
a3b8493
Small tweaks
MichaelXF Nov 12, 2024
12a7011
Improve exported types
MichaelXF Nov 16, 2024
ca2c90e
Improve CFF for Program level
MichaelXF Nov 16, 2024
b5d12bc
New comment syntax `/* @js-confuser-var */ "name"`
MichaelXF Nov 16, 2024
14b376e
Repo update
MichaelXF Nov 19, 2024
e6a0fd8
Improve Global Concealing
MichaelXF Nov 19, 2024
615e19b
CFF test for multiple deletes
MichaelXF Nov 19, 2024
0b10802
Remove src_old
MichaelXF Nov 19, 2024
4a2fd32
Improve Node Module support / New AES Test
MichaelXF Nov 19, 2024
85addf3
Add Prepack Breaker to Self Defending
MichaelXF Nov 20, 2024
9525579
Improve `Pack` and `RGF` for sharing global variables
MichaelXF Nov 20, 2024
e4cb8ac
Improve `Minify` for simple object/array destructuring
MichaelXF Nov 20, 2024
8688615
Improve default limit logic on Dead Code and Opaque Predicates
MichaelXF Nov 20, 2024
94b54d0
Improve Integrity performance
MichaelXF Nov 20, 2024
c354d19
New solution to Rename Variables default parameter
MichaelXF Nov 20, 2024
a464196
Improve default limit on lock, with option to change it
MichaelXF Nov 20, 2024
bec1c41
Improve Control Flow Flattening
MichaelXF Nov 20, 2024
fe995f8
Fix scoping issue in edge case
MichaelXF Nov 21, 2024
a22d266
Improve String Concealing changeData
MichaelXF Nov 21, 2024
24d073d
2.0.0-alpha.4
MichaelXF Nov 21, 2024
bb595bf
Set Function Length improvement
MichaelXF Nov 22, 2024
06d7766
Add reserved keyword `do`, improve profiling
MichaelXF Nov 22, 2024
ee443be
Remove unnecessary scoping adjustment
MichaelXF Nov 27, 2024
58c1283
Improve CFF
MichaelXF Nov 27, 2024
f15bfa6
2.0.0-alpha.5
MichaelXF Nov 27, 2024
6d4bb17
Add cache to String Concealing
MichaelXF Dec 1, 2024
27ae847
Generator functions for CFF
MichaelXF Dec 1, 2024
c3d8b29
Remove 'hash' variable from Integrity
MichaelXF Dec 1, 2024
c6f4938
Minor tweaks
MichaelXF Dec 1, 2024
a35eda5
2.0
MichaelXF Dec 1, 2024
1777042
Upgrade Node Versions
MichaelXF Dec 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove @babel/core
  • Loading branch information
MichaelXF committed Sep 19, 2024
commit 78fc46c17d60ae117429266048a3fa27896658cd
21 changes: 10 additions & 11 deletions src/obfuscator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ok } from "assert";
import * as babel from "@babel/core";
import * as t from "@babel/types";
import generate from "@babel/generator";
import { Node, Statement } from "@babel/types";
import traverse from "@babel/traverse";
import { parse } from "@babel/parser";
import { ObfuscateOptions } from "./options";
import { applyDefaultsToOptions, validateOptions } from "./validateOptions";
import { ObfuscationResult, ProfilerCallback } from "./obfuscationResult";
Expand Down Expand Up @@ -62,14 +63,14 @@ export default class Obfuscator {
sensitivityRegex: / |\n|;|,|\{|\}|\(|\)|\.|\[|\]/g,
},

createCountermeasuresCode: (): Statement[] => {
createCountermeasuresCode: (): t.Statement[] => {
throw new Error("Not implemented");
},
},

// After RenameVariables completes, this map will contain the renamed variables
// Most use cases involve grabbing the Program(global) mappings
renamedVariables: new Map<Node, Map<string, string>>(),
renamedVariables: new Map<t.Node, Map<string, string>>(),

// Internal functions, should not be renamed/removed
internals: {
Expand Down Expand Up @@ -136,7 +137,7 @@ export default class Obfuscator {
return this.globalState.internals.stringCompressionLibraryName;
}

getObfuscatedVariableName(originalName: string, programNode: Node) {
getObfuscatedVariableName(originalName: string, programNode: t.Node) {
const renamedVariables = this.globalState.renamedVariables.get(programNode);

return renamedVariables?.get(originalName) || originalName;
Expand Down Expand Up @@ -268,7 +269,7 @@ export default class Obfuscator {
);
}

babel.traverse(ast, plugin.visitor);
traverse(ast, plugin.visitor);
plugin.post?.();

if (plugin.finalASTHandler) {
Expand Down Expand Up @@ -317,14 +318,14 @@ export default class Obfuscator {
/**
* Calls `Obfuscator.generateCode` with the current instance options
*/
generateCode<T extends babel.types.Node = babel.types.File>(ast: T): string {
generateCode<T extends t.Node = t.File>(ast: T): string {
return Obfuscator.generateCode(ast, this.options);
}

/**
* Generates code from an AST using `@babel/generator`
*/
static generateCode<T extends babel.types.Node = babel.types.File>(
static generateCode<T extends t.Node = t.File>(
ast: T,
options: ObfuscateOptions = DEFAULT_OPTIONS
): string {
Expand All @@ -347,10 +348,8 @@ export default class Obfuscator {
*/
static parseCode(sourceCode: string): babel.types.File {
// Parse the source code into an AST
let ast = babel.parseSync(sourceCode, {
let ast = parse(sourceCode, {
sourceType: "unambiguous",
babelrc: false,
configFile: false,
});

return ast;
Expand Down
2 changes: 1 addition & 1 deletion src/transforms/astScrambler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NodePath } from "@babel/core";
import { NodePath } from "@babel/traverse";
import { PluginArg, PluginObject } from "./plugin";
import * as t from "@babel/types";
import { ok } from "assert";
Expand Down
2 changes: 1 addition & 1 deletion src/transforms/extraction/objectExtraction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NodePath } from "@babel/core";
import { NodePath } from "@babel/traverse";
import { PluginArg, PluginObject } from "../plugin";
import { Order } from "../../order";
import * as t from "@babel/types";
Expand Down
2 changes: 1 addition & 1 deletion src/transforms/flatten.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as t from "@babel/types";
import { NodePath } from "@babel/core";
import { NodePath } from "@babel/traverse";
import {
ensureComputedExpression,
getFunctionName,
Expand Down
2 changes: 1 addition & 1 deletion src/transforms/functionOutlining.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NodePath } from "@babel/core";
import { NodePath } from "@babel/traverse";
import { PluginArg, PluginObject } from "./plugin";
import { Order } from "../order";
import { ensureComputedExpression, prepend } from "../utils/ast-utils";
Expand Down
2 changes: 1 addition & 1 deletion src/transforms/identifier/globalConcealing.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as t from "@babel/types";
import { NodePath } from "@babel/core";
import { NodePath } from "@babel/traverse";
import { NameGen } from "../../utils/NameGen";
import Template from "../../templates/template";
import { PluginArg, PluginObject } from "../plugin";
Expand Down
2 changes: 1 addition & 1 deletion src/transforms/identifier/movedDeclarations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NodePath } from "@babel/core";
import { NodePath } from "@babel/traverse";
import { Order } from "../../order";
import { PluginArg, PluginObject } from "../plugin";
import { NodeSymbol, PREDICTABLE } from "../../constants";
Expand Down
2 changes: 1 addition & 1 deletion src/transforms/identifier/renameVariables.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NodePath } from "@babel/core";
import { NodePath } from "@babel/traverse";
import { Visitor } from "@babel/traverse";
import { PluginArg, PluginObject } from "../plugin";
import * as t from "@babel/types";
Expand Down
2 changes: 1 addition & 1 deletion src/transforms/lock/lock.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NodePath } from "@babel/core";
import { NodePath } from "@babel/traverse";
import { PluginArg, PluginObject } from "../plugin";
import { Order } from "../../order";
import { chance, choice } from "../../utils/random-utils";
Expand Down
2 changes: 1 addition & 1 deletion src/transforms/minify.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NodePath } from "@babel/core";
import { NodePath } from "@babel/traverse";
import { PluginArg, PluginObject } from "./plugin";
import * as t from "@babel/types";
import { Order } from "../order";
Expand Down
2 changes: 1 addition & 1 deletion src/transforms/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NodePath, PluginObj, Visitor } from "@babel/core";
import { NodePath, Visitor } from "@babel/traverse";
import Obfuscator from "../obfuscator";
import { chance, choice, getRandomString } from "../utils/random-utils";
import { Order } from "../order";
Expand Down
2 changes: 1 addition & 1 deletion src/transforms/renameLabels.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as t from "@babel/types";
import { NodePath } from "@babel/core";
import { NodePath } from "@babel/traverse";
import { PluginArg, PluginObject } from "./plugin";
import { Order } from "../order";
import { NameGen } from "../utils/NameGen";
Expand Down
2 changes: 1 addition & 1 deletion src/transforms/rgf.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NodePath } from "@babel/core";
import { NodePath } from "@babel/traverse";
import { PluginArg, PluginObject } from "./plugin";
import { Order } from "../order";
import * as t from "@babel/types";
Expand Down
2 changes: 1 addition & 1 deletion src/transforms/shuffle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NodePath } from "@babel/core";
import { NodePath } from "@babel/traverse";
import { PluginArg, PluginObject } from "./plugin";
import * as t from "@babel/types";
import { computeProbabilityMap } from "../probability";
Expand Down
2 changes: 1 addition & 1 deletion src/transforms/string/stringConcealing.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as t from "@babel/types";
import { NodePath } from "@babel/core";
import { NodePath } from "@babel/traverse";
import Template from "../../templates/template";
import { PluginArg, PluginObject } from "../plugin";
import { Order } from "../../order";
Expand Down
2 changes: 1 addition & 1 deletion src/utils/ast-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as t from "@babel/types";
import { NodePath } from "@babel/core";
import { NodePath } from "@babel/traverse";
import { ok } from "assert";
import { deepClone } from "./node";

Expand Down