Snort SSL Acid FC1 From Source
Snort SSL Acid FC1 From Source
Snort SSL Acid FC1 From Source
http://www.InternetSecurityGuru.com
This document originated when a friend of mine asked me to put together this procedure
for him so that he could install Snort and Acid. It is pretty basic and is for the Linux
newbie, as well the Snort newbie. This is not an ultra-secure end-all to Snort IDS
deployment guide; this is a “How in the hell do I get this installed and working” guide.
This document will walk you through installing a stand-alone RedHat/Fedora system
(this is not for a dual boot system).
For text editors I would suggest using nano, as it is very easy to use. Type “nano
<filename>” and it will open the file in the editor. All the commands are listed on the
bottom. (Remember that the ^ is for ctrl)
Acknowledgments:
I would like to thank all my friends and the people on the Snort-users list that proofed
this for me. First of all, to my wife Kris, who puts up with me and my ever expanding
lab. A special thanks to Nick Oliver. He downloaded and used the first document I
wrote and volunteered to do test installs and proof the spelling and punctuation for this
document. He has become quite proficient with Linux and Snort in the past year.
Without him and his valuable input this document would not be as complete as it is. Also
a great thanks to Marty and the Snort team, where would we be without you.
Comments or Corrections:
Nick Oliver has also made himself available for contact if for any reason I may be
unavailable or running behind on my large and ever growing inbox.
mailto:[email protected]
If you follow this doc line by line it will work for you. Over 90% of the e-mails I get are
from people who miss a step. However, I always welcome comments and questions and
will do my best to help when ever I can.
Websites to visit:
http://www.Snort.org
http://www.cert.org/kb/acid/
http://www.mysql.com
http://www.php.net
http://fedora.redhat.com
http://www.chiark.greenend.org.uk/~sgtatham/putty/ (the putty ssh client)
http://www.bastille-linux.org (Hardening scripts for UNIX and Linux)
http://www.internetsecurityguru.com (my website)
We will install a minimal number of packages, sufficient for a usable system. After the
install we’ll turn off anything that is not needed. By hardening the OS and further
securing the system, it will make an ideal dedicated IDS. It is, however, also a system
that can easily be added to for other uses. There are lots of good articles on how to
secure a Redhat/Fedora box on the web. Just go to http://www.google.com and search
for “securing redhat” or visit http://www.bastille-linux.org/ .
Language:
English
Keyboard:
U.S. English
Mouse Configuration:
I always use the generic drivers for my mice (PS/2 or USB, depending on the system),
but I am almost always working on a KVM. If you are on a KVM, use the generic
drivers. If not, see if your mouse is on the list.
Monitor Configuration
Choose your monitor type here, or, if you don’t know your monitor characteristics,
choose “unprobed Monitor”
Install Type:
Choose custom
Disk Partitioning:
Choose to automatically partition the hard drive
Choose to remove all partitions from this hard drive (I am assuming that this not a dual
boot box)
Make sure the review button is checked
The following is approximately how RedHat will set it up:
SWAP is twice the amount of ram
/boot is about 100 Meg
/ is the rest of the hard drive
Boot Loader:
Go with the default (if this is a dual boot system then go to google and search for info on
how to install grub for dual booting)
Network Configuration:
Hit edit
Uncheck “Configure with DHCP”
Leave “Activate on boot”
Set a static IP and subnet mask for your network
Manually set the hostname
Then set a gateway and DNS address’s
Firewall:
Leave the default “Enable Firewall”
Choose WWW and SSH only as services to pass through the firewall
Other Ports: 443
Allow traffic from other devices: Leave Blank
Additional Language:
Choose only US English
Time Setup:
Choose the closest city within your time zone
Root Password:
Set a strong root password here (a strong password has at least 8 characters with a
combination of upper case, lower case, numbers and symbols. It should also not be, or
resemble, anything that might be found in a dictionary of any language)
Suggested Packages:
Take the defaults with the following exceptions. (Default is what ever it has when you
choose custom; for example, gnome is checked by default and kde is not)
Desktops:
X Window System – click “details” and uncheck the following
• xisdnload
• VNC Server
Applications:
Editors – Choose your favorites, however, nano is suggested and is part of the base
install.
Graphical Internet – check this one and click “details”. Install only the following:
• evolution (if you want to check e-mail with an Outlook-like client in X)
• Mozilla
Graphics – check this one and click “details”. Check the following:
• Gimp – good to have if your using gnome
• Gimp data extras
• Gimp print plugin
Server Section:
Choose nothing from this entire section
Development:
Development tools – check this one and click “details” and check the following in
addition to what is checked by default
• Expect
• Gcc-objc
X Software Development – check this one and click and accept the default under optional
packages.
System:
Administration – Leave this unchecked
System Tools – check this one and click “details” and check only the following (some
will need to be unchecked)
• Ethereal
• Ethereal gnome
• Nmap
• Nmap frontend
Miscellaneous:
Choose nothing from this entire section
Remember - Do not install Apache, PHP or MySQL, we will install these from
source. You will be walked through every step.
Hit next, then next again. It will tell you that you will need all 3 CD’s. Hit continue and
the install will start. First it will format the drive(s) and then it will install the packages.
This will take a little while, depending on the speed of the system you’re on, so putting
on a pot of coffee is good right about here.
Each piece of software you install and forget to update and maintain is a vulnerability
waiting to happen, and that goes for all systems. To me this is one of the most
fundamental rules of systems administration. Make sure you know what you have, and
make sure you keep it patched and secured so you do not contribute to the next worm,
virus, or hacking spree that threatens to shut down major portions of the internet.
If this is a system you are using to learn Snort, Linux, and all the other cool Linux type
things, and is not directly connected to the Internet (i.e. NAT’d behind a firewall/Router),
then just have fun. Linux is a great operating system, and it can fully replace a Windows
desktop or server. The 3 Fedora Core 1 CD’s (as well as most other distributions) are all
you need, right there, and they are free.
If this is a production system, please make sure you learn how to secure it.
Welcome screen:
Click next
License Agreement:
Accept and hit next
User Account:
Add a user account for yourself here; make sure to give it a strong password
The root account should not be used for everyday use, if you need access to root
functions then you can “su-“ or “sudo” for root access.
Sound Card:
You can do this one or just hit next if you want
Additional CD’s:
Hit next
Finish Setup:
Hit next
Login as root
Click on the RedHat on the bottom left of the toolbar
Select System Settings
Server Settings
Services
This brings up the list of services that start when the system boots up.
Click on “Save” at the top of that window, and close the service configuration.
Click on the red icon next to the clock in the lower right of your screen and go through
the prompts to update your system.
Click on the button that says Register with Redhat
There is a tab called “exceptions”. Remove “kernel*” from this tab, then do the update.
Once the update listing has been received, select only up2date and gnome-up2date
Install these two rpm’s and close the update utility.
Run the Update feature again, this time with the new Up2date.
Reboot your system (you installed a new kernel when you updated the installation, so a
reboot is necessary). You are now up to date with all the latest packages.
You are now ready to start installing Snort and all of the software it needs. You can either
use the desktop terminal window, or SSH into the server from another box. Either will
work fine. For the novice it might be easier to do this from SSH so they can cut and
(You can cut and paste from the PDF by using the text select tool in Adobe Acrobat
Download Snort
http://www.Snort.org/dl/snort-2.1.2.tar.gz
Download Apache
http://www.apache.org/dist/httpd/httpd-2.0.49.tar.gz
Download PHP
http://www.php.net/distributions/php-4.3.4.tar.gz
Download ADODB
http://phplens.com/lens/dl/adodb411.tgz
Download Acid
Download Zlib
http://www.zlib.net/zlib-1.2.1.tar.gz
Download JPGraph
http://www.aditus.nu/jpgraph/downloads/jpgraph-1.14.tar.gz
Download LibPcap
http://www.tcpdump.org/release/libpcap-0.8.1.tar.gz
Download PCRE
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-4.4.tar.gz
Again, if you are not logged in as root, then you will need to su to root ("su -" will load
the environmental variables of root. Use that when you su.)
Ensure that you have downloaded all of the installation files before you start the install, it
will go smoother, trust me.
Go to your download directory and start with the following procedures. They will walk
you through extracting the source files of the applications, compiling, then installing and
configuring them for use with Snort.
Securing SSH
In the /etc/ssh/sshd_config file change the following lines (if it is commented out remove
the #):
Protocol 2
PermitRootLogin no
PermitEmptyPasswords no
(You will need to SSH into the box with the user account you created after this, as root
will no longer be accepted.Just “su –“ to the root account)
Installing PCRE:
Install LibPcap:
Install MySQL:
Create the user and group for MySQL with the following commands:
groupadd mysql
useradd -g mysql mysql -s /dev/null
In /root, edit the .bash_profile file so the PATH line to read as follows:
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
Go to the directory you downloaded everything to, and use the following commands to
install and configure MySQL.
scripts/mysql_install_db
cp support-files/my-medium.cnf /etc/my.cnf
If you get no errors, type “ps –ef |grep mysql”. You should see something like this:
If it all worked, then go to the next step, which is to make MySQL start when the system
boots up.
cd /root/snortinstall
cp mysql.server /etc/init.d/mysql
Use the following commands to create symbolic links in the startup folders for run levels
3 and 5. MySQL will now start automatically when you boot up.
cd /etc/rc3.d
ln -s ../init.d/mysql S85mysql
ln -s ../init.d/mysql K85mysql
cd /etc/rc5.d
ln -s ../init.d/mysql S85mysql
ln -s ../init.d/mysql K85mysql
cd ../init.d
chmod 755 mysql
This procedure will install the Apache web server in “/www”. This is where I prefer to
install it. You can, however, modify it for whatever location you wish.
Go back to the download directory and do the following to install Apache and the module
for PHP
mkdir /www/certs
cd /www/certs
openssl genrsa -out server.key 1024
openssl req -new -key server.key -x509 -out server.crt
After you type this, fill in the info
cd ..
tar -xvzf php-4.3.4.tar.gz
cd php-4.3.4
make
make install
cp php.ini-dist /www/php/php.ini
cp /www/bin/apachectl /etc/init.d/httpd
edit the /etc/init.d/httpd file and make the following changes, this will make Apache start
with SSL at boot time.
start|stop|restart|graceful)
$HTTPD -k $ARGV
ERROR=$?
;;
startssl|sslstart|start-SSL)
TO
stop|restart|graceful)
$HTTPD -k $ARGV
ERROR=$?
;;
start|startssl|sslstart|start-SSL)
cd /etc/rc3.d
ln -s ../init.d/httpd S85httpd
ln -s ../init.d/httpd K85httpd
cd /etc/rc5.d
ln -s ../init.d/httpd S85httpd
ln -s ../init.d/httpd K85httpd
(The above lines will add a startup script to the system for both run level 3 and 5)
To test the Apache – PHP install, create a file called test.php in the /www/htdocs
directory. Place the following line in the file:
Start Apache using “/etc/rc5.d/S85httpd start”. Now use a web browser to look at the file
(http://IP_Addess/test.php). It should give you info on your system, Apache, and PHP.
If you would like another test and a good little tool, try using
http://shat.net/php/nqt/nqt.php.txt. Copy the text into a file called index.php and place it
in the /www/htdocs directory, it will look like the following:
groupadd snort
useradd -g snort snort -s /dev/null
mkdir /etc/snort
mkdir /var/log/snort
mkdir /etc/snort/rules
tar -xvzf snort-2.1.2.tar.gz
cd snort-2.1.2
./configure --with-mysql=/usr/local/mysql
make
make install
var HOME_NET 10.2.2.0/24 (make this what ever your internal network is)
cd ../contrib
cp S99snort /etc/init.d/snort
# set interface
IFACE=eth0
# other options
OPTIONS="-D"
# End of configuration
Then:
Change directory to /etc/init.d and type:
chmod 755 snort (the file you just copied from the contrib folder and modified)
cd /etc/rc3.d
ln -s ../init.d/snort S99snort
ln -s ../init.d/snort K99snort
cd /etc/rc5.d
ln -s ../init.d/snort S99snort
ln -s ../init.d/snort K99Snort
I will put a line with a > in front of it so you will see what the output should be. (Note: In
MySQL, a semi-colon ” ; “character is mandatory at the end of each input line)
(new_password is whatever password you want to give)
/usr/local/mysql/bin/mysql
mysql> SET PASSWORD FOR root@localhost=PASSWORD('new_password');
>Query OK, 0 rows affected (0.25 sec)
mysql> create database snort;
>Query OK, 1 row affected (0.01 sec)
mysql> grant INSERT,SELECT on root.* to snort@localhost;
>Query OK, 0 rows affected (0.02 sec)
mysql> SET PASSWORD FOR snort@localhost=PASSWORD('new_password');
>Query OK, 0 rows affected (0.25 sec)
mysql> grant CREATE, INSERT, SELECT, DELETE, UPDATE on snort.* to snort@localhost;
>Query OK, 0 rows affected (0.02 sec)
mysql> grant CREATE, INSERT, SELECT, DELETE, UPDATE on snort.* to Snort;
>Query OK, 0 rows affected (0.02 sec)
mysql> exit
Bye
Then install the extra DB tables using the following command from the contrib directory
(you will need to cd to contrib)
zcat snortdb-extra.gz |/usr/local/mysql/bin/mysql -p Snort
Enter password:
Now you need to check and make sure that the Snort DB was created correctly
/usr/local/mysql/bin/mysql -p
>Enter password:
mysql> SHOW DATABASES;
(You should see the following)
+------------+
| Database
+------------+
| mysql
| Snort
| test
+------------+
3 rows in set (0.00 sec)
Install JPGraph:
cp jpgraph-1.14.tar.gz /www/htdocs
cd /www/htdocs
tar –xvzf jpgraph-1.14.tar.gz
rm –rf jpgraph-1.14.tar.gz
cd jpgraph-1.14
rm -rf README
Installing ADODB:
Go back to your download directory
cp adodb411.tgz /www/htdocs/
cd /www/htdocs
cp acid-0.9.6b23.tar.gz /www/htdocs
cd /www/htdocs
tar –xvzf acid-0.9.6b23.tar.gz
rm -rf acid-0.9.6b23.tar.gz
Configuring Acid:
Go to the /www/htdocs/acid/ directory and edit the acid_conf.php file. It should look like
this (except of course you will need your password): The highlighted items are what you
need to change
$DBlib_path = "/www/htdocs/adodb";
$DBtype = "mysql";
Click on the “Setup Page” hyperlink to create the tables that Acid uses, then you will see the
following.
Now when you go to http://yourhost/acid/ you should see the ACID homepage
mkdir /www/passwords
/www/bin/htpasswd -c /www/passwords/passwords acid
(acid will be the username you will use to get into this directory, along with the password
you choose)
It will ask you to enter the password you want for this user, this is what you will have to
type when you want to view your acid page
<Directory "/www/htdocs/acid">
AuthType Basic
AuthName "SnortIDS"
AuthUserFile /www/passwords/passwords
Require user acid
</Directory>
Reboot your system; watch to make sure everything starts. You can check by doing a “ps
–ef |grep <service>” the service can be any running process. i.e. mysql, httpd, Snort, etc.
If you want the machine to start at a text prompt instead of X, then change the default in
the inittab file (/etc/inittab) from 5 to 3. Go to a shell as root and check everything
important to see if it is running.
To check you can execute “ps –ef |grep <SERVICE>” where service is Snort. httpd, or
mysql.
Or use “ps –ef |grep httpd && ps –ef |grep mysql && ps –ef |grep Snort”
Now it’s time to test Snort. I suggest using something free like CIS Scanner
(http://www.cerberus-infosec.co.uk/CIS-5.0.02.zip) or Nessus (http://www.nessus.org) if
you have it, and running it against your Snort box. Check ACID when you’re done and it
should have a bunch or alerts. If you are on DSL or cable then you could already have a
bunch in there right after you start it up. When you go to the acid screen in your browser
now you should see alerts (And this is without running any programs against it)
Now you need to tune your IDS for your environment. This is an important step. Look
at the Snort list archives and the other links listed above and you will find good tips on
how to do that.
There is also a very good book out on Snort for those that want to learn more about it
http://www.amazon.com/exec/obidos/tg/stores/detail/-/books/1931836744/
When I want to download all of these real quick I take the following and create a file in
the /root/snortinstall dir called get, edit it and put the following in it
wget http://www.snort.org/dl/snort-2.1.1.tar.gz
wget http://mysql.secsup.org/Downloads/MySQL-4.0/mysql-4.0.18.tar.gz
wget http://www.apache.org/dist/httpd/httpd-2.0.49.tar.gz
wget http://www.php.net/distributions/php-4.3.4.tar.gz
wget http://phplens.com/lens/dl/adodb411.tgz
wget http://acidlab.sourceforge.net/acid-0.9.6b23.tar.gz
wget http://www.zlib.net/zlib-1.2.1.tar.gz
wget http://www.aditus.nu/jpgraph/downloads/jpgraph-1.14.tar.gz
wget http://www.tcpdump.org/release/libpcap-0.8.1.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-4.4.tar.gz
Then I save the file and type chmod +x get, then ./get and it will download all the files for
me.
Troubleshooting
Make sure that the line for MySQL in the snort.conf file is not wrapped or cut into two
lines. I have seen this happen a lot.
Next, this is an end-to-end guide. I designed it to take a system from bare metal to
functional IDS. If you follow it step by step you will get an IDS working, then you
customize it more. I have the RedHat install listed the way I do because there are some
parts that are needed.
If you do not have a sensor number, it means that you have not received an alert on that
sensor yet. Make sure everything is running without error and check ACID again
If you get errors about libpng, libjpg, or any other lib item (when you are compiling PHP)
you missed them during the install of the OS. Go to system settings (hit the “Redhat” in
the bottom left and look for it on the pop up menu), then to add/remove applications and
If you are getting nothing in ACID you could have a number of problems. Check your
/var/log/snort directory and see if you have an alert file. If it has alerts, then Snort is
working and you most likely do not have your Snort.conf output lines correct. Check
where you setup your database in it first. If you do not have an alert file then make sure
Snort is running. If it is, make sure that if you are on a switch, you are on a span (or
mirrored) port, or you will not see anything but what is destined for that port.
The best place to look for other answers is the Snort-users archive, which is indexed by
Google. If you are not proficient at searching, I would suggest reading
http://www.google.com/help/basics.html . It is a good primer, as is
http://www.googleguide.com/
Read what is out there for you. Go to http://www.snort.org and look around.
http://www.snort.org/docs/snort_manual/ is also something you should read all the way
through, as well as http://www.snort.org/docs/FAQ.txt between them and Google almost
all your questions will be answered.
Most of the problems people have had stem from them missing a step, frequently only
one step, somewhere. There are a lot of them and it is easy to do.
If you do have problems feel free to e-mail me, Nick, or the Snort-users list.
There is a huge community of people out there using this product that will help you if
you are in trouble. Remember, however, that this support is free and done out of love of
this product. You certainly should not expect the same response from the Snort
community as you would from an IDS vendor (though I have gotten better response time
from the Snort-users list than I have from some vendors in the past)
Hope this gets you going. If not, then feel free to e-mail either myself, Nick Oliver, or the
Snort-users list. They are a great bunch of people and will do all they can for you (if you
have manners). Just remember, however, that it is a volunteer thing, so you will probably
not get answers in 10 minutes. Do NOT repost your question merely because you have
not yet seen an answer.