Skip to content

Broken After 0.24 #542

Closed
Closed

Description

@beeing

After updating the lib, there's a chance that the String Array does not work correctly.

I tested below code in obfuscator.io

rows.forEach((row, index) => {
  if (o.val) fn(` CONTENT ${o.val}`)
})
  • String Array
    • Rotate
    • Shuffle
    • Base64 Encoding
    • Threshold - 0.5
  • Split String Chunk: 15

The above will generate (result differs for each run):

rows['forEach']((c, d) => {
    if (o[b('0x0')])
        fn('\x20CONTENT\x20' + o['val']);
});
rows['forEach']((c, d) => {
    if (o[b('0x1')])
        fn(b('0x0') + o['val']);
});
rows['forEach']((c, d) => {
    if (o['val'])
        fn(b('0x1') + o[b('0x0')]);
});

I was expecting the code to be below instead.

    if (o[b('0x0')])
        fn(b('0x1') + o[b('0x0')]);

Activity

  1. sanex3339 commented on Feb 3, 2020

    @sanex3339
    Member

    And what is wrong?

  2. sanex3339 commented on Feb 3, 2020

    @sanex3339
    Member

    If you worried about different indexes for string array calls, it is ok, because shuffleStringArray option is enabled.

  3. sanex3339 commented on Feb 3, 2020

    @sanex3339
    Member

    For example, i tested with the following code:

    const rows = [
        {
            val: 'foo'
        },
        {
            val: 'bar'
        },
        {
            val: 'baz'
        }
    ];
    
    rows.forEach((row, index) => {
      console.log(`CONTENT ${row.val}`);
    })
    

    And everything is ok. Order of logs is correct: 'foo', 'bar', 'baz'

  4. beeing commented on Feb 3, 2020

    @beeing
    Author

    Thanks for the quick reply. Actually you need to add the if before the console.log.

    It is ok if it does not break anything but for my case, it broke my tests.

    There are no errors but the code after the if is not executed.

  5. sanex3339 commented on Feb 3, 2020

    @sanex3339
    Member

    Can you show me a standalone small example, that is worked before obfuscation and does not work after?

    Because even with a condition, the following code works fine for me:

    const rows = [
        {
            val: 'foo'
        },
        {
            val: 'bar'
        },
        {
            val: ''
        },
        {
            val: 'baz'
        }
    ];
    
    
    rows.forEach((row, index) => {
      if (row.val)
        console.log(`CONTENT ${row.val}`);
    })
    
  6. sanex3339 commented on Feb 4, 2020

    @sanex3339
    Member

    The problem looks the same as here:
    #496

    Can you try to search for a minimum standalone example that will reproduce this error?

    Also, try to disable shuffleStringArray. Will it help? If not, set all options to false and try again

  7. beeing commented on Feb 4, 2020

    @beeing
    Author

    I've been trying to reproduce a simpler example however not able to reproduce. The source that I have i quite complex which I'm trying to find the pattern that causes it.

    Similar to #496 there is no error but produces a wrong result due to the if condition is not met.

    My initial suspect was the if condition was wrongly replaced.

  8. sanex3339 commented on Feb 4, 2020

    @sanex3339
    Member

    Try to play with options as I said before. We should find as many hints as possible

  9. beeing commented on Feb 4, 2020

    @beeing
    Author

    I've turned off every as below and still having wrong results.

        target: 'node',
        compact: false,
        controlFlowFlattening: false,
        deadCodeInjection: false,
        debugProtection: false,
        debugProtectionInterval: false,
        disableConsoleOutput: false,
        identifierNamesGenerator: 'mangled',
        log: false,
        renameGlobals: false,
        rotateStringArray: false,
        selfDefending: false,
        sourceMap: false,
        splitStrings: false,
        splitStringsChunkLength: 15,
        stringArray: false,
        stringArrayEncoding: 'base64',
        stringArrayThreshold: 0.9,
        shuffleStringArray: false,
        transformObjectKeys: false,
        unicodeEscapeSequence: false

    If you want, I can email you a sample as my code and the result.

  10. sanex3339 commented on Feb 4, 2020

    @sanex3339
    Member

    It will be nice! Send it on sanex3339 a t yandex.ru

  11. beeing commented on Feb 4, 2020

    @beeing
    Author

    Finally, found the issue here:

    function run(aaa, { missing = '' } = {}) {
        let q = `run ${aaa} `;
        if (missing)
            q += ` SOMETHING ${missing}`;
        return q;
    }
    
    console.log(run('dummy', { missing: 'IMPORTANT' }))

    The { missing } is renamed but the outside calling function is still using the same signature.

  12. sanex3339 commented on Feb 4, 2020

    @sanex3339
    Member

    Nice!

  13. sanex3339 commented on Feb 4, 2020

    @sanex3339
    Member

    PR with the fix #544

  14. sanex3339 commented on Feb 4, 2020

    @sanex3339
    Member

    Please, try 0.24.5 version

  15. sanex3339 commented on Feb 4, 2020

    @sanex3339
    Member

    Reopened until approve from your side

  16. sanex3339 commented on Feb 5, 2020

    @sanex3339
    Member

    It was fixed there:
    #496

    So expect that it was fixed here too

  17. sanex3339 commented on Feb 5, 2020

    @sanex3339
    Member

    Comment here if this problem will happen again

  18. beeing commented on Feb 5, 2020

    @beeing
    Author

    Yes. Just tested and it looks good so far. Thanks for the quick fixes!

  19. sanex3339 commented on Feb 5, 2020

    @sanex3339
    Member

    Nice! Thank you for investigating the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions