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 | |
| Persistence | |
| Privilege Escalation |
References
Telemetry coverage
Rule body
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
`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")
Stage 2: rex
| rex field=process mode=sed max_match=0 "s/(?mi)^(Path.+)|^(ScriptBlock ID.+)|^(Creating Scriptblock.+)//g"
Stage 3: rex
| rex field=process mode=sed "s/([\n\r]+)|(\s\s+)//g"
Stage 4: rex
| rex field=process max_match=0 (?<schtask>"(?i)(schtasks\s+\/(create|change)|Schedule.Service.{1,20})")
Stage 5: rex
| rex field=process max_match=0 (?<user>"(?i)/ru.+")
Stage 6: rex
| rex field=user mode=sed max_match=0 "s/(?i)^(\/ru )//g"
Stage 7: table
| table _time, host, user _time, host, process, user, signature_id, schtask
Stage 8: bucket
| bin span=300s
Stage 9: stats
| stats values(*) as * by _time, host `hec_collect`
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
EventCode | eq |
| field:"EventID" kind:eq |
Search terms
These SPL tokens match against raw event text.
| Stage | Term |
|---|---|
| 1 | "schtasks" |
| 1 | "/create" |
| 1 | "/change" |
| 1 | Schedule.Service |
| 1 | "GetFolder" |
| 1 | "New-ScheduledTask" |