Detection rules › Sigma
Indirect Command Execution From Script File Via Bash.EXE
Detects execution of Microsoft bash launcher without any flags to execute the content of a bash script directly. This can be used to potentially bypass defenses and execute Linux or Windows-based binaries directly via bash.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Stealth |
Telemetry coverage
| Provider | Record / event type |
|---|---|
| Sysmon | Event ID 1: Process creation |
Rule body
title: Indirect Command Execution From Script File Via Bash.EXE
id: 2d22a514-e024-4428-9dba-41505bd63a5b
related:
- id: 5edc2273-c26f-406c-83f3-f4d948e740dd
type: similar
status: test
description: |
Detects execution of Microsoft bash launcher without any flags to execute the content of a bash script directly.
This can be used to potentially bypass defenses and execute Linux or Windows-based binaries directly via bash.
references:
- https://lolbas-project.github.io/lolbas/Binaries/Bash/
- https://linux.die.net/man/1/bash
- Internal Research
author: Nasreddine Bencherchali (Nextron Systems)
date: 2023-08-15
tags:
- attack.stealth
- attack.t1202
logsource:
category: process_creation
product: windows
detection:
selection:
- Image|endswith:
- ':\Windows\System32\bash.exe'
- ':\Windows\SysWOW64\bash.exe'
- OriginalFileName: 'Bash.exe'
filter_main_cli_flag:
CommandLine|contains:
# Note: we're not interested in flags being passed first
- 'bash.exe -'
- 'bash -'
filter_main_no_cli:
CommandLine: null
filter_main_empty:
CommandLine: ''
filter_main_no_flag:
CommandLine:
- 'bash.exe'
- 'bash'
condition: selection and not 1 of filter_main_*
falsepositives:
- Unknown
level: medium
Stages and Predicates
Stage 0: condition
selection and not 1 of filter_main_*Stage 1: selection
selection:
- Image|endswith:
- ':\Windows\System32\bash.exe'
- ':\Windows\SysWOW64\bash.exe'
- OriginalFileName: 'Bash.exe'
Stage 2: not filter_main_*
filter_main_cli_flag:
CommandLine|contains:
- 'bash.exe -'
- 'bash -'
filter_main_no_cli:
CommandLine: null
filter_main_empty:
CommandLine: ''
filter_main_no_flag:
CommandLine:
- 'bash.exe'
- 'bash'
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
CommandLine | eq | bash | excludes:CommandLine field:"CommandLine" value:"bash" |
CommandLine | eq | bash.exe | excludes:CommandLine field:"CommandLine" value:"bash.exe" |
CommandLine | is_null | excludes:CommandLine | |
CommandLine | match | bash - | excludes:CommandLine field:"CommandLine" value:"bash -" |
CommandLine | match | bash.exe - | excludes:CommandLine field:"CommandLine" value:"bash.exe -" |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
Image | ends_with |
| field:"Image" kind:ends_with |
OriginalFileName | eq |
| field:"OriginalFileName" kind:eq value:"Bash.exe" |