Detection rules › Sigma

Scheduled persistent task with SYSTEM privileges creation

Status
experimental
Severity
high
Log source
product windows, category process_creation
Author
mdecrevoisier
Source
github.com/mdecrevoisier/SIGMA-detection-rules

Detects scenarios where an attacker creates a privileged task to establish persistence.

MITRE ATT&CK coverage

Event coverage

Rule body yaml

title: Scheduled persistent task with SYSTEM privileges creation
description: Detects scenarios where an attacker creates a privileged task to establish persistence.
references:
- https://github.com/mdecrevoisier/EVTX-to-MITRE-Attack/tree/master/TA0002-Execution/T1053.005-Scheduled%20Task
- https://www.ired.team/offensive-security/persistence/t1053-schtask
- https://pentestlab.blog/2019/11/04/persistence-scheduled-tasks/
- http://www.fuzzysecurity.com/tutorials/19.html
- https://nasbench.medium.com/a-deep-dive-into-windows-scheduled-tasks-and-the-processes-running-them-218d1eed4cce
- https://posts.specterops.io/abstracting-scheduled-tasks-3b6451f6a1c5
- https://www.darkoperator.com/blog/2009/4/11/abusing-the-scheduler-with-meterpreter.html
- https://blog.menasec.net/2019/03/threat-hunting-25-scheduled-tasks-for.html
- https://strontic.github.io/xcyclopedia/library/schtasks.exe-5BD86A7193D38880F339D4AFB1F9B63A.html
- https://redcanary.com/blog/microsoft-exchange-attacks/
- https://nasbench.medium.com/behind-the-detection-schtasks-eb67a33a8710
- https://www.linkedin.com/pulse/lolbin-attacks-scheduled-tasks-t1503005-how-detect-them-v%C3%B6gele
tags:
- attack.execution
- attack.t1053.005
author: mdecrevoisier
status: experimental
logsource:
  product: windows
  category: process_creation
detection: # Full command: "schtasks /create /sc minute /mo 1 /tn eviltask /tr C:\tools\shell.cmd /ru SYSTEM"
  selection:
    NewProcessName|endswith: \schtasks.exe
    CommandLine|contains|all:
      - create
      #- ru      # Run with privileges from user X
      #- SYSTEM  # Run with SYSTEM privileges
      - tr      # Program, path or command to run
      - sc      # Run task every X minutes
  condition: selection
falsepositives:
- Administrator
level: high

# Extract ID 4698
# <?xml version="1.0" encoding="UTF-16"?> <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"> <RegistrationInfo> <Date>2021-04-21T13:30:00</Date> <Author>demo\user1</Author> <URI>\eviltask</URI> </RegistrationInfo> <Triggers> <TimeTrigger> <Repetition> <Interval>PT1M</Interval> <StopAtDurationEnd>false</StopAtDurationEnd> </Repetition> <StartBoundary>2021-04-21T13:30:00</StartBoundary> <Enabled>true</Enabled> </TimeTrigger> </Triggers> <Settings> <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy> <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries> <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries> <AllowHardTerminate>true</AllowHardTerminate> <StartWhenAvailable>false</StartWhenAvailable> <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable> <IdleSettings> <Duration>PT10M</Duration> <WaitTimeout>PT1H</WaitTimeout> <StopOnIdleEnd>true</StopOnIdleEnd> <RestartOnIdle>false</RestartOnIdle> </IdleSettings> <AllowStartOnDemand>true</AllowStartOnDemand> <Enabled>true</Enabled> <Hidden>false</Hidden> <RunOnlyIfIdle>false</RunOnlyIfIdle> <WakeToRun>false</WakeToRun> <ExecutionTimeLimit>PT72H</ExecutionTimeLimit> <Priority>7</Priority> </Settings> <Actions Context="Author"> <Exec> <Command>C:\tools\shell.cmd</Command> </Exec> </Actions> <Principals> <Principal id="Author"> <UserId>S-1-5-18</UserId> <RunLevel>LeastPrivilege</RunLevel> </Principal> </Principals> </Task>

Stages and Predicates

Stage 0: condition

selection

Stage 1: selection

selection:
  NewProcessName|endswith: \schtasks.exe
  CommandLine|contains|all:
    - create
    - tr
    - sc

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
  • create corpus 24 (sigma 17, splunk 7)
  • sc corpus 6 (sigma 6)
  • tr
NewProcessNameends_with
  • \schtasks.exe corpus 56 (sigma 56)