MichaelXF / js-confuser

JS-Confuser is a JavaScript obfuscation tool to make your programs *impossible* to read.
https://js-confuser.com
MIT License
218 stars 32 forks source link

Question about Excluding Functions from Obfuscation #143

Open tonyy9981 opened 1 week ago

tonyy9981 commented 1 week ago

Hi there,

I am using js-confuser for obfuscating my JavaScript code, and I have a question regarding excluding certain functions from the obfuscation process.

Is there an option or feature available that allows me to exclude specific functions (e.g., upload) from being obfuscated? If so, could you please provide guidance on how to implement this?

Thank you for your help!

MichaelXF commented 1 week ago

You can use custom implementations to exclude the function transforms applying. This depends on what obfuscations you want for the upload function.

// Options.js
module.exports = {
  target: 'browser',

  // Versions 1.7.3 and below
  stack: (fnName) => fnName != 'upload',

  // Versions 2.0.0-alpha.2 and up ('stack' was renamed to 'variableMasking')
  variableMasking: (fnName) => fnName != 'upload', 

  // Other function transforms
  flatten: (fnName) => fnName != 'upload',
  dispatcher: (fnName) => fnName != 'upload',
  renameVariables: (fnName) => fnName != 'upload',
};

Nested functions within upload could be obfuscated and strings/variables inside the function could still be obfuscated.

Do you want the function to be completely unobfuscated? Because you could simply not run that through JS-Confuser and re-include that back in.