Skip to content

Commit e03b77a

Browse files
Aegrahgithub-actions[bot]
authored andcommitted
[Rule Tuning] Q2 Linux DR Tuning - Part 1 (#4162)
* [Rule Tuning] Q2 Linux DR Tuning - Part 1 * Update defense_evasion_binary_copied_to_suspicious_directory.toml (cherry picked from commit af9f9e2)
1 parent 1c63b81 commit e03b77a

9 files changed

+75
-66
lines changed

rules/linux/command_and_control_linux_chisel_client_activity.toml

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

77
[transform]
88
[[transform.osquery]]
@@ -147,28 +147,27 @@ tags = [
147147
type = "eql"
148148

149149
query = '''
150-
sequence by host.id, process.entity_id with maxspan=1s
150+
sequence by host.id, process.entity_id with maxspan=3s
151151
[process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and
152152
process.args == "client" and process.args : ("R*", "*:*", "*socks*", "*.*") and process.args_count >= 4 and
153-
process.parent.name in ("bash", "dash", "ash", "sh", "tcsh", "csh", "zsh", "ksh", "fish")]
153+
process.parent.name in ("bash", "dash", "ash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and
154+
not process.name in ("velociraptor", "nbemmcmd")]
154155
[network where host.os.type == "linux" and event.action == "connection_attempted" and event.type == "start" and
155156
destination.ip != null and destination.ip != "127.0.0.1" and destination.ip != "::1" and
156157
not process.name : (
157158
"python*", "php*", "perl", "ruby", "lua*", "openssl", "nc", "netcat", "ncat", "telnet", "awk", "java", "telnet",
158159
"ftp", "socat", "curl", "wget", "dpkg", "docker", "dockerd", "yum", "apt", "rpm", "dnf", "ssh", "sshd")]
159160
'''
160161

161-
162162
[[rule.threat]]
163163
framework = "MITRE ATT&CK"
164+
164165
[[rule.threat.technique]]
165166
id = "T1572"
166167
name = "Protocol Tunneling"
167168
reference = "https://attack.mitre.org/techniques/T1572/"
168169

169-
170170
[rule.threat.tactic]
171171
id = "TA0011"
172172
name = "Command and Control"
173173
reference = "https://attack.mitre.org/tactics/TA0011/"
174-

rules/linux/command_and_control_linux_kworker_netcon.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -68,19 +68,20 @@ process.name:kworker* and not destination.ip:(
6868
"::1" or
6969
"FE80::/10" or
7070
"FF00::/8"
71-
) and not destination.port:2049
71+
) and not destination.port:("2049" or "111" or "892" or "597")
7272
'''
7373

74-
7574
[[rule.threat]]
7675
framework = "MITRE ATT&CK"
7776

7877
[rule.threat.tactic]
7978
id = "TA0011"
8079
name = "Command and Control"
8180
reference = "https://attack.mitre.org/tactics/TA0011/"
81+
8282
[[rule.threat]]
8383
framework = "MITRE ATT&CK"
84+
8485
[[rule.threat.technique]]
8586
id = "T1014"
8687
name = "Rootkit"
@@ -91,29 +92,28 @@ id = "T1036"
9192
name = "Masquerading"
9293
reference = "https://attack.mitre.org/techniques/T1036/"
9394

94-
9595
[rule.threat.tactic]
9696
id = "TA0005"
9797
name = "Defense Evasion"
9898
reference = "https://attack.mitre.org/tactics/TA0005/"
99+
99100
[[rule.threat]]
100101
framework = "MITRE ATT&CK"
102+
101103
[[rule.threat.technique]]
102104
id = "T1041"
103105
name = "Exfiltration Over C2 Channel"
104106
reference = "https://attack.mitre.org/techniques/T1041/"
105107

106-
107108
[rule.threat.tactic]
108109
id = "TA0010"
109110
name = "Exfiltration"
110111
reference = "https://attack.mitre.org/tactics/TA0010/"
111112

112113
[rule.new_terms]
113114
field = "new_terms_fields"
114-
value = ["process.name", "destination.ip", "destination.port"]
115+
value = ["process.name", "host.id"]
116+
115117
[[rule.new_terms.history_window_start]]
116118
field = "history_window_start"
117119
value = "now-14d"
118-
119-

rules/linux/command_and_control_suspicious_network_activity_from_unknown_executable.toml

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

77
[transform]
88
[[transform.osquery]]
@@ -180,35 +180,39 @@ type = "new_terms"
180180

181181
query = '''
182182
host.os.type:linux and event.category:network and event.action:(connection_attempted or ipv4_connection_attempt_event) and
183-
process.executable:(
184-
(/etc/crontab or /etc/rc.local or ./* or /boot/* or /dev/shm/* or /etc/cron.*/* or /etc/init.d/* or /etc/rc*.d/* or
183+
process.executable : (
184+
/etc/crontab or /etc/rc.local or ./* or /boot/* or /dev/shm/* or /etc/cron.*/* or /etc/init.d/* or /etc/rc*.d/* or
185185
/etc/update-motd.d/* or /home/*/.* or /tmp/* or /usr/lib/update-notifier/* or /var/log/* or /var/tmp/*
186-
) and
187-
not (/tmp/newroot/* or /tmp/snap.rootfs*) and
188-
not /etc/cron.hourly/BitdefenderRedline) and
189-
source.ip:(10.0.0.0/8 or 127.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16) and
190-
not process.name:(
191-
apt or chrome or curl or dnf or dockerd or dpkg or firefox-bin or git-remote-https or java or kite-update or kited or node
192-
or rpm or saml2aws or selenium-manager or solana-validator or wget or yum or ansible* or aws* or php* or pip* or python*
193-
or steam* or terraform*
194-
) and
195-
not destination.ip:(
196-
0.0.0.0 or 10.0.0.0/8 or 100.64.0.0/10 or 127.0.0.0/8 or 169.254.0.0/16 or 172.16.0.0/12 or 192.0.0.0/24 or 192.0.0.0/29 or
197-
192.0.0.10/32 or 192.0.0.170/32 or 192.0.0.171/32 or 192.0.0.8/32 or 192.0.0.9/32 or 192.0.2.0/24 or 192.168.0.0/16 or
198-
192.175.48.0/24 or 192.31.196.0/24 or 192.52.193.0/24 or 192.88.99.0/24 or 198.18.0.0/15 or 198.51.100.0/24 or 203.0.113.0/24
199-
or 224.0.0.0/4 or 240.0.0.0/4 or "::1" or "FE80::/10" or "FF00::/8"
186+
) and process.name : * and
187+
not (
188+
process.executable : (
189+
/tmp/newroot/* or /tmp/snap.rootfs* or /etc/cron.hourly/BitdefenderRedline or /tmp/go-build* or /srv/snp/docker/* or
190+
/run/containerd/* or /tmp/.mount* or /run/k3s/containerd/* or /tmp/selenium* or /tmp/tmp.*/juliainstaller or
191+
/tmp/.criu.mntns* or /home/*/.local/share/containers/* or /etc/update-motd.d/*
192+
) or
193+
source.ip:(10.0.0.0/8 or 127.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16) or
194+
process.name : (
195+
apt or chrome or curl or dnf or dockerd or dpkg or firefox-bin or git-remote-https or java or kite-update or
196+
kited or node or rpm or saml2aws or selenium-manager or solana-validator or wget or yum or ansible* or aws* or
197+
php* or pip* or python* or steam* or terraform*
198+
) or
199+
destination.ip:(
200+
0.0.0.0 or 10.0.0.0/8 or 100.64.0.0/10 or 127.0.0.0/8 or 169.254.0.0/16 or 172.16.0.0/12 or 192.0.0.0/24 or
201+
192.0.0.0/29 or 192.0.0.10/32 or 192.0.0.170/32 or 192.0.0.171/32 or 192.0.0.8/32 or 192.0.0.9/32 or 192.0.2.0/24 or
202+
192.168.0.0/16 or 192.175.48.0/24 or 192.31.196.0/24 or 192.52.193.0/24 or 192.88.99.0/24 or 198.18.0.0/15 or
203+
198.51.100.0/24 or 203.0.113.0/24 or 224.0.0.0/4 or 240.0.0.0/4 or "::1" or "FE80::/10" or "FF00::/8"
204+
)
200205
)
201206
'''
202207

203-
204208
[[rule.threat]]
205209
framework = "MITRE ATT&CK"
210+
206211
[[rule.threat.technique]]
207212
id = "T1071"
208213
name = "Application Layer Protocol"
209214
reference = "https://attack.mitre.org/techniques/T1071/"
210215

211-
212216
[rule.threat.tactic]
213217
id = "TA0011"
214218
name = "Command and Control"
@@ -217,8 +221,7 @@ reference = "https://attack.mitre.org/tactics/TA0011/"
217221
[rule.new_terms]
218222
field = "new_terms_fields"
219223
value = ["process.executable"]
224+
220225
[[rule.new_terms.history_window_start]]
221226
field = "history_window_start"
222227
value = "now-20d"
223-
224-

rules/linux/credential_access_potential_linux_local_account_bruteforce.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -58,7 +58,7 @@ sequence by host.id, process.parent.executable, user.id with maxspan=1s
5858
[process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and process.name == "su" and
5959
not process.parent.name in (
6060
"bash", "dash", "ash", "sh", "tcsh", "csh", "zsh", "ksh", "fish", "clickhouse-server", "ma", "gitlab-runner",
61-
"updatedb.findutils", "cron"
61+
"updatedb.findutils", "cron", "perl", "sudo", "java", "cloud-app-identify", "ambari-sudo.sh"
6262
)
6363
] with runs=10
6464
'''

rules/linux/defense_evasion_binary_copied_to_suspicious_directory.toml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2023/08/29"
33
integration = ["endpoint"]
44
maturity = "production"
5-
updated_date = "2024/09/23"
5+
updated_date = "2024/10/17"
66

77
[rule]
88
author = ["Elastic"]
@@ -59,7 +59,7 @@ timestamp_override = "event.ingested"
5959
type = "eql"
6060

6161
query = '''
62-
file where host.os.type == "linux" and event.type == "change" and event.action == "rename" and
62+
file where host.os.type == "linux" and event.type == "change" and event.action == "rename" and process.name != null and
6363
file.Ext.original.path : (
6464
"/bin/*", "/usr/bin/*", "/usr/local/bin/*", "/sbin/*", "/usr/sbin/*", "/usr/local/sbin/*"
6565
) and not (
@@ -79,6 +79,11 @@ file.Ext.original.path : (
7979
"/usr/lib/systemd/systemd", "/usr/sbin/sshd", "/sbin/sshd", "/usr/local/sbin/sshd", "/usr/sbin/crond", "/sbin/crond",
8080
"/usr/local/sbin/crond", "/usr/sbin/gdm"
8181
) or
82+
process.name like (
83+
"python*", "packagekitd", "systemd", "ln", "platform-python", "dnf_install", "runc", "apt-get", "ssm-agent-worker",
84+
"convert-usrmerge", "updatenow.static-cpanelsync", "apk", "exe", "php", "containerd-shim-runc-v2", "dpkg", "sed",
85+
"platform-python*", "gedit", "crond", "sshd", "ruby", "sudo", "chainctl", "update-alternatives", "pip*"
86+
) or
8287
file.Ext.original.path : (
8388
"/bin/*.tmp", "/usr/bin/*.tmp", "/usr/local/bin/*.tmp", "/sbin/*.tmp", "/usr/sbin/*.tmp", "/usr/local/sbin/*.tmp"
8489
) or
@@ -91,27 +96,25 @@ file.Ext.original.path : (
9196
)
9297
'''
9398

94-
9599
[[rule.threat]]
96100
framework = "MITRE ATT&CK"
101+
97102
[[rule.threat.technique]]
98103
id = "T1036"
99104
name = "Masquerading"
100105
reference = "https://attack.mitre.org/techniques/T1036/"
106+
101107
[[rule.threat.technique.subtechnique]]
102108
id = "T1036.003"
103109
name = "Rename System Utilities"
104110
reference = "https://attack.mitre.org/techniques/T1036/003/"
105111

106-
107112
[[rule.threat.technique]]
108113
id = "T1564"
109114
name = "Hide Artifacts"
110115
reference = "https://attack.mitre.org/techniques/T1564/"
111116

112-
113117
[rule.threat.tactic]
114118
id = "TA0005"
115119
name = "Defense Evasion"
116120
reference = "https://attack.mitre.org/tactics/TA0005/"
117-

rules/linux/defense_evasion_chattr_immutable_file.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -71,30 +71,31 @@ tags = [
7171
]
7272
timestamp_override = "event.ingested"
7373
type = "eql"
74-
7574
query = '''
76-
process where host.os.type == "linux" and event.type == "start" and user.id == "0" and
77-
process.executable : "/usr/bin/chattr" and process.args : ("-*i*", "+*i*") and
78-
not process.parent.executable: ("/lib/systemd/systemd", "/usr/local/uems_agent/bin/*", "/usr/lib/systemd/systemd") and
79-
not process.parent.name in ("systemd", "cf-agent", "ntpdate", "xargs", "px", "preinst", "auth")
75+
process where host.os.type == "linux" and event.type == "start" and process.parent.executable != null and
76+
process.executable : "/usr/bin/chattr" and process.args : ("-*i*", "+*i*") and not (
77+
process.parent.executable: ("/lib/systemd/systemd", "/usr/local/uems_agent/bin/*", "/usr/lib/systemd/systemd") or
78+
process.parent.name in (
79+
"systemd", "cf-agent", "ntpdate", "xargs", "px", "preinst", "auth", "cf-agent", "dcservice", "dcagentupgrader",
80+
"sudo", "ephemeral-disk-warning"
81+
)
82+
)
8083
'''
8184

82-
8385
[[rule.threat]]
8486
framework = "MITRE ATT&CK"
87+
8588
[[rule.threat.technique]]
8689
id = "T1222"
8790
name = "File and Directory Permissions Modification"
8891
reference = "https://attack.mitre.org/techniques/T1222/"
92+
8993
[[rule.threat.technique.subtechnique]]
9094
id = "T1222.002"
9195
name = "Linux and Mac File and Directory Permissions Modification"
9296
reference = "https://attack.mitre.org/techniques/T1222/002/"
9397

94-
95-
9698
[rule.threat.tactic]
9799
id = "TA0005"
98100
name = "Defense Evasion"
99101
reference = "https://attack.mitre.org/tactics/TA0005/"
100-

rules/linux/defense_evasion_dynamic_linker_file_creation.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2024/08/08"
33
integration = ["endpoint"]
44
maturity = "production"
5-
updated_date = "2024/08/08"
5+
updated_date = "2024/10/17"
66

77
[rule]
88
author = ["Elastic"]
@@ -66,16 +66,18 @@ not (
6666
"/usr/local/sbin/apk", "/usr/bin/apt", "/usr/sbin/pacman", "/bin/podman", "/usr/bin/podman", "/usr/bin/puppet",
6767
"/bin/puppet", "/opt/puppetlabs/puppet/bin/puppet", "/usr/bin/chef-client", "/bin/chef-client",
6868
"/bin/autossl_check", "/usr/bin/autossl_check", "/proc/self/exe", "/dev/fd/*", "/usr/bin/pamac-daemon",
69-
"/bin/pamac-daemon", "/usr/lib/snapd/snapd", "/usr/local/bin/dockerd", "/usr/libexec/platform-python"
69+
"/bin/pamac-daemon", "/usr/lib/snapd/snapd", "/usr/local/bin/dockerd", "/usr/libexec/platform-python",
70+
"/usr/lib/snapd/snap-update-ns", "/usr/bin/vmware-config-tools.pl"
7071
) or
7172
file.extension in ("swp", "swpx", "swx", "dpkg-remove") or
7273
file.Ext.original.extension == "dpkg-new" or
7374
process.executable : (
74-
"/nix/store/*", "/var/lib/dpkg/*", "/snap/*", "/dev/fd/*", "/usr/lib/virtualbox/*"
75+
"/nix/store/*", "/var/lib/dpkg/*", "/snap/*", "/dev/fd/*", "/usr/lib/virtualbox/*", "/opt/dynatrace/oneagent/*"
7576
) or
7677
process.executable == null or
78+
process.name == "java" or
7779
(process.name == "sed" and file.name : "sed*") or
78-
(process.name == "perl" and file.name : "e2scrub_all.tmp*")
80+
(process.name == "perl" and file.name : "e2scrub_all.tmp*")
7981
)
8082
'''
8183

rules/linux/defense_evasion_file_mod_writable_dir.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -74,7 +74,7 @@ type = "new_terms"
7474
query = '''
7575
host.os.type:linux and event.category:process and event.type:start and
7676
process.name:(chattr or chgrp or chmod or chown) and process.working_directory:(/dev/shm or /tmp or /var/tmp) and
77-
not process.parent.name:(apt-key or update-motd-updates-available)
77+
not process.parent.name:(apt-key or update-motd-updates-available or apt-get)
7878
'''
7979

8080

0 commit comments

Comments
 (0)