javascript-obfuscator: [BUG] Split Strings Broke Code

Info

I use webpack and webpack plugin for obfuscate. Maybe this obfuscator broke webpack code… but I didn’t sure on 100%…

Actualy, need more test. Maybe this trouble is not new and this is a duplicate…

Description

Today, I was write some code. I found what my code, after obfuscation, didn’t work. I would think what this is trouble in properties rename (how I found in readme) I will try change settings, disable all, enable and and etc.

After all tests, I found something…

If I setup ONLY property renamer - all is work fine. If I setup ONLY split strings - all is … fine? But, if I setup settings:

      renameGlobals: true,
      renameProperties: true,
      splitStrings: true,
      splitStringsChunkLength: 1, // Actualy, I test 1 and 3 values. This both call error. If this value 5 or greater all is good

I get error (check stack trace) and my code is BROKEN now.

Expected Behavior

Not broke code with too many symbols in splitStringsChunkLength

Current Behavior

If splitStringsChunkLength < 5 (tested only on 3 and 1 values) I get broken code after obfuscation.

PS: Actually I didn’t know what code really broke after that… maybe webpack, maybe code what I was write…

Steps to Reproduce

I was setup settings in tosplitStrings: true,

  1. Setup settings (look in description block)
  2. Obfuscate code
  3. Try start code
  4. Maybe you get the same error like me

I think this trouble verry … hard repeatfull. I think without code (what I can’t share currently) this trouble can be hard to repeat.

Stack trace

VM2399:formatted:287 Uncaught TypeError: _0x1368a0[("b" + "q" + "C" + "a" + "s")] is not a function
    at <anonymous>:1:10081
    at <anonymous>:1:12128
    at <anonymous>:1:46619

Minimal working example that will help to reproduce issue

I can’t share with code from current project (maybe later … if I would can do that) Now, I can give only this line with error:

        if (_0x1368a0['b' + 'q' + 'C' + 'a' + 's'](_0x1368a0['P' + 'I' + 'n' + 'z' + 'c'], _0x1368a0['P' + 'I' + 'n' + 'z' + 'c'])) {

PS: Sorry if I give too low info about all. Call and ask me if you want more info.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 37 (37 by maintainers)

Commits related to this issue

Most upvoted comments

This was introduced in 1.12.0 and will be fixed in 2.0.0 soon. Right now you can use javascript-obfuscator and webpack-obfuscator@1.11.0. Thank you for your help!

PS: this bug is a result of the invalid test that didn’t fail when I changed the order of the transformers.

I’ve just released both javascript-obfuscator@1.12.1 and webpack-obfuscator@1.12.1

If it adds comment, add @preserve or @license line to this comment and it won’t be removed after obfuscation. For the code, wrap this code with conditional comments https://github.com/javascript-obfuscator/javascript-obfuscator#conditional-comments

Obfuscated code looks like:

function (_0x3ba5ab, _0x4d6f18) {
        const _0x1d8bbf = { '_0x2dc854': 0x1 };
        console['log'](_0x1d8bbf['foobar' + 'baz']);
    }

So the property call of the object inside console.log is not renamed