MichaelXF / js-confuser

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

using chinese characters #150

Open slush3 opened 2 weeks ago

slush3 commented 2 weeks ago

Hi, we can make Function Names and, if necessary, Constants names even more unreadable by using Chinese characters. (This feature is not available in the current version.)

Note: I don't know if they told you about this feature, but I thought I would tell you.

doctor8296 commented 2 weeks ago

I thought zero-length characters is enough. Also we can do this by adding "dict" option like in javascript-obfuscator, contain characters to craft variables with

MichaelXF commented 1 week ago

You can write your own variable name generator by providing a function for identifierGenerator:

const options = {
  target: "node",

  // Custom variable names
  identifierGenerator: function () {
    return "$" + Math.random().toString(36).substring(7);
  },
  renameVariables: true,
};

You can implement the function however you'd like, just make sure to return valid identifiers. More info on the 2.0 docs: https://new--confuser.netlify.app/docs/options/identifiergenerator#custom-implementation

MichaelXF commented 1 week ago

Also willing to add a Chinese character mode (cause why not) if you have an implementation for it, just send it as a reply or create a PR.

Le0Developer commented 1 week ago

I've this function laying around for generating chinese characters:

function generateChineseName(length: number) {
    const names = [];
    for (let i = 0; i < length; i++)
        names.push(
            String.fromCharCode(
                Math.floor(Math.random() * (0x9fff - 0x4e00)) + 0x4e00,
            ),
        );
    return names.join("");
}

hf

doctor8296 commented 1 week ago

You can write your own variable name generator by providing a function for identifierGenerator:

const options = {
  target: "node",

  // Custom variable names
  identifierGenerator: function () {
    return "$" + Math.random().toString(36).substring(7);
  },
  renameVariables: true,
};

You can implement the function however you'd like, just make sure to return valid identifiers. More info on the 2.0 docs: https://new--confuser.netlify.app/docs/options/identifiergenerator#custom-implementation

Should custom generator return unique values?

MichaelXF commented 1 week ago

You can write your own variable name generator by providing a function for identifierGenerator:

const options = {
  target: "node",

  // Custom variable names
  identifierGenerator: function () {
    return "$" + Math.random().toString(36).substring(7);
  },
  renameVariables: true,
};

You can implement the function however you'd like, just make sure to return valid identifiers. More info on the 2.0 docs: https://new--confuser.netlify.app/docs/options/identifiergenerator#custom-implementation

Should custom generator return unique values?

Yes. The generator function will be called until a unique value is found.

https://github.com/MichaelXF/js-confuser/blob/new/src/utils/NameGen.ts#L78