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 = "2024/10/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]
43type = "eql"
44
45query = '''
46sequence by host.id with maxspan = 30s
47  [any where host.os.type == "windows" and 
48    (event.category : ("library", "driver") or (event.category == "process" and event.action : "Image loaded*")) and
49    (?dll.name : "taskschd.dll" or file.name : "taskschd.dll") and
50    process.name : ("cscript.exe", "wscript.exe", "powershell.exe", "pwsh.exe", "powershell_ise.exe")]
51  [registry where host.os.type == "windows" and event.type == "change" and registry.value : "Actions" and
52    registry.path : (
53      "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Schedule\\TaskCache\\Tasks\\*\\Actions",
54      "\\REGISTRY\\MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Schedule\\TaskCache\\Tasks\\*\\Actions"
55  )]
56'''
57
58
59[[rule.threat]]
60framework = "MITRE ATT&CK"
61[[rule.threat.technique]]
62id = "T1053"
63name = "Scheduled Task/Job"
64reference = "https://attack.mitre.org/techniques/T1053/"
65[[rule.threat.technique.subtechnique]]
66id = "T1053.005"
67name = "Scheduled Task"
68reference = "https://attack.mitre.org/techniques/T1053/005/"
69
70
71
72[rule.threat.tactic]
73id = "TA0003"
74name = "Persistence"
75reference = "https://attack.mitre.org/tactics/TA0003/"
76[[rule.threat]]
77framework = "MITRE ATT&CK"
78[[rule.threat.technique]]
79id = "T1059"
80name = "Command and Scripting Interpreter"
81reference = "https://attack.mitre.org/techniques/T1059/"
82[[rule.threat.technique.subtechnique]]
83id = "T1059.001"
84name = "PowerShell"
85reference = "https://attack.mitre.org/techniques/T1059/001/"
86
87[[rule.threat.technique.subtechnique]]
88id = "T1059.005"
89name = "Visual Basic"
90reference = "https://attack.mitre.org/techniques/T1059/005/"
91
92
93
94[rule.threat.tactic]
95id = "TA0002"
96name = "Execution"
97reference = "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