From 414d32027632a49fb239abb8fbbb55d3fa8dd861 Mon Sep 17 00:00:00 2001 From: Brent Murphy <56412096+bm11100@users.noreply.github.com> Date: Thu, 8 Apr 2021 14:28:21 -0400 Subject: [PATCH] [Rule Tuning] Local Scheduled Task Commands (#1043) * Update persistence_local_scheduled_task_commands.toml Co-authored-by: Justin Ibarra Co-authored-by: Samirbous <64742097+Samirbous@users.noreply.github.com> --- ...istence_local_scheduled_task_commands.toml | 41 ------------- ...istence_local_scheduled_task_creation.toml | 57 +++++++++++++++++++ 2 files changed, 57 insertions(+), 41 deletions(-) delete mode 100644 rules/windows/persistence_local_scheduled_task_commands.toml create mode 100644 rules/windows/persistence_local_scheduled_task_creation.toml diff --git a/rules/windows/persistence_local_scheduled_task_commands.toml b/rules/windows/persistence_local_scheduled_task_commands.toml deleted file mode 100644 index e6182cd21..000000000 --- a/rules/windows/persistence_local_scheduled_task_commands.toml +++ /dev/null @@ -1,41 +0,0 @@ -[metadata] -creation_date = "2020/02/18" -maturity = "production" -updated_date = "2021/03/03" - -[rule] -author = ["Elastic"] -description = "A scheduled task can be used by an adversary to establish persistence, move laterally, and/or escalate privileges." -false_positives = ["Legitimate scheduled tasks may be created during installation of new software."] -from = "now-9m" -index = ["winlogbeat-*", "logs-endpoint.events.*", "logs-windows.*"] -language = "kuery" -license = "Elastic License v2" -name = "Local Scheduled Task Commands" -risk_score = 21 -rule_id = "afcce5ad-65de-4ed2-8516-5e093d3ac99a" -severity = "low" -tags = ["Elastic", "Host", "Windows", "Threat Detection", "Persistence"] -timestamp_override = "event.ingested" -type = "query" - -query = ''' -event.category:process and event.type:(start or process_started) and - process.name:schtasks.exe and - process.args:(-change or -create or -run or -s or /S or /change or /create or /run) -''' - - -[[rule.threat]] -framework = "MITRE ATT&CK" -[[rule.threat.technique]] -id = "T1053" -name = "Scheduled Task/Job" -reference = "https://attack.mitre.org/techniques/T1053/" - - -[rule.threat.tactic] -id = "TA0003" -name = "Persistence" -reference = "https://attack.mitre.org/tactics/TA0003/" - diff --git a/rules/windows/persistence_local_scheduled_task_creation.toml b/rules/windows/persistence_local_scheduled_task_creation.toml new file mode 100644 index 000000000..a326f2dac --- /dev/null +++ b/rules/windows/persistence_local_scheduled_task_creation.toml @@ -0,0 +1,57 @@ +[metadata] +creation_date = "2020/02/18" +maturity = "production" +updated_date = "2021/03/15" + +[rule] +author = ["Elastic"] +description = "A scheduled task can be used by an adversary to establish persistence, move laterally, and/or escalate privileges." +false_positives = ["Legitimate scheduled tasks may be created during installation of new software."] +from = "now-9m" +index = ["winlogbeat-*", "logs-endpoint.events.*", "logs-windows.*"] +language = "eql" +license = "Elastic License v2" +name = "Local Scheduled Task Creation" +risk_score = 21 +rule_id = "afcce5ad-65de-4ed2-8516-5e093d3ac99a" +severity = "low" +tags = ["Elastic", "Host", "Windows", "Threat Detection", "Persistence"] +timestamp_override = "event.ingested" +type = "eql" + +query = ''' +sequence with maxspan=1m + [process where event.type != "end" and + ((process.name : ("cmd.exe", "wscript.exe", "rundll32.exe", "regsvr32.exe", "wmic.exe", "mshta.exe", + "powershell.exe", "pwsh.exe", "WmiPrvSe.exe", "wsmprovhost.exe", "winrshost.exe") or + process.pe.original_file_name : ("cmd.exe", "wscript.exe", "rundll32.exe", "regsvr32.exe", "wmic.exe", "mshta.exe", + "powershell.exe", "pwsh.exe", "WmiPrvSe.exe", "wsmprovhost.exe", + "winrshost.exe")) or + process.code_signature.trusted == false)] by process.entity_id + [process where event.type == "start" and + (process.name : "schtasks.exe" or process.pe.original_file_name == "schtasks.exe") and + process.args : ("/create", "-create") and process.args : ("/RU", "/SC", "/TN", "/TR", "/F", "/XML") and + /* exclude SYSTEM SIDs - look for task creations by non-SYSTEM user */ + not user.id : ("S-1-5-18", "S-1-5-19", "S-1-5-20")] by process.parent.entity_id +''' + + +[[rule.threat]] +framework = "MITRE ATT&CK" +[[rule.threat.technique]] +id = "T1053" +name = "Scheduled Task/Job" +reference = "https://attack.mitre.org/techniques/T1053/" + +[[rule.threat.technique.subtechnique]] +id = "T1053.005" +name = "Scheduled Task" +reference = "https://attack.mitre.org/techniques/T1053/005/" + + + +[rule.threat.tactic] +id = "TA0003" +name = "Persistence" +reference = "https://attack.mitre.org/tactics/TA0003/" +