Techniques
Sample rules
Windows Scheduled Task Service Spawned Shell
- source: splunk
- technicques:
- T1053.005
- T1059
Description
The following analytic detects when the Task Scheduler service (“svchost.exe -k netsvcs -p -s Schedule”) spawns common command line, scripting, or shell execution binaries such as “powershell.exe” or “cmd.exe”. This detection leverages data from Endpoint Detection and Response (EDR) agents, focusing on process and parent process relationships. This activity is significant as attackers often abuse the Task Scheduler for execution and persistence, blending in with legitimate Windows operations. If confirmed malicious, this could allow attackers to execute arbitrary code, maintain persistence, or escalate privileges within the environment.
Detection logic
| tstats `security_content_summariesonly`
count min(_time) as firstTime
max(_time) as lastTime
from datamodel=Endpoint.Processes where
Processes.parent_process_name="svchost.exe"
Processes.parent_process="*-k*"
Processes.parent_process= "*netsvcs*"
Processes.parent_process="*-p*"
Processes.parent_process="*-s*"
Processes.parent_process="*Schedule*"
Processes.process_name IN(
"bash.exe",
"cmd.exe",
"cscript.exe",
"ksh.exe",
"powershell.exe",
"pwsh.exe",
"scrcons.exe",
"sh.exe",
"wscript.exe",
"zsh.exe"
)
by Processes.action Processes.dest Processes.original_file_name
Processes.parent_process Processes.parent_process_exec
Processes.parent_process_guid Processes.parent_process_id
Processes.parent_process_name Processes.parent_process_path
Processes.process Processes.process_exec Processes.process_guid
Processes.process_hash Processes.process_id Processes.process_integrity_level
Processes.process_name Processes.process_path Processes.user
Processes.user_id Processes.vendor_product
| `drop_dm_object_name(Processes)`
| `security_content_ctime(firstTime)`
| `security_content_ctime(lastTime)`
| `windows_scheduled_task_service_spawned_shell_filter`