Каталог Поиск 0 Сравнить 0 Закладки 0 Корзина Войти
Каталог
105082, Москва, ул. Фридриха Энгельса, 75с21, БЦ Бауманский ИТКОЛ
Пн - Пт: с 09-00 до 18-00 Сб: с 10-00 до 18-00 Вс: выходной
Страницы: 1
RSS
Разбор syslog UNIFI, wifiman
 
Привет, у меня есть UDM Pro, коммутатор UniFi и куча точек доступа UniFi. Я отправляю syslog с UDM в SIEM (Wazuh). Кто-нибудь сталкивался с парсингом и может поделиться примером парсера?
 
Всем привет! Недавно (около 3 месяцев) я начал использовать Wazuh для расширяющейся инфраструктуры. Мне легко удалось интегрировать логи Fortigate (включая трафик), Docker, Office 365, разные агенты ОС (Linux, macOS и т.д.). Сейчас у меня проблемы с Syslog от других источников, в том числе от Ubiquiti. По сути, логи нормально доходят до моего Wazuh-сервера, но толку от этого немного. Я пытался поиграть с декодерами, которые здесь предоставлены (большое спасибо за них), но, видимо, мне всё ещё не хватает правил, чтобы сделать это действительно полезным. Это очень раздражает, тем более что Ubiquiti недавно сделали столько для улучшения интеграции с SIEM. Кстати... именно они должны были бы предоставлять руководство по интеграции и декодеры. Есть кто-то в теме, кто продвинулся дальше с этим вопросом?
 
Я установил wazuh и добавил к нему дюжину клиентов на Windows — не важно, какие руководства я изучаю или что делаю, мне никак не удаётся увидеть в консоли wazuh никаких данных по syslog. Могу сделать tcpdump на порт 514 и увидеть трафик и сообщения от unifi, но понятия не имею, как правильно настроить или сконфигурировать это в этом продукте с моим новичковым опытом. Есть у кого-нибудь гайд или сырые файлы с GitHub, которые я мог бы скачать через wget? Может, нужно изменить какие-то другие настройки в стандартном файле ossec.conf? Я пытался включить log all в yes, но... всё равно ничего не вижу, хотя и не совсем уверен, где именно это должно отображаться.
 
Знаешь, я создал новый файл (пытался изменить существующий), и он потом сохранился :/
 
