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
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.
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 |
Browser Compatibility
Browser | Compatible Versions | Tested Versions | Notes |
Chrome | 80+ | 80+ | |
Firefox | 80+ | 80+ | |
Internet Explorer | 8+ | 8+ | |
Microsoft Edge | 111+ | 111+ | |
Safari | 12.1+ | 12.1+ | |
API Parameters
Example:
{
"keys": {
"accessKey": "XXXXXX",
"secretKey": "YYYYYY"
},
"applicationId": "ZZZZZZ",
"params": [
{
"name": "dotToBracketNotation",
"options": {
"mode": "INLINE"
}
}
]
}