Well , its been an age old question from the days when people started using computers on network ... is my network secure ?? ... ah , i don't think that in this world there is any system that can't be penetrated !! unless there is no way to communicate with system other then mouse and keyboard ,without internet or any network ... hell even without FDD or CDD !!! ... because in many cases when system get jeopardized , by the inside man ( and believe me ,there is no way to protect the system from that mole until information gets stolen ) !!! ... anyways .... as a preventive measure , network admins install grid of network activity sensors , with help of Intrusion Detection System a.k.a. IDS .... basic function of IDS is to detect unauthorized attempt to enter network or other kind of activity that is illegal according to what so ever network policy ... Snort is the most famous personal IDS ,system that is used for network monitoring purpose .... it is also IPS , intrusion prevention system , and it works with other softwares such as BASE, OSSIM to provide visual output with good interface ...
For my trial , i have used SNORT with BASE (for front end )and My-SQL (for storing data in to database for analysis) and APACHE2 server ....
Getting Prepared ......
The first thing I like to do is grab all the dependent packages that I can from Synaptic. From the Desktop go to System > Administration > Synaptic Package Manager. Enter your password and select Search.
Search for the following packages and install them:
* Libpcap0.8-dev
* libmysqlclient15-dev
* mysql-client-5.0
* mysql-server-5.0
* bison
* flex
* apache2
* libapache2-mod-php5
* php5-gd
* php5-mysql
* libphp-adodb
* php-pear
Gain Root Privileges ...
From the Desktop go to Applications > Accessories > Terminal and type:
$ sudo -i
$ Then your password.
We need to get one more package here,
# apt-get install libc6-dev g++ gcc
Gathering Resources ...
We want to create a temp directory to download and untar files. I'm going to use edge's structure here. In the terminal window type the following:
# cd /root
# mkdir snorttmp
# cd /root/snorttmp
Let's get snort. The latest version of snort at the time of writing is 2.8.3.
Open a web browser and navigate to http://www.snort.org/dl; right click on the most recent release and copy link location.
In the terminal type:
# wget http://www.snort.org/dl/current/snort-2.8.3.tar.gz
It's time to untar the Snort package and remove the tar file.
# tar -xzvf /root/snorttmp/snort-2.8.3.tar.gz
# rm /root/snorttmp/snort-2.8.3.tar.gz
Get Snort Rules ...
Change directories into the new snort-2.8.3 folder.
# cd /root/snorttmp/snort-2.8.3
Open a web browser and navigate to http://www.snort.org/pub-bin/downloads.cgi.
Scroll down to the "Sourcefire VRT Certified Rules - The Official Snort Rule set (unregistered user release)" section. Right click on the most recent release and copy link location.
If you are a forum member you can get newer rules which are under the "registered user release".
In the terminal type:
# wget http://www.snort.org/pub-bin/downloads.cgi/Download/vrt_pr/snortrules-pr-2.4.tar.gz
Untar the Snort Rules and remove the tar file.
# tar -xzvf /root/snorttmp/snort-2.8.3/snortrules-pr-2.4.tar.gz
# rm /root/snorttmp/snort-2.8.3/snortrules-pr-2.4.tar.gz
Getting PCRE ... Perl Compatible Regular Epressions ...
Change directory back into the snorttmp folder.
# cd /root/snorttmp
Open a web browser and go to http://www.pcre.org.
Click on the link for the newest release, right click on the newest tar.gz package and select copy link (at the time of writing this is pcre-7.8).
In the terminal type:
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.8.tar.gz
Untar PCRE and remove the tar file.
# tar -xzvf /root/snorttmp/pcre-7.8.tar.gz
# rm /root/snorttmp/pcre-7.8.tar.gz
Getting BASE ... Basic Analysis and Security Engine ...
Change directory back into the snorttmp folder.
# cd /root/snorttmp
Open a web browser and go to http://sourceforge.net/project/showfiles.php?group_id=103348.
Click on download then right click on the newest tar.gz package and select copy link (at the time of writing this is base-1.4.1).
In the terminal type:
# wget http://downloads.sourceforge.net/secureideas/base-1.4.1.tar.gz?modtime=1217804205&big_mirror=0
Untar BASE and remove the tar file.
# tar -xzvf /root/snorttmp/base-1.4.1.tar.gz
# rm /root/snorttmp/base-1.4.1.tar.gz
Getting ADOdb ... a database abstraction library for PHP ...
Change directory back into the snorttmp folder.
# cd /root/snorttmp
Open a web browser and go to http://sourceforge.net/project/showfiles.php?group_id=42718.
Click on the download link for adodb-php5-only then right click on the adodb505.tgz package and select copy link (adodb505 is the most recent package at the time of writing).
In the terminal type:
# wget http://downloads.sourceforge.net/adodb/adodb505.tgz?modtime=1215766049&big_mirror=0
Untar ADOdb and remove the tar file.
# tar -xzvf /root/snorttmp/adodb505.tgz
# rm /root/snorttmp/adodb505.tgz
Do an ls to be sure you have all the packages.
# ls /root/snorttmp
Lets have Some Fun !!
a. PCRE install.
# cd /root/snorttmp/pcre-7.8
Here we will do a make/install
# ./configure
# make
# make install
b. Snort install.
# cd /root/snorttmp/snort-2.8.3
Here we will do a make/install
# ./configure -enable-dynamicplugin --with-mysql
# make
# make install
We need to create some folders in /etc for snort to function correctly and copy some files over to them.
# mkdir /etc/snort /etc/snort/rules /var/log/snort
Let's move some files.
# cd /root/snorttmp/snort-2.8.3/rules
# cp * /etc/snort/rules/
Let's get the /etc snort files also.
# cd /root/snorttmp/snort-2.8.3/etc
# cp * /etc/snort/
One more file.
# cp /usr/local/lib/libpcre.so.0 /usr/lib
Configuring Snort ...
We need to modify the snort.conf file to suite our needs.
Open /etc/snort/snort.conf with your favorite text editor (nano, vi, vim, gedit etc.).
# gedit /etc/snort/snort.conf
Change "var HOME_NET any" to "var HOME_NET 192.168.1.0/24" (your home network may differ from 192.168.1.0)
Change "var EXTERNAL_NET any" to "var EXTERNAL_NET !$HOME_NET" (this is stating everything except HOME_NET is external)
Change "var RULE_PATE ../rules" to "var RULE_PATH /etc/snort/rules"
Scroll down the list to the section with "# output database: log, mysql, user=", remove the "#" from in front of this line.
Leave the "user=root", change the "password=password" to "password=YOUR_PASSWORD", "dbname=snort"
Make note of the username, password, and dbname. You will need this information when we set up the Mysql db.
Save and quit.
Setting UP My-SQL Database ...
Log into the mysql server.
# mysql -u root -p
Sometimes there is no password set so just hit enter.
If you get a failed logon, try the above command again and enter YOUR_PASSWORD.
If there is no password you need to create a password for the root account.
Note: Once you are in mysql the # is now a mysql>
mysql> SET PASSWORD FOR root@localhost=PASSWORD('YOUR_PASSWORD');
Create the snort database.
mysql> create database snort;
mysql> exit
We will use the snort schema for the layout of the database.
# mysql -D snort -u root -p < /root/snorttmp/snort-2.8.3/schemas/create_mysql We need to comment out a few lines in the web rules before we can test snort, I am unsure if this has been fixed in the subscriber version. Open up /etc/snort/rules/web-misc.rules with your favorite text editor. # gedit /etc/snort/rules/web-misc.rules Comment out line's 97, 98, and 452 with a "#" (no quotes).
Testing Snort ...
we need to be sure that our installation works fine ,so we do a test drive of snort ...
In the terminal type:
# snort -c /etc/snort/snort.conf
If everything went well you should see an ascii pig.
To end the test hit ctrl + c.
Setting up BASE and APACHE2 ...
We have already installed both Apache2 and BASE, all we have to do now is move some files and modify a config file.
Create a file called test.php in /var/www/ with your favorite text editor.
# gedit /var/www/test.php
write in it:
Save and close this file
We need to edit /etc/php5/apache2/php.ini file.
# gedit /etc/php5/apache2/php.ini
You need to add the following under "Dynamic Extensions".
extension=mysql.so
extension=gd.so
Restart Apache2.
# /etc/init.d/apache2 restart
Get the ip address of the machine you are working on.
# ifconfig -a
Open a web browser and go to http://YOUR.IP.ADDRESS/test.php.
If everything went well, you will have PHP information displayed. Moving more files...
We need to move ADOdb into the /var/www directory.
# mv /root/snorttmp/adodb505 /var/www/
Let's make a directory in www and move BASE.
# mkdir /var/www/web
# mv /root/snorttmp/base-1.4.1 /var/www/web/
We need to temporarily enable writing to the base-1.4.1 folder for setup.
# chmod 757 /var/www/web/base-1.4.1
We also need to modify a PHP setup file using your favorite text editor.
# vim /var/www/web/base-1.4.1/setup/setup1.php
Find the line that says "base_header" and change it to "header".
Save and exit.
We want the graphs in base to work so we need to install a few pear extensions.
# pear install Image_Color
# pear install Image_Canvas-alpha
# pear install Image_Graph-alpha
BASE Setup via the web....
Open a web browser and navigate to http://YOUR.IP.ADDRESS/web/base-1.4.1/setup.
Click continue on the first page.
Step 1 of 5: Enter the path to ADODB.
This is /var/www/adodb505.
Step 2 of 5:
Database type = MySQL, Database name = snort, Database Host = localhost, Database username = root, Database Password = YOUR_PASSWORD
Step 3 of 5: If you want to use authentication enter a username and password here.
Step 4 of 5: Click on Create BASE AG.
Step 5 of 5: one step 4 is done at the bottom click on Now continue to step 5.
Bookmark this page.
Change the permissions back on the /var/www/web/base-1.4.1 folder.
# chmod 775 /var/www/web/base-1.4.1
We are DONE !!!
To start Snort in the terminal type:
# snort -c /etc/snort/snort.conf -i eth0 -D
This starts snort using eth0 interface in a daemon mode.
To make sure it is running you can check with the following command:
# ps aux | grep snort
If it's running you will see an entry similar to snort -c /etc/snort/snort.conf -i eth0 -D.
Finally , to see the snort in action , we can run BASE engine , by going that page we are using to run via apache server ...
phewww ... after following brain twisting procedures i was finally able to setup my personal IDS using SNORT ,which took me almost more then one and half hour ... i hope this walkthrough will work for you guys too ...
njoy ....