Skip to content

scottvr/maxify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 

Repository files navigation

maxify

Maxify is a command-line tool that automates the unpacking and deminification of JavaScript projects from sourcemap files (with sourcesContent keys).

When such a need arose for me, searching the obvious terms yielded only many, many online "paste javascript here" BeautifyJS-type sites and nothing that would actually extract multiple files and write them to my disk. Maxify recreates the original directory structure of the minified/uglified js app and unpacks all source files to their unminified, human-readable form - ideal for debugging, reverse engineering, or forensic analysis.

update

This tool came about when for some reason I had a map file in my home directory, with no corresponding source. Opening it I found that it had a base64-encoded string that indicated it was probably the URL to the source. So I got curious, and by the time I was finished I had aa weirdly specific tool, and told myself it wasn't a waste of time because now the next time I encountered such a situation, the work will be automatable. That waas two years ago and I have never encountered the situation again since. So I have updated it to try to make it useful. It now takes a map or a source or both, and does its best to restore the source to its readable original state, even if the paths are relative and would refer to a file up five parant directories from where you are and back down into soe other directory by trying to find it locally, or at a url, if any, was gleaned from its innput.

usage:

maxifier.py [-h] [-v] [-a [INPUT]] [-m MAP] [-f FILE] [-o OUT_DIR] [input]

Recreate unminified source paths on disk from (json) .map file

positional arguments:

input Map or JS reference (http(s), file://, or local path).

options:

-h, --help show this help message and exit

-a [INPUT], --auto [INPUT], --auto_map [INPUT] Auto-resolve the missing map/js pair. Optional INPUT keeps legacy --auto_map INPUT usage.

-m MAP, --map MAP Sourcemap reference (http(s), file://, local path, or base64 data URL).

-f FILE, --file FILE JavaScript file reference (http(s), file://, or local path).

-o OUT_DIR, --out_dir OUT_DIR Directory to save extracted files

-v, --verbose Enable verbose output

Examples:

cat /tmp/json.map | python ./maxifier.py -v
maxifier.py app.js.map -o ./output_dir
maxifier.py app.js -a -o ./output_dir
maxifier.py --auto file:///Users/me/build/app.js -o ./output_dir
maxifier.py --map https://example.com/scripts/app.js.map --file ./app.js -a -o ./output_dir

Additional info:

With -a/--auto, maxify does best-effort pairing:

  • From JS -> checks X-SourceMap/SourceMap headers (for HTTP), then //# sourceMappingURL=..., then tries a default <js>.map.
  • From map -> checks the sourcemap file field, then tries the map filename without the .map suffix.
  • If a discovered reference fails (404/ENOENT), maxify also tries a same-basename fallback in the current working directory.

If you already have a json .map file, maxify can read it directly.

License

MIT

Contributions

Certainly.

About

Maxify is a command-line tool that automates the unpacking and deminification of JavaScript projects from sourcemap files.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages