Snort on FreeBSD 6.2

Prerequisites:

FreeBSD (Base + Autoconf, Automake, Bash and GCC)
unixODBC (Optional if you are building with --with-odbc)
wget - from UNIX Network Tools
MySQL (Needed to compile MySQL logging into snort)
PHP and Apache (Only if this install will also be your BASE console)

Snort Network Intrusion Detection

Home:  

http://www.snort.org

# Download (Notes: Users behind a Proxy Server should read this and users without Internet but have a CDRom read this.)

# Install libdnet
cd /usr/ports/net/libdnet
make install clean

 

# Install libnet
cd /usr/ports/net/libnet10
make install clean

 

# Install Snort
cd /usr/ports/security/snort
make install PREFIX=/opt/snort

# Manual clean-up
mv /opt/snort/etc/rc.d/snort /opt/snort/share/examples/snort.sh.example
mv /opt/snort/lib /usr/local/lib
mv /opt/snort/etc/snort/* /opt/snort/etc/
mv /opt/snort/share/doc/snort/* /opt/snort/share/doc
mv /opt/snort/share/examples/snort/* /opt/snort/share/examples
rm -R /opt/snort/share/doc/snort/
rm -R /opt/snort/share/examples/snort/
rm -R /opt/snort/etc/snort
rm -R /opt/snort/etc/rc.d
rm -R /opt/snort/include
rm -R /opt/snort/info
rm -R /opt/snort/libdata
rm -R /opt/snort/libexec
rm -R /opt/snort/man
rm -R /opt/snort/sbin
rm -R /opt/snort/share/aclocal
rm -R /opt/snort/share/dict
rm -R /opt/snort/share/doc/ja
rm -R /opt/snort/share/emacs
rm -R /opt/snort/share/java
rm -R /opt/snort/share/locale
rm -R /opt/snort/share/misc
rm -R /opt/snort/share/nls
rm -R /opt/snort/share/sgml
rm -R /opt/snort/share/skel
rm -R /opt/snort/share/xml
rm -R /opt/snort/www
rm -R /opt/snort/etc/pam.d
rm -R /opt/snort/src
mkdir /opt/snort/etc/rules-backup

# Clean the src directory
make clean

# Create a startup script for boot-time
vi /usr/local/etc/rc.d/snort.sh

# Make the startup script executable
chmod +x /usr/local/etc/rc.d/snort.sh

# Create the snort database
# Create the snort table
/opt/mysql/bin/mysqladmin --user=mysql -p create snort
# Import the snort table structure
/opt/mysql/bin/mysql --user=mysql -p snort < /opt/snort/share/examples/create_mysql
# Give permission for the snort database user to access the snort database tables
/opt/mysql/bin/mysql --user=mysql -p mysql
GRANT ALL ON snort.* TO snort@localhost IDENTIFIED BY 'snortpassword';
GRANT ALL ON snort.* TO snort@"%" IDENTIFIED BY 'snortpassword';
flush privileges;
exit

 

# Edit the snort configuration file
vi /opt/snort/etc/snort.conf



# Install Oinkmaster
# Change to your source downloads directory
cd /usr/src
# Download Oinkmaster
fetch http://easynews.dl.sourceforge.net/sourceforge/oinkmaster/oinkmaster-2.0.tar.gz
# Decompress and extract the archive
tar xvf oinkmaster-2.0.tar.gz
# Manually copy files to correct destinations
cp /usr/src/oinkmaster-2.0/oinkmaster.conf /etc/oinkmaster.conf
cp /usr/src/oinkmaster-2.0/contrib/*.pl /opt/snort/bin/
cp /usr/src/oinkmaster-2.0/oinkmaster.1 /usr/local/man/man1/
cp /usr/src/oinkmaster-2.0/oinkmaster.pl /opt/snort/bin/
touch /etc/autodisable.conf

# Configure Oinkmaster
# Edit the oinkmaster.conf file and uncomment and edit the "url" sources you wish to use
vi /etc/oinkmaster.conf
# You need to setup a free Snort account to get your Oink Code
url = http://www.snort.org/pub-bin/oinkmaster.cgi/<YourOinkCodeHere>/snortrules-snapshot-2.4.tar.gz
# and uncomment the Bleeding Snort line as well
url = http://www.bleedingsnort.com/bleeding.rules.tar.gz
# Test out Oinkmaster to see if it downloads rules
/opt/snort/bin/oinkmaster.pl -o /opt/snort/etc/rules -b /opt/snort/etc/rules-backup

# Create a script to run Oinkmaster each day and update the snort rules
vi /etc/periodic/daily/990.oinkmaster

# Set the script executable
chmod +x /etc/periodic/daily/990.oinkmaster
# Note: You may need to setup a proxy server in your wget configuration if your company uses proxy
vi /usr/local/etc/wgetrc

# Create a snort user and group and set permissions
# Add a snort group
pw groupadd snort
# Add a snort user
pw useradd snort -n snort -G snort -s /usr/sbin/nologin
# Fix file permissions
chown -R snort:snort /opt/snort/
chown -R snort:snort /var/log/snort/

# After editing your rules and commenting out specific rules, create an autodisable.conf:
/usr/opt/snort/bin/makesidex.pl /opt/snort/etc/rules > /etc/autodisable.conf

# Fix a path bug from a lame installer
mv /usr/local/lib/lib/snort/ /usr/local/lib/snort

# Test Snort
# Test as user root, should start up and stop without error
/opt/snort/bin/snort -T -c /opt/snort/etc/snort.conf
# Test as user mysql, should start up and stop without error
/opt/snort/bin/snort -T -u snort -g snort -c /opt/snort/etc/snort.conf
# Launch snort and run it for a minute or so
/opt/snort/bin/snort -u snort -g snort -c /opt/snort/etc/snort.conf
#CTRL+C after a minute and you should see statistics on exit

# Run snort manually in the background
/opt/snort/bin/snort -u snort -g snort -c /opt/snort/etc/snort.conf &
ps wwaux | grep snort

# Reboot and snort should run automatically if your rc script is functioning
ps wwaux | grep snort

 

# BASE - Basic Analysis and Security Engine

# Install ADODB
cd /usr/src
fetch http://superb-east.dl.sourceforge.net/sourceforge/adodb/adodb492.tgz
tar xvf adodb492.tgz -C /opt/apache/htdocs
rm adodb492.tgz

# Install BASE
cd /usr/src
fetch http://easynews.dl.sourceforge.net/sourceforge/secureideas/base-1.3.6.tar.gz
tar xvf base-1.3.6.tar.gz
mv /usr/src/base-1.3.6 /opt/apache/htdocs/base
cp /opt/apache/htdocs/base/base_conf.php.dist /opt/apache/htdocs/base/base_conf.php
vi /opt/apache/htdocs/base/base_conf.php
$BASE_urlpath = '/base';
$DBlib_path = '/opt/apache/htdocs/adodb/';
$DBtype = 'mysql';
$alert_dbname = 'snort';
$alert_host = 'localhost';
$alert_port = '';
$alert_user = 'snort';
$alert_password = 'snortpassword';

 

chown -R www:www /opt/apache/htdocs/

# Complete the web based setup
http://YourServer/base
Click "Setup"
Click "Create Tables"
Click "Home"

# Use the "pear" install tool to add the graphing PHP component:
pear config-show
pear config-set http_proxy http://YourCompanyProxy:8080
pear config-show
pear install --alldeps Image_Graph-alpha