j4k0xb / webcrack

Deobfuscate obfuscator.io, unminify and unpack bundled javascript
https://webcrack.netlify.app
MIT License
647 stars 73 forks source link

FeatReq | Extend webcrack instance #48

Open gokaybiz opened 6 months ago

gokaybiz commented 6 months ago

It'd be great If we can extend rules/scripts. Depends on choice, before or after deobfuscation.

For example:

import {
    webcrack
} from 'webcrack';

const result = await webcrack(input);
result.code.extend(async ({
    types
}) => {
    Identifier(path) {
        //....
    }
});
console.log(result.code)
j4k0xb commented 6 months ago

Sounds like a good idea I'd rather pass them as options so it works with async and can edit the AST directly instead of having to parse/generate result.code again And also change the format to be compatible with babel plugins (https://babeljs.io/docs/plugins#plugin-development)

How about such an API?

function myPlugin({ types }) {
  return {
    runAfter: 'deobfuscate', // 'parse' | 'prepare' | 'unminify' | 'deobfuscate' | 'unpack'
    visitor: {
      Identifier(path) {}
    },
  };
}

const result = await webcrack(input, { plugins: [myPlugin] });
console.log(result.code);
0xdevalias commented 5 months ago

And also change the format to be compatible with babel plugins

I 🖤 that idea!

gokaybiz commented 5 months ago

Sounds like a good idea I'd rather pass them as options so it works with async and can edit the AST directly instead of having to parse/generate result.code again And also change the format to be compatible with babel plugins (https://babeljs.io/docs/plugins#plugin-development)

How about such an API?

function myPlugin({ types }) {
  return {
    runAfter: 'deobfuscate', // 'parse' | 'prepare' | 'unminify' | 'deobfuscate' | 'unpack'
    visitor: {
      Identifier(path) {}
    },
  };
}

const result = await webcrack(input, { plugins: [myPlugin] });
console.log(result.code);

Great!