mervick/javascript-unpacker

PHP helper that makes easy to unpack JavaScript code packed by Dean Edwards packer tool

v1.0.1 2015-11-12 13:34 UTC

This package is not auto-updated.

Last update: 2024-11-09 18:11:46 UTC


README

Makes easy to unpacking JavaScript code packed by Dean Edwards packer tool. Supports of all known encodings. The input script may contain multiple encoded code blocks, mixes with the non-encoded code, and is also supported for repeatedly encoded code.

Installation via Composer

composer require "mervick/javascript-unpacker"

Usage

echo JavaScriptUnpacker::unpack(file_get_contents('/path/to/packed.js'));

Unpack JavaScript via PHP eval(function(p,a,c,k,e,d)

$js =<<<JS
eval(function(p,a,c,k,e,r){e=String;if(!''.replace(/^/,String)){while(c--)r[c]=k[c]||c;k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('0.1(\'2 3!\');',4,4,'console|log|Hello|world'.split('|'),0,{}));
JS;

echo JavaScriptUnpacker::unpack($js);
// output: console.log('Hello world!');;

Requirements

PHP >= 5.4

License

MIT