|Applies to Product:||USM Appliance™||AlienVault OSSIM®|
In this tutorial, we use Microsoft Exchange to show how to develop a log plugin. The preferred method of collecting logs from the Exchange Server is through NXLog. See Microsoft Exchange Server through NXLog for details.
Plugin Development Steps
- Examine the log file from the data source from which you want to create a plugin. Identify all the types of log messages, as well as messages sharing a common structure, but using different values.
- Create the <filename>.cfg file, either by writing a new file or by copying an existing and similar file, then rewriting it.
- Give the plugin a numeric ID. (See Creating a Plugin Configuration File for available values.)
- Specify the location of the file from which the plugin should read.
- Write regular expressions to parse individual messages from the log file.
- Test your regular expressions to see if they perform as they should, using a testing tool such as the one available at regex101.com.
- Create the .sql file by copying an existing and similar .sql file. Change the fields to describe events included in the custom plugin.
Write the .sql file to the SIEM database.
- Enable the plugin through either the AlienVault Setup menu, the USM Appliance web UI, or a USM Appliance asset. (See Enable Plugins.)
- Test the plugin by sending logs from the data source to USM Appliance. (See Verify that an Enabled Plugin Is Working Properly.)
This task creates a plugin configuration file for a data source called "exchangews," and which uses SNMP for data transfer.
- (Optional) Use an existing plugin as a template for the new one by copying an existing plugin file like SSH.cfg and renaming it exchangews.cfg.
- Write the new plugin configuration settings:
Change the plugin_id field, using any value in the range from 9001 to 2147483647 except for the following:
90003, 90005, 90007, 90008, 10002, 12001, 19004, 19005, 19006, 20505
Note: Because you have copied SSH.cfg, you do not need to create a header. If you created a file from scratch, you would need to create one at this juncture. See The Plugin File Header.
- Change location to point to the log file /var/log/exchangews.log.
- Delete the startup and shutdown fields. These fields are not going to be used. There is no application associated with this plugin.
- (Optional) Create a new translation table.
- Create new rules, filling up the fields below.
- Create two regular expressions to parse the data, because there are two different formats in the log file.
[exchangews - Generic rule]
#2011-10-09 05:00:15 220.127.116.11 36A42160 SMTPSVC1 MEE-PDC 192.168.1.2 0 HELO - +36A42160 250 0 48 13 0 SMTP - - - -
#2011-10-09 05:00:16 18.104.22.168 36A42160 SMTPSVC1 MEE-PDC 192.168.1.2 0 MAIL - +FROM:+<email@example.com> 250 0 57 45 0 SMTP - - - -
[exchangews = Generic rule 2 NCSA Format]
#22.214.171.124 - 126.96.36.199 [11/Oct/2011:13:16:40 -0600] "HELO -?+188.8.131.52 SMTP" 250 46
#184.108.40.206 - 220.127.116.11 [11/Oct/2011:13:16:41 -0600] "MAIL -?+FROM:+<Keith@testdomain.com> SMTP" 250 46
- Check regular expressions with logs inside the file /var/log/exchangews.log.
A translation table translates a string to a number so that it can be used as a plugin_sid.
There are several utilities on the Internet to test regular expressions written in Python. It is recommended to use one of these utilities to check that the created regular expressions match the logs.
Note: The location parameter is limited to 100 files.
The following example shows the plugin .sql file corresponding to the plugin configuration file example.
INSERT INTO plugin (id, type, name, description) VALUES (9001, 1, 'exchangews', 'Exchange E-mail Web server');
INSERT INTO plugin_sid (plugin_id, sid, category_id, class_id, name, priority, reliability) VALUES (9001, 1, NULL, NULL, 'exchangews: HELO' ,3, 2);
INSERT INTO plugin_sid (plugin_id, sid, category_id, class_id, name, priority, reliability) VALUES (9001, 9999, NULL, NULL, 'exchangews: Generic exchange event' ,3, 2);
USM Appliance must store all the plugin IDs and event types in its database before it can store any events. For this reason, if you develop a new plugin and you don't first update the database with that data, the USM Appliance Server drops those events, even though the plugin is working correctly.
To update the SIEM database
Write the changes to the SIEM database:
cat exchangews.sql | ossim-db
Apply changes in the SIEM: