Skip to content

Commit bcec8a4

Browse files
Linux Shell Evasion Rule Tuning (#1878)
* Linux Shell Evasion Rule Tuning * Update execution_python_tty_shell.toml * Update rules/linux/execution_apt_binary.toml Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com> * Update rules/linux/execution_apt_binary.toml * Update rules/linux/execution_awk_binary_shell.toml Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com> * Update rules/linux/execution_awk_binary_shell.toml * Update rules/linux/execution_c89_c99_binary.toml Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com> * Update rules/linux/execution_c89_c99_binary.toml * Update rules/linux/execution_cpulimit_binary.toml Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com> * Update rules/linux/execution_cpulimit_binary.toml * Update rules/linux/execution_expect_binary.toml Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com> * Update rules/linux/execution_expect_binary.toml Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com> * Update rules/linux/execution_expect_binary.toml * Update rules/linux/execution_find_binary.toml Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com> * Update rules/linux/execution_find_binary.toml * Update rules/linux/execution_gcc_binary.toml Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com> * Update rules/linux/execution_gcc_binary.toml * Update rules/linux/execution_mysql_binary.toml Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com> * Update rules/linux/execution_mysql_binary.toml * Update rules/linux/execution_nice_binary.toml Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com> * Update rules/linux/execution_nice_binary.toml * Update rules/linux/execution_ssh_binary.toml Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com> * Update rules/linux/execution_ssh_binary.toml * Update execution_perl_tty_shell.toml * Update execution_python_tty_shell.toml * Update rules/linux/execution_apt_binary.toml Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com> * Update rules/linux/execution_awk_binary_shell.toml Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com> * Update rules/linux/execution_c89_c99_binary.toml Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com> * Update rules/linux/execution_cpulimit_binary.toml Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com> * Update rules/linux/execution_expect_binary.toml Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com> * Update rules/linux/execution_find_binary.toml Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com> * Update rules/linux/execution_gcc_binary.toml Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com> * Update rules/linux/execution_mysql_binary.toml Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com> * Update rules/linux/execution_nice_binary.toml Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com> * Update rules/linux/execution_ssh_binary.toml Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com> Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com>
1 parent fb40a4a commit bcec8a4

15 files changed

+36
-43
lines changed

rules/linux/execution_apt_binary.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ timestamp_override = "event.ingested"
2626
type = "eql"
2727

2828
query = '''
29-
sequence by host.id, process.pid with maxspan=1m
30-
[process where process.name : ("apt", "apt-get") and process.args : "changelog"]
31-
[process where process.name : "sensible-pager" and process.args : ("/bin/sh", "/bin/bash") and
32-
process.parent.name : ("apt", "apt-get")]
29+
process where event.type == "start" and process.name == "sensible-pager" and
30+
process.args in ("/bin/sh", "/bin/bash", "/bin/dash", "sh", "bash", "dash") and
31+
process.parent.name in ("apt", "apt-get") and process.parent.args == "changelog"
3332
'''
3433

3534

rules/linux/execution_awk_binary_shell.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ timestamp_override = "event.ingested"
2525
type = "eql"
2626

2727
query = '''
28-
sequence by host.id, process.pid with maxspan=1m
29-
[process where process.name : ("nawk", "mawk", "awk", "gawk") and process.args : "BEGIN {system(*)}"]
30-
[process where process.parent.name : ("nawk", "mawk", "awk", "gawk") and process.name : ("sh", "bash")]
28+
process where event.type == "start" and process.name in ("sh", "bash", "dash") and
29+
process.parent.name in ("nawk", "mawk", "awk", "gawk") and process.parent.args : "BEGIN {system(*)}"
3130
'''
3231

3332

rules/linux/execution_busybox_binary.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[metadata]
22
creation_date = "2022/03/15"
33
maturity = "production"
4-
updated_date = "2022/03/15"
4+
updated_date = "2022/03/24"
55

66
[rule]
77
author = ["Elastic"]
@@ -25,7 +25,7 @@ timestamp_override = "event.ingested"
2525
type = "eql"
2626

2727
query = '''
28-
process where event.type == "start" and process.name : "busybox" and process.args_count == 2 and process.args : ("/bin/sh", "/bin/ash", "sh", "ash")
28+
process where event.type == "start" and process.name == "busybox" and process.args_count == 2 and process.args in ("/bin/sh", "/bin/ash", "sh", "ash")
2929
'''
3030

3131

rules/linux/execution_c89_c99_binary.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[metadata]
22
creation_date = "2022/03/15"
33
maturity = "production"
4-
updated_date = "2022/03/15"
4+
updated_date = "2022/03/24"
55

66
[rule]
77
author = ["Elastic"]
@@ -25,9 +25,9 @@ timestamp_override = "event.ingested"
2525
type = "eql"
2626

2727
query = '''
28-
sequence by host.id, process.pid with maxspan=1m
29-
[process where process.name :("c89","c99") and process.args == "-wrapper" and process.args : ("sh,-s", "bash,-s", "dash,-s", "/bin/sh,-s", "/bin/bash,-s", "/bin/dash,-s")]
30-
[process where process.parent.name : ("bash", "sh", "dash")]
28+
process where event.type == "start" and process.name in ("sh", "dash", "bash") and
29+
process.parent.name in ("c89","c99") and process.parent.args == "-wrapper" and
30+
process.parent.args in ("sh,-s", "bash,-s", "dash,-s", "/bin/sh,-s", "/bin/bash,-s", "/bin/dash,-s")
3131
'''
3232

3333

rules/linux/execution_cpulimit_binary.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[metadata]
22
creation_date = "2022/03/17"
33
maturity = "production"
4-
updated_date = "2022/03/17"
4+
updated_date = "2022/03/24"
55

66
[rule]
77
author = ["Elastic"]
@@ -26,9 +26,9 @@ timestamp_override = "event.ingested"
2626
type = "eql"
2727

2828
query = '''
29-
sequence by host.id, process.pid with maxspan=1m
30-
[process where event.type == "start" and process.name == "cpulimit" and process.args == "-f" and process.args : ("/bin/sh", "/bin/bash", "/bin/dash", "sh", "bash", "dash")]
31-
[process where process.parent.name == "cpulimit" and process.name : ("bash", "sh", "dash")]
29+
process where event.type == "start" and process.name in ("bash", "sh", "dash") and
30+
process.parent.name == "cpulimit" and process.parent.args == "-f" and
31+
process.parent.args in ("/bin/sh", "/bin/bash", "/bin/dash", "sh", "bash", "dash")
3232
'''
3333

3434

rules/linux/execution_crash_binary.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[metadata]
22
creation_date = "2022/03/21"
33
maturity = "production"
4-
updated_date = "2022/03/21"
4+
updated_date = "2022/03/24"
55

66
[rule]
77
author = ["Elastic"]
@@ -25,9 +25,7 @@ timestamp_override = "event.ingested"
2525
type = "eql"
2626

2727
query = '''
28-
sequence by host.id, process.pid with maxspan=1m
29-
[process where event.type == "start" and process.name == "crash" and process.args : "-h"]
30-
[process where process.parent.name == "crash" and process.name : "sh"]
28+
process where event.type == "start" and process.parent.name == "crash" and process.parent.args == "-h" and process.name == "sh"
3129
'''
3230

3331

rules/linux/execution_expect_binary.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
creation_date = "2022/03/07"
3-
maturity = "development"
3+
maturity = "production"
44
updated_date = "2022/03/28"
55

66
[rule]
@@ -25,9 +25,9 @@ timestamp_override = "event.ingested"
2525
type = "eql"
2626

2727
query = '''
28-
sequence by host.id, process.pid with maxspan=1m
29-
[process where process.name == "expect" and process.args : "-c" and process.args : ("spawn /bin/sh;interact", "spawn /bin/bash;interact", "spawn /bin/dash;interact", "spawn sh;interact","spawn bash;interact", "spawn dash;interact")]
30-
[process where process.parent.name == "expect" and process.name : ("bash", "sh", "dash")]
28+
process where event.type == "start" and process.name in ("bash", "sh", "dash") and
29+
process.parent.name == "expect" and process.parent.args == "-c" and
30+
process.parent.args in ("spawn /bin/sh;interact", "spawn /bin/bash;interact", "spawn /bin/dash;interact", "spawn sh;interact", "spawn bash;interact", "spawn dash;interact")
3131
'''
3232

3333

rules/linux/execution_find_binary.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ timestamp_override = "event.ingested"
2525
type = "eql"
2626

2727
query = '''
28-
sequence by host.id, process.pid with maxspan=1m
29-
[process where process.name == "find" and process.args : "-exec" and process.args : ("/bin/bash", "/bin/sh", "bash", "sh") and process.args : ";"]
30-
[process where process.parent.name == "find" and process.name : ("bash", "sh")]
28+
process where event.type == "start" and process.name in ("bash", "sh") and
29+
process.parent.name == "find" and process.parent.args == "-exec" and
30+
process.parent.args == ";" and process.parent.args in ("/bin/bash", "/bin/sh", "bash", "sh")
3131
'''
3232

3333

rules/linux/execution_gcc_binary.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ timestamp_override = "event.ingested"
2525
type = "eql"
2626

2727
query = '''
28-
sequence by host.id, process.pid with maxspan=1m
29-
[process where process.name == "gcc" and process.args == "-wrapper" and process.args : ("sh,-s", "bash,-s", "dash,-s", "/bin/sh,-s", "/bin/bash,-s", "/bin/dash,-s")]
30-
[process where process.parent.name == "gcc" and process.name : ("bash", "sh", "dash")]
28+
process where event.type == "start" and process.name in ("sh", "dash", "bash") and
29+
process.parent.name == "gcc" and process.parent.args == "-wrapper" and
30+
process.parent.args in ("sh,-s", "bash,-s", "dash,-s", "/bin/sh,-s", "/bin/bash,-s", "/bin/dash,-s")
3131
'''
3232

3333

rules/linux/execution_mysql_binary.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ timestamp_override = "event.ingested"
2525
type = "eql"
2626

2727
query = '''
28-
sequence by host.id, process.pid with maxspan=1m
29-
[process where process.name == "mysql" and process.args == "-e" and process.args : ("\\!*sh", "\\!*bash", "\\!*dash", "\\!*/bin/sh", "\\!*/bin/bash", "\\!*/bin/dash")]
30-
[process where process.parent.name == "mysql" and process.name : ("bash", "sh", "dash")]
28+
process where event.type == "start" and process.name in ("bash", "sh", "dash") and
29+
process.parent.name == "mysql" and process.parent.args == "-e" and
30+
process.parent.args : ("\\!*sh", "\\!*bash", "\\!*dash", "\\!*/bin/sh", "\\!*/bin/bash", "\\!*/bin/dash")
3131
'''
3232

3333

0 commit comments

Comments
 (0)