Detection rules › Sigma

Suspicious Command Patterns In Scheduled Task Creation

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

Detects scheduled task creation using "schtasks" that contain potentially suspicious or uncommon commands

MITRE ATT&CK coverage

Event coverage

Rule body yaml

title: Suspicious Command Patterns In Scheduled Task Creation
id: f2c64357-b1d2-41b7-849f-34d2682c0fad
status: test
description: Detects scheduled task creation using "schtasks" that contain potentially suspicious or uncommon commands
references:
    - https://app.any.run/tasks/512c1352-6380-4436-b27d-bb62f0c020d6/
    - https://twitter.com/RedDrip7/status/1506480588827467785
    - https://www.ncsc.gov.uk/static-assets/documents/malware-analysis-reports/devil-bait/NCSC-MAR-Devil-Bait.pdf
author: Florian Roth (Nextron Systems)
date: 2022-02-23
modified: 2024-03-19
tags:
    - attack.privilege-escalation
    - attack.persistence
    - attack.execution
    - attack.t1053.005
logsource:
    product: windows
    category: process_creation
detection:
    selection_schtasks:
        Image|endswith: '\schtasks.exe'
        CommandLine|contains: '/Create '
    selection_pattern_1:
        CommandLine|contains:
            - '/sc minute '
            - '/ru system '
    selection_pattern_2:
        CommandLine|contains:
            - 'cmd /c'
            - 'cmd /k'
            - 'cmd /r'
            - 'cmd.exe /c '
            - 'cmd.exe /k '
            - 'cmd.exe /r '
    selection_uncommon:
        CommandLine|contains:
            - ' -decode '
            - ' -enc '
            - ' -w hidden '
            - ' bypass '
            - ' IEX'
            - '.DownloadData'
            - '.DownloadFile'
            - '.DownloadString'
            - '/c start /min ' # https://twitter.com/RedDrip7/status/1506480588827467785
            - 'FromBase64String'
            - 'mshta http'
            - 'mshta.exe http'
    selection_anomaly_1:
        CommandLine|contains:
            - ':\ProgramData\'
            - ':\Temp\'
            - ':\Tmp\'
            - ':\Users\Public\'
            - ':\Windows\Temp\'
            - '\AppData\'
            - '%AppData%'
            - '%Temp%'
            - '%tmp%'
    selection_anomaly_2:
        CommandLine|contains:
            - 'cscript'
            - 'curl'
            - 'wscript'
    condition: selection_schtasks and ( all of selection_pattern_* or selection_uncommon or all of selection_anomaly_* )
falsepositives:
    - Software installers that run from temporary folders and also install scheduled tasks are expected to generate some false positives
level: high

Stages and Predicates

Stage 0: condition

selection_schtasks and ( all of selection_pattern_* or selection_uncommon or all of selection_anomaly_* )

Stage 1: selection_schtasks

selection_schtasks:
    Image|endswith: '\schtasks.exe'
    CommandLine|contains: '/Create '

Stage 2: selection_pattern_1

selection_pattern_1:
    CommandLine|contains:
        - '/sc minute '
        - '/ru system '

Stage 3: selection_pattern_2

selection_pattern_2:
    CommandLine|contains:
        - 'cmd /c'
        - 'cmd /k'
        - 'cmd /r'
        - 'cmd.exe /c '
        - 'cmd.exe /k '
        - 'cmd.exe /r '

Stage 4: selection_uncommon

selection_uncommon:
    CommandLine|contains:
        - ' -decode '
        - ' -enc '
        - ' -w hidden '
        - ' bypass '
        - ' IEX'
        - '.DownloadData'
        - '.DownloadFile'
        - '.DownloadString'
        - '/c start /min '
        - 'FromBase64String'
        - 'mshta http'
        - 'mshta.exe http'

Stage 5: selection_anomaly_1

selection_anomaly_1:
    CommandLine|contains:
        - ':\ProgramData\'
        - ':\Temp\'
        - ':\Tmp\'
        - ':\Users\Public\'
        - ':\Windows\Temp\'
        - '\AppData\'
        - '%AppData%'
        - '%Temp%'
        - '%tmp%'

Stage 6: selection_anomaly_2

selection_anomaly_2:
    CommandLine|contains:
        - 'cscript'
        - 'curl'
        - 'wscript'

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
  • -decode corpus 4 (sigma 4)
  • -enc corpus 6 (sigma 6)
  • -w hidden corpus 5 (sigma 5)
  • IEX
  • bypass corpus 2 (sigma 1, splunk 1)
  • %AppData% corpus 13 (sigma 11, chronicle 2)
  • %Temp% corpus 16 (sigma 13, chronicle 2, kusto 1)
  • %tmp% corpus 15 (sigma 13, chronicle 2)
  • .DownloadData
  • .DownloadFile corpus 3 (sigma 2, chronicle 1)
  • .DownloadString corpus 2 (sigma 2)
  • /Create corpus 5 (sigma 3, splunk 2)
  • /c start /min
  • /ru system
  • /sc minute
  • :\ProgramData\ corpus 9 (sigma 9)
  • :\Temp\ corpus 14 (sigma 14)
  • :\Tmp\ corpus 2 (sigma 2)
  • :\Users\Public\ corpus 18 (sigma 18)
  • :\Windows\Temp\ corpus 16 (sigma 16)
  • FromBase64String corpus 12 (sigma 9, splunk 2, elastic 1)
  • \AppData\ corpus 8 (sigma 8)
  • cmd /c corpus 5 (sigma 5)
  • cmd /k corpus 4 (sigma 4)
  • cmd /r corpus 3 (sigma 3)
  • cmd.exe /c corpus 6 (sigma 6)
  • cmd.exe /k corpus 5 (sigma 5)
  • cmd.exe /r corpus 5 (sigma 5)
  • cscript corpus 15 (sigma 15)
  • curl corpus 17 (sigma 14, elastic 2, splunk 1)
  • mshta http
  • mshta.exe http
  • wscript corpus 16 (sigma 16)
Imageends_with
  • \schtasks.exe corpus 56 (sigma 56)