« Tuning Snort and flex response

Installing Snort sensor with Mysql and BASE on CentOS Linux

10/30/08 | by Andrew Useckas [mail] | Categories: Uncategorized

Installing Snort

After the system comes back up, login as root. The first step is to install prerequisites for Snort. The following packages are required:

mysql-server
mysql-bench
mysql-devel
mysqlclient10
libpcap
libpcap-devel
pcre-devel

To make sure they are all installed execute the following:

# yum install mysql-server mysql-bench mysql-devel mysqlclient10 libpcap libpcap-devel pcre-devel

After the packages are installed configure mysql database by following these steps:

Start mysql server by executing:

# /etc/init.d/mysqld start

Set mysql root password by executing:

# mysqladmin -u root password 'password'

Download the latest tarball from snort. At the time of writing this article the latest version is 2.8.3.1 and the tarball is http://www.snort.org/dl/snort-2.8.3.1.tar.gz

You can use wget to download it into "/tmp" directory:

# cd /tmp
# wget http://www.snort.org/dl/snort-2.8.3.1.tar.gz

Next uncompress the tarball:

# tar xvzf snort-2.8.3.1.tar.gz

Change directory into the snort distributable:

# cd snort-2.8.3.1

Create user and group to be used by snort:

# groupadd snort
# useradd -g snort snort

Build snort:

# ./configure --with-mysql --prefix=/usr
# make all
# make install

 

Next we need to create the database where snort will log the events:

# mysql -p

Enter your mysql root password.

# mysql> create database snort;

Configure database user for snort:

# mysql> grant create, insert, select, delete, update on snort.* to snort@"localhost";
# mysql> set password for snort@"localhost"=password('password');
# mysql> exit

Now create mysql tables for snort:

# cd schemas
# cd schemas
# mysql -p snort < create_mysql

Enter mysql root password you set earlier.

 

Now you need to download the latest rules for snort. First you need to register with Snort and obtain a key. After getting the key you can download the rules from this URL: http://www.snort.org/pub-bin/oinkmaster.cgi/[your_key]/snortrules-snapshot-2.8.tar.gz

You can download the latest rules to /tmp directory using wget:

# cd /tmp
# wget http://www.snort.org/pub-bin/oinkmaster.cgi/[your_key]/snortrules-snapshot-2.8.tar.gz

Now uncompress the latest rules to /etc/snort directory:

# mkdir -p /etc/snort/rules
# cd /etc/snort
# tar xvzf /tmp/snortrules-snapshot-2.8.tar.gz

Move the content of etc to the current (snort) directory:

# mv etc/* .
# rmdir etc

 vvvvvv

Now configure snort.conf using your favorite editor. I will use "vi" :)

# vi snort.conf

Change the "HOME_NET" variable to your local area network, the network you wish to protect, such as:

var HOME_NET [192.168.0.0/24]

And change the "EXTERNAL_NET" to include everything bu the HOME_NET:

var EXTERNAL_NET !$HOME_NET

Change RULE_PATH to:

var RULE_PATH /etc/snort/rules

Remove the comment from the last line:

#include threshold.conf

This is the file where you will tune your ruleset.

Change all references from "/usr/local" to "/usr". For example:

dynamicpreprossesor /usr/local/lib/snort_dynamicpreprossesor/libsf_dcerpc_preproc.so

needs to be changed to:

dynamicpreprossesor /usr/lib/snort_dynamicpreprossesor/libsf_dcerpc_preproc.so

Finally add this line to the end of the file:

output database: log, mysql, user=snort password=password dbname=snort host localhost

This line will enable logging to mysql.

Adjust other variables as needed.

 

Snort is all ready to go. Now we need to configure the startup scripts for mysql and snort.

In order to start mysql during bootup run the following:

# chkconfig --level 345 mysqld on

The procedure is more complicated for snort as we need to manually adjust the startup scripts. First we will copy sysconfig and startup scripts from the snort distribution:

# cd /tmp/snort-2.8.3.1
# cd rpm
# cp snortd /etc/init.d/
# cp snort.sysconfig /etc/sysconfig/snort

Make snortd executable:

# chmod 755 /etc/init.d/snortd

Edit snort startup file:

# vi /etc/init.d/snortd

Change all references from "/sbin/snort" to "/bin/snort".

Edit snort sysconfig file:

# vi /etc/sysconfig/snort

Change variable "INTERFACE" to the interfaces that will be used for packet capture.

Save the file.

Now you need to create the directory where Snort will store it's log files:

# mkdir -p /var/log/snort
# chown snort:snort /var/log/snort

As the last step you should make snort start automatically at boot:

# chkconfig --add snortd
# chkconfig --level 345 snortd

Reboot the system. When the system comes back you should have a working Snort sensor. The alerts will be logged to "/var/log/snort/alert" file as well as mysql database. Mysql database is where BASE is going to get it's alerts from.

Use /etc/snort/threshold.conf file to tune false positives. Instructions how to accomplish this task can be found within the file itself.

Pages: 1 · 2 · 3

6 comments

Comment from: Fred [Visitor]
Nice job Andrew. Thanks for posting this.
10/31/08 @ 19:28
Comment from: jiangzhw2008@yeah.net [Visitor] Email
Thank you for your wonderful work!When i
execute the "./configure --with-mysql --prefix-/usr
" ,it prompts "no such file or directory",what
is the purpose of this command?Besides,when i
run the "yum install mysqlclient10",it tells me
there is no mysqlclient10 available then i install
the mysqlclient10-3.23.58-9.2.1.i386.rpm,is that
OK?Lookforward your reply.
02/10/09 @ 23:09
Comment from: Ayo Rotibi [Visitor] Email · http://rotibi.cet
Thanks Andrew, I am a 1st timer Linux and I have been able to use this guide to install Snort on my network.
06/30/09 @ 09:38
Comment from: sergio [Visitor]
Nice manual! thank you!
12/15/09 @ 04:29
Comment from: chami [Visitor]
100 % working. every easy to understand even for a beginner. great job. thanks boss.
03/12/10 @ 06:04
Comment from: chami [Visitor]
one more thing... i got a problem when installing pear install Image_Canvas-alpha
and pear install Image_Graph-alpha. it said my PEAR installer version is not enough. what you have to do is download new package and intall it.
03/12/10 @ 06:08

This post has 16 feedbacks awaiting moderation...

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
September 2010
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Andrew Useckas shares his Linux experience

Search

XML Feeds

powered by b2evolution