Potential Malware-Driven SSH Brute Force Attempt
This detection identifies a Linux host that has potentially been infected with malware and is being used to conduct brute-force attacks against external systems over SSH (port 22 and common alternative SSH ports). The detection looks for a high volume of outbound connection attempts to non-private IP addresses from a single process. A compromised host may be part of a botnet or controlled by an attacker, attempting to gain unauthorized access to remote systems. This behavior is commonly observed in SSH brute-force campaigns where malware hijacks vulnerable machines to expand its attack surface. ES|QL rules have limited fields available in its alert documents. Make sure to review the original documents to aid in the investigation of this alert.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2025/02/20"
3integration = ["endpoint"]
4maturity = "production"
5updated_date = "2025/03/20"
6
7[rule]
8author = ["Elastic"]
9description = """
10This detection identifies a Linux host that has potentially been infected with malware and is being used to conduct
11brute-force attacks against external systems over SSH (port 22 and common alternative SSH ports). The detection looks
12for a high volume of outbound connection attempts to non-private IP addresses from a single process. A compromised host
13may be part of a botnet or controlled by an attacker, attempting to gain unauthorized access to remote systems. This
14behavior is commonly observed in SSH brute-force campaigns where malware hijacks vulnerable machines to expand its
15attack surface. ES|QL rules have limited fields available in its alert documents. Make sure to review the original
16documents to aid in the investigation of this alert.
17"""
18from = "now-61m"
19interval = "1h"
20language = "esql"
21license = "Elastic License v2"
22name = "Potential Malware-Driven SSH Brute Force Attempt"
23risk_score = 47
24rule_id = "77122db4-5876-4127-b91b-6c179eb21f88"
25setup = """## Setup
26
27This rule requires data coming in from Elastic Defend.
28
29### Elastic Defend Integration Setup
30Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
31
32#### Prerequisite Requirements:
33- Fleet is required for Elastic Defend.
34- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
35
36#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
37- Go to the Kibana home page and click "Add integrations".
38- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
39- Click "Add Elastic Defend".
40- Configure the integration name and optionally add a description.
41- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
42- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
43- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
44- Enter a name for the agent policy in "New agent policy name". If other agent policies already exist, you can click the "Existing hosts" tab and select an existing policy instead.
45For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
46- Click "Save and Continue".
47- To complete the integration, select "Add Elastic Agent to your hosts" and continue to the next section to install the Elastic Agent on your hosts.
48For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
49"""
50severity = "medium"
51tags = [
52 "Domain: Endpoint",
53 "OS: Linux",
54 "Use Case: Threat Detection",
55 "Tactic: Impact",
56 "Tactic: Execution",
57 "Tactic: Command and Control",
58 "Data Source: Elastic Defend",
59]
60timestamp_override = "event.ingested"
61type = "esql"
62
63query = '''
64from logs-endpoint.events.network-*
65| keep @timestamp, host.os.type, event.type, event.action, destination.port, process.executable, destination.ip, agent.id
66| where @timestamp > now() - 1 hours
67| where host.os.type == "linux" and event.type == "start" and event.action == "connection_attempted" and
68 destination.port in (22, 222, 2222, 10022, 2022, 2200, 62612, 8022) and not
69 CIDR_MATCH(
70 destination.ip, "10.0.0.0/8", "127.0.0.0/8", "169.254.0.0/16", "172.16.0.0/12", "192.0.0.0/24", "192.0.0.0/29", "192.0.0.8/32", "192.0.0.9/32",
71 "192.0.0.10/32", "192.0.0.170/32", "192.0.0.171/32", "192.0.2.0/24", "192.31.196.0/24", "192.52.193.0/24", "192.168.0.0/16", "192.88.99.0/24",
72 "224.0.0.0/4", "100.64.0.0/10", "192.175.48.0/24","198.18.0.0/15", "198.51.100.0/24", "203.0.113.0/24", "224.0.0.0/4", "240.0.0.0/4", "::1",
73 "FE80::/10", "FF00::/8"
74 )
75| stats cc = count(), agent_count = count_distinct(agent.id) by process.executable, destination.port
76| where agent_count == 1 and cc > 15
77| sort cc asc
78| limit 100
79'''
80
81
82[[rule.threat]]
83framework = "MITRE ATT&CK"
84[[rule.threat.technique]]
85id = "T1496"
86name = "Resource Hijacking"
87reference = "https://attack.mitre.org/techniques/T1496/"
88
89
90[rule.threat.tactic]
91id = "TA0040"
92name = "Impact"
93reference = "https://attack.mitre.org/tactics/TA0040/"
94[[rule.threat]]
95framework = "MITRE ATT&CK"
96[[rule.threat.technique]]
97id = "T1059"
98name = "Command and Scripting Interpreter"
99reference = "https://attack.mitre.org/techniques/T1059/"
100[[rule.threat.technique.subtechnique]]
101id = "T1059.004"
102name = "Unix Shell"
103reference = "https://attack.mitre.org/techniques/T1059/004/"
104
105
106
107[rule.threat.tactic]
108id = "TA0002"
109name = "Execution"
110reference = "https://attack.mitre.org/tactics/TA0002/"
111[[rule.threat]]
112framework = "MITRE ATT&CK"
113[[rule.threat.technique]]
114id = "T1071"
115name = "Application Layer Protocol"
116reference = "https://attack.mitre.org/techniques/T1071/"
117
118
119[rule.threat.tactic]
120id = "TA0011"
121name = "Command and Control"
122reference = "https://attack.mitre.org/tactics/TA0011/"
Related rules
- Memory Swap Modification
- Simple HTTP Web Server Creation
- Unusual Command Execution from Web Server Parent
- Unusual Process Spawned from Web Server Parent
- Uncommon Destination Port Connection by Web Server