Skip to content

Commit 6ac7105

Browse files
w0rk3rSamirbous
andauthored
[Rule Tuning] Remote File Download via PowerShell (#5062)
* [Rule Tuning] Remote File Download via PowerShell * Update command_and_control_remote_file_copy_powershell.toml * Update rules/windows/command_and_control_remote_file_copy_powershell.toml Co-authored-by: Samirbous <[email protected]> * Update command_and_control_remote_file_copy_powershell.toml --------- Co-authored-by: Samirbous <[email protected]>
1 parent 4aa6c4e commit 6ac7105

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

rules/windows/command_and_control_remote_file_copy_powershell.toml

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2020/11/30"
33
integration = ["endpoint"]
44
maturity = "production"
5-
updated_date = "2025/02/03"
5+
updated_date = "2025/09/04"
66

77
[transform]
88
[[transform.osquery]]
@@ -133,18 +133,29 @@ type = "eql"
133133

134134
query = '''
135135
sequence by process.entity_id with maxspan=30s
136-
137-
[network where host.os.type == "windows" and
138-
process.name : ("powershell.exe", "pwsh.exe", "powershell_ise.exe") and network.protocol == "dns" and
139-
not dns.question.name : (
140-
"localhost", "*.microsoft.com", "*.azureedge.net", "*.powershellgallery.com",
141-
"*.windowsupdate.com", "metadata.google.internal", "dist.nuget.org",
142-
"artifacts.elastic.co", "*.digicert.com", "packages.chocolatey.org",
143-
"outlook.office365.com"
144-
) and not user.id : "S-1-5-18"]
136+
[network where host.os.type == "windows" and
137+
process.name : ("powershell.exe", "pwsh.exe", "powershell_ise.exe") and
138+
network.protocol == "dns" and
139+
not dns.question.name : (
140+
"*.microsoft.com", "*.azureedge.net", "*.powershellgallery.com", "*.windowsupdate.com",
141+
"metadata.google.internal", "dist.nuget.org", "artifacts.elastic.co", "*.digicert.com",
142+
"*.chocolatey.org", "outlook.office365.com", "cdn.oneget.org", "ci.dot.net",
143+
"packages.icinga.com", "login.microsoftonline.com", "*.gov", "*.azure.com", "*.python.org",
144+
"dl.google.com", "sensor.cloud.tenable.com", "*.azurefd.net", "*.office.net", "*.anac*",
145+
"aka.ms", "dot.net", "*.visualstudio.com", "*.local") and
146+
not user.id == "S-1-5-18" and
147+
/* Filter out NetBIOS/LLMNR-style names (e.g. host, localhost, etc.) */
148+
dns.question.name regex """.*\.[a-zA-Z]{2,5}"""]
145149
[file where host.os.type == "windows" and event.type == "creation" and
146-
process.name : "powershell.exe" and file.extension : ("exe", "dll", "ps1", "bat") and
147-
not file.name : "__PSScriptPolicy*.ps1"]
150+
process.name : "powershell.exe" and
151+
(file.extension : ("exe", "dll", "ps1", "bat") or file.Ext.header_bytes : "4d5a*") and
152+
not file.name : "__PSScriptPolicy*.ps1" and
153+
not file.path : (
154+
"?:\\Users\\*\\AppData\\Local\\Temp\\????????.dll",
155+
"?:\\Users\\*\\AppData\\Local\\Temp\\*\\????????.dll",
156+
"?:\\Windows\\TEMP\\ansible-tmp-*\\AnsiballZ*.ps1"
157+
) and
158+
not user.id == "S-1-5-18"]
148159
'''
149160

150161

0 commit comments

Comments
 (0)