Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jehna/humanify

Deobfuscate Javascript code using ChatGPT
https://github.com/jehna/humanify

Last synced: about 2 months ago
JSON representation

Deobfuscate Javascript code using ChatGPT

Awesome Lists containing this project

README

        

# Humanify
> Deobfuscate Javascript code using LLMs ("AI")

This tool uses large language modeles (like ChatGPT & llama2) and other tools to
deobfuscate, unminify, transpile, decompile and unpack Javascript code. Note
that LLMs don't perform any structural changes – they only provide hints to
rename variables and functions. The heavy lifting is done by Babel on AST level
to ensure code stays 1-1 equivalent.

### ➡️ Check out the [introduction blog post][blogpost] for in-depth explanation!

[blogpost]: https://thejunkland.com/blog/using-llms-to-reverse-javascript-minification

## Example

Given the following minified code:

```javascript
function a(e,t){var n=[];var r=e.length;var i=0;for(;i .env && npm start -- -o deobfuscated.js obfuscated-file.js
export OPENAI_TOKEN="your-token" && npm start -- -o deobfuscated.js obfuscated-file.js
OPENAI_TOKEN=your-token npm start -- -o deobfuscated.js obfuscated-file.js
npm start -- --key="your-token" -o deobfuscated.js obfuscated-file.js
```

Use your preferred way to provide the API key. Use `npm start -- --help` to see
all available options.

### llama2

Prerequisites:
* You'll need to have a Python 3 environment with [conda installed][conda].
* You need a Huggingface account with access to [llama-2-7b-chat-hf
model][llama2model]. Make sure to read the instructions on the model page
about how to access the model.

[conda]: https://docs.conda.io/projects/conda/en/stable/user-guide/install/index.html
[llama2model]: https://huggingface.co/meta-llama/Llama-2-7b-chat-hf

Run the following command to install the required Python packages and activate the environment:

```shell
conda env create -f environment.yaml
conda activate humanify
```

You can now run the tool with:

```shell
npm start -- --local -o deobfuscated.js obfuscated-file.js
```

Note: this downloads ~13gb of model data to your computer on the first run.

## Features

The main features of the tool are:
* Uses ChatGPT functions/llama2 to get smart suggestions to rename variable and
function names
* Uses custom and off-the-shelf Babel plugins to perform AST-level unmanging
* Uses Webcrack to unbundle Webpack bundles

## Contributing

If you'd like to contribute, please fork the repository and use a feature
branch. Pull requests are warmly welcome.

## Licensing

The code in this project is licensed under MIT license.