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"
 5min_stack_comments = "New fields added: required_fields, related_integrations, setup"
 6min_stack_version = "8.3.0"
 7updated_date = "2024/04/08"
 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 = ["winlogbeat-*", "logs-endpoint.events.registry-*", "logs-endpoint.events.library-*", "logs-windows.sysmon_operational-*", "endgame-*"]
18language = "eql"
19license = "Elastic License v2"
20name = "Scheduled Task Created by a Windows Script"
21note = """## Triage and analysis
22
23Decode the base64 encoded Tasks Actions registry value to investigate the task's configured action."""
24risk_score = 47
25rule_id = "689b9d57-e4d5-4357-ad17-9c334609d79a"
26severity = "medium"
27tags = ["Domain: Endpoint", "OS: Windows", "Use Case: Threat Detection", "Tactic: Persistence", "Tactic: Execution", "Data Source: Elastic Endgame", "Data Source: Elastic Defend", "Data Source: Sysmon"]
28type = "eql"
29
30query = '''
31sequence by host.id with maxspan = 30s
32  [any where host.os.type == "windows" and 
33    (event.category : ("library", "driver") or (event.category == "process" and event.action : "Image loaded*")) and
34    (?dll.name : "taskschd.dll" or file.name : "taskschd.dll") and
35    process.name : ("cscript.exe", "wscript.exe", "powershell.exe", "pwsh.exe", "powershell_ise.exe")]
36  [registry where host.os.type == "windows" and registry.path : (
37    "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Schedule\\TaskCache\\Tasks\\*\\Actions",
38    "\\REGISTRY\\MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Schedule\\TaskCache\\Tasks\\*\\Actions")]
39'''
40
41
42[[rule.threat]]
43framework = "MITRE ATT&CK"
44[[rule.threat.technique]]
45id = "T1053"
46name = "Scheduled Task/Job"
47reference = "https://attack.mitre.org/techniques/T1053/"
48[[rule.threat.technique.subtechnique]]
49id = "T1053.005"
50name = "Scheduled Task"
51reference = "https://attack.mitre.org/techniques/T1053/005/"
52
53
54
55[rule.threat.tactic]
56id = "TA0003"
57name = "Persistence"
58reference = "https://attack.mitre.org/tactics/TA0003/"
59
60[[rule.threat]]
61framework = "MITRE ATT&CK"
62[[rule.threat.technique]]
63id = "T1059"
64name = "Command and Scripting Interpreter"
65reference = "https://attack.mitre.org/techniques/T1059/"
66[[rule.threat.technique.subtechnique]]
67id = "T1059.001"
68name = "PowerShell"
69reference = "https://attack.mitre.org/techniques/T1059/001/"
70
71[[rule.threat.technique.subtechnique]]
72id = "T1059.005"
73name = "Visual Basic"
74reference = "https://attack.mitre.org/techniques/T1059/005/"
75
76
77
78[rule.threat.tactic]
79id = "TA0002"
80name = "Execution"
81reference = "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