Skip to content

Commit d291893

Browse files
Merge branch 'main' into issue-4023
2 parents a785a60 + 74f11db commit d291893

17 files changed

+421
-162
lines changed

.github/workflows/version-code-and-release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
- 'hunting/**/*.py'
88
- '!hunting/**/*.md'
99
- '!hunting/index.md'
10+
- '!hunting/**/*.toml'
1011
- 'pyproject.toml'
1112
- 'Makefile'
1213
- 'docs/**'

hunting/linux/docs/persistence_via_ssh_configurations_and_keys.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ SELECT
3737
g.groupname AS group_owner,
3838
datetime(f.atime, 'unixepoch') AS file_last_access_time,
3939
datetime(f.mtime, 'unixepoch') AS file_last_modified_time,
40-
datetime(f.ctime, 'unixepoch') AS file_last_status change_time,
40+
datetime(f.ctime, 'unixepoch') AS file_last_status_change_time,
4141
datetime(f.btime, 'unixepoch') AS file_created_time,
4242
f.size AS size_bytes
4343
FROM
@@ -51,7 +51,27 @@ WHERE
5151
OR f.path LIKE "/home/%/.ssh/%"
5252
OR f.path LIKE "/etc/ssh/%"
5353
OR f.path LIKE "/etc/ssh/sshd_config.d/%"
54-
OR f.path LIKE "/etc/ssh/ssh_config.d/%"
54+
OR f.path LIKE "/usr/sbin/.ssh/%"
55+
OR f.path LIKE "/bin/.ssh/%"
56+
OR f.path LIKE "/usr/games/.ssh/%"
57+
OR f.path LIKE "/var/cache/man/.ssh/%"
58+
OR f.path LIKE "/var/mail/.ssh/%"
59+
OR f.path LIKE "/var/spool/news/.ssh/%"
60+
OR f.path LIKE "/var/spool/lpd/.ssh/%"
61+
OR f.path LIKE "/var/backups/.ssh/%"
62+
OR f.path LIKE "/var/list/.ssh/%"
63+
OR f.path LIKE "/run/ircd/.ssh/%"
64+
OR f.path LIKE "/var/lib/gnats/.ssh/%"
65+
OR f.path LIKE "/nonexistent/.ssh/%"
66+
OR f.path LIKE "/run/systemd/.ssh/%"
67+
OR f.path LIKE "/var/cache/pollinate/.ssh/%"
68+
OR f.path LIKE "/run/sshd/.ssh/%"
69+
OR f.path LIKE "/home/syslog/.ssh/%"
70+
OR f.path LIKE "/run/uuidd/.ssh/%"
71+
OR f.path LIKE "/var/lib/tpm/.ssh/%"
72+
OR f.path LIKE "/var/lib/landscape/.ssh/%"
73+
OR f.path LIKE "/var/lib/usbmux/.ssh/%"
74+
OR f.path LIKE "/var/snap/lxd/common/lxd/.ssh/%";
5575
```
5676

5777
```sql

hunting/linux/queries/persistence_via_ssh_configurations_and_keys.toml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ SELECT
3737
g.groupname AS group_owner,
3838
datetime(f.atime, 'unixepoch') AS file_last_access_time,
3939
datetime(f.mtime, 'unixepoch') AS file_last_modified_time,
40-
datetime(f.ctime, 'unixepoch') AS file_last_status change_time,
40+
datetime(f.ctime, 'unixepoch') AS file_last_status_change_time,
4141
datetime(f.btime, 'unixepoch') AS file_created_time,
4242
f.size AS size_bytes
4343
FROM
@@ -51,7 +51,27 @@ WHERE
5151
OR f.path LIKE "/home/%/.ssh/%"
5252
OR f.path LIKE "/etc/ssh/%"
5353
OR f.path LIKE "/etc/ssh/sshd_config.d/%"
54-
OR f.path LIKE "/etc/ssh/ssh_config.d/%"
54+
OR f.path LIKE "/usr/sbin/.ssh/%"
55+
OR f.path LIKE "/bin/.ssh/%"
56+
OR f.path LIKE "/usr/games/.ssh/%"
57+
OR f.path LIKE "/var/cache/man/.ssh/%"
58+
OR f.path LIKE "/var/mail/.ssh/%"
59+
OR f.path LIKE "/var/spool/news/.ssh/%"
60+
OR f.path LIKE "/var/spool/lpd/.ssh/%"
61+
OR f.path LIKE "/var/backups/.ssh/%"
62+
OR f.path LIKE "/var/list/.ssh/%"
63+
OR f.path LIKE "/run/ircd/.ssh/%"
64+
OR f.path LIKE "/var/lib/gnats/.ssh/%"
65+
OR f.path LIKE "/nonexistent/.ssh/%"
66+
OR f.path LIKE "/run/systemd/.ssh/%"
67+
OR f.path LIKE "/var/cache/pollinate/.ssh/%"
68+
OR f.path LIKE "/run/sshd/.ssh/%"
69+
OR f.path LIKE "/home/syslog/.ssh/%"
70+
OR f.path LIKE "/run/uuidd/.ssh/%"
71+
OR f.path LIKE "/var/lib/tpm/.ssh/%"
72+
OR f.path LIKE "/var/lib/landscape/.ssh/%"
73+
OR f.path LIKE "/var/lib/usbmux/.ssh/%"
74+
OR f.path LIKE "/var/snap/lxd/common/lxd/.ssh/%";
5575
''',
5676
'''
5777
from logs-endpoint.events.process-*

rules/integrations/azure/defense_evasion_azure_blob_permissions_modified.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2021/09/22"
33
integration = ["azure"]
44
maturity = "production"
5-
updated_date = "2024/05/21"
5+
updated_date = "2025/01/11"
66

