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/05/21"
 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 registry.path : (
50    "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Schedule\\TaskCache\\Tasks\\*\\Actions",
51    "\\REGISTRY\\MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Schedule\\TaskCache\\Tasks\\*\\Actions")]
52'''
53
54
55[[rule.threat]]
56framework = "MITRE ATT&CK"
57[[rule.threat.technique]]
58id = "T1053"
59name = "Scheduled Task/Job"
60reference = "https://attack.mitre.org/techniques/T1053/"
61[[rule.threat.technique.subtechnique]]
62id = "T1053.005"
63name = "Scheduled Task"
64reference = "https://attack.mitre.org/techniques/T1053/005/"
65
66
67
68[rule.threat.tactic]
69id = "TA0003"
70name = "Persistence"
71reference = "https://attack.mitre.org/tactics/TA0003/"
72[[rule.threat]]
73framework = "MITRE ATT&CK"
74[[rule.threat.technique]]
75id = "T1059"
76name = "Command and Scripting Interpreter"
77reference = "https://attack.mitre.org/techniques/T1059/"
78[[rule.threat.technique.subtechnique]]
79id = "T1059.001"
80name = "PowerShell"
81reference = "https://attack.mitre.org/techniques/T1059/001/"
82
83[[rule.threat.technique.subtechnique]]
84id = "T1059.005"
85name = "Visual Basic"
86reference = "https://attack.mitre.org/techniques/T1059/005/"
87
88
89
90[rule.threat.tactic]
91id = "TA0002"
92name = "Execution"
93reference = "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