WEBVTT

00:00:01.840 --> 00:00:04.660
Okay, time to start our rule creation journey.

00:00:05.040 --> 00:00:11.690
Let's exec into the wazuh‑manager‑container. Custom rules are

00:00:11.690 --> 00:00:14.360
defined within the etc/rules directory.

00:00:14.940 --> 00:00:15.960
You might be wondering,

00:00:16.340 --> 00:00:19.940
how do custom files get into the container? For this, check out

00:00:19.940 --> 00:00:23.350
the Wazuh containers volume section within the Docker Compose

00:00:23.350 --> 00:00:25.750
file. For additional context on this,

00:00:25.830 --> 00:00:28.850
please check out course notes number 10 and number 11.

00:00:29.740 --> 00:00:32.350
Okay, let's go ahead and check out our first rule.

00:00:36.240 --> 00:00:38.670
At this point, we see two custom rules.

00:00:39.640 --> 00:00:43.270
The first rule fires when a change to etc preload occurs.

00:00:43.840 --> 00:00:47.340
The second rule fires when multiple changes to etc preload occur.

00:00:47.650 --> 00:00:48.240
For now,

00:00:48.390 --> 00:00:51.550
let's focus on the first rule. We'll get to the other one a little bit later.

00:00:52.440 --> 00:00:54.060
Why do we need this first rule?

00:00:54.540 --> 00:00:58.010
As a brief recap, the ossec.conf file configured

00:00:58.010 --> 00:01:00.150
syscheck to monitor these paths.

00:01:00.390 --> 00:01:01.560
This configuration,

00:01:01.940 --> 00:01:05.220
coupled with the syscheck rules that we previously saw, allows

00:01:05.220 --> 00:01:08.150
Wazuh to create alerts for file operations.

00:01:09.440 --> 00:01:14.060
However, we want to trigger a custom script whenever etc preload changes.

00:01:14.440 --> 00:01:17.050
For that, we need to create a more granular rule.

00:01:17.640 --> 00:01:18.220
First,

00:01:18.230 --> 00:01:21.940
we define an overarching group for our customizations. In

00:01:21.940 --> 00:01:25.670
general, Wazuh uses local to refer to custom rules.

00:01:26.340 --> 00:01:27.050
Second,

00:01:27.170 --> 00:01:35.650
we declare the rule. Wazuh reserves rule ids 100000 to 120000 for custom rules.

00:01:36.140 --> 00:01:38.140
Next up is the rule severity,

00:01:38.380 --> 00:01:44.220
which can be between 0 and 15, 11 maps to integrity checking warning.

00:01:44.220 --> 00:01:47.160
To see a mapping of all of the severity levels,

00:01:47.290 --> 00:01:49.050
please go to course notes number 12.

00:01:50.040 --> 00:01:52.930
The ignore field makes sure this rule is only triggered

00:01:52.940 --> 00:01:55.270
every 1 second. As a blue teamer,

00:01:55.400 --> 00:01:59.550
you need to think of how attackers can use your mitigations in unintended ways.

00:02:00.040 --> 00:02:02.560
If a rule triggers a resource‑intensive script,

00:02:02.940 --> 00:02:06.940
we don't want a flood of alerts to cause a denial‑of‑service attack on

00:02:06.940 --> 00:02:09.500
Wazuh. If we were using this rule in production,

00:02:09.530 --> 00:02:11.670
the ignore value would be a little bit higher.

00:02:11.850 --> 00:02:12.530
However,

00:02:12.540 --> 00:02:16.870
I'll keep that value low for testing purposes. To make sure the rule is

00:02:16.870 --> 00:02:23.830
active, I'm going to delete the noalert attribute. If_group means that this

00:02:23.830 --> 00:02:28.130
rule will fire if another rule in the syscheck group is triggered. In an

00:02:28.130 --> 00:02:32.270
earlier section, we saw that FIM rules for adding, modifying, and deleting

00:02:32.270 --> 00:02:34.660
files were housed within the syscheck group.

00:02:35.640 --> 00:02:37.560
Okay, so what about match?

00:02:38.040 --> 00:02:41.250
Match will match text somewhere within the alert body.

00:02:42.040 --> 00:02:44.250
Alright, onto the description tag.

00:02:44.940 --> 00:02:47.160
This text appears within the Kibana alert.

00:02:47.540 --> 00:02:50.020
So if you want to stay on the pleasant side of your teammates,

00:02:50.030 --> 00:02:52.460
you'd want to make this somewhat descriptive.

00:02:53.040 --> 00:02:54.450
Alright, nice, we're done.

00:02:54.840 --> 00:02:56.670
I'm going to save our changes and exit.