77
[rule]
88
author = ["Austin Songer"]
@@ -32,8 +32,7 @@ tags = [
3232
"Domain: Cloud",
3333
"Data Source: Azure",
3434
"Use Case: Identity and Access Audit",
35-
"Tactic: Defense Evasion",
36-
"Data Source: Elastic Defend",
35+
"Tactic: Defense Evasion"
3736
]
3837
timestamp_override = "event.ingested"
3938
type = "query"
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
[metadata]
2+
creation_date = "2025/01/09"
3+
integration = ["auditd_manager"]
4+
maturity = "production"
5+
updated_date = "2025/01/09"
6+
7+
[rule]
8+
author = ["Elastic"]
9+
description = """
10+
This rule leverages Auditd data to detect the use of the `prctl` syscall to potentially hide a process
11+
by changing its name. The `prctl` syscall is used to control various process attributes. Attackers can use
12+
this syscall to change the name of a process to a hidden directory or file, making it harder to detect. The query
13+
looks for the `prctl` syscall with the `PR_SET_NAME` argument set to `f` (PR_SET_NAME is used to set the name of a process).
14+
"""
15+
from = "now-9m"
16+
index = ["logs-auditd_manager.auditd-*", "auditbeat-*"]
17+
language = "eql"
18+
license = "Elastic License v2"
19+
name = "Potential Process Name Stomping with Prctl"
20+
references = [
21+
"https://haxrob.net/process-name-stomping/",
22+
"https://haxrob.net/hiding-in-plain-sight-part-2/",
23+
"https://www.elastic.co/security-labs/linux-detection-engineering-with-auditd",
24+
]
25+
risk_score = 47
26+
rule_id = "fef62ecf-0260-4b71-848b-a8624b304828"
27+
setup = """## Setup
28+
29+
This rule requires data coming in from Auditd Manager.
30+
31+
### Auditd Manager Integration Setup
32+
The Auditd Manager Integration receives audit events from the Linux Audit Framework which is a part of the Linux kernel.
33+
Auditd Manager provides a user-friendly interface and automation capabilities for configuring and monitoring system auditing through the auditd daemon. With `auditd_manager`, administrators can easily define audit rules, track system events, and generate comprehensive audit reports, improving overall security and compliance in the system.
34+
35+
#### The following steps should be executed in order to add the Elastic Agent System integration "auditd_manager" on a Linux System:
36+
- Go to the Kibana home page and click “Add integrations”.
37+
- In the query bar, search for “Auditd Manager” and select the integration to see more details about it.
38+
- Click “Add Auditd Manager”.
39+
- Configure the integration name and optionally add a description.
40+
- Review optional and advanced settings accordingly.
41+
- Add the newly installed “auditd manager” to an existing or a new agent policy, and deploy the agent on a Linux system from which auditd log files are desirable.
42+
- Click “Save and Continue”.
43+
- For more details on the integration refer to the [helper guide](https://docs.elastic.co/integrations/auditd_manager).
44+
45+
#### Rule Specific Setup Note
46+
Auditd Manager subscribes to the kernel and receives events as they occur without any additional configuration.
47+
However, if more advanced configuration is required to detect specific behavior, audit rules can be added to the integration in either the "audit rules" configuration box or the "auditd rule files" box by specifying a file to read the audit rules from.
48+
- For this detection rule the following additional audit rules are required to be added to the integration:
49+
-- "-a exit,always -F arch=b64 -S prctl -k prctl_detection"
50+
"""
51+
severity = "medium"
52+
tags = [
53+
"Data Source: Auditd Manager",
54+
"Domain: Endpoint",
55+
"OS: Linux",
56+
"Use Case: Threat Detection",
57+
"Tactic: Defense Evasion",
58+
]
59+
timestamp_override = "event.ingested"
60+
type = "eql"
61+
query = '''
62+
process where host.os.type == "linux" and auditd.data.syscall == "prctl" and auditd.data.a0 == "f" and
63+
process.executable like (
64+
"/boot/*", "/dev/shm/*", "/etc/cron.*/*", "/etc/init.d/*", "/var/run/*", "/etc/update-motd.d/*",
65+
"/tmp/*", "/var/log/*", "/var/tmp/*", "/home/*", "/run/shm/*", "/run/*", "./*"
66+
)
67+
'''
68+
69+
[[rule.threat]]
70+
framework = "MITRE ATT&CK"
71+
72+
[[rule.threat.technique]]
73+
id = "T1036"
74+
name = "Masquerading"
75+
reference = "https://attack.mitre.org/techniques/T1036/"
76+
77+
[[rule.threat.technique.subtechnique]]
78+
id = "T1036.005"
79+
name = "Match Legitimate Name or Location"
80+
reference = "https://attack.mitre.org/techniques/T1036/005/"
81+
82+
[rule.threat.tactic]
83+
id = "TA0005"
84+
name = "Defense Evasion"
85+
reference = "https://attack.mitre.org/tactics/TA0005/"
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
[metadata]
2+
creation_date = "2025/01/14"
3+
integration = ["windows", "system"]
4+
maturity = "production"
5+
updated_date = "2025/01/14"
6+
min_stack_version = "8.14.0"
7+
min_stack_comments = "Breaking change at 8.14.0 for the Windows Integration."
8+
9+
[rule]
10+
author = ["Elastic"]
11+
description = """
12+
Identifies attempts to disable auditing for some security sensitive audit policy sub-categories. This is often done by
13+
attackers in an attempt to evade detection and forensics on a system.
14+
"""
15+
from = "now-9m"
16+
index = [
17+
"winlogbeat-*",
18+
"logs-windows.forwarded*",
19+
"logs-system.security-*"
20+
]
21+
language = "kuery"
22+
license = "Elastic License v2"
23+
name = "Sensitive Audit Policy Sub-Category Disabled"
24+
note = """## Triage and analysis
25+
26+
### Investigating Sensitive Audit Policy Sub-Category Disabled
27+
28+
Windows event logs are a fundamental data source for security monitoring, forensics, and incident response. Adversaries can tamper, clear, and delete this data to break SIEM detections, cover their tracks, and slow down incident response.
29+
30+
This rule looks for attempts to disable security-sensitive audit policies.
31+
32+
#### Possible investigation steps
33+
34+
- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
35+
- Identify the user account that performed the action and whether it should perform this kind of action.
36+
- Contact the account owner and confirm whether they are aware of this activity.
37+
- Investigate other alerts associated with the user/host during the past 48 hours.
38+
- Verify if any other anti-forensics behaviors were observed.
39+
- Investigate the event logs prior to the action for suspicious behaviors that an attacker may be trying to cover up.
40+
41+
### False positive analysis
42+
43+
- This activity is unlikely to happen legitimately. Benign true positives (B-TPs) can be added as exceptions if necessary.
44+
45+
### Response and remediation
46+
47+
- Initiate the incident response process based on the outcome of the triage.
48+
- Isolate the involved host to prevent further post-compromise behavior.
49+
- Re-enable affected logging components, services, and security monitoring.
50+
- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
51+
- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
52+
- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
53+
- 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).
54+
"""
55+
references = [
56+
"https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/event-4719",
57+
"https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-gpac/77878370-0712-47cd-997d-b07053429f6d",
58+
]
59+
risk_score = 47
60+
rule_id = "0ef5d3eb-67ef-43ab-93b7-305cfa5a21f6"
61+
setup = """## Setup
62+
63+
The 'Audit Audit Policy Change' logging policy must be configured for (Success, Failure).
64+
Steps to implement the logging policy with Advanced Audit Configuration:
65+
66+
```
67+
Computer Configuration >
68+
Policies >
69+
Windows Settings >
70+
Security Settings >
71+
Advanced Audit Policies Configuration >
72+
Audit Policies >
73+
Policy Change >
74+
Audit Audit Policy Change (Success,Failure)
75+
```
76+
"""
77+
severity = "medium"
78+
tags = [
79+
"Domain: Endpoint",
80+
"OS: Windows",
81+
"Use Case: Threat Detection",
82+
"Tactic: Defense Evasion",
83+
"Resources: Investigation Guide",
84+
"Data Source: System",
85+
]
86+
timestamp_override = "event.ingested"
87+
type = "query"
88+
89+
query = '''
90+
event.action : "changed-audit-config" and event.code : "4719" and host.os.type : "windows" and
91+
winlog.event_data.AuditPolicyChangesDescription : "Success removed" and
92+
winlog.event_data.SubCategory : ("Logon" or "Audit Policy Change" or "Process Creation" or "Audit Other System Events" or "Audit Security Group Management" or "Audit User Account Management")
93+
'''
94+
95+
96+
[[rule.threat]]
97+
framework = "MITRE ATT&CK"
98+
[[rule.threat.technique]]
99+
id = "T1070"
100+
name = "Indicator Removal"
101+
reference = "https://attack.mitre.org/techniques/T1070/"
102+
[[rule.threat.technique.subtechnique]]
103+
id = "T1070.001"
104+
name = "Clear Windows Event Logs"
105+
reference = "https://attack.mitre.org/techniques/T1070/001/"
106+
107+
108+
[[rule.threat.technique]]
109+
id = "T1562"
110+
name = "Impair Defenses"
111+
reference = "https://attack.mitre.org/techniques/T1562/"
112+
[[rule.threat.technique.subtechnique]]
113+
id = "T1562.002"
114+
name = "Disable Windows Event Logging"
115+
reference = "https://attack.mitre.org/techniques/T1562/002/"
116+
117+
[[rule.threat.technique.subtechnique]]
118+
id = "T1562.006"
119+
name = "Indicator Blocking"
120+
reference = "https://attack.mitre.org/techniques/T1562/006/"
121+
122+
123+
124+
[rule.threat.tactic]
125+
id = "TA0005"
126+
name = "Defense Evasion"
127+
reference = "https://attack.mitre.org/tactics/TA0005/"

