有没有人使用任何自定义解码器与OSSEC?

我在RHEL 6服务器上运行OSSEC HIDS软件2.8.3版。 我们已经在实验室用DNS服务器testing了这一点,以跟踪进入我们的RPZ和恶意软件区域的查询。 DNS服务器安装了OSSEC代理。 为了这个工作,我们不得不使用一个自定义的书面解码器。 除了那些“开箱即用”安装的以外,其他人是否还有OSSEC和定制解码器的使用经验? 我主要希望获得有关其他系统pipe理员正在使用OSSEC的创意,这对于我们的生产环境也很有用。

例如,有没有人成功地编写/使用自定义解码器来检测Linux的USB存储?

更新:我一直在处理一个自定义的解码器和规则来检测何时USB设备插入到服务器。 以下是我想要匹配的日志行:

Feb 3 10:23:08 testsys kernel: usb 1-1.2: New USB device found, idVendor=0781, idProduct=5575 

我的解码器规则在OSSCE中:

 <decoder name="usb-storage"> <program_name>kernel</program_name> </decoder> <decoder name="usb-storage-attached"> <parent>usb-storage</parent> <regex offset="after_parent">^USB \S+: New</regex> <order>extra_data</order> </decoder> 

我在OSSEC的规则:

 <group name="syslog,"> <!-- USB Storage Detection Log Types --> <!-- level=0 for not generating alerts by default --> <rule id="310201" level="0"> <decoded_as>usb-storage</decoded_as> <description>Looking for unknown USB attached storage</description> </rule> <!-- USB Storage Detection Event Chains --> <!-- Fire an alert (level=8) if the log line contains "New USB device found" --> <rule id="310202" level="8"> <if_sid>310201</if_sid> <match>^New USB device found</match> <description>Attached USB Storage</description> </rule> </group> 

iptables使用内核作为程序名

 <decoder name="iptables"> <program_name>^kernel</program_name> </decoder> 

我们可以使用iptables作为父节点( 内核的 intead)。 此外, id字段用于方便创build规则。 所以,你需要这个解码器:

 <decoder name="usb-storage-attached"> <parent>iptables</parent> <regex offset="after_parent">^(usb) </regex> <order>id</order> </decoder> 

规则可以是:

 <rule id="310201" level="0"> <decoded_as>iptables</decoded_as> <id>usb</id> <description>USB messages grouped.</description> </rule> <rule id="310202" level="1"> <if_sid>310201</if_sid> <match>New USB device found</match> <description>Attached USB Storage</description> </rule> 

现在,您可以使用规则310201来处理与USB有关的所有事情。 规则310202是你想要的规则:

 Feb 3 10:23:08 testsys kernel: usb 1-1.2: New USB device found, idVendor=0781, idProduct=5575 **Phase 1: Completed pre-decoding. full event: 'Feb 3 10:23:08 testsys kernel: usb 1-1.2: New USB device found, idVendor=0781, idProduct=5575' hostname: 'testsys' program_name: 'kernel' log: 'usb 1-1.2: New USB device found, idVendor=0781, idProduct=5575' **Phase 2: Completed decoding. decoder: 'iptables' id: 'usb' **Phase 3: Completed filtering (rules). Rule id: '310202' Level: '1' Description: 'Attached USB Storage' **Alert to be generated. 

我刚刚添加到我们的规则集库: 解码器和规则 。

您可以试试我们的OSSEC规则集。 它定期更新与新的解码器和规则。

在这里能find它:

https://github.com/wazuh/ossec-rules

和说明在这里(包括一个脚本来自动运行更新):

http://documentation.wazuh.com/en/latest/ossec_ruleset.html

关于USB存储检测,我已经为Windows做了这样的configuration:

 <localfile> <frequency>10</frequency> <log_format>full_command</log_format> <command>reg QUERY HKLM\SYSTEM\CurrentControlSet\Enum\USBSTOR</command> </localfile> 

而这样的规则:

 <rule id="140125" level="7"> <if_sid>530</if_sid> <match>ossec: output: 'reg QUERY</match> <check_diff /> <description>New USB device connected</description> </rule> 

对于Linux,我认为它会更容易。 你有一个日志消息的例子吗? 很可能你只需要为它创build规则。