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