OSSEC Output and Alert options Sending output to a Database OSSEC supports MySQL and PostgreSQL database outputs. 1. Configuration options These configurations options can be specified in the server or local install ossec.conf file. database_output: hostname IP Address of the database server. Allowed: any valid IP address username Username to access the database. Allowed: Any Valid Username password Password to access the database. Allowed: Any Password database Database name to store the alerts. Allowed: database name type Type of database (Mysql or PostgreSQL). Allowed: mysql/postgresql 2. Enabling Database Support You must have the MySQL or PgSQL Client libraries installed on the OSSEC server. # sudo apt-get install libmysqlclient-dev # sudo apt-get install mysql-server # sudo apt-get install mysql-client Before you run the 」./install.sh」 script execute the following to compile OSSEC with database support. # cd ossec-hids-* # cd src; make setdb; cd .. # ./install.sh 3. Enable Database output in the configuration After installation is complete database support needs to be enabled. The following command will enable the database daemon on the next restart. # /var/ossec/bin/ossec-control enable database 4. Database Specific Setup 4.1 Database Setup Create a database, setup the database user, and add the schema (located in the src/os_dbd directory of the distribution) with the following commands. # mysql -u root -proot mysql> create database ossec; mysql> grant INSERT,SELECT,UPDATE,CREATE,DELETE,EXECUTE on ossec.* to caoqing@'192.168.27.%'; mysql> set password for caoqing@'192.168.27.%'=PASSWORD('caoqing'); mysql> flush privileges; mysql> quit # mysql -u root -proot ossec < /root/soft/ossec-hids-2.7.1/src/os_dbd/mysql.schema # mysql -u root -proot ossec mysql> show tables; +----------------------------+ | Tables_in_ossec | +----------------------------+ | agent | | alert | | category | | data | | location | | server | | signature | | signature_category_mapping | +----------------------------+ 8 rows in set (0.00 sec) 4.2 OSSEC Setup In order for ossec to output alerts and other data into the database the /var/ossec/etc/ossec.conf will need to have a <database_output> section added. <ossec_config> <database_output> <hostname>192.168.27.23</hostname> <username>caoqing</username> <password>caoqing</password> <database>ossec</database> <type>mysql</type> </database_output> </ossec_config> The values will need to be corrected for your installations hostname, mysql user, password, and database. 4.3 Complete MySQL Output All that is left is to enable the database daemon and restart ossec for the changes to take effect. # /var/ossec/bin/ossec-control enable database # /var/ossec/bin/ossec-control restart # /var/ossec/bin/ossec-control status ossec-monitord is running... ossec-logcollector is running... ossec-remoted is running... ossec-syscheckd is running... ossec-analysisd is running... ossec-maild not running... ossec-execd is running... ossec-dbd is running...