<localfile>
<log_format>syslog</log_format>
<location>/var/log/pfsense/pfsense_pfB.log</location>
</localfile>
Unfortunately, it seems that the already available (standard) pfSense decoder/rules are not able to process the log lines similar to the following ones:
2023-06-07T14:30:58+02:00 pfSense_LAN - Jun 7 14:30:58,1770023929,em0,DMZ,block,4,17,UDP,x.x.x.x,y.y.y.y,64974,53,out,RU,pfB_Top_v4,193.232.128.0/20,RU_v4,a.dns.ripn.net,wan,null,+
TEST n.1:
/var/ossec/bin/wazuh-logtest-legacy
2023/06/07 13:24:58 wazuh-testrule: INFO: Started (pid: 12315).
Since Wazuh v4.1.0 this binary is deprecated. Use wazuh-logtest instead
wazuh-testrule: Type one log per line.
2023-06-07T14:30:58+02:00 pfSense_LAN - Jun 7 14:30:58,1770023929,em0,DMZ,block,4,17,UDP,x.x.x.x,y.y.y.y,64974,53,out,RU,pfB_Top_v4,193.232.128.0/20,RU_v4,a.dns.ripn.net,wan,null,+
**Phase 1: Completed pre-decoding.
full event: '2023-06-07T14:30:58+02:00 pfSense_LAN - Jun 7 14:30:58,1770023929,em0,DMZ,block,4,17,UDP,x.x.x.x,y.y.y.y,64974,53,out,RU,pfB_Top_v4,193.232.128.0/2'
timestamp: '2023-06-07T14:30:58+02:00'
hostname: 'pfSense_LAN'
program_name: '(null)'
log: '- Jun 7 14:30:58,1770023929,em0,DMZ,block,4,17,UDP,x.x.x.x,y.y.y.y,64974,53,out,RU,pfB_Top_v4,193.232.128.0/2'
**Phase 2: Completed decoding.
No decoder matched.
TEST n. 2
/var/ossec/bin/wazuh-logtest
Starting wazuh-logtest v4.4.1
Type one log per line
2023-06-07T14:30:58+02:00 pfSense_LAN - Jun 7 14:30:58,1770023929,em0,DMZ,block,4,17,UDP,x.x.x.x,y.y.y.y,64974,53,out,RU,pfB_Top_v4,193.232.128.0/20,RU_v4,a.dns.ripn.net,wan,null,+
**Phase 1: Completed pre-decoding.
full event: '2023-06-07T14:30:58+02:00 pfSense_LAN - Jun 7 14:30:58,1770023929,em0,DMZ,block,4,17,UDP,x.x.x.x,y.y.y.y,64974,53,out,RU,pfB_Top_v4,193.232.128.0/2'
timestamp: '2023-06-07T14:30:58+02:00'
**Phase 2: Completed decoding.
No decoder matched.
Could you please help me to extract relevant fields from the logs using regex?
Watching the log line mentioned above, the relevant fields are:
Event time: Jun 7 14:30:58
interface name: em0
interface label: DMZ
action: block
Protocol: UDP
SRC IP: x.x.x.x
DST IP: y.y.y.y
RU: geo location
pfB_top_v4: blacklist name
I tried to do ti by myself, but I'm very newbie to solve this problem :(
Thank you in advance,
Mauro
Hello Mauro,
Thank you for posting in our community!
Allow me to clarify the 3 phases in the logtest tool.
As we can see in your briefing, in both tests, the 2nd phase showed the No decoder matched. message, and without decoders, we won’t be able to trigger alerts right?
While you take a look at our documentation here:
Especially these links:
Adding new decoders and rules
Changing an existing rule
Changing an existing decoder
Traditional decoders
Dynamic decoders
Decoders Syntax
Rules Syntax
Regular Expression Syntax
Perl-compatible Regular Expressions
Sibling Decoders
Configuration
Using the Wazuh dashboard and the command line tool
Using the Wazuh API
I will prepare a decoder for this log format you attached to the message.
2023-06-07T14:30:58+02:00 pfSense_LAN - Jun 7 14:30:58,1770023929,em0,DMZ,block,4,17,UDP,x.x.x.x,y.y.y.y,64974,53,out,RU,pfB_Top_v4,193.232.128.0/20,RU_v4,a.dns.ripn.net,wan,null,+
I’ll keep you posted!
Hey Mauro,
I’m back! Firstly, allow me to mention that the logtest-legacy tool shows you how to deal with this log, you need to decode this part of the log:
log: - Jun 7 14:30:58,1770023929,em0,DMZ,block,4,17,UDP,x.x.x.x,y.y.y.y,64974,53,out,RU,pfB_Top_v4,193.232.128.0/20,RU_v4,a.dns.ripn.net,wan,null,+
Here’s how the decoder would go:
In /var/ossec/decoders/local_decoder.xml add these lines:
<decoder name="pf"> <prematch>^- \w\w\w \d+ \d\d:\d\d:\d\d,\d+,</prematch> </decoder> <decoder name="pf_child"> <parent>pf</parent> <regex>^- (\w\w\w \d+ \d\d:\d\d:\d\d),(\d+),(\S+),(\S+),(\S+),(\S+),(\S+),(\S+),(\S+),(\S+),(\S+),(\S+),(\S+),(\S+),(\S+),(\S+),(\S+),(\S+),(\S+),(\S+),</regex> <order>evt_timestamp,evt_code,iface_name,iface_label,action,value4,value5,protocol,srcip,dstip,value9,value10,value11,value12,value13,value14,value15,value16,value17,value18</order> </decoder>Then, we’ll need to modify the stock pfsense ruleID 87700 by adding these lines at the end of the file /var/ossec/rules/local_rules.xml:
<group name="pfsense,"> <rule id="87700" level="0" overwrite="yes"> <decoded_as>pf</decoded_as> <description>pfSense firewall rules grouped.</description> </rule> </group>Now, let’s see how the wazuh engine reacts to the log you provided:
Hope this helps!
John.-
--
You received this message because you are subscribed to a topic in the Google Groups "Wazuh mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wazuh/PYOjFtZ6K9o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wazuh+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wazuh/def48e6b-22ac-400a-bdfc-ea07ce593babn%40googlegroups.com.
Hey Mauro,
My last message was deleted, here’s the answer again.
The data.srcip is working correctly for the GeoLocation, I tested using my IP, and the alert showed me my country, then I used the IP 193.232.128.10 and the alert showed me this:
Which is also correct.
You should check that pfsense documentation and make sure the order of the fields in the log is correct.
Regards,
John.-
--
You received this message because you are subscribed to a topic in the Google Groups "Wazuh mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wazuh/PYOjFtZ6K9o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wazuh+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wazuh/0d914070-3b0f-4da4-b8d5-1e82a6298dd4n%40googlegroups.com.
Please see the steps below:
The first thing will be to download the updated version of the databases used by the wazuh-indexer to enrich alerts with GeoIP information, you can sign-up here for a free account: GeoLite2 Sign Up | MaxMind
Once you have your new account, sign in and you will be able to download the databases (see screenshot).
Stop the wazuh-indexer service by running this command: systemctl stop wazuh-indexer
Rename or move these files from the following directory: /usr/share/wazuh-indexer/modules/ingest-geoip/
Extract the downloaded zip files and copy the three .mmdb files to the directory /usr/share/wazuh-indexer/modules/ingest-geoip/
Change the ownership and permissions of the files with: chown wazuh-indexer:wazuh-indexer /usr/share/wazuh-indexer/modules/ingest-geoip/GeoLite2-* and chmod 640 /usr/share/wazuh-indexer/modules/ingest-geoip/GeoLite2-*
Start the wazuh-indexer service with systemctl start wazuh-indexer