rules_building_block/collection_common_compressed_archived_file.toml

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@ bypass_bbr_timing = true
33
creation_date = "2023/10/11"
44
integration = "endpoint"
55
maturity = "production"
6-
updated_date = "2024/05/21"
6+
updated_date = "2025/01/09"
77

88
[rule]
99
author = ["Elastic"]
1010
building_block_type = "default"
1111
description = """
12-
Detects files being compressed or archived into common formats. This is a common technique used to obfuscate files to
13-
evade detection or to staging data for exfiltration.
12+
Detects files being compressed or archived into common formats by unsigned processes. This is a common technique used to
13+
obfuscate files to evade detection or to staging data for exfiltration.
1414
"""
1515
from = "now-9m"
1616
index = ["logs-endpoint.events.file-*"]
1717
language = "eql"
1818
license = "Elastic License v2"
19-
max_signals = 1000
20-
name = "File Compressed or Archived into Common Format"
19+
name = "File Compressed or Archived into Common Format by Unsigned Process"
2120
references = ["https://en.wikipedia.org/wiki/List_of_file_signatures"]
2221
risk_score = 21
2322
rule_id = "79124edf-30a8-4d48-95c4-11522cad94b1"
@@ -34,7 +33,8 @@ timestamp_override = "event.ingested"
3433
type = "eql"
3534

