Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/lockblock-dev/pkg-unpacker

Unpack any pkg application
https://github.com/lockblock-dev/pkg-unpacker

bytecode decompiler javascript-app pkg reverse-engineering unpacker

Last synced: 3 months ago
JSON representation

Unpack any pkg application

Awesome Lists containing this project

README

        

# pkg unpacker

Unpack any [pkg](https://github.com/vercel/pkg) application.

Keep in mind that this doesn't give you the full source code if the application was compiled into V8 bytecode. See [How it works](#how-it-works).

This should work with any pkg application, but errors may occur.

This app may broke at any pkg major update.

## Installation

- Install [NodeJS](https://nodejs.org).
- Download or clone the project.
- Go to the `pkg-unpacker` folder and run `npm install`.

## Usage

```console
node unpack.js [options]

Options:

-i input file name / path to the input file
-o output file name / path to the output file
--run try to run the entrypoint of the app

Examples:

– Unpack an UNIX app
$ node unpack.js -i ./pkg_app -o ./unpacked
– Unpack a Windows app
$ node unpack.js -i ./pkg_app.exe -o ./unpacked
– Unpack an UNIX app and run it
$ node unpack.js -i ./pkg_app -o ./unpacked --run
```

## Features

- Compression detection (Gzip, Brotli)
- Code evaluation
- Symlink handling
- Unpack binaries of all operating systems

## How it works

This application **DOES NOT** decompile any code. By default [pkg](https://github.com/vercel/pkg) compiles code to V8 bytecode. Extracted files will remain in this format except for assets.

Code evaluation works best with small applications. Requirements can be broken.

[pkg](https://github.com/vercel/pkg) writes the file name, path, offset, length and compression at the bottom of each binary. This application analyzes these fields, then extracts and decompresses (if compressed) all the files of the binary.

Examples:

```js
//UNIX app

{"/snapshot/pkg/index.js":{"0":[0,568],"3":[568,118]},"/snapshot/pkg":{"2":[686,12],"3":[698,117]},"/snapshot":{"2":[815,7],"3":[822,117]}} //virtual file system
,
"/snapshot/pkg/index.js" //entrypoint
,
{} //symlinks
,
{} //files dictionnary
,
0 //0: no compression, 1: Gzip, 2: Brotli
```

```js
//Windows app

{"C:\\snapshot\\pkg\\index.js":{"0":[0,568],"3":[568,118]},"C:\\snapshot\\pkg":{"2":[686,12],"3":[698,117]},"C:\\snapshot":{"2":[815,7],"3":[822,117]}} //virtual file system
,
"C:\\snapshot\\pkg\\index.js" //entrypoint
,
{} //symlinks
,
{} //files dictionnary
,
0 //0: no compression, 1: Gzip, 2: Brotli
```

## Credits

[pkg](https://github.com/vercel/pkg)

## Copyright

See the [license](/LICENSE).