Skip to content

Commit a66394c

Browse files
[New BBR] Reverse Connection through Port Knocking (#3219)
* [New BBR] Reverse Connection through Port Knocking * Attempt to fix unit testing error * Mitre list fix? * Revert "Mitre list fix?" This reverts commit 83682b8. * Update command_and_control_linux_port_knocking_reverse_connection.toml * Update command_and_control_linux_port_knocking_reverse_connection.toml * Update rules_building_block/command_and_control_linux_port_knocking_reverse_connection.toml * Update command_and_control_linux_port_knocking_reverse_connection.toml * Update command_and_control_linux_port_knocking_reverse_connection.toml --------- Co-authored-by: Colson Wilhoit <48036388+DefSecSentinel@users.noreply.github.com>
1 parent d093336 commit a66394c

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
[metadata]
2+
bypass_bbr_timing = true
3+
creation_date = "2023/10/24"
4+
integration = ["endpoint", "network_traffic"]
5+
maturity = "production"
6+
min_stack_comments = "New fields added: required_fields, related_integrations, setup"
7+
min_stack_version = "8.3.0"
8+
updated_date = "2023/10/24"
9+
10+
[rule]
11+
author = ["Elastic"]
12+
building_block_type = "default"
13+
description = """
14+
Monitors for a sequence of network activity on atypical ports, prior to receiving a single packet on such a non-standard
15+
port, which potentially indicates signal port knocking activity. Port knocking is a covert method of externally opening
16+
ports by sending a sequence of packets to previously closed ports, which adversaries may leverage to discreetly gain
17+
access without directly alerting traditional monitoring systems.
18+
"""
19+
from = "now-9m"
20+
index = ["logs-endpoint.events.*", "logs-network_traffic.*"]
21+
language = "eql"
22+
license = "Elastic License v2"
23+
name = "Potential Linux Reverse Connection through Port Knocking"
24+
references = ["https://github.com/f0rb1dd3n/Reptile"]
25+
risk_score = 21
26+
rule_id = "86c3157c-a951-4a4f-989b-2f0d0f1f9518"
27+
severity = "low"
28+
tags = [
29+
"Domain: Endpoint",
30+
"OS: Linux",
31+
"Use Case: Threat Detection",
32+
"Tactic: Command and Control",
33+
"Data Source: Elastic Defend",
34+
"Rule Type: BBR"
35+
]
36+
type = "eql"
37+
query = '''
38+
sequence by host.id with maxspan=10s
39+
[network where host.os.type == "linux" and event.action in ("connection_accepted", "connection_attempted") and
40+
event.type == "start" and process.name : "*" and (
41+
process.name : (
42+
"python*", "php*", "perl*", "ruby", "lua*", "openssl", "nc", "netcat", "ncat", "telnet",
43+
"awk", "gawk", "mawk", "nawk", "bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh"
44+
) or not process.executable : ("/usr/bin/*", "/bin/*")
45+
) and not (
46+
cidrmatch(destination.ip, "127.0.0.0/8", "169.254.0.0/16", "224.0.0.0/4", "::1") or destination.port in (
47+
20, 21, 22, 23, 25, 53, 67, 68, 69, 80, 110, 123, 137, 138, 139, 143, 161, 162, 179, 443, 445, 465, 514, 515,
48+
587,636, 989, 990, 993, 995, 1025, 1026, 1080, 1194, 1433, 1434, 1521, 1701, 1723, 1812, 1813, 2082, 2083, 2086,
49+
2087, 2095, 2096, 2121, 2483, 2484, 3306, 3389, 3478, 3497, 3544, 3689, 3784, 3785, 389, 3998, 5060, 5061, 5190,
50+
5222, 5223, 5228, 5432, 5500, 554, 5631, 5632, 5800, 5801, 5900, 5901, 8000, 8008, 8080, 8081, 8443, 8888, 9100,
51+
9200, 9443, 10000
52+
) or source.port in (
53+
20, 21, 22, 23, 25, 53, 67, 68, 69, 80, 110, 123, 137, 138, 139, 143, 161, 162, 179, 443, 445, 465, 514, 515,
54+
587, 636, 989, 990, 993, 995, 1025, 1026, 1080, 1194, 1433, 1434, 1521, 1701, 1723, 1812, 1813, 2082, 2083, 2086,
55+
2087, 2095, 2096, 2121, 2483, 2484, 3306, 3389, 3478, 3497, 3544, 3689, 3784, 3785, 389, 3998, 5060, 5061, 5190,
56+
5222, 5223, 5228, 5432, 5500, 554, 5631, 5632, 5800, 5801, 5900, 5901, 8000, 8008, 8080, 8081, 8443, 8888, 9100,
57+
9200, 9443, 10000)
58+
)
59+
] by destination.ip
60+
[network where event.dataset == "network_traffic.flow" and host.os.type == "linux" and event.action == "network_flow"
61+
and event.type == "connection" and source.packets == 1 and flow.final == false and not (
62+
cidrmatch(destination.ip, "127.0.0.0/8", "169.254.0.0/16", "224.0.0.0/4", "::1") or destination.port in (
63+
20, 21, 22, 23, 25, 53, 67, 68, 69, 80, 110, 123, 137, 138, 139, 143, 161, 162, 179, 443, 445, 465, 514, 515,
64+
587,636, 989, 990, 993, 995, 1025, 1026, 1080, 1194, 1433, 1434, 1521, 1701, 1723, 1812, 1813, 2082, 2083, 2086,
65+
2087, 2095, 2096, 2121, 2483, 2484, 3306, 3389, 3478, 3497, 3544, 3689, 3784, 3785, 389, 3998, 5060, 5061, 5190,
66+
5222, 5223, 5228, 5432, 5500, 554, 5631, 5632, 5800, 5801, 5900, 5901, 8000, 8008, 8080, 8081, 8443, 8888, 9100,
67+
9200, 9443, 10000
68+
) or source.port in (
69+
20, 21, 22, 23, 25, 53, 67, 68, 69, 80, 110, 123, 137, 138, 139, 143, 161, 162, 179, 443, 445, 465, 514, 515,
70+
587, 636, 989, 990, 993, 995, 1025, 1026, 1080, 1194, 1433, 1434, 1521, 1701, 1723, 1812, 1813, 2082, 2083, 2086,
71+
2087, 2095, 2096, 2121, 2483, 2484, 3306, 3389, 3478, 3497, 3544, 3689, 3784, 3785, 389, 3998, 5060, 5061, 5190,
72+
5222, 5223, 5228, 5432, 5500, 554, 5631, 5632, 5800, 5801, 5900, 5901, 8000, 8008, 8080, 8081, 8443, 8888, 9100,
73+
9200, 9443, 10000)
74+
)
75+
] by source.ip
76+
'''
77+
78+
[[rule.threat]]
79+
framework = "MITRE ATT&CK"
80+
81+
[rule.threat.tactic]
82+
id = "TA0011"
83+
name = "Command and Control"
84+
reference = "https://attack.mitre.org/tactics/TA0011/"
85+
86+
[[rule.threat.technique]]
87+
id = "T1571"
88+
name = "Non-Standard Port"
89+
reference = "https://attack.mitre.org/techniques/T1571/"
90+
91+
[[rule.threat.technique]]
92+
id = "T1205"
93+
name = "Traffic Signaling"
94+
reference = "https://attack.mitre.org/techniques/T1205/"
95+
96+
[[rule.threat.technique.subtechnique]]
97+
id = "T1205.001"
98+
name = "Port Knocking"
99+
reference = "https://attack.mitre.org/techniques/T1205/001/"
100+
101+
[[rule.threat]]
102+
framework = "MITRE ATT&CK"
103+
104+
[rule.threat.tactic]
105+
id = "TA0005"
106+
name = "Defense Evasion"
107+
reference = "https://attack.mitre.org/tactics/TA0005/"
108+

0 commit comments

Comments
 (0)