Skip to content

Commit 6bc1913

Browse files
authored
[Rule Tuning] PowerShell Rules (#3903)
1 parent a71bbe0 commit 6bc1913

14 files changed

+82
-42
lines changed

rules/windows/collection_posh_keylogger.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2021/10/15"
33
integration = ["windows"]
44
maturity = "production"
5-
updated_date = "2024/05/21"
5+
updated_date = "2024/07/17"
66

77
[rule]
88
author = ["Elastic"]
@@ -57,7 +57,7 @@ references = [
5757
"https://github.com/EmpireProject/Empire/blob/master/data/module_source/collection/Get-Keystrokes.ps1",
5858
"https://github.com/MojtabaTajik/FunnyKeylogger/blob/master/FunnyLogger.ps1",
5959
]
60-
risk_score = 47
60+
risk_score = 73
6161
rule_id = "bd2c86a0-8b61-4457-ab38-96943984e889"
6262
setup = """## Setup
6363
@@ -77,7 +77,7 @@ Steps to implement the logging policy via registry:
7777
reg add "hklm\\SOFTWARE\\Policies\\Microsoft\\Windows\\PowerShell\\ScriptBlockLogging" /v EnableScriptBlockLogging /t REG_DWORD /d 1
7878
```
7979
"""
80-
severity = "medium"
80+
severity = "high"
8181
tags = [
8282
"Domain: Endpoint",
8383
"OS: Windows",

rules/windows/credential_access_posh_invoke_ninjacopy.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -50,9 +50,9 @@ Invoke-NinjaCopy is a PowerShell script capable of reading SYSTEM files that wer
5050
references = [
5151
"https://github.com/BC-SECURITY/Empire/blob/main/empire/server/data/module_source/collection/Invoke-NinjaCopy.ps1",
5252
]
53-
risk_score = 47
53+
risk_score = 73
5454
rule_id = "b8386923-b02c-4b94-986a-d223d9b01f88"
55-
severity = "medium"
55+
severity = "high"
5656
tags = [
5757
"Domain: Endpoint",
5858
"OS: Windows",

rules/windows/credential_access_posh_kerb_ticket_dump.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -61,7 +61,7 @@ This rule indicates the use of scripts that contain code capable of dumping Kerb
6161
- 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).
6262
"""
6363
references = ["https://github.com/MzHmO/PowershellKerberos/blob/main/dumper.ps1"]
64-
risk_score = 47
64+
risk_score = 73
6565
rule_id = "fddff193-48a3-484d-8d35-90bb3d323a56"
6666
setup = """## Setup
6767
@@ -81,7 +81,7 @@ Steps to implement the logging policy via registry:
8181
reg add "hklm\\SOFTWARE\\Policies\\Microsoft\\Windows\\PowerShell\\ScriptBlockLogging" /v EnableScriptBlockLogging /t REG_DWORD /d 1
8282
```
8383
"""
84-
severity = "medium"
84+
severity = "high"
8585
tags = [
8686
"Domain: Endpoint",
8787
"OS: Windows",

rules/windows/credential_access_posh_relay_tools.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -22,7 +22,7 @@ references = [
2222
"https://github.com/nettitude/PoshC2/blob/master/resources/modules/Invoke-Tater.ps1",
2323
"https://github.com/Kevin-Robertson/Inveigh/blob/master/Inveigh.ps1",
2424
]
25-
risk_score = 47
25+
risk_score = 73
2626
rule_id = "951779c2-82ad-4a6c-82b8-296c1f691449"
2727
setup = """## Setup
2828
@@ -42,7 +42,7 @@ Steps to implement the logging policy via registry:
4242
reg add "hklm\\SOFTWARE\\Policies\\Microsoft\\Windows\\PowerShell\\ScriptBlockLogging" /v EnableScriptBlockLogging /t REG_DWORD /d 1
4343
```
4444
"""
45-
severity = "medium"
45+
severity = "high"
4646
tags = [
4747
"Domain: Endpoint",
4848
"OS: Windows",
@@ -63,7 +63,8 @@ event.category:process and host.os.type:windows and
6363
"0x4e,0x54,0x20,0x4c,0x4d" or
6464
"0x53,0x4d,0x42,0x20,0x32" or
6565
"0x81,0xbb,0x7a,0x36,0x44,0x98,0xf1,0x35,0xad,0x32,0x98,0xf0,0x38"
66-
)
66+
) and
67+
not file.directory : "C:\ProgramData\Microsoft\Windows Defender Advanced Threat Protection\Downloads"
6768
'''
6869

6970

rules/windows/defense_evasion_posh_assembly_load.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ integration = ["windows"]
44
maturity = "production"
55
min_stack_comments = "KQL handles backslash and ? characters differently in 8.12+."
66
min_stack_version = "8.12.0"
7-
updated_date = "2024/03/12"
7+
updated_date = "2024/07/17"
88

99
[transform]
1010
[[transform.osquery]]
@@ -142,6 +142,9 @@ event.category:process and host.os.type:windows and
142142
("Get-SolutionFiles" or "Get-VisualStudio" or "Select-MSBuildPath") and
143143
file.name : "PathFunctions.ps1"
144144
) and
145+
not powershell.file.script_block_text : (
146+
"Microsoft.PowerShell.Workflow.ServiceCore" and "ExtractPluginProperties([string]$pluginDir"
147+
) and
145148
not user.id : "S-1-5-18"
146149
'''
147150

rules/windows/defense_evasion_posh_compressed.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ integration = ["windows"]
44
maturity = "production"
55
min_stack_comments = "KQL handles backslash and ? characters differently in 8.12+."
66
min_stack_version = "8.12.0"
7-
updated_date = "2024/03/12"
7+
updated_date = "2024/07/17"
88

99
[transform]
1010
[[transform.osquery]]
@@ -103,7 +103,7 @@ Attackers can embed compressed and encoded payloads in scripts to load directly
103103
- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
104104
- 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).
105105
"""
106-
risk_score = 47
106+
risk_score = 73
107107
rule_id = "81fe9dc6-a2d7-4192-a2d8-eed98afc766a"
108108
setup = """## Setup
109109
@@ -123,7 +123,7 @@ Steps to implement the logging policy via registry:
123123
reg add "hklm\\SOFTWARE\\Policies\\Microsoft\\Windows\\PowerShell\\ScriptBlockLogging" /v EnableScriptBlockLogging /t REG_DWORD /d 1
124124
```
125125
"""
126-
severity = "medium"
126+
severity = "high"
127127
tags = ["Domain: Endpoint", "OS: Windows", "Use Case: Threat Detection", "Tactic: Defense Evasion", "Resources: Investigation Guide", "Data Source: PowerShell Logs"]
128128
timestamp_override = "event.ingested"
129129
type = "query"

rules/windows/defense_evasion_posh_encryption.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -81,7 +81,12 @@ event.category:process and host.os.type:windows and
8181
".CreateEncryptor" or
8282
".CreateDecryptor"
8383
)
84-
) and not user.id : "S-1-5-18"
84+
) and
85+
not user.id : "S-1-5-18" and
86+
not (
87+
file.name : "Bootstrap.Octopus.FunctionAppenderContext.ps1" and
88+
powershell.file.script_block_text : ("function Decrypt-Variables" or "github.com/OctopusDeploy")
89+
)
8590
'''
8691

8792

rules/windows/defense_evasion_posh_process_injection.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2021/10/14"
33
integration = ["windows"]
44
maturity = "production"
5-
updated_date = "2024/05/21"
5+
updated_date = "2024/07/17"
66

77
[rule]
88
author = ["Elastic"]
@@ -60,7 +60,7 @@ references = [
6060
"https://github.com/BC-SECURITY/Empire/blob/master/empire/server/data/module_source/credentials/Invoke-Mimikatz.ps1",
6161
"https://www.elastic.co/security-labs/detect-credential-access",
6262
]
63-
risk_score = 47
63+
risk_score = 73
6464
rule_id = "2e29e96a-b67c-455a-afe4-de6183431d0d"
6565
setup = """## Setup
6666
@@ -80,7 +80,7 @@ Steps to implement the logging policy via registry:
8080
reg add "hklm\\SOFTWARE\\Policies\\Microsoft\\Windows\\PowerShell\\ScriptBlockLogging" /v EnableScriptBlockLogging /t REG_DWORD /d 1
8181
```
8282
"""
83-
severity = "medium"
83+
severity = "high"
8484
tags = [
8585
"Domain: Endpoint",
8686
"OS: Windows",
@@ -101,8 +101,10 @@ event.category:process and host.os.type:windows and
101101
(WriteProcessMemory or CreateRemoteThread or NtCreateThreadEx or CreateThread or QueueUserAPC or
102102
SuspendThread or ResumeThread or GetDelegateForFunctionPointer)
103103
) and not
104-
(user.id:("S-1-5-18" or "S-1-5-19") and
105-
file.directory: "C:\\ProgramData\\Microsoft\\Windows Defender Advanced Threat Protection\\SenseCM")
104+
file.directory: (
105+
"C:\ProgramData\Microsoft\Windows Defender Advanced Threat Protection\SenseCM" or
106+
"C:\ProgramData\Microsoft\Windows Defender Advanced Threat Protection\Downloads"
107+
)
106108
'''
107109

