-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Security Monitoring with Wazuh
By :

Wazuh is an open-source security monitoring platform that provides extended detection and response (XDR) and SIEM functionality. Wazuh’s capabilities include log analysis, intrusion detection, vulnerability detection, and real-time alerting, helping organizations enhance their security posture and respond to threats effectively. In this section, we will first get a basic understanding of the Wazuh platform and its core components and deployment methods, and then we will set up the Wazuh agent and connect with the Wazuh platform. Next, we will set up a Suricata IDS and integrate it with the Wazuh agent. Some of the main points we will explore are as follows:
Wazuh provides a centralized platform for monitoring and managing security events across the organization’s IT infrastructure. Wazuh collects, analyzes, and connects log data from different sources, such as endpoints, network devices, firewalls, proxy servers, and cloud instances. Once the logs are collected, Wazuh provides several capabilities to the security team such as file integrity monitoring, malware detection, vulnerability detection, command monitoring, system inventory, threat hunting, security configuration assessment, and incident response. The Wazuh solution is made up of three main parts: the Wazuh server, the Wazuh indexer, and the Wazuh dashboard. The Wazuh agent is installed on the endpoints that need to be monitored.
This central component is also used to manage the agents and analyze the data received from them:
It is responsible for indexing and storing alerts generated by the Wazuh server:
Note
Indexing is the process of arranging and arranging data to enable effective and quick retrieval. It involves creating a data structure called an index.
wazuh-alerts-*
: This is the index pattern for alerts generated by the Wazuh serverwazuharchives-*
: This is the index pattern for all events sent to the Wazuh serverwazuh-monitoring-*
: This pattern is for monitoring the status of Wazuh agentswazuh-statistics-*
: This is used for statistical information about the Wazuh serverThe Wazuh dashboard is a web interface that allows you to perform visualization and analysis. It also allows you to create rules, monitor events, monitor regulatory compliances (such as PCI DSS, GDPR, CIS, HIPPA, and NIST 800-53), detect vulnerable applications, and much more.
Wazuh agents are installed on endpoints such as servers, desktops, laptops, cloud compute instances, or VMs. Wazuh utilizes the OSSEC HIDS module to collect all the endpoint events.
Note
OSSEC is a popular and open-source host-based IDS (HIDS). It is a powerful correlation and analysis module that integrates log analysis, file integrity monitoring, Windows registry monitoring, centralized policy enforcement, rootkit detection, real-time alerting, and active response. It can be installed on most operating systems (OSs) such as Linux, OpenBSD, FreeBSD, MacOS and Windows.Wazuh deployment options
Wazuh is known for its ability to fully monitor security and detect threats. It also has several flexible deployment options. Depending on your requirement, you can deploy Wazuh in an on-premises server, cloud, Docker container, Kubernetes, or another environment. For a production environment, Wazuh core components (i.e., the Wazuh server, the Wazuh indexer, and the Wazuh dashboard) should be installed in cluster mode. Cluster mode deployment involves setting up more than one Wazuh server node to work collectively. By spreading the work and duties among several nodes in the cluster, this configuration aims to improve speed, scalability, and resilience. Let’s cover some important deployment options:
If you want to test all the use cases throughout the book, I suggest you use the Wazuh VM deployment option by downloading the OVA file; however, for the production-level deployment, you can choose any of the remaining options. The Wazuh community has done a brilliant job in documenting the installation guide. You can refer to this link for step-by-step assistance: https://documentation.wazuh.com/current/installation-guide/index.html.
Wazuh has a set of modules that work together to help organizations handle security events, find threats, make sure they are following the rules, and keep their systems and data safe. Once you access the Wazuh manager, the topmost option is Modules. By default, you can find multiple modules categorized under four sections as mentioned in the following diagram:
Figure 1.6 – Default Wazuh modules
Let us look into each of those four sections in detail:
Note
ATT&CK stands for adversarial tactics, techniques, and common knowledge. MITRE is a government-funded research organization based in Bedford, MA, and McLean, VA. MITRE ATT&CK is a framework that helps organizations with attacker’s tactics, techniques, and procedures to test their security controls.
Note
The Center for Internet Security (CIS) benchmarks are a set of best practices that are known around the world and are based on consensus. They are meant to help security professionals set up and manage their cybersecurity defenses.
Next, let’s talk about the Wazuh Administration, where we will discuss some core features of the Wazuh manager.
Under the Management section of the Wazuh dashboard, we have the Administration section. As you can see in the following diagram, the Administration section includes capabilities such as Rules, Decoders, CDB lists, Groups, and Configuration.
Figure 1.7 – Wazuh administration
All the features mentioned under the Administration tab play a pivotal role in ensuring the effectiveness of the Wazuh platform for real-time monitoring and threat detection. We will understand each of these features as explained in the following sections.
Decoders are responsible for reading incoming log entries, pulling out the important information, and putting them into a standard format that the Wazuh system can easily understand and analyze. Raw log entries can be in different formats, such as syslog, JSON, XML, or custom text formats. The job of the decoder is to figure out how these logs are put together and pull out meaningful fields and values. There are many pre-built decoders in Wazuh such as the syslog decoder, OpenSSH decoder, Suricata decoder, and the Cisco ASA decoder. To understand what decoders are and how they work, let us look at how logs from the Barracuda Web Application Firewall (WAF) are processed:
<decoder name="barracuda-svf1"> <parent>barracuda-svf-email</parent> <prematch>^\S+[\S+]|</prematch> <prematch>^\S+</prematch> <regex>^\S+[(\S+)] (\d+-\w+-\w+) \d+ \d+ |</regex> <regex>^(\S+) (\d+-\w+-\w+) \d+ \d+ </regex> <order>srcip, id</order> </decoder>
Let’s break down the parts of this Wazuh decoder:
decoder name
: This indicates the name of the decoder.parent
: This gives us the name of the parent decoder. The parent decoder will be processed before the child decoders.prematch
: This is like a condition that must match to apply the decoder. It uses regular expressions to look for a match.regex
: This represents the regular expression to extract data. In the preceding decoder, we have two regex
instances.order
: This indicates the list of fields in which the extracted information or value will be stored.Decoders have many more configuration options available to them. Visit the Decoders Syntax page (https://documentation.wazuh.com/current/user-manual/ruleset/ruleset-xml-syntax/decoders.html) in the Wazuh documentation to see all of the available options.
Wazuh rules help the system detect attacks in the early stages, such as intrusions, software misuse, configuration issues, application errors, malware, rootkits, system anomalies, and security policy violations. Wazuh comes with several pre-built rules and decoders but also allows you to add custom rules. Let’s take a sample Wazuh rule:
<rule id="200101" level="1"> <if_sid>60009</if_sid> <field name="win.system.providerName">^PowerShell$</field> <mitre> <id>T1086</id> </mitre> <options>no_full_log</options> <group>windows_powershell,</group> <description>Powershell Information EventLog</description> </rule>
Let’s break this code down:
rule id
: This represents the unique identifier for the Wazuh rule.level
: The rule’s classification level ranges between 0 and 15. According to the rule categories page (https://documentation.wazuh.com/current/user-manual/ruleset/rules-classification.html) in the Wazuh documentation, each number indicates a distinct value and severity.if_sid
: This specifies the ID of another rule (in our case, it’s 60009
), which triggers the current rule. The “if” condition is considered as the “parent” rule that must be checked first.field name
: This specifies the name of the field extracted from the decoder. The value is matched by a regular expression. In this case, we are looking for the field name win.system.providerName
with a value of PowerShell
.group
: This is used to organize the Wazuh rules. It contains the list of categories that the rules belong to. We have organized our rule in the windows_powershell
group.There are tons of other options available for Wazuh rules. I would suggest you check out the Rules Syntax page at the following link: https://documentation.wazuh.com/current/user-manual/ruleset/ruleset-xml-syntax/rules.html) in the Wazuh documentation.
The Constant Database (CDB) list enables the categorization and management of IP addresses and domains based on their characteristics. These lists can include known malicious IP addresses, suspicious domains, trusted IP addresses, whitelisted domains, and more. Admins maintain these lists by adding or removing entries based on reputation or risk levels. To learn more about CDB lists, you can visit the official Wazuh documentation for CDB lists: https://documentation.wazuh.com/current/user-manual/ruleset/cdb-list.html.
Agents can be grouped based on their OS or functionalities using groups; for example, all Windows agents can be grouped under a single group named Windows Agents. This is helpful when you want to push configuration changes from the Wazuh manager to all Windows agents at once. This becomes a simple and single-step solution. To learn more about grouping agents, you can visit the official Wazuh documentation here: https://documentation.wazuh.com/current/user-manual/agents/grouping-agents.html.
This helps security teams to fine-tune Wazuh’s main configurations such as cluster configuration, alert and output management, log data analysis, cloud security, vulnerabilities, inventory data, active response, commands, Docker listeners, and monitoring (Amazon S3, Azure logs, Google Cloud, GitHub, Office 365, etc.). All these features can even be customized from the command-line option as well. You need to locate the ossec.conf
file in your Wazuh manager or Wazuh agent at the /
var/ossec/etc
directory.
Now, let’s start deploying our Wazuh agent on the Ubuntu machine and then we will install Suricata on the same machine.
The Wazuh server is the central component of the Wazuh security platform. It consists of two important elements: the Wazuh manager and Filebeat. The Wazuh manager collects and analyzes data from the Wazuh agents and triggers alerts when it detects any threats. Filebeat forwards alerts and events to the Wazuh indexer. The Wazuh server can be installed in multiple ways, however, I’d recommend the multi-node cluster method for a production environment and the VM method for a lab environment. You can follow the guidelines for both methods in the following sections.
To set up Wazuh in the production environment, it is recommended to deploy the Wazuh server and Wazuh indexer on different hosts. This helps you handle traffic from a large number of endpoints and also to achieve high availability. The step-by-step guide to install the Wazuh server along with the indexer and dashboard is mentioned here: https://documentation.wazuh.com/current/installation-guide/index.html.
You can use the Wazuh VM OVA file for a lab environment as it is easy to deploy. All the Wazuh components including the Wazuh server, indexer, and dashboard are unified. To install Wazuh using an OVA file, follow these steps:
Figure 1.8 – Accessing the Wazuh web interface
You need to enter the following:
admin
admin
A Wazuh agent is compatible with multiple OSs. Once a Wazuh agent is installed, it will communicate with the Wazuh server, pushing information and system logs in real-time using an encrypted channel.
To deploy a Wazuh agent on the Ubuntu Server, you need to install the agent and configure the deployment variables. To get started with installation, you need to log in to your Wazuh dashboard, navigate to Agents, click on Deploy an agent and then follow these steps:
Figure 1.9 – Deploying a new agent
Figure 1.10 – Choosing a server address and optional settings
Let’s break down what we’ve inputted:
192.168.29.32
: This is the IP address of the Wazuh serverubu-serv
: This indicates the name of the Wazuh agentdefault
: It represents the Wazuh agent groupcurl
command to download the Wazuh module and start the Wazuh agent service as mentioned in the following diagram.Figure 1.11 – Retrieving the commands to download and install a Wazuh agent
Note
Make sure that there are no firewall rules blocking communication between the agent and the Wazuh manager. The agent should be able to communicate with the manager over the configured port (the default is 1514
/514
for syslog).
Finally, you can verify whether the agent is connected and activated by logging in to the Wazuh manager and navigating to Agents.
Figure 1.12 – Visualizing Wazuh agents
As you can see in the preceding diagram, the ubu-serv-03
agent is connected with the following:
006
192.168.29.172
Now, let’s install the Wazuh agent on Windows Server. The process will be the same for the Windows desktop, too.
You can monitor real-time events from Windows Server or a desktop on the Wazuh server by using the command line interface (CLI) or graphical user interface (GUI). To get started with installation, you need to log in to your Wazuh dashboard, navigate to Agents, click on Deploy an agent and then follow these steps:
Figure 1.13 – Selecting the Windows package for the Wazuh agent
Figure 1.14 – Entering the server address and optional settings
Figure 1.15 – Retrieving the commands to download and install the Wazuh agent on a Windows machine
Finally, you can verify whether the agent is connected and activated by logging in to the Wazuh manager and navigating to Agents.
Figure 1.16 – Visualizing Wazuh agents installed on a Windows machine
As you can see in the preceding diagram, the WIN-AGNT
agent is connected with the following:
004
192.168.29.77
We have successfully learned how to deploy Wazuh agents on both the Ubuntu Server and Windows Server. In the next section, we will learn how to set up a Suricata IDS on Ubuntu Server.
With the ability to detect malicious or suspicious activities in real time, Suricata is an NSM tool, which has the potential to work as an IPS/IDS. Its goal is to stop intrusion, malware, and other types of malicious attempts from taking advantage of a network. In this section, we will learn how to install Suricata on Ubuntu server. Let’s first learn about the prerequisites.
To install Suricata IDS on Ubuntu Server, the prerequisites are as follows:
This process involves the installation of Suricata packages using the apt-get
command line tool and then we need to install the free and open source Suricata rules created by the ET community. The rules within the ET ruleset cover a broad spectrum of threat categories, including malware, exploits, policy violations, anomalies, botnets, and so on. To complete the installation, follow these steps:
sudo add-apt-repository ppa:oisf/suricata-stable sudo apt-get update sudo apt-get install suricata –y
/
etc/suricata/rules
directory:cd /tmp/ && curl -LO https://rules.emergingthreats.net/open/suricata-6.0.8/emerging.rules.tar.gz sudo tar -xvzf emerging.rules.tar.gz && sudo mv rules/*.rules /etc/suricata/rules/ sudo chmod 640 /etc/suricata/rules/*.rules
Note
If the rule directory is not present, you can create one by using the mkdir /etc/suricata/
rules and then you can enter the previously mentioned commands.
/etc/suricata/suricata.yaml
:HOME_NET: "<AGENT_IP>" EXTERNAL_NET: "any" default-rule-path: /etc/suricata/rules rule-files: - "*.rules" # Linux high speed capture support af-packet: - interface: eth01
Let’s break down this code further:
HOME_NET
: This is a variable that needs to be set with the agent IP address.EXTERNAL_NET
: This variable needs to be set with "any"
to ensure Suricata will monitor the traffic from any external IP address.default-rule-path
: This is set to our Suricata rule path.af-packet
: This is a packet capture method used to capture network traffic directory from a network interface card (NIC). You can check your current NIC by using the ifconfig
command and updating the af-packet
settings.$ sudo systemctl restart suricata
ossec
config file located at /var/ossec/etc/ossec.conf
. Suricata stores all the logs at /var/log/suricata/eve.json
. You are required to mention this file under the <location>
tag in the ossec.conf
file:<ossec_config> <localfile> <log_format>json</log_format> <location>/var/log/suricata/eve.json</location> </localfile> </ossec_config>
$ sudo systemctl restart wazuh-agent
This completes Suricata’s integration with Wazuh. The Suricata IDS has been installed on Ubuntu Server along with the ET ruleset. Your endpoints are ready to trigger alerts if any malicious traffic is matched against any of the ET rulesets. Before getting into some practical use cases, let’s first get a basic understanding of Suricata rules and how to create one.
Change the font size
Change margin width
Change background colour