Detection rules › Splunk
Create_Modify Schtasks (PowerShell)
Detects possible persistent backdoor access using schtasks -- Threat Group Association: Actinium/Gamaredon/Primitive Bear, Alloy Taurus/Gallium, APT29/Nobelium/Cozy Bear, APT31, APT33, APT34/OilRig, APT35/Phosphorus/Magic Hound, APT41, APT43, BlackByte, BlackCat, Blind Eagle/APT-C-36, Evilnum, FIN7, FIN12, Gamaredon Group/Shuckworm, GoldenJackal, Lazarus, Memento Team, MuddyWater, Redfly, TA428, Turla (akaSecret Blizzard, KRYPTON, and UAC-0003), Vice Society, WinterVivern/UAC-0114, WIRTE, Witchetty
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution | T1053.005 Scheduled Task/Job: Scheduled Task |
| Persistence | T1053.005 Scheduled Task/Job: Scheduled Task |
| Privilege Escalation | T1053.005 Scheduled Task/Job: Scheduled Task |
References
Event coverage
| Provider | Event | Title |
|---|---|---|
| PowerShell | Event ID 4103 | Payload Context: ContextInfo User Data: UserData. |
| PowerShell | Event ID 4104 | Creating Scriptblock text (MessageNumber of MessageTotal). |
Rule body yaml
id: '1071.1109'
title: Create_Modify Schtasks
description: 'Detects possible persistent backdoor access using schtasks -- Threat
Group Association: Actinium/Gamaredon/Primitive Bear, Alloy Taurus/Gallium, APT29/Nobelium/Cozy
Bear, APT31, APT33, APT34/OilRig, APT35/Phosphorus/Magic Hound, APT41, APT43, BlackByte,
BlackCat, Blind Eagle/APT-C-36, Evilnum, FIN7, FIN12, Gamaredon Group/Shuckworm,
GoldenJackal, Lazarus, Memento Team, MuddyWater, Redfly, TA428, Turla (akaSecret
Blizzard, KRYPTON, and UAC-0003), Vice Society, WinterVivern/UAC-0114, WIRTE, Witchetty
- Software Association: Blackbyte, Black Basta, BianLian, Cactus, Conti, GoMet,
HermeticWiper/Trojan.Killdisk, Lockbit, Lorenz, LV, NanoCore, Play, Prestige, Prometheus/Spook,
Rhysida, Trickbot, XingLocker - Atomics T1036.004 Test #1 Atomics T1053.005 Test#1
Atomics T1053.005 Test#2 Atomics T1053.005 Test#3 Atomics T1053.005 Test#4 - #TrendingThreat
#Russia #Ukraine'
logic_format: Splunk
logic: '`get_endpoint_data` `get_endpoint_data_powershell` (TERM(EventCode=4104) OR
TERM(EventCode=4103)) AND (("schtasks" AND ("/create" OR "/change")) OR (TERM(Schedule.Service)
"GetFolder") OR "New-ScheduledTask")| rex field=process mode=sed max_match=0 "s/(?mi)^(Path.+)|^(ScriptBlock
ID.+)|^(Creating Scriptblock.+)//g"| rex field=process mode=sed "s/([\n\r]+)|(\s\s+)//g"|
rex field=process max_match=0 (?<schtask>"(?i)(schtasks\s+\/(create|change)|Schedule.Service.{1,20})")|
rex field=process max_match=0 (?<user>"(?i)/ru.+")| rex field=user mode=sed max_match=0
"s/(?i)^(\/ru )//g"| table _time, host, user _time, host, process, user, signature_id,
schtask| bin span=300s | stats values(*) as * by _time, host `hec_collect`'
techniques:
- execution:scheduled task/job:scheduled task
- persistence:scheduled task/job:scheduled task
technique_id:
- T1053.005
data_category:
- PowerShell logs
- Process command-line parameters
references:
- https://attack.mitre.org/techniques/T1053/005/
Stages and Predicates
Stage 1: search
search EventCode=4103 EventCode=4104 source="*" source IN ("WinEventLog:Microsoft-Windows-PowerShell/Operational", "WinEventLog:Windows", "XmlWinEventLog:Microsoft-Windows-PowerShell/Operational")
Stage 2: eval
eval _rex_sed_skipped = (...)
Stage 3: eval
eval _rex_sed_skipped = (...)
Stage 4: rex
rex field=process ... -> schtask
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.
| Field | Kind | Values |
|---|---|---|
EventCode | eq |
|
Search terms
Bare-string tokens in the SPL search body. Splunk matches each token against _raw (the untyped raw event text) anywhere it appears, not against a specific field. These don't surface in the Indicators table because they aren't predicates on a known field.
| Stage | Term |
|---|---|
| 1 | TERM |
| 1 | TERM |
| 1 | "schtasks" |
| 1 | "/create" |
| 1 | "/change" |
| 1 | TERM |
| 1 | Schedule.Service |
| 1 | "GetFolder" |
| 1 | "New-ScheduledTask" |