No description
Find a file
Daniel Bulant 95afabfb3f
use text content where possible; speedup
major speedup by not reading the file fully each iteration for each time, as the offset doesn't change.
prefer to use text content where possible, although pkg defaults to blob only for normal sources, there's an option to store both blob and text (and dependencies sometimes have only text), so let's default to text so it's more readable.
possibly add --prefer-blob to use the old behaviour if that's needed by anyone.
2022-11-27 14:33:38 +01:00
.github initial commit 2022-08-04 17:48:35 +02:00
.gitignore initial commit 2022-08-04 17:48:35 +02:00
LICENSE initial commit 2022-08-04 17:48:35 +02:00
package.json initial commit 2022-08-04 17:48:35 +02:00
README.md initial commit 2022-08-04 17:48:35 +02:00
unpack.js use text content where possible; speedup 2022-11-27 14:33:38 +01:00

pkg unpacker

Unpack any 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.

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

This app may broke at any pkg major update.

Installation

  • Install NodeJS.
  • Download or clone the project.
  • Go to the pkg-unpacker folder and run npm install.

Usage

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 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 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:

//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
//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

See the license.