Detection rules › Sigma

Scheduled Task Executing Encoded Payload from Registry

Status
test
Severity
high
Log source
product windows, category process_creation
Author
pH-T (Nextron Systems), @Kostastsale, TheDFIRReport, X__Junior (Nextron Systems), Nasreddine Bencherchali (Nextron Systems)
Source
github.com/SigmaHQ/sigma

Detects the creation of a schtask that potentially executes a base64 encoded payload stored in the Windows Registry using PowerShell.

MITRE ATT&CK coverage

Event coverage

ProviderEventTitle
SysmonEvent ID 1Process creation

Rule body yaml

title: Scheduled Task Executing Encoded Payload from Registry
id: c4eeeeae-89f4-43a7-8b48-8d1bdfa66c78
status: test
description: Detects the creation of a schtask that potentially executes a base64 encoded payload stored in the Windows Registry using PowerShell.
references:
    - https://thedfirreport.com/2022/02/21/qbot-and-zerologon-lead-to-full-domain-compromise/
author: pH-T (Nextron Systems), @Kostastsale, TheDFIRReport, X__Junior (Nextron Systems), Nasreddine Bencherchali (Nextron Systems)
date: 2022-02-12
modified: 2023-02-04
tags:
    - attack.privilege-escalation
    - attack.execution
    - attack.persistence
    - attack.t1053.005
    - attack.t1059.001
logsource:
    product: windows
    category: process_creation
detection:
    selection_img:
        # schtasks.exe /Create /F /TN "{97F2F70B-10D1-4447-A2F3-9B070C86E261}" /TR "cmd /c start /min \"\" powershell.exe -Command IEX([System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String((Get-ItemProperty -Path HKCU:\SOFTWARE\Pvoeooxf).yzbbvhhdypa))) " /SC MINUTE /MO 30
        - Image|endswith: '\schtasks.exe'
        - OriginalFileName: 'schtasks.exe'
    selection_cli_create:
        CommandLine|contains: '/Create'
    selection_cli_encoding:
        CommandLine|contains:
            - 'FromBase64String'
            - 'encodedcommand'
    selection_cli_get:
        CommandLine|contains:
            - 'Get-ItemProperty'
            - ' gp ' # Alias
    selection_cli_hive:
        CommandLine|contains:
            - 'HKCU:'
            - 'HKLM:'
            - 'registry::'
            - 'HKEY_'
    condition: all of selection_*
falsepositives:
    - Unlikely
level: high

Stages and Predicates

Stage 0: condition

all of selection_*

Stage 1: selection_img

selection_img:
    - Image|endswith: '\schtasks.exe'
    - OriginalFileName: 'schtasks.exe'

Stage 2: selection_cli_create

selection_cli_create:
    CommandLine|contains: '/Create'

Stage 3: selection_cli_encoding

selection_cli_encoding:
    CommandLine|contains:
        - 'FromBase64String'
        - 'encodedcommand'

Stage 4: selection_cli_get

selection_cli_get:
    CommandLine|contains:
        - 'Get-ItemProperty'
        - ' gp '

Stage 5: selection_cli_hive

selection_cli_hive:
    CommandLine|contains:
        - 'HKCU:'
        - 'HKLM:'
        - 'registry::'
        - 'HKEY_'

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
  • gp corpus 2 (sigma 2)
  • /Create corpus 9 (sigma 6, splunk 2, kusto 1)
  • FromBase64String corpus 12 (sigma 9, splunk 2, elastic 1)
  • Get-ItemProperty corpus 2 (sigma 2)
  • HKCU: corpus 2 (sigma 2)
  • HKEY_ corpus 2 (sigma 2)
  • HKLM: corpus 2 (sigma 2)
  • encodedcommand
  • registry:: corpus 2 (sigma 2)
Imageends_with
  • \schtasks.exe corpus 56 (sigma 56)
OriginalFileNameeq
  • schtasks.exe corpus 23 (sigma 18, splunk 4, elastic 1)