
Catching an Attack in Progress: Deploying Wazuh HIDS and Watching It Work
Every firewall lab I'd worked through up to this point answered the same basic question: was a connection allowed or blocked? This lab asked a different one entirely: if an attack gets through anyway, does anyone actually notice? A firewall can be perfectly configured and an attack can still happen using credentials it was never designed to stop.
Every firewall lab I'd worked through up to this point answered the same basic question: was a connection allowed or blocked? This lab asked a different one entirely: if an attack gets through anyway, does anyone actually notice? A firewall can be perfectly configured and an attack can still happen using credentials it was never designed to stop. That's exactly the gap a Host-based Intrusion Detection System is built to close, and this lab walked through deploying one, Wazuh, from a cold install to watching it flag a real, live attack as it happened.
What a HIDS Is Actually For
Wazuh (built on the OSSEC engine) is a host-level intrusion detection system. The distinction in "host-level" matters: rather than watching network traffic pass by from the outside, a HIDS agent runs directly on the machine it's protecting, with visibility into logs, configuration, and system events that a purely network-based tool never sees. It combines signature-based detection (recognizing known attack patterns) with anomaly-based detection (noticing behavior that deviates from an established baseline), which together let it catch both well-known attack signatures and the kind of unusual activity that doesn't match any specific known pattern.
The architecture has two halves: a central Wazuh manager that collects and correlates events, and lightweight agents installed on each monitored host, reporting back to that manager. This lab set up exactly that relationship between two machines, and then, critically, actually tested whether it worked by launching a real attack against the monitored host and watching for the alert.
Registering the Agent on the Manager
I started on the machine acting as the Wazuh manager. From a root terminal, I ran the agent management tool:
/var/ossec/bin/manage_agents
This is an interactive menu-driven tool. Selecting
A to add a new agent, I provided a name ( WebServer ) and the IP address of the machine I intended to monitor, then confirmed. The manager assigned the new agent an ID (001 in this case) and registered it internally.Registering an agent on the manager side is only half the setup, though. Each agent needs a unique authentication key to actually establish trust with the manager, so I extracted it:
E001
That returned the key as a text string, which I copied. This key is the credential that lets the eventual agent installation on the monitored machine authenticate back to this specific manager instance, rather than any Wazuh manager it might happen to find.
Getting the Key to the Monitored Machine
With the key copied, I saved it into a local file (
key.txt ), then needed to get that file onto the web server machine I intended to monitor.I connected to that machine's file share directly:
smb://10.10.1.16
Authenticated with valid administrator credentials, this opened the remote machine's shared folder structure, letting me copy
key.txt directly into its C$ share. This step is a reminder that setting up monitoring infrastructure isn't purely a software configuration exercise, it also requires actual network connectivity and file transfer between the systems involved, and that connectivity itself has to be explicitly permitted.Opening the Firewall for Agent Communication
Specifically, before the agent and manager could actually talk to each other, I had to open a path for that communication:
sudo ufw allow proto udp from 10.10.1.16 to 10.10.1.79 port 1514
Wazuh agents communicate with their manager over UDP port 1514 by default. Without this rule, the manager's own host firewall would have silently blocked the very traffic the monitoring setup depended on, a reminder that deploying a security tool doesn't exempt it from the security controls already in place; it has to be explicitly accommodated by them.
Installing the Agent on the Monitored Machine
Switching to the web server itself, I ran through the Wazuh agent's installer. After accepting the license and completing the wizard, the installer launched the Wazuh Agent Manager configuration window directly, where I supplied two pieces of information: the manager's IP address, and the authentication key I'd copied over via the file share earlier.
After saving and confirming the key import, the agent was configured but, by default, stopped. I had to explicitly start it (Manage → Start), then refresh the status view to confirm it showed as Running.
Confirming the Connection From Both Sides
Back on the manager machine, I restarted the Wazuh service to pick up the new agent:
/var/ossec/bin/ossec-control restart
Then confirmed the agent's status directly:
/var/ossec/bin/agent_control -l
This listed
WebServer as Active, confirming both halves, the agent-side configuration and the manager-side registration, had actually come together into a working connection. That verification step matters: an agent that's installed but not actively reporting, or a manager that has an agent registered but never hears from it, both look superficially fine until you actually check.Generating a Real Attack to Monitor
This is where the lab stopped being purely a configuration exercise. From a separate attacker machine, I ran a dictionary attack against the web server's FTP service:
hydra -L 'wrd.txt' -P 'pwd.txt' ftp://10.10.1.16
This is the same technique I'd used in an earlier lab on cracking FTP credentials, Hydra working through username and password wordlists against an exposed FTP service. The point here wasn't the attack itself, it was already familiar, it was whether the monitoring infrastructure I'd just built would actually notice it happening.
Watching the Alert Appear
Back on the manager machine, I launched Sguil, a network security monitoring interface for working with IDS alerts. After authenticating and selecting all available interfaces to monitor, the Sguil console populated with live events.
And there it was: an OSSEC alert for a Windows Logon Failure - unknown user, with a destination IP matching the web server I'd just attacked. Clicking into that alert's detail view showed the specifics the Wazuh agent had actually captured on the host itself, a direct result of the agent watching local authentication events and recognizing a pattern of repeated, failing login attempts against the FTP service.
That's the moment the whole exercise actually proved itself. A firewall rule wouldn't have stopped this attack; valid-looking authentication attempts against an open FTP port aren't something a simple allow/block rule distinguishes from legitimate login attempts. What caught it was something watching the host itself, correlating a pattern of failed logons that, individually, might mean nothing, but together represented exactly the kind of brute-force attempt Hydra was actually performing.
What This Lab Actually Demonstrates
A few things stood out, beyond the mechanics of the Wazuh setup itself.
Detection and prevention are genuinely separate problems. Every prior lab in this module dealt with prevention, deciding in advance what traffic is or isn't allowed. This lab dealt with detection, noticing when something happened that prevention didn't or couldn't stop. An organization needs both, because no prevention layer catches everything, and the things it misses need a different kind of control to even become visible.
A HIDS sees what a network firewall structurally cannot. The attack here was a series of FTP login attempts, traffic that, from a pure network perspective, looks like completely normal, permitted FTP traffic. It's only visible as an attack when something is watching the host's own authentication outcomes and recognizing the pattern of repeated failures. That's information a host-based agent has access to that a packet-filtering firewall never will.
Deploying a monitoring tool is itself an exercise in careful configuration. Agent registration, key exchange, firewall rules to permit the monitoring traffic itself, explicit service starts, this wasn't a single install-and-done step. Each piece had to be configured and then independently verified (agent status, active listing) before the system as a whole could be trusted to actually work.
An untested detection system is just as risky as no detection system. The real proof here wasn't the installation completing successfully, it was deliberately generating a known attack and confirming the alert actually appeared. A monitoring tool nobody has tested against a real attack pattern is an assumption, not a verified control.
This lab closed a gap that every prior firewall-focused lab in the module had left open. Blocking traffic at the host or network level is necessary, but it's not sufficient, because not every attack looks like traffic a firewall rule would recognize as malicious. A credential-stuffing attempt against an open FTP port is, from a packet's perspective, indistinguishable from someone typing their password wrong. What makes it visible is something watching the host itself, correlating the pattern those individually-unremarkable events actually represent.
That's the real argument for a HIDS: prevention controls decide what's allowed to happen. Detection controls notice when something happened anyway. Both are necessary, and this lab was a direct demonstration of exactly why.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article