Dot to Bracket Notation

Potency Low
Resilience Low
Cost Low
Tags: dot, bracket, array

Description

Dot to Bracket Notation transforms composite references in dot notation into square bracket notation. Optionally, this transformation may also extract some of the property strings into arrays.

Code Annotation Example

// @jscrambler define dotToBracketNotation { mode: "<insert mode here>" } as dbn
// @jscrambler enable dbn

If no mode is specified, then GLOBAL mode is used.

Example

The following example is a composite reference in dot notation:

navigator.plugins.length

After transformation in INLINE mode, the composite reference is in square bracket notation

navigator["plugins"]["length"];

Consider combining this transformation with Duplicate Literals Removal to replace the string literals with variables (aliases) that will make the resulting code more resilient to automated de-obfuscator tools.

Information about modes

Dot to bracket notation has three modes of operation. In INLINE mode, all generated property accesses reference the property name directly (e.g., navigator["plugins"]). In GLOBAL mode, the property names are stored in a global array (e.g., x8dg = ["plugins"]; ... navigator[x8dg[0]]). In LOOP_INVARIANT mode, property names outside of loops are treated as INLINE, but property names inside loops are extracted to an array that is specific to each function.

If no mode is specified, then INLINE is used. The built-in templates use GLOBAL mode.

Option Types

Name Required Default Value Description
mode No INLINE Transformation Modes
options No [] List of available options

Mode

Name Description
GLOBAL Extract and reuse property names to a global scope
LOOP_INVARIANT Reuse property names on loops and extract them to the function scope
INLINE Do not extract and/or reuse property names

Options

Name Description
ignoreClassMethods Do not target class methods.

Browser Compatibility

Browser Compatible Versions Tested Versions Notes
Chrome 80+ 80+
Firefox 90+ 90+
Internet Explorer 8+ 8+
Microsoft Edge 116+ 116+
Safari 13.1+ 13.1+

API Parameters

Example:

{
  "keys": {
    "accessKey": "XXXXXX",
    "secretKey": "YYYYYY"
  },
  "applicationId": "ZZZZZZ",
  "params": [
    {
      "name": "dotToBracketNotation",
      "options": {
        "mode": "INLINE",
        "options": []
      }
    }
  ]
}