Очень ценю проделанную работу над этим декодером, однако, @r4nd0m, вот что у меня получается при попытке сохранить:  
Ошибка: Не удалось загрузить декодер (1113) - ошибка синтаксиса XML  
at WzRequest.returnErrorInstance (https://wazuh.alliedmech.com/410008/bundles/plugin/wazuh/wazuh.plugin.js:1:499117)  
at WzRequest.apiReq (https://wazuh.alliedmech.com/410008/bundles/plugin/wazuh/wazuh.plugin.js:1:498259)  
at async resources_handler_ResourcesHandler.updateFile (https://wazuh.alliedmech.com/410008/bundles/plugin/wazuh/wazuh.chunk.2.js:1:3128236)  
at async file_editor_WzFileEditor.save (https://wazuh.alliedmech.com/410008/bundles/plugin/wazuh/wazuh.chunk.2.js:1:3197792)
 
Спасибо, @r4nd0m, за декодер. На основе твоих данных я создал несколько правил, которые вытягивают события из архивов в алерты. В стандартном ossec.conf алерты сначала логируются с уровнем 3, поэтому два правила с уровнем 1 не будут видны. Остальные уровни — просто для теста.

<group name="Unifi">
 <rule id="100001" level="10">
   <decoded_as>Dream-Machine-Rack-cef</decoded_as>
   <category>firewall</category>
   <description>Сработало правило блокировки фаервола</description>
 </rule>
 <rule id="100002" level="12">
   <decoded_as>Dream-Machine-Rack-cef</decoded_as>
   <match>security_detections</match>
   <description>Обнаружение безопасности IPS/IDS</description>
 </rule>
 <rule id="100003" level="1">
   <decoded_as>Dream-Machine-Rack-cef</decoded_as>
   <match>admin_activity</match>
   <description>Активность администратора в Unifi</description>
 </rule>
 <rule id="100002" level="1">
   <decoded_as>Dream-Machine-Rack-cef</decoded_as>
   <match>client</match>
   <description>Подключение/отключение клиента</description>
 </rule>
</group>
 
Вау, это здорово, большое спасибо!
 
Я начал извлекать некоторые из новых сообщений

<!-- unifi-CEF -->
<decoder name="unifi-udm-pro-cef">
   <program_name>CEF</program_name>
</decoder>

<decoder name="unifi-udm-pro-cef-messages">
   <parent>unifi-udm-pro-cef</parent>
   <regex type="pcre2" offset="after_parent">\|(.*?)\|(.*?)\|(.*?)\|(client)(?:-.*?)\|(.*?)\.\sTime Connected:\s(.*)\.\sData Used:\s(.*)\.\sLast Connected To:\s(.*)\.\|(\w+)</regex>
   <order>cef.vendor,cef.product,cef.prodversion,cef.facility,cef.message,cef.duration,cef.volume,cef.AP,cef.risk</order>
</decoder>

<decoder name="unifi-udm-pro-cef-messages">
   <parent>unifi-udm-pro-cef</parent>
   <regex type="pcre2" offset="after_parent">\|(.*?)\|(.*?)\|(.*?)\|(triggers)(?:-.*?)\|(.*?)\|(\w+)</regex>
   <order>cef.vendor,cef.product,cef.prodversion,cef.facility,cef.message,cef.risk</order>
</decoder>

<decoder name="unifi-udm-pro-cef-messages">
   <parent>unifi-udm-pro-cef</parent>
   <regex type="pcre2" offset="after_parent">\|(.*?)\|(.*?)\|(.*?)\|(security_detections)(?:-.*?)\|(.*?)\|(\w+)\|(signature_type)=(\w+)\ssignature_id=(\d{1,8})</regex>
   <order>cef.vendor,cef.product,cef.prodversion,cef.facility,cef.message,cef.risk,cef.type,cef.signatureType,cef.signatureId</order>
</decoder>

<decoder name="unifi-udm-pro-cef-messages">
   <parent>unifi-udm-pro-cef</parent>
   <regex type="pcre2" offset="after_parent">\|(.*?)\|(.*?)\|(.*?)\|(admin_activity)(?:-.*?)\|(.*?)\|(\w+)\|admin_ip=(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})</regex>
   <order>cef.vendor,cef.product,cef.prodversion,cef.facility,cef.message,cef.risk,srcip</order>
</decoder>

<decoder name="unifi-udm-pro-cef-messages">
   <parent>unifi-udm-pro-cef</parent>
   <regex type="pcre2" offset="after_parent">>setting_preference=\[(.*)]->\[(.*)] state_invalid=\[(.*)]->\[(.*)] state_new=\[(.*)]->\[(.*)] state_related=\[(.*)]->\[(.*)] ruleset=\[(.*)]->\[(.*)] name=\[(.*)]->\[(.*)] action=\[(.*)]->\[(.*)] logging=\[(.*)]->\[(.*)] rule_index=\[(.*)]->\[(.*)] state_established=\[(.*)]->\[(.*)] protocol_match_excepted=\[(.*)]->\[(.*)] protocol_v6=\[(.*)]->\[(.*)] enabled=\[(.*)]->\[(.*)]</regex>
   <order>setting_preference.oldValue,setting_preference.newValue,state_invalid.oldValue,state_invalid.newValue,state_new.oldValue,state_new.newValue,state_related.oldValue,state_related.newValue,ruleset.oldValue,ruleset.newValue,name.oldValue,name.newValue,action.oldValue,action.newValue,logging.oldValue,logging.newValue,rule_index.oldValue,rule_index.newValue,state_established.oldValue,state_established.newValue,protocol_match_excepted.oldValue,protocol_match_excepted.newValue,protocol_v6.oldValue,protocol_v6.newValue,enabled.oldValue,enabled.newValue</order>
</decoder>
 
Они находятся в одном и том же потоке syslog. Можно либо включить logall в Wazuh и забрать оттуда, либо я просто вытаскиваю их с помощью tcpdump: tcpdump -nnAs0 -i <interface> port <syslog_port>. Там видно все входящие сообщения, и можно отобрать нужные, например, через конвейер в grep, исключая строки с DESCR, а потом либо записать их в файл (> filename), либо взять прямо с консоли.
 
Где я могу легко получить логи с моего DMP, точек доступа и коммутаторов, чтобы начать их парсить?
 
К сожалению, нет, так как их реализация только фиксирует срабатывание правила в логе, а не выполняет действие правила. Единственный способ обойти это — создать явные правила и затем извлекать accept/deny, например, из описания.
 
Спасибо! Это именно то, что я искал. Есть ли способ получить поле действия для block, deny и так далее?
 
Я сделал ещё несколько, сообщений довольно много, поэтому буду добавлять их по мере появления или если посчитаю, что они полезны.

<!--
<decoder name="unifi-udm-pro-se-fw-fields">
   <parent>unifi-udm-pro-se</parent>
   <regex type="pcre2">DESCR="(.*)"\sIN=(\S*)\sOUT=(\S*)\sMAC=((?:[A-Fa-f0-9]{2}[:-]){5}(?:[A-Fa-f0-9]{2})):((?:[A-Fa-f0-9]{2}[:-]){5}(?:[A-Fa-f0-9]{2})):08:00\sSRC=(\S*)\sDST=(\S*)\sLEN=(\S*)\sTOS=(\S*)\sPREC=(\S*)\sTTL=(\S*)\sID=(\S*)\s(?:(?:(DF)(?:\s)|))PROTO=(\S*)\sSPT=(\S*)\sDPT=(\S*)\s</regex>
   <order>rule,interface_in,interface_out,source_mac, destination_mac,srcip,dstip,framelength,tos,prec,ttl,id,actionflags,protocol,srcport,dstport</order>
</decoder>

<decoder name="unifi-udm-pro-se">
   <prematch type="pcre2">^.*(\[LAN.*\])\s</prematch>
</decoder>
-->

<!-- ubios-udapi-dhcp сообщения -->
<decoder name="unifi-udm-pro-dhcp">
   <prematch type="pcre2">^.*(dnsmasq)</prematch>
</decoder>

<decoder name="unifi-udm-pro-se-dhcp-fields">
   <parent>unifi-udm-pro-dhcp</parent>
   <regex type="pcre2">(dnsmasq-dhcp)\[(\d{1,8})]:\s(\w+)\((.*)\)\s(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})\s((?:[A-Fa-f0-9]{2}[:-]){5}(?:[A-Fa-f0-9]{2}))\s(.*)</regex>
   <order>process.name,process.pid,command,interface_in,port.local.ip,destination_mac,hostname</order>
</decoder>

<decoder name="unifi-udm-pro-se-dhcp-fields">
   <parent>unifi-udm-pro-dhcp</parent>
   <regex type="pcre2">(dnsmasq-dhcp)\[(\d{1,8})]:\s(\w+)\((.*)\)\s(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})\s((?:[A-Fa-f0-9]{2}[:-]){5}(?:[A-Fa-f0-9]{2}))</regex>
   <order>process.name,process.pid,command,interface_in,port.local.ip,destination_mac</order>
</decoder>

<decoder name="unifi-udm-pro-se-dhcp-fields">
   <parent>unifi-udm-pro-dhcp</parent>
   <regex type="pcre2">(dnsmasq)\[(\d{1,8})]:\s*(\w+),\s(.*)\s(.*)</regex>
   <order>process.name,process.pid,command,audit.command,file</order>
</decoder>

<decoder name="unifi-udm-pro-se-dhcp-fields">
   <parent>unifi-udm-pro-dhcp</parent>
   <regex type="pcre2">(dnsmasq-dhcp)\[(\d{1,8})]:\s(\w+)\((.*)\)\s((?:[A-Fa-f0-9]{2}[:-]){5}(?:[A-Fa-f0-9]{2}))</regex>
   <order>process.name,process.pid,command,interface_in,source_mac</order>
</decoder>

<!-- ubios-udapi-server сообщения -->
<decoder name="unifi-udm-pro-services">
   <prematch type="pcre2">^.*ubios-udapi-server\[</prematch>
</decoder>

<decoder name="unifi-udm-pro-se-services-fields">
   <parent>unifi-udm-pro-services</parent>
   <regex type="pcre2" offset="after_parent">(\d{1,7})]:\s\[(\w+)]\s(\w+-\w+-\w+):\s(.*"(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})")\s(\w+):\s(.*)$</regex>
   <order>process.pid,process.args,process.name,lookup,remote.ip,result,status</order>
</decoder>

(\d{1,7})]:\s\[(\w+)]\s(\w+-\w+-\w+):\s(mdns data):\s(.*)
<decoder name="unifi-udm-pro-se-services-fields">
   <parent>unifi-udm-pro-services</parent>
   <regex type="pcre2" offset="after_parent">(\d{1,7})]:\s\[(\w+)]\s(\w+-\w+-\w+):\s(mdns data):\s(.*)</regex>
   <order>process.pid,process.args,process.name,program,status</order>
