Skip to content

Commit aa97487

Browse files
authored
[Rule Tuning] PowerShell Rules (#5056)
* [Rule Tuning] PowerShell Rules * Update defense_evasion_posh_defender_tampering.toml * [Rule Tuning] Connection to Commonly Abused Web Services * Revert "[Rule Tuning] Connection to Commonly Abused Web Services" This reverts commit 74dcea0.
1 parent b5d7795 commit aa97487

10 files changed

+50
-52
lines changed

rules/windows/collection_mailbox_export_winlog.toml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2023/01/11"
33
integration = ["windows"]
44
maturity = "production"
5-
updated_date = "2025/03/20"
5+
updated_date = "2025/09/03"
66

77
[rule]
88
author = ["Elastic"]
@@ -80,26 +80,20 @@ event.category:process and host.os.type:windows and
8080

8181

8282
[[rule.filters]]
83-
8483
[rule.filters.meta]
8584
negate = true
8685
[rule.filters.query.wildcard."file.path"]
8786
case_insensitive = true
8887
value = "?:\\\\Users\\\\*\\\\AppData\\\\Roaming\\\\Microsoft\\\\Exchange\\\\RemotePowerShell\\\\*"
89-
[[rule.filters]]
9088

91-
[rule.filters.meta]
92-
negate = true
93-
[rule.filters.query.wildcard."file.path"]
94-
case_insensitive = true
95-
value = "?:\\\\Users\\\\*\\\\AppData\\\\Local\\\\Temp\\\\tmp_????????.???\\\\tmp_????????.???.ps?1"
9689
[[rule.filters]]
97-
9890
[rule.filters.meta]
9991
negate = true
10092
[rule.filters.query.wildcard."file.path"]
10193
case_insensitive = true
102-
value = "?:\\\\Windows\\\\TEMP\\\\tmp_????????.???\\\\tmp_????????.???.ps?1"
94+
value = "*\\\\tmp_????????.???\\\\tmp_????????.???.ps?1"
95+
96+
10397
[[rule.threat]]
10498
framework = "MITRE ATT&CK"
10599
[[rule.threat.technique]]

rules/windows/collection_posh_audio_capture.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2021/10/19"
33
integration = ["windows"]
44
maturity = "production"
5-
updated_date = "2025/03/20"
5+
updated_date = "2025/09/03"
66

77
[rule]
88
author = ["Elastic"]
@@ -52,7 +52,7 @@ Attackers can use PowerShell to interact with the Windows API with the intent of
5252
- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
5353
"""
5454
references = ["https://github.com/PowerShellMafia/PowerSploit/blob/master/Exfiltration/Get-MicrophoneAudio.ps1"]
55-
risk_score = 47
55+
risk_score = 73
5656
rule_id = "2f2f4939-0b34-40c2-a0a3-844eb7889f43"
5757
setup = """## Setup
5858
@@ -72,7 +72,7 @@ Steps to implement the logging policy via registry:
7272
reg add "hklm\\SOFTWARE\\Policies\\Microsoft\\Windows\\PowerShell\\ScriptBlockLogging" /v EnableScriptBlockLogging /t REG_DWORD /d 1
7373
```
7474
"""
75-
severity = "medium"
75+
severity = "high"
7676
tags = [
7777
"Domain: Endpoint",
7878
"OS: Windows",

rules/windows/collection_posh_clipboard_capture.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2023/01/12"
33
integration = ["windows"]
44
maturity = "production"
5-
updated_date = "2025/03/20"
5+
updated_date = "2025/09/03"
66

77
[rule]
88
author = ["Elastic"]
@@ -105,7 +105,7 @@ event.category:process and host.os.type:windows and
105105
) and
106106
not user.id : "S-1-5-18" and
107107
not (
108-
file.path : C\:\\Program?Files\\WindowsPowerShell\\*Modules*.ps1 and
108+
file.path : *WindowsPowerShell\\Modules\\*.ps1 and
109109
file.name : ("Convert-ExcelRangeToImage.ps1" or "Read-Clipboard.ps1")
110110
)
111111
'''

rules/windows/collection_posh_mailbox.toml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2023/01/11"
33
integration = ["windows"]
44
maturity = "production"
5-
updated_date = "2025/03/20"
5+
updated_date = "2025/09/03"
66

77
[rule]
88
author = ["Elastic"]
@@ -93,16 +93,23 @@ type = "query"
9393
query = '''
9494
event.category:process and host.os.type:windows and
9595
(
96-
powershell.file.script_block_text : (
97-
"Microsoft.Office.Interop.Outlook" or
98-
"Interop.Outlook.olDefaultFolders" or
99-
"::olFolderInBox"
100-
) or
101-
powershell.file.script_block_text : (
102-
"Microsoft.Exchange.WebServices.Data.Folder" or
103-
"Microsoft.Exchange.WebServices.Data.FileAttachment"
104-
)
105-
) and not user.id : "S-1-5-18"
96+
(
97+
powershell.file.script_block_text : (
98+
"Microsoft.Office.Interop.Outlook" or
99+
"Interop.Outlook.olDefaultFolders" or
100+
"olFolderInBox" or
101+
"Outlook.Application"
102+
) and powershell.file.script_block_text : ("MAPI" or "GetDefaultFolder" or "GetNamespace" or "Session" or "GetSharedDefaultFolder")
103+
) or
104+
(
105+
powershell.file.script_block_text : (
106+
"Microsoft.Exchange.WebServices.Data.Folder" or
107+
"Microsoft.Exchange.WebServices.Data.FileAttachment" or
108+
"Microsoft.Exchange.WebServices.Data.ExchangeService"
109+
) and
110+
powershell.file.script_block_text : ("FindItems" or "Bind" or "WellKnownFolderName" or "FolderId" or "ItemView" or "PropertySet" or "SearchFilter" or "Attachments")
111+
)
112+
)
106113
'''
107114

108115

rules/windows/credential_access_posh_request_ticket.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2022/01/24"
33
integration = ["windows"]
44
maturity = "production"
5-
updated_date = "2025/03/20"
5+
updated_date = "2025/09/03"
66

77
[rule]
88
author = ["Elastic"]
@@ -53,7 +53,7 @@ references = [
5353
"https://cobalt.io/blog/kerberoast-attack-techniques",
5454
"https://github.com/EmpireProject/Empire/blob/master/data/module_source/credentials/Invoke-Kerberoast.ps1",
5555
]
56-
risk_score = 47
56+
risk_score = 73
5757
rule_id = "eb610e70-f9e6-4949-82b9-f1c5bcd37c39"
5858
setup = """## Setup
5959
@@ -73,7 +73,7 @@ Steps to implement the logging policy via registry:
7373
reg add "hklm\\SOFTWARE\\Policies\\Microsoft\\Windows\\PowerShell\\ScriptBlockLogging" /v EnableScriptBlockLogging /t REG_DWORD /d 1
7474
```
7575
"""
76-
severity = "medium"
76+
severity = "high"
7777
tags = [
7878
"Domain: Endpoint",
7979
"OS: Windows",

rules_building_block/defense_evasion_posh_defender_tampering.toml renamed to rules/windows/defense_evasion_posh_defender_tampering.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
[metadata]
2-
bypass_bbr_timing = true
32
creation_date = "2024/09/11"
43
integration = ["windows"]
54
maturity = "production"
6-
updated_date = "2025/03/20"
5+
updated_date = "2025/09/03"
76

87
[rule]
98
author = ["Elastic"]
10-
building_block_type = "default"
119
description = """
1210
Identifies PowerShell scripts containing cmdlets and parameters that attackers can abuse to disable Windows Defender
1311
features. Attackers can tamper with antivirus to reduce the risk of detection when executing their payloads.
@@ -44,7 +42,6 @@ tags = [
4442
"Use Case: Threat Detection",
4543
"Tactic: Defense Evasion",
4644
"Data Source: PowerShell Logs",
47-
"Rule Type: BBR",
4845
]
4946
timestamp_override = "event.ingested"
5047
type = "query"
@@ -67,7 +64,8 @@ not powershell.file.script_block_text : (
6764
("cmdletization" and "cdxml-Help.xml") or
6865
("function Set-MpPreference" and "Microsoft.PowerShell.Cmdletization.GeneratedTypes.MpPreference.SubmitSamplesConsentType")
6966
) and
70-
not file.directory : "C:\ProgramData\Microsoft\Windows Defender Advanced Threat Protection\SenseCM"
67+
not file.directory : "C:\ProgramData\Microsoft\Windows Defender Advanced Threat Protection\SenseCM" and
68+
not user.id : "S-1-5-18"
7169
'''
7270

7371

rules/windows/discovery_posh_invoke_sharefinder.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2022/08/17"
33
integration = ["windows"]
44
maturity = "production"
5-
updated_date = "2025/03/20"
5+
updated_date = "2025/09/03"
66

77
[rule]
88
author = ["Elastic"]
@@ -53,7 +53,7 @@ references = [
5353
"https://thedfirreport.com/2022/04/04/stolen-images-campaign-ends-in-conti-ransomware/",
5454
"https://github.com/atc-project/atc-data/blob/master/docs/Logging_Policies/LP_0109_windows_powershell_script_block_log.md",
5555
]
56-
risk_score = 47
56+
risk_score = 73
5757
rule_id = "4c59cff1-b78a-41b8-a9f1-4231984d1fb6"
5858
setup = """## Setup
5959
@@ -74,7 +74,7 @@ Steps to implement the logging policy via registry:
7474
reg add "hklm\\SOFTWARE\\Policies\\Microsoft\\Windows\\PowerShell\\ScriptBlockLogging" /v EnableScriptBlockLogging /t REG_DWORD /d 1
7575
```
7676
"""
77-
severity = "medium"
77+
severity = "high"
7878
tags = [
7979
"Domain: Endpoint",
8080
"OS: Windows",

rules/windows/execution_posh_hacktool_authors.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2024/05/08"
33
integration = ["windows"]
44
maturity = "production"
5-
updated_date = "2025/03/20"
5+
updated_date = "2025/09/03"
66

77
[rule]
88
author = ["Elastic"]
@@ -53,7 +53,7 @@ PowerShell is a powerful scripting language and automation framework used in Win
5353
references = [
5454
"https://github.com/atc-project/atc-data/blob/master/docs/Logging_Policies/LP_0109_windows_powershell_script_block_log.md",
5555
]
56-
risk_score = 73
56+
risk_score = 47
5757
rule_id = "2553a9af-52a4-4a05-bb03-85b2a479a0a0"
5858
setup = """## Setup
5959
@@ -73,7 +73,7 @@ Steps to implement the logging policy via registry:
7373
reg add "hklm\\SOFTWARE\\Policies\\Microsoft\\Windows\\PowerShell\\ScriptBlockLogging" /v EnableScriptBlockLogging /t REG_DWORD /d 1
7474
```
7575
"""
76-
severity = "high"
76+
severity = "medium"
7777
tags = [
7878
"Domain: Endpoint",
7979
"OS: Windows",
@@ -111,7 +111,8 @@ host.os.type:windows and event.category:process and
111111
"jaredcatkinson" or "ChrisTruncer" or
112112
"monoxgas" or "TheRealWover" or
113113
"splinter_code"
114-
)
114+
) and
115+
not powershell.file.script_block_text : ("Get-UEFIDatabaseSigner" or "Posh-SSH")
115116
'''
116117

117118

rules/windows/execution_posh_hacktool_functions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2023/01/17"
33
integration = ["windows"]
44
maturity = "production"
5-
updated_date = "2025/05/03"
5+
updated_date = "2025/09/03"
66

77
[transform]
88
[[transform.osquery]]
@@ -272,7 +272,7 @@ event.category:process and host.os.type:windows and
272272
"Invoke-SMBExec" or "Invoke-PSRemoting" or
273273
"Invoke-ExecuteMSBuild" or "Invoke-DCOM" or
274274
"Invoke-InveighRelay" or "Invoke-PsExec" or
275-
"Invoke-SSHCommand" or "Find-ActiveUsersWMI" or
275+
"Find-ActiveUsersWMI" or
276276
"Get-SystemDrivesWMI" or "Get-ActiveNICSWMI" or
277277
"Remove-Persistence" or "DNS_TXT_Pwnage" or
278278
"Execute-OnTime" or "HTTP-Backdoor" or

rules_building_block/discovery_posh_password_policy.toml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2023/07/12"
33
integration = ["windows"]
44
maturity = "production"
5-
updated_date = "2025/03/20"
5+
updated_date = "2025/09/03"
66

77
[rule]
88
author = ["Elastic"]
@@ -80,14 +80,12 @@ event.category: "process" and host.os.type:windows and
8080
)
8181
)
8282
)
83-
) and not powershell.file.script_block_text : (
84-
"sentinelbreakpoints" and "Set-PSBreakpoint" and "PowerSploitIndicators"
85-
)
86-
and not
87-
(
88-
powershell.file.script_block_text : ("43c15630-959c-49e4-a977-758c5cc93408" and "CmdletsToExport" and "ActiveDirectory.Types.ps1xml")
89-
)
90-
and not user.id : "S-1-5-18"
83+
) and
84+
85+
not powershell.file.script_block_text : ("sentinelbreakpoints" and "Set-PSBreakpoint" and "PowerSploitIndicators") and
86+
not powershell.file.script_block_text : ("43c15630-959c-49e4-a977-758c5cc93408" and "CmdletsToExport" and "ActiveDirectory.Types.ps1xml") and
87+
not file.directory: "C:\Program Files\LogicMonitor\Agent\tmp" and
88+
not user.id : "S-1-5-18"
9189
'''
9290

9391

0 commit comments

Comments
 (0)