Skip to content

Commit

Permalink
docs: add unminify examples
Browse files Browse the repository at this point in the history
  • Loading branch information
j4k0xb committed Dec 17, 2023
1 parent 148f78d commit 4f080e3
Show file tree
Hide file tree
Showing 6 changed files with 209 additions and 39 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Test](https://github.com/j4k0xb/webcrack/actions/workflows/test.yml/badge.svg)](https://github.com/j4k0xb/webcrack/actions/workflows/test.yml)
[![Test](https://github.com/j4k0xb/webcrack/actions/workflows/ci.yml/badge.svg)](https://github.com/j4k0xb/webcrack/actions/workflows/test.yml)
[![npm](https://img.shields.io/npm/v/webcrack)](https://www.npmjs.com/package/webcrack)
[![license](https://img.shields.io/github/license/j4k0xb/webcrack)](https://github.com/j4k0xb/webcrack/blob/master/LICENSE)
[![Netlify Status](https://api.netlify.com/api/v1/badges/ba64bf80-7053-4ed8-a282-d3762742c0dd/deploy-status)](https://app.netlify.com/sites/webcrack/deploys)
Expand All @@ -16,7 +16,7 @@ to resemble the original source code as much as possible.

Try it in the [online playground](https://webcrack.netlify.app/) or view the [documentation](https://webcrack.netlify.app/docs).

- 🚀 **Performance** - 500% faster than [synchrony](https://github.com/relative/synchrony)
- 🚀 **Performance** - Various optimizations to make it fast
- 🛡️ **Safety** - Considers variable references and scope
- 🔬 **Auto-detection** - Finds code patterns without needing a config
- ✍🏻 **Readability** - Removes obfuscator/bundler artifacts
Expand Down
6 changes: 1 addition & 5 deletions apps/docs/src/concepts/deobfuscate.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Deobfuscation

## javascript-obfuscator

The most popular obfuscator ([GitHub](https://github.com/javascript-obfuscator/javascript-obfuscator), [obfuscator.io](https://obfuscator.io)).

webcrack can deobfuscate code obfuscated with the following options (pretty much all available ones):
webcrack can deobfuscate code obfuscated with [javascript-obfuscator](https://github.com/javascript-obfuscator/javascript-obfuscator) ([obfuscator.io](https://obfuscator.io))

- String Array
- Rotate
Expand Down
211 changes: 199 additions & 12 deletions apps/docs/src/concepts/unminify.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,204 @@ Bundlers and obfuscators commonly minify code (remove new lines and whitespace,

Most unminify sites just format the code, but webcrack also converts the syntax back to make it more readable and similar to the original code:

## block-statement

```js
if (a) b(); // [!code --]
if (a) { // [!code ++]
b(); // [!code ++]
} // [!code ++]
```

## computed-properties

```js
console["log"](a); // [!code --]
console.log(a); // [!code ++]
```

## infinity

```js
1 / 0 // [!code --]
Infinity // [!code ++]
```

### json-parse

```js
JSON.parse("[1,2,3]") // [!code --]
[1, 2, 3] // [!code ++]
```

## logical-to-if

```js
x && y && z(); // [!code --]
if (x && y) { // [!code ++]
z(); // [!code ++]
} // [!code ++]
```

```js
x || y || z(); // [!code --]
if (!(x || y)) { // [!code ++]
z(); // [!code ++]
} // [!code ++]
```

## merge-else-if

```js
if (x) {
} else { // [!code --]
if (y) {} // [!code --]
} // [!code --]

if (x) {
} else if (y) {} // [!code ++]
```

## merge-strings

```js
"a" + "b" + "c" // [!code --]
"abc" // [!code ++]
```

## number-expressions

```js
-0x1021e + -0x7eac8 + 0x17 * 0xac9c // [!code --]
431390 // [!code ++]
```

## raw-literals

```js
'\x61"\u270F\uFE0F\t' // [!code --]
"a\"✏️\t" // [!code ++]
```

```js
0x1 // [!code --]
1 // [!code ++]
```

## sequence

```js
if (a) b(), c(); // [!code --]
if (a) { // [!code ++]
b(); // [!code ++]
c(); // [!code ++]
} // [!code ++]
```

```js
if (a(), b()) c(); // [!code --]
a(); // [!code ++]
if (b()) { // [!code ++]
c(); // [!code ++]
} // [!code ++]
```

```js
return a(), b(), c(); // [!code --]
a(); // [!code ++]
b(); // [!code ++]
return c(); // [!code ++]
```

```js
for (let key in a = 1, object) {} // [!code --]
a = 1; // [!code ++]
for (let key in object) {} // [!code ++]
```

```js
for((a(), b());;) {} // [!code --]
a(); // [!code ++]
b(); // [!code ++]
for(;;) {} // [!code ++]
```

```js
for(; i < 10; a(), b(), i++) {} // [!code --]
for(; i < 10; i++) { // [!code ++]
a(); // [!code ++]
b(); // [!code ++]
} // [!code ++]
```

```js
t = (o = null, o); // [!code --]
o = null; // [!code ++]
t = o; // [!code ++]
```

## split-variable-declarations

```js
const a = 1, b = 2, c = 3; // [!code --]
const a = 1; // [!code ++]
const b = 2; // [!code ++]
const c = 3; // [!code ++]
```

## template-literals

<https://babeljs.io/docs/babel-plugin-transform-template-literals>

```js
"'".concat(foo, "' \"").concat(bar, "\"") // [!code --]
`'${foo}' "${bar}"` // [!code ++]
```

## ternary-to-if

```js
a ? b() : c(); // [!code --]
if (a) { // [!code ++]
b(); // [!code ++]
} else { // [!code ++]
c(); // [!code ++]
} // [!code ++]
```

```js
return a ? b() : c(); // [!code --]
if (a) { // [!code ++]
return b(); // [!code ++]
} else { // [!code ++]
return c(); // [!code ++]
} // [!code ++]
```

## unminify-booleans

```js
!0 // [!code --]
true // [!code ++]
```

```js
!1 // [!code --]
false // [!code ++]
```

## void-to-undefined

```js
void 0 // [!code --]
undefined // [!code ++]
```

## yoda

<https://eslint.org/docs/latest/rules/yoda> and <https://babeljs.io/docs/en/babel-plugin-minify-flip-comparisons>

```js
console['\x6c\x6f\x67']('\x61'); // console.log('a')
x && y && z(); // if (x && y) z();
x || y || z(); // if (!(x || y)) z();
!0; // true
!1; // false
![]; // false
!![]; // true
return a(), b(), c(); // a(); b(); return c();
if ((a(), b())) c(); // a(); if (b()) c();
void 0; // undefined
'red' === color; // color === 'red'
JSON.parse('{"a":1}'); // { a: 1 }
"red" === color // [!code --]
color === "red" // [!code ++]
```
25 changes: 7 additions & 18 deletions apps/docs/src/guide/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,18 @@ It can deobfuscate [obfuscator.io](https://github.com/javascript-obfuscator/java
and unpack [webpack](https://webpack.js.org/)/[browserify](https://browserify.org/),
to resemble the original source code as much as possible.

- 🚀 **Performance** - 500% faster than [synchrony](https://github.com/relative/synchrony)
- 🚀 **Performance** - Various optimizations to make it fast
- 🛡️ **Safety** - Considers variable references and scope
- 🔬 **Auto-detection** - Finds code patterns without needing a config
- ✍🏻 **Readability** - Removes obfuscator/bundler artifacts
- ⌨️ **TypeScript** - All code is written in TypeScript
- 🧪 **Tests** - To make sure nothing breaks

## Platforms

| Platform | Deobfuscate | Unminify | Unpack | Configurable |
| -------- | ----------- | -------- | ------ | ------------ |
| node |||||
| cli |||| 🚧 |
| web |||| 🚧 |

🚧: only the `mangle` option can be toggled as of now

## Planned Features

- support older obfuscator.io versions
- unpack `rollup`, `parcel`, `swc`, etc.
- unpack multi-chunk bundles
- download zip of all unpacked modules in the playground
- convert [@babel/preset-env](https://babeljs.io/docs/babel-preset-env) helpers to modern syntax
- decompile typescript enums
- decompile other frontend frameworks: `vue`, `svelte`, etc.
- Support older obfuscator.io versions
- Unpack `rollup`, `parcel`, `swc`, etc.
- Unpack multi-chunk bundles
- Download zip of all unpacked modules in the playground
- Convert [@babel/preset-env](https://babeljs.io/docs/babel-preset-env) helpers to modern syntax
- Decompile typescript enums
1 change: 0 additions & 1 deletion apps/playground/README.md

This file was deleted.

1 change: 0 additions & 1 deletion packages/webcrack/README.md

This file was deleted.

0 comments on commit 4f080e3

Please sign in to comment.