Skip to content

Commit 501cd76

Browse files
authored
Merge pull request #158 from MichaelXF/new
2.0
2 parents 2dcc2c6 + 1777042 commit 501cd76

File tree

188 files changed

+18100
-26582
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

188 files changed

+18100
-26582
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ assignees: ''
99

1010
**Describe the bug:**
1111

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

1414
**Config and Small code sample**
1515

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

3131
**Expected behavior**
3232

33-
The program should output "My Small Code Sample"
33+
Example: The program should output "My Small Code Sample"
3434

3535
**Actual behavior**
3636

37-
The program stalls forever and never outputs anything
37+
Example: The program stalls indefinitely and never outputs the expected message.
3838

3939
**Additional context**
4040

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

.github/workflows/node.js.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

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

2121
steps:

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ dev.error.js
112112
dev.input.js
113113
dev.output.js
114114
dev.ts
115+
dev.profile.json
115116

116117
package-lock.json
117118

.npmignore

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Decrease NPM bunlde size
2+
src_old/
3+
test/
4+
docs/
5+
babel.config.js
6+
babel.register.js
7+
8+
9+
# Logs
10+
logs
11+
*.log
12+
npm-debug.log*
13+
yarn-debug.log*
14+
yarn-error.log*
15+
lerna-debug.log*
16+
17+
# Diagnostic reports (https://nodejs.org/api/report.html)
18+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
19+
20+
# Runtime data
21+
pids
22+
*.pid
23+
*.seed
24+
*.pid.lock
25+
26+
# Directory for instrumented libs generated by jscoverage/JSCover
27+
lib-cov
28+
29+
# Coverage directory used by tools like istanbul
30+
coverage
31+
*.lcov
32+
33+
# nyc test coverage
34+
.nyc_output
35+
36+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
37+
.grunt
38+
39+
# Bower dependency directory (https://bower.io/)
40+
bower_components
41+
42+
# node-waf configuration
43+
.lock-wscript
44+
45+
# Compiled binary addons (https://nodejs.org/api/addons.html)
46+
build/Release
47+
48+
# Dependency directories
49+
node_modules/
50+
jspm_packages/
51+
52+
coverage/
53+
54+
# TypeScript v1 declaration files
55+
typings/
56+
57+
# TypeScript cache
58+
*.tsbuildinfo
59+
60+
# Optional npm cache directory
61+
.npm
62+
63+
# Optional eslint cache
64+
.eslintcache
65+
66+
# Microbundle cache
67+
.rpt2_cache/
68+
.rts2_cache_cjs/
69+
.rts2_cache_es/
70+
.rts2_cache_umd/
71+
72+
# Optional REPL history
73+
.node_repl_history
74+
75+
# Output of 'npm pack'
76+
*.tgz
77+
78+
# Yarn Integrity file
79+
.yarn-integrity
80+
81+
# dotenv environment variables file
82+
.env
83+
.env.test
84+
85+
# parcel-bundler cache (https://parceljs.org/)
86+
.cache
87+
88+
# Next.js build output
89+
.next
90+
91+
# Nuxt.js build / generate output
92+
.nuxt
93+
dist
94+
95+
# Gatsby files
96+
.cache/
97+
# Comment in the public line in if your project uses Gatsby and *not* Next.js
98+
# https://nextjs.org/blog/next-9-1#public-directory-support
99+
# public
100+
101+
# vuepress build output
102+
.vuepress/dist
103+
104+
# Serverless directories
105+
.serverless/
106+
107+
# FuseBox cache
108+
.fusebox/
109+
110+
# DynamoDB Local files
111+
.dynamodb/
112+
113+
# TernJS port file
114+
.tern-port
115+
116+
# VS Code prettier ignore list
117+
.prettierignore
118+
119+
dev.error.js
120+
dev.input.js
121+
dev.output.js
122+
dev.ts
123+
dev.profile.json
124+
125+
package-lock.json
126+
127+
Cash.output.js
128+
129+
ES6.output.js
130+
131+
.vscode/
132+
133+
src/dev.ts
134+
135+
.DS_Store
136+

.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"tabWidth": 2,
3+
"singleQuote": false
4+
}

CHANGELOG.md

