WEBVTT

00:00:02.240 --> 00:00:05.450
Okay, let's hop back into the Wazuh manager container.

00:00:06.440 --> 00:00:08.060
Let's go back to our rules file.

00:00:12.140 --> 00:00:16.250
Now, it's time to focus on our second rule, which is the escalation rule.

00:00:16.640 --> 00:00:19.250
For this rule, I'm going to create an escalation group.

00:00:19.840 --> 00:00:20.870
As a brief aside,

00:00:20.900 --> 00:00:24.160
I'm only going to highlight attributes that haven't already been covered.

00:00:24.640 --> 00:00:28.000
The frequency attribute specifies the number of times the rule

00:00:28.000 --> 00:00:30.250
needs to be fired within a given timeframe.

00:00:30.640 --> 00:00:34.470
So in other words, if this rule is fired twice within 300 seconds,

00:00:34.470 --> 00:00:36.200
an alert will be raised.

00:00:36.200 --> 00:00:40.270
Now, the 300 seconds is seen within the timeframe attribute.

00:00:41.140 --> 00:00:44.270
If_matched_group will trigger this rule when any rule

00:00:44.280 --> 00:00:46.670
within the invisible_process group fires.

00:00:46.670 --> 00:00:50.970
As you probably remember, we created the invisible_process group above.

00:00:51.840 --> 00:00:53.150
Okay, before I forget,

00:00:53.320 --> 00:00:57.270
I'm going to remove the noalert attribute to activate this rule.

00:01:00.440 --> 00:01:02.270
Okay, I'll go ahead and save the file.

00:01:03.840 --> 00:01:08.370
Let's go back into ossec.conf so we can create the active_response entry.

00:01:11.540 --> 00:01:14.960
Nice, let's go to our second active_response configuration.

00:01:18.440 --> 00:01:21.350
So what does our escalation active_response do?

00:01:21.740 --> 00:01:24.940
I created the script for this tutorial, and it will quarantine an

00:01:24.950 --> 00:01:28.220
instance by blocking all egress and ingress traffic,

00:01:28.220 --> 00:01:30.440
with the exception of one CIDR range.

00:01:30.440 --> 00:01:33.820
The CIDR range is defined within the script.

00:01:33.820 --> 00:01:38.940
For testing purposes, I set the default to 8.8.8.8,

00:01:38.950 --> 00:01:41.170
which is one of Google's DNS servers.

00:01:41.540 --> 00:01:45.520
If this was a real‑world environment, we would set it to a bastion host,

00:01:45.530 --> 00:01:48.340
or some other host that you can leverage to SSH into

00:01:48.340 --> 00:01:50.150
the instance under investigation.

00:01:50.940 --> 00:01:55.050
Everything in the command in active_response tag should be familiar to you.

00:01:55.640 --> 00:02:00.310
Notice that the rules_id matches the escalation rule that we just defined.

00:02:00.940 --> 00:02:04.640
In summary, if the pre‑load file is mutated multiple times,

00:02:04.770 --> 00:02:06.670
the quarantine command will be activated.

00:02:07.340 --> 00:02:11.140
Okay, let's exit _____.

00:02:11.140 --> 00:02:14.580
Similar to before,

00:02:14.590 --> 00:02:18.150
we need to restart the Wazuh manager for the escalation rule to take effect.

00:02:23.440 --> 00:02:24.970
Alright, let's log in.

00:02:31.040 --> 00:02:32.960
Okay, we see the foothold script ran.

00:02:33.840 --> 00:02:38.530
I'm going to log out using Ctrl+D. Perfect. Let's log

00:02:38.530 --> 00:02:40.270
back into the container one more time.

00:02:47.240 --> 00:02:47.960
Okay,

00:02:47.970 --> 00:02:52.720
let's check and see if our quarantine script worked. Here I'm going to ping

00:02:52.720 --> 00:02:58.450
an IP that shouldn't be allowed, Operation not permitted.

00:02:58.840 --> 00:03:01.660
Go into Ctrl+C, perfect.

00:03:02.340 --> 00:03:09.860
Let's try an allowed IP. Bingo! Go into Ctrl+C really quick.

00:03:13.340 --> 00:03:15.170
It looks like our quarantine script worked.

00:03:15.940 --> 00:03:18.250
Now, if you'd like to check out the quarantine script,

00:03:18.300 --> 00:03:20.260
please see course notes number 15.

00:03:23.740 --> 00:03:24.650
If you recall,

00:03:24.660 --> 00:03:28.150
the Merlin agent is able to run for a small amount of time before

00:03:28.150 --> 00:03:30.670
being killed by the initial active_response script.

00:03:31.540 --> 00:03:32.080
Well,

00:03:32.250 --> 00:03:34.650
let's assume that the attacker was able to do some

00:03:34.650 --> 00:03:36.500
recon, and through that process,

00:03:36.510 --> 00:03:39.370
a database backup file was found on the victim's machine.

00:03:39.840 --> 00:03:40.680
At this point,

00:03:40.690 --> 00:03:43.880
the attacker is simply waiting for the agent to reconnect so this

00:03:43.880 --> 00:03:47.690
command can be executed, but, due to the quarantine,

00:03:47.880 --> 00:03:49.170
that day will never come.

00:03:49.840 --> 00:03:51.670
Let's try executing this command.

00:03:55.440 --> 00:03:59.670
I've waited a few minutes now, and as you can tell, no progress has been made.

00:04:00.540 --> 00:04:01.250
Obviously,

00:04:01.260 --> 00:04:06.360
this was huge, and Wazuh coupled with the active_response script was able

00:04:06.360 --> 00:04:09.550
to quarantine the instance and stop data exfiltration.