3635
query = '''
37-
file where host.os.type == "windows" and event.type in ("creation", "change") and process.executable != null and not user.id : ("S-1-5-18", "S-1-5-17") and
36+
file where host.os.type == "windows" and event.type in ("creation", "change") and
37+
process.executable != null and process.code_signature.trusted != true and
3838
file.Ext.header_bytes : (
3939
/* compression formats */
4040
"1F9D*", /* tar zip, tar.z (Lempel-Ziv-Welch algorithm) */
@@ -70,44 +70,6 @@ file where host.os.type == "windows" and event.type in ("creation", "change") an
7070
"78617221*", /* xar */
7171
"4F4152*", /* oar */
7272
"49536328*" /* cab archive */
73-
) and
74-
not (
75-
(
76-
process.name : "firefox.exe" and
77-
process.code_signature.subject_name : "Mozilla Corporation" and process.code_signature.trusted == true
78-
) or
79-
(
80-
process.name : "wazuh-agent.exe" and
81-
process.code_signature.subject_name : "Wazuh, Inc" and process.code_signature.trusted == true and
82-
file.name : ("ossec-*.log.gz", "tmp-entry.gz", "tmp-entry", "last-entry.gz")
83-
) or
84-
(
85-
process.name : ("excel.exe", "winword.exe", "powerpnt.exe") and
86-
process.code_signature.subject_name : "Microsoft Corporation" and process.code_signature.trusted == true
87-
) or
88-
(
89-
process.name : "OneDrive.exe" and
90-
process.code_signature.subject_name : "Microsoft Corporation" and process.code_signature.trusted == true and
91-
(
92-
file.extension : ("xlsx", "docx", "pptx", "xlsm") or
93-
file.path : "?:\\Users\\*\\AppData\\Local\\Microsoft\\OneDrive\\logs\\*"
94-
)
95-
) or
96-
(
97-
process.name : "Dropbox.exe" and
98-
process.code_signature.subject_name : "Dropbox, Inc" and process.code_signature.trusted == true and
99-
file.name : "store.bin"
100-
) or
101-
(
102-
process.name : "DellSupportAssistRemedationService.exe" and
103-
process.code_signature.subject_name : "Dell Inc" and process.code_signature.trusted == true and
104-
file.extension : "manifest"
105-
) or
106-
(
107-
process.name : "w3wp.exe" and
108-
process.code_signature.subject_name : "Microsoft Windows" and process.code_signature.trusted == true and
109-
file.path : "?:\\inetpub\\temp\\IIS Temporary Compressed Files\\*"
110-
)
11173
)
11274
'''
11375

0 commit comments

Comments
 (0)