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

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

API Parameters

Example:

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