Skip to content

[Improvement] Numbers to expressions improvement #773

Open

Description

@da411d

Hello!
I have some ideas how to improve numbersToExpressions feature.
One of pros it that code will become uglier and also it will be harder to parse it with regex, as it does javascript-deobfuscator 😏


I think this construction is familiar to you:

const a = ("foo", "bar");

It is not kind of array or similar, it is just chain of literals, so result will be the last - a == "bar".

So, my idea is to replace some number literals to this construction.

// Before:
-0xd93 + -0x10b4 + 0x41 * 0x67

// After
-0xd93 + (-0xff8, -0x10b4) + 0x41 * 0x67

And second idea is even for all numbers.
Use different number formats.
Not only hexadecomal, but also decimal, binary and octal:

// Before:
-0x377 * 0x1 + 0x1 * 0x1871 + -0x1e * 0xb3

// After
-887 * 0x1 + 0x1 * 0o14161 + -0b11110 * 0xb3

// Uppercase - even uglier=)
-887 * 0X1 + 0X1 * 0O14161 + -0B11110 * 0XB3

Activity

  1. sanex3339 commented on Oct 10, 2020

    @sanex3339
    Member

    So. It's a slightly different thing. The type of number view does not relate with numbersToExpressions option.
    It just could be an enhancement of base numbers transformation.

    But here is a problem. If I will just randomly transform number to one of the number formats, it can be hard to test it, because right now all tests with numbers depend on the hexadecimal format.

  2. da411d commented on Oct 10, 2020

    @da411d
    ContributorAuthor

    It can be moved to another option like numbersFormats (array) with list of supported formats

  3. sanex3339 commented on Oct 10, 2020

    @sanex3339
    Member

    Hmm. Looks good to me.

  4. rmcf commented on Aug 28, 2023

    @rmcf

    I tried to use “numbersToExpressions” option, but received “not obfuscated” results in some cases:

    // 1. OBJECT PROPERTY: number without decimals
    const data = {value: 54} // input
    const data={'value':0x36}; // output
    // 2. OBJECT PROPERTY: number with decimals in array
    const data = {value: [54.8543]} // input
    const data={'value':[0x2*0x11f2+-0x21a6+0xd*-0x28+0.8543000000000021]} // output
    // 3. OBJECT PROPERTY: number with decimals
    const data = {value: 54.8543} // input
    const data={'value':54.8543} // output
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