A tool to detect and deobfuscate JavaScript code obfuscated using the P.A.C.K.E.R. method. The `JsUnpacker` class can identify obfuscated code and convert it back to its original readable form.
npm install js-unpacker
JsUnpacker class can identify obfuscated code and convert it back to its original readable form.
bash
npm install js-unpacker
`
Usage
`javascript
const JsUnpacker = require('js-unpacker');
const packedJS = "eval(function(p,a,c,k,e,d){...}('packed code',...,...,'symbols|split|by|pipe'))";
const unpacker = new JsUnpacker(packedJS);
if (unpacker.detect()) {
const unpackedCode = unpacker.unpack();
console.log(unpackedCode);
} else {
console.log("Code doesn't appear to be P.A.C.K.E.R. obfuscated");
}
`
API
$3
#### Constructor
`javascript
new JsUnpacker(packedJS)
`
- packedJS: String - Obfuscated JavaScript code
#### Methods
| Method | Returns | Description |
|-------------|---------------|-------------|
| detect() | boolean | Returns true if code appears to be P.A.C.K.E.R. obfuscated |
| unpack() | string|null | Attempts to deobfuscate code, returns readable version or null if failed |
Example
`javascript
const packedCode = "eval(function(p,a,c,k,e,r){...}('0 1=2',3,3,'var|foo|42'.split('|'),0,{}))";
const unpacker = new JsUnpacker(packedCode);
if (unpacker.detect()) {
console.log(unpacker.unpack());
// Output: var foo=42
}
`
How It Works
The unpacker:
1. Detects the P.A.C.K.E.R. pattern: eval(function(p,a,c,k,e,`