Detection rules › Sigma

Potential Persistence Via PowerShell User Profile Using Add-Content

Status
test
Severity
medium
Log source
product windows, category ps_script
Author
frack113, Nasreddine Bencherchali (Nextron Systems)
Source
github.com/SigmaHQ/sigma

Detects calls to "Add-Content" cmdlet in order to modify the content of the user profile and potentially adding suspicious commands for persistence

MITRE ATT&CK coverage

Event coverage

Rule body yaml

title: Potential Persistence Via PowerShell User Profile Using Add-Content
id: 05b3e303-faf0-4f4a-9b30-46cc13e69152
status: test
description: Detects calls to "Add-Content" cmdlet in order to modify the content of the user profile and potentially adding suspicious commands for persistence
references:
    - https://github.com/redcanaryco/atomic-red-team/blob/f339e7da7d05f6057fdfcdd3742bfcf365fee2a9/atomics/T1546.013/T1546.013.md
author: frack113, Nasreddine Bencherchali (Nextron Systems)
date: 2021-08-18
modified: 2023-05-04
tags:
    - attack.persistence
    - attack.privilege-escalation
    - attack.t1546.013
logsource:
    product: windows
    category: ps_script
    definition: 'Requirements: Script Block Logging must be enabled'
detection:
    selection_add:
        ScriptBlockText|contains: 'Add-Content $profile'
    selection_options:
        ScriptBlockText|contains:
            # Note: You can add more suspicious values
            - '-Value "IEX '
            - '-Value "Invoke-Expression'
            - '-Value "Invoke-WebRequest'
            - '-Value "Start-Process'
            - "-Value 'IEX "
            - "-Value 'Invoke-Expression"
            - "-Value 'Invoke-WebRequest"
            - "-Value 'Start-Process"
    condition: all of selection_*
falsepositives:
    - Legitimate administration and tuning scripts that aim to add functionality to a user PowerShell session
level: medium

Stages and Predicates

Stage 0: condition

all of selection_*

Stage 1: selection_add

selection_add:
    ScriptBlockText|contains: 'Add-Content $profile'

Stage 2: selection_options

selection_options:
    ScriptBlockText|contains:
        - '-Value "IEX '
        - '-Value "Invoke-Expression'
        - '-Value "Invoke-WebRequest'
        - '-Value "Start-Process'
        - "-Value 'IEX "
        - "-Value 'Invoke-Expression"
        - "-Value 'Invoke-WebRequest"
        - "-Value 'Start-Process"

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
ScriptBlockTextmatch
  • -Value "IEX
  • -Value "Invoke-Expression
  • -Value "Invoke-WebRequest
  • -Value "Start-Process
  • -Value 'IEX
  • -Value 'Invoke-Expression
  • -Value 'Invoke-WebRequest
  • -Value 'Start-Process
  • Add-Content $profile