I have the latest Wazuh, v4.4.0. I'm collecting logs from my router via remote syslog. Particularly the DHCP logs. I've got decoders and rules working, with a lot of help from you guys (Wazuh support).
Here's the pertinent rule:
<rule id="100010" level="3">
<decoded_as>SGPfsense</decoded_as>
<field name="dhcpreqorack">DHCPACK</field>
<description>SG - IP address $(ipassigned) assigned to $(tomacaddress)</description>
</rule>
Again, this is working great, thank you.
Now for my actual question. I was wondering if it's possible to do something like this - have a text file (maybe a .csv file, or .txt file, or some other type of text file) somewhere on the Wazuh server that contains a list of known MAC addresses that connect to my network. So something like this:
knownmacaddressesonmynetwork.txt
59:09:aa:dd:58:8c
a9:b8:6c:04:05:77
b9:7b:34:7b:95:96
9c:f8:2e:f9:e6:ae
58:4c:94:a6:2d:9b
With that file in place, I would like the following to happen:
Every time my rule#100010 fires, compare the $(tomacaddress) to the list of MAC addresses in my 'knownmacaddressesonmynetwork.txt' file. If it's not in the list, then alert me with another alert and/or email. And then possibly automatically add the new MAC address to the end of the file (I'm still deciding if I want to do that or not, but leaning toward I would like to do that).
I have a feeling that Wazuh being so awesome that this is possible, but being a Wazuh newbie, I have no idea where to even start. I'm guessing it would involve some sort of Python script, which I'm totally fine with - I know some basic Python scripting, but I just don't know what has to happen on the Wazuh side of things.
I'm not trying to ask anyone to do this for me or spell out every single step in every single detail. I was just hoping for some basic guidance or a general outline of the things I would need to do. Or at the very least, where the heck do I start?
Thank you,
Jamie
Since the Wazuh alerts are indexed, I’m afraid you will have to use the ElasticSearch API instead of the Wazuh one. This should not be any harder though.
Taking a look at the ElasticSearch API documentation, there’s the Search API, which returns hits that match the query in the request from an index. To build the request, you will need the following:
Now, the basic request to retrieve all your alerts would be:
curl -k -u <USER>:<PASSWORD> -X GET "https://<WAZUH_INDEXER_IP>:9200/wazuh-alerts-4.x-*/_search"
Keep in mind that
this API can receive several parameters to filter results. For
instance, if you want to retrieve all the alerts from a certain day,
taking a look at the index format from a hit in the general request
(response.hits.hits[0]):