Defending Your Network: Detecting SSH Brute-Force Attacks with Wazuh
Introduction:
In today's digital landscape, cybersecurity threats are ever-evolving, with SSH brute-force attacks posing a significant risk to organizations' data and network security. Detecting and mitigating these attacks is crucial to safeguarding sensitive information and maintaining the integrity of your systems. In this guide, I'll walk through the process of detecting SSH brute-force attacks using Wazuh, a powerful open-source security monitoring platform.
Overview:
Throughout this post, you'll gain valuable knowledge on:
Understanding Brute-Force Attacks:
Brute-force attacks are a pervasive threat in cybersecurity, leveraging relentless, systematic attempts to discover valid credentials. Particularly in the context of SSH, adversaries exploit vulnerabilities in authentication protocols, utilizing automated tools to exhaustively cycle through credential combinations. The ramifications of a successful SSH brute-force attack are severe, as unauthorized access to critical systems can lead to compromised data integrity and confidentiality, posing significant risks to organizational security.
Hydra, Medusa, and Ncrack are powerful tools commonly used for conducting brute-force attacks.
Hydra is a versatile password-cracking tool capable of launching brute-force attacks against a variety of protocols, including SSH. It supports parallelized brute-forcing and offers extensive customization options.
GitHub Repository: https://github.com/vanhauser-thc/thc-hydra
GitHub Repository: https://github.com/jmk-foofus/medusa
GitHub Repository: https://github.com/nmap/ncrack
GitHub DDoS Attack (2020): In 2020, GitHub was targeted by a DDoS attack that leveraged SSH and Git traffic. Attackers abused GitHub Actions workflows to mine cryptocurrency on GitHub servers, causing disruption to the platform's services.
Home-Lab Requirements:
Before delving into the technical details, ensure the following prerequisites are met:
Virtualization Software:
To run virtual machines on your computer, you'll need virtualization software. Download from the following options based on your preference and compatibility with your operating system:
Wazuh Server OVA:
Serving as the central management platform for Wazuh deployments, facilitating centralized monitoring and analysis.
For a quicker setup, you can use the Wazuh Server OVA file. This file is prebuilt and can be easily imported into virtualization software such as VirtualBox or VMware. Obtain the Wazuh Server OVA file from the official Wazuh documentation website.
3. Ubuntu Server: Configured as a Wazuh agent for real-time monitoring and analysis of system events.
Kali Linux: Utilized as the offensive platform for simulating brute-force attempts against SSH.
Mirai Botnet (2016): Mirai infected Internet of Things (IoT) devices, including routers and cameras, by exploiting weak SSH credentials. It then used these devices to launch massive distributed denial-of-service (DDoS) attacks.
Setting up Wazuh Manager:
Virtualization Software: Oracle VirtualBox
ifconfig
Username: admin
Password: admin
Adding Ubuntu Agent:
Configure the Ubuntu Server as a Wazuh agent to enable seamless integration with the Wazuh Manager.
To deploy a new Wazuh agent, you need to choose the appropriate package based on your system architecture and package manager. Here's a brief explanation of each option:
Since I am using an Ubuntu server from Osboxes, I selected 'DEB amd64'
To assign a server address for the Wazuh agent to communicate with, you need to provide the IP address or fully qualified domain name (FQDN) of your Wazuh manager server. This server address should be accessible from the network where the agent is installed.
When assigning an agent name in Wazuh, it's important to choose a unique name that identifies the agent. By default, Wazuh uses the hostname of the system as the agent name. However, you have the option to specify a different agent name if needed.
I named the agent "BF_Watcher" and selected the "Default Group" under "Select one or more existing groups".
To configure Ubuntu Server and install the Wazuh agent on the Ubuntu server, I will create a Ubuntu Server in Oracle VirtualBox and run the following commands:
Install the Wazuh Agent:
Run the following commands to download and install the Wazuh agent:
wget https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_4.7.2-1_amd64.deb && sudo WAZUH_MANAGER='192.168.1.110' WAZUH_AGENT_GROUP='default' WAZUH_AGENT_NAME='BF_Watcher' dpkg -i ./wazuh-agent_4.7.2-1_amd64.deb
Ensure to replace '192.168.1.110' with the IP address of your Wazuh manager.
Once the agent is installed, start it by running the following commands:
sudo systemctl daemon-reload
sudo systemctl enable wazuh-agent
sudo systemctl start wazuh-agent
Adding Ubuntu Agent:
Create Ubuntu Server VM in VirtualBox:
Run the following commands to download and install the Wazuh agent:
wget https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_4.7.2-1_amd64.deb && sudo WAZUH_MANAGER='192.168.1.110' WAZUH_AGENT_GROUP='default' WAZUH_AGENT_NAME='BF_Watcher' dpkg -i ./wazuh-agent_4.7.2-1_amd64.deb
Once the agent is installed, start it by running the following commands:
sudo systemctl daemon-reload
sudo systemctl enable wazuh-agent
sudo systemctl start wazuh-agent
To determine the status of the Wazuh agent, execute the following command:
sudo systemctl status wazuh-agent
Activate the agent and verified successful registration and connectivity with the Wazuh Manager interface.
To simulate brute-force SSH attacks, you'll need SSH installed on your Ubuntu server. Follow these simple steps to install SSH
sudo apt update
sudo apt install openssh-server
sudo systemctl enable ssh
To check whether SSH is installed and running successfully on your Ubuntu server, you can use the following command
sudo systemctl status ssh
In case of any issues with the Wazuh VM on VirtualBox, streamline troubleshooting by removing the existing VM and creating a new one. Follow these steps:
sudo nano /var/ossec/etc/ossec.conf
To save changes after modifying the IP address in the ossec.conf file using the nano text editor, you can follow these steps:
sudo systemctl restart wazuh-agent
This approach saves time and effort by avoiding a complete setup redo.
Exim SSH Backdoor (2019): The Exim email server software was targeted by attackers who exploited a vulnerability to install a backdoor via SSH, allowing them to gain persistent access to compromised systems.
Configuring the Offensive Machine (Kali Linux):
Setting Up Kali Linux in Oracle VirtualBox:
Testing Connectivity: Ping to Ensure Connection from Kali Attack Machine to Ubuntu Server
ping -c 5 192.168.1.104
Performing Brute-Force Attacks with Hydra:
Now that we have set up our offensive platform (Kali Linux), let's proceed with performing brute-force attacks using Hydra. Hydra is a powerful and versatile tool capable of launching brute-force attacks against various protocols, including SSH.
To perform a brute-force attack against SSH using Hydra, follow these steps:
We'll simulate a failed brute-force attack and monitor if Wazuh registers the attempt. Follow these command (Replace 192.168.1.104 with the IP address of your Ubuntu server.):
hydra -l admin -p test ssh://192.168.1.104
Observing the Wazuh interface, we can confirm that the attack has been logged within the "Security Events" section.
Let's examine a specific security event in detail:
Event Details:
Event Summary:
An authentication attempt using the username "admin" was made from the source IP address 192.168.1.102, targeting the SSH service running on the agent with ID 001 (named BF_Watcher). The attempt was unsuccessful and triggered multiple times (4 occurrences).
Rule Details:
Additional Insights:
This event indicates an attempted login using the non-existent user "admin" from the source IP address 192.168.1.102, which triggered multiple times (4 times in this case). It's flagged as a significant event with a rule level of 5, indicating potential security concerns related to credential access and lateral movement, according to the MITRE framework. Additionally, it aligns with various compliance standards such as GDPR, GPG13, HIPAA, NIST 800-53, PCI DSS, and TSC.
British Airways Data Breach (2018): In 2018, British Airways suffered a data breach that affected over 380,000 customers. Attackers exploited vulnerabilities in the airline's website and mobile app, allowing them to capture sensitive information during the payment process. While the exact method of attack was not disclosed, SSH-based attacks, including credential stuffing or SSH key compromise, could have played a role in gaining unauthorized access to the airline's systems.
Now that we've confirmed that Wazuh is effectively detecting security incidents, let's delve deeper into Hydra. To do so, we'll utilize commonly used username and password lists to simulate real-world scenarios and assess system vulnerabilities more comprehensively.
I will utilize the wget command to download commonly used username and password lists onto the Kali Linux.
Usernames:
wget https://github.com/pentestmonkey/yaptest/raw/master/ssh-usernames.txt
Passwords:
wget https://github.com/danielmiessler/SecLists/raw/master/Passwords/Common-Credentials/top-20-common-SSH-passwords.txt
After running the command, you can verify that the file has been downloaded by listing the files in the current directory using the 'ls' command:
ls
To use Hydra to perform an SSH brute-force attack with a list of usernames and passwords I used the following command:
hydra -L ssh-usernames.txt -P top-20-common-SSH-passwords.txt ssh://192.168.1.104
An evident surge in security events within Wazuh suggests a notable increase in authentication failures, reflecting heightened activity in unauthorized access attempts. Notably, among the top MITRE ATT&CK techniques observed are instances of "password guessing", particularly targeting the "SSH" protocol through "brute-force attacks".
Conclusion:
In summary, safeguarding against SSH brute-force attacks is crucial for maintaining compliance with cybersecurity standards like GDPR, HIPAA, NIST, PCI DSS, and TSC, while protecting organizational systems and sensitive data. By employing comprehensive detection methods and robust mitigation strategies, businesses can thwart unauthorized access attempts and mitigate risks effectively.
Throughout this guide, we've explored detecting SSH brute-force attacks using Wazuh and practical testing techniques. Real-world examples underscored the importance of identifying and countering such attacks to prevent data breaches and system compromises.
To mitigate the risks associated with SSH brute-force attacks, organizations can implement a plethora of measures:
By embracing these mitigation strategies and maintaining vigilance in monitoring and securing SSH access, organizations can effectively mitigate the risks posed by SSH brute-force attacks and uphold a robust security posture compliant with GDPR, HIPAA, NIST, PCI DSS, and TSC standards amidst today's dynamic threat landscape.
Thank you for taking the time to read this article. Your feedback and suggestions are greatly appreciated!
#Cybersecurity #Wazuh #ThreatHunting #InfoSec #SecurityAudit
Responsable Security Engineer SOC - CERT-PY | MITIC
12 个月good
Cybersecurity Speaker, TTX designer, SOC builder, Ex-Hacker ?? DM or book a call below ??
1 年If you deploy denyhosts first you will have a lot less to worry about
Consultant | SME | Educator | R&D - InfoSec & Cybersecurity
1 年Great! Keep up the good work.
Cybersecurity Analyst II
1 年Ajith Chandran Thank you for sharing.