Detection rules › Sigma

Windows Shell/Scripting Application File Write to Suspicious Folder

Status
test
Severity
high
Log source
product windows, category file_event
Author
Florian Roth (Nextron Systems)
Source
github.com/SigmaHQ/sigma

Detects Windows shells and scripting applications that write files to suspicious folders

MITRE ATT&CK coverage

Event coverage

ProviderEventTitle
SysmonEvent ID 11FileCreate

Rule body yaml

title: Windows Shell/Scripting Application File Write to Suspicious Folder
id: 1277f594-a7d1-4f28-a2d3-73af5cbeab43
status: test
description: Detects Windows shells and scripting applications that write files to suspicious folders
references:
    - Internal Research
author: Florian Roth (Nextron Systems)
date: 2021-11-20
modified: 2023-03-29
tags:
    - attack.execution
    - attack.t1059
logsource:
    category: file_event
    product: windows
detection:
    selection_1:
        Image|endswith:
            - '\bash.exe'
            - '\cmd.exe'
            - '\cscript.exe'
            - '\msbuild.exe'  # https://github.com/elastic/detection-rules/blob/c76a39796972ecde44cb1da6df47f1b6562c9770/rules/windows/defense_evasion_execution_msbuild_started_by_office_app.toml
            - '\powershell.exe'
            - '\pwsh.exe'
            - '\sh.exe'
            - '\wscript.exe'
        TargetFilename|startswith:
            - 'C:\PerfLogs\'
            - 'C:\Users\Public\'
    selection_2:
        Image|endswith:
            - '\certutil.exe'
            - '\forfiles.exe'
            - '\mshta.exe'
            # - '\rundll32.exe' # Potential FP
            - '\schtasks.exe'
            - '\scriptrunner.exe'
            - '\wmic.exe'  # https://app.any.run/tasks/c903e9c8-0350-440c-8688-3881b556b8e0/
        TargetFilename|contains:
            - 'C:\PerfLogs\'
            - 'C:\Users\Public\'
            - 'C:\Windows\Temp\'
    condition: 1 of selection_*
falsepositives:
    - Unknown
level: high

Stages and Predicates

Stage 0: condition

1 of selection_*

Stage 1: selection_1

selection_1:
    Image|endswith:
        - '\bash.exe'
        - '\cmd.exe'
        - '\cscript.exe'
        - '\msbuild.exe'
        - '\powershell.exe'
        - '\pwsh.exe'
        - '\sh.exe'
        - '\wscript.exe'
    TargetFilename|startswith:
        - 'C:\PerfLogs\'
        - 'C:\Users\Public\'

Stage 2: selection_2

selection_2:
    Image|endswith:
        - '\certutil.exe'
        - '\forfiles.exe'
        - '\mshta.exe'
        - '\schtasks.exe'
        - '\scriptrunner.exe'
        - '\wmic.exe'
    TargetFilename|contains:
        - 'C:\PerfLogs\'
        - 'C:\Users\Public\'
        - 'C:\Windows\Temp\'

Indicators

Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.

FieldKindValues
Imageends_with
  • \bash.exe corpus 22 (sigma 22)
  • \certutil.exe corpus 43 (sigma 43)
  • \cmd.exe corpus 130 (sigma 130)
  • \cscript.exe corpus 73 (sigma 73)
  • \forfiles.exe corpus 12 (sigma 12)
  • \msbuild.exe corpus 10 (sigma 10)
  • \mshta.exe corpus 67 (sigma 67)
  • \powershell.exe corpus 182 (sigma 182)
  • \pwsh.exe corpus 168 (sigma 168)
  • \schtasks.exe corpus 56 (sigma 56)
  • \scriptrunner.exe corpus 12 (sigma 12)
  • \sh.exe corpus 16 (sigma 16)
  • \wmic.exe corpus 60 (sigma 60)
  • \wscript.exe corpus 75 (sigma 75)
TargetFilenamematch
  • C:\PerfLogs\ corpus 2 (sigma 2)
  • C:\Users\Public\ corpus 2 (sigma 2)
  • C:\Windows\Temp\
TargetFilenamestarts_with
  • C:\PerfLogs\ corpus 2 (sigma 2)
  • C:\Users\Public\