+103-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,105 @@
1+
# `2.0.0`
2+
2.0 Rewrite 🎉
3+
4+
### Complete rewrite of JS-Confuser using Babel! 🎉
5+
6+
**⚠️ Breaking changes**
7+
8+
> 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.
9+
10+
- Revamped API Interface
11+
12+
- - JSConfuser.obfuscate() resolves to an object
13+
14+
| Property | Type | Description |
15+
| --- | --- | --- |
16+
| `code` | `string` | The obfuscated code. |
17+
18+
- Renamed `Stack` to `Variable Masking`
19+
20+
- Added configurable limits to options:
21+
22+
```js
23+
const options = {
24+
target: "node",
25+
26+
rgf: {
27+
value: 0.5, // = 50% of eligible functions
28+
limit: 10 // Maximum of 10 changes for performance reasons
29+
},
30+
31+
// Original format is still valid (No limit applied)
32+
rgf: 0.5
33+
}
34+
```
35+
36+
### 2.0 Changes
37+
38+
- Added [Custom String Encoding](https://js-confuser.com/docs/options/customStringEncodings) and [Custom Lock Code](https://js-confuser.com/docs/options/customLocks) options
39+
40+
- Added `Rename Labels` [Learn more here](https://js-confuser.com/docs/options/renamelabels#rename-labels)
41+
42+
- Added `Pack` [Learn more here](https://js-confuser.com/docs/options/pack#pack)
43+
44+
- RGF no longers uses `new Function` instead uses `eval`
45+
46+
- Improved code transforms!
47+
48+
- Improved `Control Flow Flattening`
49+
50+
- - Obfuscates the [Call Graph](https://en.wikipedia.org/wiki/Call_graph)
51+
52+
- - Now supports lexical bindings (`let`, `const`, `class`)
53+
54+
- - `with () { }` statement obfuscation
55+
56+
- Improved `Minify`
57+
58+
- - Removes unused variables and functions
59+
60+
- Improved `Moved Declaration` ability to move variables as unused function parameters
61+
62+
- Improved `String` transforms
63+
64+
- - [Template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) are now obfuscated (First converted into equivalent String Literal)
65+
66+
- - [Regular expressions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions) are now obfuscated (First converted into equivalent RegExp() constructor calls)
67+
68+
- - `String Compression` now uses LZ-string compression ([lz-string](https://www.npmjs.com/package/lz-string))
69+
70+
- New Comment Syntax
71+
72+
- - `/* @js-confuser-var */ "name"` for improved variable mappings, such as eval() calls
73+
74+
```js
75+
// Input
76+
var name = "Internet User";
77+
eval( "console.log(" + /* @js-confuser-var */ "name" + ")" );
78+
79+
// Output
80+
var zC3PLKu = "Internet User";
81+
eval("console.log(" + "zC3PLKu" + ")");
82+
```
83+
84+
Note: The function `__JS_CONFUSER_VAR__` is still supported.
85+
86+
### JS-Confuser.com Revamp
87+
88+
A new UI for [JS-Confuser.com](https://js-confuser.com), featuring an advanced playground and documentation pages.
89+
90+
The previous version will remain available at [old--confuser.netlify.com](https://old--confuser.netlify.app/).
91+
92+
**Removed features**
93+
94+
- Removed `ES5` option - Use Babel Instead
95+
96+
- Removed `Browser Lock` and `OS Lock` - Use [Custom Locks](https://js-confuser.com/docs/options/customlocks#custom-locks) instead
97+
98+
- Removed `Shuffle`'s Hash option
99+
100+
- Removed `Indent` option
101+
102+
1103
# `1.7.3`
2104
Tamper Protection
3105

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

31133
- Improve `String Compression`
32134

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

35137

36138
# `1.7.2`

Migration.md

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
## Migration guide to JS-Confuser 2.0
2+
3+
JS-Confuser 2.0 is complete rewrite of the original JS-Confuser created in 2020!
4+
5+
## API Interface changed
6+
7+
### JSConfuser.obfuscate() returns an object now
8+
9+
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.
10+
11+
```diff
12+
const JSConfuser = require("js-confuser");
13+
const sourceCode = `console.log("Hello World")`;
14+
const options = {
15+
target: "node",
16+
preset: "high"
17+
};
18+
19+
JSConfuser.obfuscate(sourceCode, options).then(result=>{
20+
// 'result' is now an object
21+
- console.log(result);
22+
+ console.log(result.code);
23+
});
24+
```
25+
26+
### Removed Anti Debug Lock / Browser Lock / OS Lock
27+
28+
These features have been removed but you can still add these locks using the `lock.customLocks` option.
29+
30+
```js
31+
{
32+
target: "node",
33+
34+
// ... Your obfuscator settings ...
35+
36+
lock: {
37+
customLocks: [
38+
{
39+
code: `
40+
// This code will be sprinkled throughout your source code
41+
// (Will also be obfuscated)
42+
43+
if( window.navigator.userAgent.includes('Chrome') ){
44+
{countermeasures}
45+
}
46+
47+
// The {countermeasures} template variable is required.
48+
// Must be placed in a Block or Switch Case body
49+
`,
50+
percentagePerBlock: 0.1, // = 10%
51+
maxCount: 25, // Default = 25 - You probably don't want an excessive amount placed
52+
minCount: 1 // Default = 1 - Ensures this custom lock is placed
53+
}
54+
]
55+
}
56+
}
57+
```
58+
59+
### Stack renamed to Variable Masking
60+
61+
The option `stack` has been renamed to `variableMasking`
62+
63+
[Similar to JScrambler's Variable Masking](https://docs.jscrambler.com/code-integrity/documentation/transformations/variable-masking)
64+
65+
```diff
66+
const options = {
67+
target: "node",
68+
preset: "high"
69+
70+
- stack: true,
71+
+ variableMasking: true
72+
};
73+
```

0 commit comments

Comments
 (0)