108110

rules/windows/discovery_posh_suspicious_api_functions.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ integration = ["windows"]
44
maturity = "production"
55
min_stack_comments = "KQL handles backslash and ? characters differently in 8.12+."
66
min_stack_version = "8.12.0"
7-
updated_date = "2024/03/12"
7+
updated_date = "2024/07/17"
88

99
[rule]
1010
author = ["Elastic"]
@@ -57,7 +57,7 @@ references = [
5757
"https://github.com/BC-SECURITY/Empire/blob/9259e5106986847d2bb770c4289c0c0f1adf2344/data/module_source/situational_awareness/network/powerview.ps1#L21413",
5858
"https://github.com/atc-project/atc-data/blob/master/docs/Logging_Policies/LP_0109_windows_powershell_script_block_log.md",
5959
]
60-
risk_score = 47
60+
risk_score = 21
6161
rule_id = "61ac3638-40a3-44b2-855a-985636ca985e"
6262
setup = """## Setup
6363
@@ -77,7 +77,7 @@ Steps to implement the logging policy via registry:
7777
reg add "hklm\\SOFTWARE\\Policies\\Microsoft\\Windows\\PowerShell\\ScriptBlockLogging" /v EnableScriptBlockLogging /t REG_DWORD /d 1
7878
```
7979
"""
80-
severity = "medium"
80+
severity = "low"
8181
tags = ["Domain: Endpoint", "OS: Windows", "Use Case: Threat Detection", "Tactic: Discovery", "Tactic: Collection", "Tactic: Execution", "Resources: Investigation Guide", "Data Source: PowerShell Logs"]
8282
timestamp_override = "event.ingested"
8383
type = "query"
@@ -109,6 +109,11 @@ event.category:process and host.os.type:windows and
109109
LsaEnumerateTrustedDomains or
110110
NetScheduleJobEnum or
111111
NetUserModalsGet
112+
) and
113+
not powershell.file.script_block_text : (
114+
("DsGetSiteName" and ("DiscoverWindowsComputerProperties.ps1" and "param($SourceType, $SourceId, $ManagedEntityId, $ComputerIdentity)")) or
115+
("# Copyright: (c) 2018, Ansible Project" and "#Requires -Module Ansible.ModuleUtils.AddType" and "#AnsibleRequires -CSharpUtil Ansible.Basic") or
116+
("Ansible.Windows.Setup" and "Ansible.Windows.Setup" and "NativeMethods.NetWkstaGetInfo(null, 100, out netBuffer);")
112117
)
113118
'''
114119

rules/windows/execution_posh_hacktool_authors.toml

Lines changed: 4 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 = "2024/05/21"
5+
updated_date = "2024/07/17"
66

77
[rule]
88
author = ["Elastic"]
@@ -73,9 +73,9 @@ host.os.type:windows and event.category:process and
7373
"itm4n" or "nurfed1" or
7474
"cfalta" or "Scott Sutherland" or
7575
"_nullbind" or "_tmenochet" or
76-
"Boe Prox" or "jaredcatkinson" or
77-
"ChrisTruncer" or "monoxgas" or
78-
"TheRealWover" or "splinter_code"
76+
"jaredcatkinson" or "ChrisTruncer" or
77+
"monoxgas" or "TheRealWover" or
78+
"splinter_code"
7979
)
8080
'''
8181

0 commit comments

Comments
 (0)