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

TypeError

Open Krex38 opened this issue 3 years ago • 9 comments

Describe the bug:

TypeError: Cannot read properties of null (reading 'type')

Config and Small code sample

Too Big

Code:

Too big can't upload

Expected behavior

The Program should be obfuscated successfully

Actual behavior

Not Obfusacting

Krex38 avatar Aug 24 '22 10:08 Krex38

Hi, can you provide the entire error stack so I can understand better

MichaelXF avatar Aug 24 '22 15:08 MichaelXF

Hi, can you provide the entire error stack so I can understand better

i'm only getting the same error

Krex38 avatar Aug 24 '22 16:08 Krex38

I mean please show the stack trace. It should appear like this: (example)

/Users/michael/Desktop/test/node_modules/js-confuser/dist/index.js:89
    throw new TypeError("code must be type string");
          ^

TypeError: code must be type string
    at JsConfuser (/Users/michael/Desktop/test/node_modules/js-confuser/dist/index.js:89:11)
    at Object.obfuscate (/Users/michael/Desktop/test/node_modules/js-confuser/dist/index.js:56:16)
    at Object.<anonymous> (/Users/michael/Desktop/test/index.js:3:12)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47

MichaelXF avatar Aug 24 '22 16:08 MichaelXF

Oh here

C:\Users\onmaz\Downloads\Krex Priv Gr@bber\Priv\node_modules\js-confuser\dist\transforms\controlFlowFlattening\switchCaseObfuscation.js:31
    return object.type == "SwitchStatement" && !object.cases.find(x => !(x.test.type == "Literal" && typeof x.test.value === "number" && Math.abs(x.test.value) < 100000));
                                                                                ^

TypeError: Cannot read properties of null (reading 'type')
    at C:\Users\onmaz\Downloads\Krex Priv Gr@bber\Priv\node_modules\←[4mjs-confuser←[24m\dist\transforms\controlFlowFlattening\switchCaseObfuscation.js:31:81
    at Array.find (<anonymous>)
    at SwitchCaseObfuscation.match (C:\Users\onmaz\Downloads\Krex Priv Gr@bber\Priv\node_modules\←[4mjs-confuser←[24m\dist\transforms\controlFlowFlattening\switchCaseObfuscation.js:31:62)
    at SwitchCaseObfuscation.input (C:\Users\onmaz\Downloads\Krex Priv Gr@bber\Priv\node_modules\←[4mjs-confuser←[24m\dist\transforms\transform.js:189:14)
    at C:\Users\onmaz\Downloads\Krex Priv Gr@bber\Priv\node_modules\←[4mjs-confuser←[24m\dist\transforms\transform.js:141:21
    at walk (C:\Users\onmaz\Downloads\Krex Priv Gr@bber\Priv\node_modules\←[4mjs-confuser←[24m\dist\traverse.js:59:18)
    at walk (C:\Users\onmaz\Downloads\Krex Priv Gr@bber\Priv\node_modules\←[4mjs-confuser←[24m\dist\traverse.js:76:15)
    at walk (C:\Users\onmaz\Downloads\Krex Priv Gr@bber\Priv\node_modules\←[4mjs-confuser←[24m\dist\traverse.js:65:13)
    at walk (C:\Users\onmaz\Downloads\Krex Priv Gr@bber\Priv\node_modules\←[4mjs-confuser←[24m\dist\traverse.js:76:15)
    at walk (C:\Users\onmaz\Downloads\Krex Priv Gr@bber\Priv\node_modules\←[4mjs-confuser←[24m\dist\traverse.js:76:15)

Krex38 avatar Aug 25 '22 08:08 Krex38

Thanks I will get to working on this soon. It seems to do with Switch statements with default cases.

MichaelXF avatar Aug 25 '22 15:08 MichaelXF

Thanks I will get to working on this soon. It seems to do with Switch statements with default cases.

oh ok

Krex38 avatar Aug 25 '22 16:08 Krex38

Sounds like #45 which is closed. @Krex38 can you still reproduce the issue? If so, can you try to get a minimal reproduction case?

Le0Developer avatar Jan 18 '23 14:01 Le0Developer

I'm running into this same issue. I don't know if it helps, but I got a different error that the maximum call stack was exceeded when I tried to add verbose: true to the options. There are some decently big files that I'm working with. They're all chunked by webpack, but it always fails in the same spot. I've tried adjusting options to no avail. I'm on the latest version.

kitsune7 avatar Feb 10 '23 19:02 kitsune7

Using the low preset, but setting minify and compact to false seemed to fix the issue for me.

kitsune7 avatar Feb 10 '23 20:02 kitsune7

Closing for now, feel free to reopen

MichaelXF avatar Sep 30 '24 15:09 MichaelXF