MichaelXF / js-confuser

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

Node _dirname becomes undefined #131

Closed clubside closed 2 months ago

clubside commented 4 months ago

Describe the bug:

The Electron project won't start because the Node variable __dirname becomes undefined once run through js-confuser.

Config and Small code sample

Config:

{
  target: "node",
  preset: "medium"
}

Code:

const mainWindowOptions = {
    width: 800,
    height: 600,
    icon: 'build/icon.png',
    webPreferences: {
        preload: path.join(__dirname, 'preload.js'),
        nodeIntegration: false,
        enableRemoteModule: false,
        contextIsolation: true,
        sandbox: true,
        autoHideMenuBar: true,
        webviewTag: true
    }
}

Expected behavior

The program should be able to create a path to a file based on the working directory.

Actual behavior

Program won't start:

App threw an error during load
TypeError: Cannot read properties of undefined (reading '__dirname')       
    at Xge_5_ (*** path to file***\main.js:1:38379)
    at Object.<anonymous> (*** path to file***\main.js:1:13041) 
    at Module._compile (node:internal/modules/cjs/loader:1391:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1451:10)   
    at Module.load (node:internal/modules/cjs/loader:1214:32)
    at Module._load (node:internal/modules/cjs/loader:1030:12)
    at c._load (node:electron/js2c/node_init:2:13672)
    at cjsLoader (node:internal/modules/esm/translators:360:17)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:305:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)

Additional context

The internal node variable __dirname is no longer recognized.

MichaelXF commented 2 months ago

Disable globalConcealing until next release