Scheduled Task Created by a Windows Script

A scheduled task was created by a Windows script via cscript.exe, wscript.exe or powershell.exe. This can be abused by an adversary to establish persistence.

Elastic rule (View on GitHub)

 1[metadata]
 2creation_date = "2020/11/29"
 3integration = ["endpoint", "windows"]
 4maturity = "production"
 5updated_date = "2025/01/15"
 6min_stack_version = "8.14.0"
 7min_stack_comments = "Breaking change at 8.14.0 for the Windows Integration."
 8
 9[rule]
10author = ["Elastic"]
11description = """
12A scheduled task was created by a Windows script via cscript.exe, wscript.exe or powershell.exe. This can be abused by
13an adversary to establish persistence.
14"""
15false_positives = ["Legitimate scheduled tasks may be created during installation of new software."]
16from = "now-9m"
17index = [
18    "winlogbeat-*",
19    "logs-endpoint.events.registry-*",
20    "logs-endpoint.events.library-*",
21    "logs-windows.sysmon_operational-*",
22    "endgame-*",
23]
24language = "eql"
25license = "Elastic License v2"
26name = "Scheduled Task Created by a Windows Script"
27note = """## Triage and analysis
28
29Decode the base64 encoded Tasks Actions registry value to investigate the task's configured action."""
30risk_score = 47
31rule_id = "689b9d57-e4d5-4357-ad17-9c334609d79a"
32severity = "medium"
33tags = [
34    "Domain: Endpoint",
35    "OS: Windows",
36    "Use Case: Threat Detection",
37    "Tactic: Persistence",
38    "Tactic: Execution",
39    "Data Source: Elastic Endgame",
40    "Data Source: Elastic Defend",
41    "Data Source: Sysmon",
42    "Resources: Investigation Guide",
43]
44type = "eql"
45
46query = '''
47sequence by host.id with maxspan = 30s
48  [any where host.os.type == "windows" and 
49    (event.category : ("library", "driver") or (event.category == "process" and event.action : "Image loaded*")) and
50    (?dll.name : "taskschd.dll" or file.name : "taskschd.dll") and
51    process.name : ("cscript.exe", "wscript.exe", "powershell.exe", "pwsh.exe", "powershell_ise.exe")]
52  [registry where host.os.type == "windows" and event.type == "change" and registry.value : "Actions" and
53    registry.path : (
54      "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Schedule\\TaskCache\\Tasks\\*\\Actions",
55      "\\REGISTRY\\MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Schedule\\TaskCache\\Tasks\\*\\Actions"
56  )]
57'''
58
59
60[[rule.threat]]
61framework = "MITRE ATT&CK"
62[[rule.threat.technique]]
63id = "T1053"
64name = "Scheduled Task/Job"
65reference = "https://attack.mitre.org/techniques/T1053/"
66[[rule.threat.technique.subtechnique]]
67id = "T1053.005"
68name = "Scheduled Task"
69reference = "https://attack.mitre.org/techniques/T1053/005/"
70
71
72
73[rule.threat.tactic]
74id = "TA0003"
75name = "Persistence"
76reference = "https://attack.mitre.org/tactics/TA0003/"
77[[rule.threat]]
78framework = "MITRE ATT&CK"
79[[rule.threat.technique]]
80id = "T1059"
81name = "Command and Scripting Interpreter"
82reference = "https://attack.mitre.org/techniques/T1059/"
83[[rule.threat.technique.subtechnique]]
84id = "T1059.001"
85name = "PowerShell"
86reference = "https://attack.mitre.org/techniques/T1059/001/"
87
88[[rule.threat.technique.subtechnique]]
89id = "T1059.005"
90name = "Visual Basic"
91reference = "https://attack.mitre.org/techniques/T1059/005/"
92
93
94
95[rule.threat.tactic]
96id = "TA0002"
97name = "Execution"
98reference = "https://attack.mitre.org/tactics/TA0002/"

Triage and analysis

Decode the base64 encoded Tasks Actions registry value to investigate the task's configured action.

Related rules

to-top