Detection rules › Sigma

Execute Code with Pester.bat

Status
test
Severity
medium
Log source
product windows, category process_creation
Author
Julia Fomina, oscd.community
Source
github.com/SigmaHQ/sigma

Detects code execution via Pester.bat (Pester - Powershell Modulte for testing)

MITRE ATT&CK coverage

Event coverage

Rule body yaml

title: Execute Code with Pester.bat
id: 59e938ff-0d6d-4dc3-b13f-36cc28734d4e
status: test
description: Detects code execution via Pester.bat (Pester - Powershell Modulte for testing)
references:
    - https://twitter.com/Oddvarmoe/status/993383596244258816
    - https://github.com/api0cradle/LOLBAS/blob/d148d278f5f205ce67cfaf49afdfb68071c7252a/OSScripts/pester.md
author: Julia Fomina, oscd.community
date: 2020-10-08
modified: 2023-11-09
tags:
    - attack.execution
    - attack.stealth
    - attack.t1059.001
    - attack.t1216
logsource:
    category: process_creation
    product: windows
detection:
    powershell_module:
        Image|endswith:
            - '\powershell.exe'
            - '\pwsh.exe'
        CommandLine|contains|all:
            - 'Pester'
            - 'Get-Help'
    cmd_execution:
        Image|endswith: '\cmd.exe'
        CommandLine|contains|all:
            - 'pester'
            - ';'
    get_help:
        CommandLine|contains:
            - 'help'
            - '\?'
    condition: powershell_module or (cmd_execution and get_help)
falsepositives:
    - Legitimate use of Pester for writing tests for Powershell scripts and modules
level: medium

Stages and Predicates

Stage 0: condition

powershell_module or (cmd_execution and get_help)

Stage 1: powershell_module

powershell_module:
    Image|endswith:
        - '\powershell.exe'
        - '\pwsh.exe'
    CommandLine|contains|all:
        - 'Pester'
        - 'Get-Help'

Stage 2: cmd_execution

cmd_execution:
    Image|endswith: '\cmd.exe'
    CommandLine|contains|all:
        - 'pester'
        - ';'

Stage 3: get_help

get_help:
    CommandLine|contains:
        - 'help'
        - '\?'

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
CommandLinematch
  • ; corpus 2 (sigma 2)
  • Get-Help
  • Pester
  • \?
  • help
  • pester
Imageends_with
  • \cmd.exe corpus 130 (sigma 130)
  • \powershell.exe corpus 182 (sigma 182)
  • \pwsh.exe corpus 168 (sigma 168)