Command Line
Synopsis
Splits a command line string into its argument array, using the Windows quoting rules that CommandLineToArgvW applies.
Schema
- command_line:
field: <ident>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>
target_field: <ident>
Configuration
The following fields are used to define the processor:
| Field | Required | Default | Description |
|---|---|---|---|
field | Y | - | Field containing the command line string |
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | See Handling Failures |
ignore_missing | N | false | If true, quietly exit if field doesn't exist |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
tag | N | - | Identifier |
disabled | N | false | When true, the processor is skipped and the event continues to the next one. Lets you take a processor out of the path without removing its configuration |
target_field | N | field | Field to store the argument array. Defaults to field, replacing the command line string |
Details
These are the Windows rules, not shell rules, and the difference matters when reading process-creation telemetry. A backslash is only an escape character when it precedes a quote; elsewhere it is an ordinary character, which is why a Windows path such as C:\Windows\System32 survives unescaped. Two backslashes before a quote produce one literal backslash and leave the quote as a delimiter.
Splitting on whitespace with a regular expression gets this wrong on exactly the arguments an analyst cares about — quoted paths containing spaces, and arguments whose values are themselves quoted.
The result is an array of strings, with the executable as element 0, so an argument can be referenced by position downstream.
The field must hold a string. Anything else is an error.
target_field defaults to field, which replaces the command line string with the array. Set it explicitly to keep the original text, which is usually what a detection rule matches on.
Examples
Quoted Paths
Splitting a command line whose path contains spaces... | |
keeping each quoted path as one argument: | |
Extracting the Executable
The executable is always element 0... | |
so it can be lifted into its own field: | |
Backslashes Before Quotes
A backslash escapes only a quote, so paths stay readable... | |
with the doubled backslash collapsing to one and the quote closing the argument: | |