js-confuser
js-confuser copied to clipboard
Rename Variables breaks with statement
Config and Small code sample
Config:
{
target: "node",
renameVariables: true
}
Code:
var a = "Incorrect value";
with ({ a: "Correct Value" }) {
console.log(a);
}
// "Correct Value"
Obfuscated Code:
var Tru_whk = "Incorrect value";
with ({ ["a"]: "Correct Value" }) {
console["log"](Tru_whk);
}
// "Incorrect value"
Additional context
Might be easiest to disable renaming fully in with statements or not support it entirely. Since any object can be passed in, theres no way for the obfuscator to know if the name will be shadowed or not.
But then sadly you have a bunch of __p_7812057763_flat___p_1597929504_dLR_4__JS_PREDICT____JS_PREDICT__
@MichaelXF At leat can you make only rename confuser generated variables and only pre mangle my code
@MichaelXF please make a version for 1.7.4 with the option just to mangle the obfuscator generated variables and don't touch the code ones cause I want to have a minified version of obfuscated code. I cant just minify the output code because it has global variables and if I minify the obfuscated code will rename them.
All obfuscated variables start with "__p_". You can use a custom Rename Variables function to only change them. Also Rename Variables only changes names that are defined within the code, it will not change global variables (such as console, Math, or jQuery, unless you explicitly define them)
Source Code: https://github.com/MichaelXF/js-confuser/blob/19d74ddaa084f234df1c4874efb6f13f842133aa/src/constants.ts#L84
const options = {
target: "node",
renameVariables: (varName) => varName.startsWith("__p_"),
};
Other options may still change variable names, and some dead code snippets contain variables without the placeholder prefix.
what I mean is to add a temporary option to minify obfuscated generated code only, without breaking anything, cause minifiers I need to specify top level to be able to do it but I have some variables that I don't want to be top level.