js-confuser icon indicating copy to clipboard operation
js-confuser copied to clipboard

Template string obfuscation

Open Le0Developer opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe.

Strings inside template literals are currently not obfuscated.

For example:

console.log(`Hello World`)

Will preserve the Hello world 1:1 into the generated code without obfuscation.

Describe the solution you'd like

[!NOTE] Codeblocks below are using ´ so they are displayed correctly.

Template strings should be obfuscated, there are multiple ways to achieve this:

  • replace with normal string concats (eg ´Hello ${name}´ gets turned into "Hello " + name – where "Hello " is processed like a normal string with string concealing etc)
  • replace with string literals (eg ´Hello world´ into ´${"Hello world"}´)

Tagged function calls can be turned into regular function calls instead:

test´hello ${world}´ -> test(["hello "], world)

Le0Developer avatar Nov 26 '23 13:11 Le0Developer

This is good and needs to be fixed

MichaelXF avatar Nov 30 '23 23:11 MichaelXF

How about using babel or another tool directly instead of https://github.com/MichaelXF/js-confuser#es5 It already has all the plugins like https://babeljs.io/docs/babel-plugin-transform-template-literals so you wouldn't have to re-implement them

j4k0xb avatar Dec 17 '23 15:12 j4k0xb

How about using babel or another tool directly instead of https://github.com/MichaelXF/js-confuser#es5 It already has all the plugins like https://babeljs.io/docs/babel-plugin-transform-template-literals so you wouldn't have to re-implement them

Yes I plan to use Babel in the future, maybe for a 2.0 rewrite? I noticed Babel tools are very fast and has nice APIs that Webcrack and other projects use (ex: referenced identifiers)

MichaelXF avatar Aug 12 '24 01:08 MichaelXF