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 all commits
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
10 changes: 6 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ assignees: ''

**Describe the bug:**

The program gets stuck in a infinite loop
The program enters an infinite loop and does not produce the expected output.

**Config and Small code sample**

Expand All @@ -30,12 +30,14 @@ console.log("My Small Code Sample");

**Expected behavior**

The program should output "My Small Code Sample"
Example: The program should output "My Small Code Sample"

**Actual behavior**

The program stalls forever and never outputs anything
Example: The program stalls indefinitely and never outputs the expected message.

**Additional context**

Seems the program gets stuck in a infinite loop due to Control Flow Flattening. Disabling the feature seems to rid of the bug.
Example: It appears that the issue is caused by Control Flow Flattening. Disabling this feature resolves the problem.


2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
node-version: [14.15, 16.10, 18.0, 20.16]
node-version: [18.0, 20.16, 22.11, 23.3]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ dev.error.js
dev.input.js
dev.output.js
dev.ts
dev.profile.json

package-lock.json

Expand Down
136 changes: 136 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Decrease NPM bunlde size
src_old/
test/
docs/
babel.config.js
babel.register.js


# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

coverage/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# VS Code prettier ignore list
.prettierignore

dev.error.js
dev.input.js
dev.output.js
dev.ts
dev.profile.json

package-lock.json

Cash.output.js

ES6.output.js

.vscode/

src/dev.ts

.DS_Store

4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tabWidth": 2,
"singleQuote": false
}
104 changes: 103 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,105 @@
# `2.0.0`
2.0 Rewrite 🎉

### Complete rewrite of JS-Confuser using Babel! 🎉

**⚠️ Breaking changes**

> Check out the [Migration guide](./Migration.md) on how to properly update from 1.X to 2.0. The obfuscation upgrades in 2.0 are worth the small refactoring.

- Revamped API Interface

- - JSConfuser.obfuscate() resolves to an object

| Property | Type | Description |
| --- | --- | --- |
| `code` | `string` | The obfuscated code. |

- Renamed `Stack` to `Variable Masking`

- Added configurable limits to options:

```js
const options = {
target: "node",

rgf: {
value: 0.5, // = 50% of eligible functions
limit: 10 // Maximum of 10 changes for performance reasons
},

// Original format is still valid (No limit applied)
rgf: 0.5
}
```

### 2.0 Changes

- Added [Custom String Encoding](https://js-confuser.com/docs/options/customStringEncodings) and [Custom Lock Code](https://js-confuser.com/docs/options/customLocks) options

- Added `Rename Labels` [Learn more here](https://js-confuser.com/docs/options/renamelabels#rename-labels)

- Added `Pack` [Learn more here](https://js-confuser.com/docs/options/pack#pack)

- RGF no longers uses `new Function` instead uses `eval`

- Improved code transforms!

- Improved `Control Flow Flattening`

- - Obfuscates the [Call Graph](https://en.wikipedia.org/wiki/Call_graph)

- - Now supports lexical bindings (`let`, `const`, `class`)

- - `with () { }` statement obfuscation

- Improved `Minify`

- - Removes unused variables and functions

- Improved `Moved Declaration` ability to move variables as unused function parameters

- Improved `String` transforms

- - [Template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) are now obfuscated (First converted into equivalent String Literal)

- - [Regular expressions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions) are now obfuscated (First converted into equivalent RegExp() constructor calls)

- - `String Compression` now uses LZ-string compression ([lz-string](https://www.npmjs.com/package/lz-string))

- New Comment Syntax

- - `/* @js-confuser-var */ "name"` for improved variable mappings, such as eval() calls

```js
// Input
var name = "Internet User";
eval( "console.log(" + /* @js-confuser-var */ "name" + ")" );

// Output
var zC3PLKu = "Internet User";
eval("console.log(" + "zC3PLKu" + ")");
```

Note: The function `__JS_CONFUSER_VAR__` is still supported.

### JS-Confuser.com Revamp

A new UI for [JS-Confuser.com](https://js-confuser.com), featuring an advanced playground and documentation pages.

The previous version will remain available at [old--confuser.netlify.com](https://old--confuser.netlify.app/).

**Removed features**

- Removed `ES5` option - Use Babel Instead

- Removed `Browser Lock` and `OS Lock` - Use [Custom Locks](https://js-confuser.com/docs/options/customlocks#custom-locks) instead

- Removed `Shuffle`'s Hash option

- Removed `Indent` option


# `1.7.3`
Tamper Protection

Expand Down Expand Up @@ -30,7 +132,7 @@ eval('console.log(' + 'CA1HU0' + ')');

- Improve `String Compression`

- New Web UI sneak peak: https://new--confuser.netlify.app/
- New Web UI sneak peak: https://js-confuser.com/


# `1.7.2`
Expand Down
73 changes: 73 additions & 0 deletions Migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
## Migration guide to JS-Confuser 2.0

JS-Confuser 2.0 is complete rewrite of the original JS-Confuser created in 2020!

## API Interface changed

### JSConfuser.obfuscate() returns an object now

The method `JSConfuser.obfuscate()` resolves to a object now instead of a string. This result object contains a property `code` which is the obfuscated code.

```diff
const JSConfuser = require("js-confuser");
const sourceCode = `console.log("Hello World")`;
const options = {
target: "node",
preset: "high"
};

JSConfuser.obfuscate(sourceCode, options).then(result=>{
// 'result' is now an object
- console.log(result);
+ console.log(result.code);
});
```

### Removed Anti Debug Lock / Browser Lock / OS Lock

These features have been removed but you can still add these locks using the `lock.customLocks` option.

```js
{
target: "node",

// ... Your obfuscator settings ...

lock: {
customLocks: [
{
code: `
// This code will be sprinkled throughout your source code
// (Will also be obfuscated)

if( window.navigator.userAgent.includes('Chrome') ){
{countermeasures}
}

// The {countermeasures} template variable is required.
// Must be placed in a Block or Switch Case body
`,
percentagePerBlock: 0.1, // = 10%
maxCount: 25, // Default = 25 - You probably don't want an excessive amount placed
minCount: 1 // Default = 1 - Ensures this custom lock is placed
}
]
}
}
```

### Stack renamed to Variable Masking

The option `stack` has been renamed to `variableMasking`

[Similar to JScrambler's Variable Masking](https://docs.jscrambler.com/code-integrity/documentation/transformations/variable-masking)

```diff
const options = {
target: "node",
preset: "high"

- stack: true,
+ variableMasking: true
};
```
Loading