Skip to content

Commit a6c5cfc

Browse files
[Rule Tuning] Optimize query for Query Registry using Built-in Tools (#3330)
* [Rule Tuning] Optimize query for Query Registry using Built-in Tools * reduce history window to 7d * use args vs command_line wildcards --------- Co-authored-by: brokensound77 <[email protected]>
1 parent 4b183be commit a6c5cfc

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

rules_building_block/discovery_generic_registry_query.toml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ integration = ["endpoint"]
44
maturity = "production"
55
min_stack_comments = "Multiple field support in the New Terms rule type was added in Elastic 8.6"
66
min_stack_version = "8.6.0"
7-
updated_date = "2023/09/21"
7+
updated_date = "2023/12/13"
88
bypass_bbr_timing = true
99

1010
[rule]
@@ -14,8 +14,9 @@ description = """
1414
This rule identifies the execution of commands that can be used to query the Windows Registry. Adversaries may query the
1515
registry to gain situational awareness about the host, like installed security software, programs and settings.
1616
"""
17-
from = "now-9m"
18-
index = ["logs-endpoint.events.*"]
17+
from = "now-24h"
18+
index = ["logs-endpoint.events.process*"]
19+
interval = "24h"
1920
language = "kuery"
2021
license = "Elastic License v2"
2122
name = "Query Registry using Built-in Tools"
@@ -33,11 +34,20 @@ timestamp_override = "event.ingested"
3334
type = "new_terms"
3435

3536
query = '''
36-
host.os.type:windows and event.category:process and event.type:start and (
37-
(process.name.caseless:"reg.exe" and process.args:"query") or
38-
(process.name.caseless:("powershell.exe" or "powershell_ise.exe" or "pwsh.exe") and
39-
process.command_line.caseless:((*Get-ChildItem* or *Get-Item* or *Get-ItemProperty*) and
40-
(*HKCU* or *HKEY_CURRENT_USER* or *HKEY_LOCAL_MACHINE* or *HKLM* or *Registry\:\:*))))
37+
host.os.type:windows and event.category:process and event.type:start and
38+
(
39+
(process.name.caseless:"reg.exe" and process.args:"query") or
40+
(process.name.caseless:("powershell.exe" or "powershell_ise.exe" or "pwsh.exe") and
41+
process.args:(
42+
("get-childitem" or "Get-ChildItem" or "gci" or "dir" or "ls" or
43+
"get-item" or "Get-Item" or "gi" or
44+
"get-itemproperty" or "Get-ItemProperty" or "gp") and
45+
("hkcu" or "HKCU" or "hkey_current_user" or "HKEY_CURRENT_USER" or
46+
"hkey_local_machine" or "HKEY_LOCAL_MACHINE" or
47+
"hklm" or "HKLM" or registry\:\:*)
48+
)
49+
)
50+
)
4151
'''
4252

4353
[[rule.threat]]
@@ -59,4 +69,4 @@ value = ["host.id", "user.id"]
5969

6070
[[rule.new_terms.history_window_start]]
6171
field = "history_window_start"
62-
value = "now-14d"
72+
value = "now-7d"

0 commit comments

Comments
 (0)