On 16 Jun 2023, at 22:13, 'John Soliani' via Wazuh mailing list <wa...@googlegroups.com> wrote:
Hello Mauro,After doing some research, I found that the GeoLocation database of `OpenSearch` is outdated and you can update it manually to improve the detection. Here's how to do this:
Please see the steps below:
The first thing will be to download the updated version of the databases used by the wazuh-indexer to enrich alerts with GeoIP information, you can sign-up here for a free account: GeoLite2 Sign Up | MaxMind Once you have your new account, sign in and you will be able to download the databases (see screenshot). Stop the wazuh-indexer service by running this command: systemctl stop wazuh-indexer Rename or move these files from the following directory: /usr/share/wazuh-indexer/modules/ingest-geoip/ Extract the downloaded zip files and copy the three .mmdb files to the directory /usr/share/wazuh-indexer/modules/ingest-geoip/ Change the ownership and permissions of the files with: chown wazuh-indexer:wazuh-indexer /usr/share/wazuh-indexer/modules/ingest-geoip/GeoLite2-* and chmod 640 /usr/share/wazuh-indexer/modules/ingest-geoip/GeoLite2-* Start the wazuh-indexer service with systemctl start wazuh-indexer
To view this discussion on the web visit https://groups.google.com/d/msgid/wazuh/bf606485-c83f-4ef3-979d-a7846eab91b2n%40googlegroups.com.
<2023-06-16_17-03.jpg>
<localfile>
<log_format>syslog</log_format>
<location>/var/log/syslog</location>
</localfile>