</decoder>

<!-- DPI flow stats -->

<decoder name="unifi-udm-pro-dpi">
   <prematch type="pcre2">^.*(dpi-flow-stats)\[</prematch>
</decoder>

<decoder name="unifi-udm-pro-se-services-fields">
   <parent>unifi-udm-pro-dpi</parent>
   <regex type="pcre2">.*(dpi-flow-stats)\[(\d{1,5})\]:\s(\w+-\w+-\w+):(.*"(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})")\s(\w+):\s(.*$)</regex>
   <order>process.name,process.pid,process.command,lookup,remote.ip,result,status</order>
</decoder>

<decoder name="unifi-udm-pro-se-services-fields">
   <parent>unifi-udm-pro-dpi</parent>
   <regex type="pcre2">.*(dpi-flow-stats)\[(\d{1,5})\]:\s(\w+-\w+-\w+):\s(.*):\s(.*$)</regex>
   <order>process.name,process.pid,process.command,program,status</order>
</decoder>

<!-- firewall сообщения -->
<decoder name="unifi-udm-pro-se">
   <prematch type="pcre2">^.*(\[.*\])\s</prematch>
</decoder>

<decoder name="unifi-udm-pro-se-fw-fields">
   <parent>unifi-udm-pro-se</parent>
   <regex type="pcre2">DESCR="(.*)"\sIN=(\S*)\sOUT=(\S*)\sMAC=((?:[A-Fa-f0-9]{2}[:-]){5}(?:[A-Fa-f0-9]{2})):((?:[A-Fa-f0-9]{2}[:-]){5}(?:[A-Fa-f0-9]{2})):08:00\s</regex>
   <order>rule,interface_in,interface_out,source_mac,destination_mac</order>
</decoder>

<decoder name="unifi-udm-pro-se-fw-fields">
   <parent>unifi-udm-pro-se</parent>
   <regex type="pcre2">\sSRC=(\S*)\sDST=(\S*)\s</regex>
   <order>srcip,dstip</order>
</decoder>

<decoder name="unifi-udm-pro-se-fw-fields">
   <parent>unifi-udm-pro-se</parent>
   <regex type="pcre2">\sSRC=(\S*)\sDST=(\S*)\sLEN=(\S*)\sTOS=(\S*)\sPREC=(\S*)\s</regex>
   <order>port.local_ip,port.remote_ip,framelength,tos,prec</order>
</decoder>

<decoder name="unifi-udm-pro-se-fw-fields">
   <parent>unifi-udm-pro-se</parent>
   <regex type="pcre2">\sTTL=(\S*)\sID=(\S*)\s(?:(?:(DF)(?:\s)|))PROTO=(\S*)\sSPT=(\S*)\sDPT=(\S*)\s</regex>
   <order>ttl,id,actionflags,port.protocol,port.local_port,port.remote_port</order>
</decoder>

<decoder name="unifi-udm-pro-se-fw-fields">
   <parent>unifi-udm-pro-se</parent>
   <regex offset="after_parent">LEN=(\S*)\sMARK=(\S*)</regex>
   <order>packetlength,mark</order>
</decoder>

<decoder name="unifi-udm-pro-se-fw-fields">
   <parent>unifi-udm-pro-se</parent>
   <regex type="pcre2" offset="after_parent">URGP=(\S+)\sMARK=(\S+)</regex>
   <order>urgp,mark</order>
</decoder>

<decoder name="unifi-udm-pro-se-fw-fields">
   <parent>unifi-udm-pro-se</parent>
   <regex type="pcre2" offset="after_parent">SEQ=(\S+)\sACK=(\S+)\sWINDOW=(\S+)\s((ACK FIN)|(ACK PSH)|(ACK SYN)|(ACK)|(SYN)|(FIN))\sURGP=(\S+)</regex>
   <order>seq,ack,window,flags</order>
</decoder>

<decoder name="unifi-udm-pro-se-fw-fields">
   <parent>unifi-udm-pro-se</parent>
   <regex type="pcre2" offset="after_parent">\sURGP=(\S+)\sUID=(\S+)\sGID=(\S+)\sMARK=(\S+)</regex>
   <order>urgp,uid,gid,mark</order>
</decoder>
 
следующее...
 
Я, наверное, написал тысячи парсеров на regex для разных задач, но всё равно не могу заставить это работать с wazuh — даже с помощью Gemini или ChatGPT ничего не вышло... Хотя кое-каких успехов добился. Для сообщений файрвола ipv4 можно использовать следующий декодер:

<!--
<decoder name="unifi-udm-pro-se-fw-fields">
   <parent>unifi-udm-pro-se</parent>
   <regex type="pcre2">DESCR="(.*)"\sIN=(\S*)\sOUT=(\S*)\sMAC=((?:[A-Fa-f0-9]{2}[:-]){5}(?:[A-Fa-f0-9]{2})):((?:[A-Fa-f0-9]{2}[:-]){5}(?:[A-Fa-f0-9]{2})):08:00\sSRC=(\S*)\sDST=(\S*)\sLEN=(\S*)\sTOS=(\S*)\sPREC=(\S*)\sTTL=(\S*)\sID=(\S*)\s(?:(?:(DF)(?:\s)|))PROTO=(\S*)\sSPT=(\S*)\sDPT=(\S*)\s</regex>
   <order>rule,interface_in,interface_out,source_mac, destination_mac,srcip,dstip,framelength,tos,prec,ttl,id,actionflags,protocol,srcport,dstport</order>
</decoder>

<decoder name="unifi-udm-pro-se">
   <prematch type="pcre2">^.*(\[LAN.*\])\s</prematch>
</decoder>
-->

<decoder name="unifi-udm-pro-se">
   <prematch type="pcre2">^.*(\[.*\])\s</prematch>
</decoder>



<decoder name="unifi-udm-pro-se-fw-fields">
   <parent>unifi-udm-pro-se</parent>
   <regex type="pcre2">DESCR="(.*)"\sIN=(\S*)\sOUT=(\S*)\sMAC=((?:[A-Fa-f0-9]{2}[:-]){5}(?:[A-Fa-f0-9]{2})):((?:[A-Fa-f0-9]{2}[:-]){5}(?:[A-Fa-f0-9]{2})):08:00\s</regex>
   <order>rule,interface_in,interface_out,source_mac,destination_mac</order>
</decoder>

<decoder name="unifi-udm-pro-se-fw-fields">
   <parent>unifi-udm-pro-se</parent>
   <regex type="pcre2">\sSRC=(\S*)\sDST=(\S*)\sLEN=(\S*)\sTOS=(\S*)\sPREC=(\S*)\s</regex>
   <order>port.local_ip,port.remote_ip,framelength,tos,prec</order>
</decoder>

<decoder name="unifi-udm-pro-se-fw-fields">
   <parent>unifi-udm-pro-se</parent>
   <regex type="pcre2">\sTTL=(\S*)\sID=(\S*)\s(?:(?:(DF)(?:\s)|))PROTO=(\S*)\sSPT=(\S*)\sDPT=(\S*)\s</regex>
   <order>ttl,id,actionflags,port.protocol,port.local_port,port.remote_port</order>
</decoder>

<decoder name="unifi-udm-pro-se-fw-fields">
   <parent>unifi-udm-pro-se</parent>
   <regex offset="after_parent">LEN=(\S*)\sMARK=(\S*)</regex>
   <order>packetlength,mark</order>
</decoder>

<decoder name="unifi-udm-pro-se-fw-fields">
   <parent>unifi-udm-pro-se</parent>
   <regex type="pcre2" offset="after_parent">URGP=(\S+)\sMARK=(\S+)</regex>
   <order>urgp,mark</order>
</decoder>

<decoder name="unifi-udm-pro-se-fw-fields">
   <parent>unifi-udm-pro-se</parent>
   <regex type="pcre2" offset="after_parent">SEQ=(\S+)\sACK=(\S+)\sWINDOW=(\S+)\s((ACK FIN)|(ACK PSH)|(ACK SYN)|(ACK)|(SYN)|(FIN))\sURGP=(\S+)</regex>
   <order>seq,ack,window,flags</order>
</decoder>

<decoder name="unifi-udm-pro-se-fw-fields">
   <parent>unifi-udm-pro-se</parent>
   <regex type="pcre2" offset="after_parent">\sURGP=(\S+)\sUID=(\S+)\sGID=(\S+)\sMARK=(\S+)</regex>
   <order>urgp,uid,gid,mark</order>
</decoder>

Возможно, придётся чуть подправить prematch, если хотите логировать другие правила, которые не подходят под интерфейс LAN — просто посмотрите логи. Чтобы видеть события в wazuh, нужно повысить уровень оповещений, это можно сделать с помощью такого правила:

<group name="unifi-udm-pro-se">
 <rule id="100010" level="3">
   <decoded_as>unifi-udm-pro-se</decoded_as>
   <description>Unifi UDM Pro Event</description>
 </rule>
</group>
 
Есть ли какая-нибудь документация по этому поводу или кто-то может подробно объяснить этот процесс? Ищу то же самое.
 
напомню * Я тоже хочу сделать то же самое.
Страницы: 1
Читают тему (гостей: 1)