Monitor traffic with Snort – intrusion detection

What is Snort

As described in its site:

Snort is an open source network intrusion prevention system, capable of performing real-time traffic analysis and packet logging on IP networks. It can perform protocol analysis, content searching/matching, and can be used to detect a variety of attacks and probes, such as buffer overflows, stealth port scans, CGI attacks, SMB probes, OS fingerprinting attempts, and much more.

This is a really powerful

Prerequisite:

  • any Centos 6.x, fully updated
  • root access (in this document all commands are executed as root)
  • Epel repo ready

1 – install all packages you needed

yum install gcc make rpm-build autoconf automake flex libpcap-devel bison libdnet libdnet-devel mysql-devel pcre-devel php-mysql

2 – get the last sources

go to www.snort.org and take a look to the last version available to download
in our case
daq-2.0.6-1
snort-2.9.7.6-1

cd /root
wget https://www.snort.org/downloads/snort/daq-2.0.6-1.src.rpm
wget https://www.snort.org/downloads/snort/snort-2.9.7.6-1.src.rpm

3 – Compile daq

rpmbuild –rebuild daq-2.0.6-1.src.rpm
rpm -Uvh ./rpmbuild/RPMS/x86_64/daq-2.0.6-1.x86_64.rpm

(NB in case it is a i686 processor, like my howe fw, it is a little different path like ./rpmbuild/RPMS/i686/daq-2.0.6-1.i686.rpm)

4 – Compile Snort
Before compiling Snort we are going to change a little the configuration file to make it able to manage more features like zipped connections, IPv6, etc
Extract files:

rpm -Uvh snort-2.9.7.6-1.src.rpm
vi ./rpmbuild/SPECS/snort.spec

around line 133 change the configuration files adding red lines

SNORT_BASE_CONFIG=”–prefix=%{_prefix} \
–bindir=%{_sbindir} \
–sysconfdir=%{_sysconfdir}/snort \
–with-libpcap-includes=%{_includedir} \
–enable-targetbased \
–enable-zlib \
–enable-ipv6 \
–enable-normalizer \
–enable-sourcefire \
–enable-control-socket”

save and compile

rpmbuild -bb /root/rpmbuild/SPECS/snort.spec  -D ‘debug_package %{nil}’
rpm -Uvh /root/rpmbuild/RPMS/x86_64/snort-2.9.7.6-1.x86_64.rpm

DONE!! Compiled and installed
5 – Configuration

Snort is based on rules that needs to be regular updated. Let’s go for the first setup.
Complete rules are released to registered people, so you need to go to www.snort.org register yourself, confirm your email and download the snort rules.
There is a subscription too, rules for subscribers are immediately updated, 30 days later are released to registered people.
Last rules I downloaded are snortrules-snapshot-2976.tar.gz.and I moved to /root

mkdir /root/snortrules
cd /root/snortrules
tar -xvf ../snortrules-snapshot-2976.tar.gz
mv -f rules so_rules preproc_rules /etc/snort/

#not to do if an update

cd etc
mv -f * /etc/snort/

Let’s go to edit /etc/snort/snort.conf

vi /etc/snort/snort.conf

# line 45: change to your own local network

ipvar HOME_NET 10.0.0.0/24

# line 48: change

ipvar EXTERNAL_NET !$HOME_NET

# line 105:

changevar RULE_PATH  /etc/snort/rules
var SO_RULE_PATH /etc/snort/so_rules
var PREPROC_RULE_PATH /etc/snort/preproc_rules# line 113: change
var WHITE_LIST_PATH /etc/snort/rules
var BLACK_LIST_PATH /etc/snort/rules#in dynamic part (check your path)# path to dynamic preprocessor libraries
dynamicpreprocessor directory /usr/lib64/snort-2.9.7.6_dynamicpreprocessor/# path to base preprocessor engine
dynamicengine /usr/lib64/snort-2.9.7.6_dynamicengine/libsf_engine.so# path to dynamic rules libraries
dynamicdetection directory /usr/local/lib/snort_dynamicrules

IMPORTANT: default generic configuration for IP is quite wide and can generate false positive. So for a long time monitoring is suggested to put your network, so SNORT will monitor for attacks OUT -> IN.
But in case you want to check if there is malicious software even inside, better to leave the standard configuration

# Setup the network addresses you are protecting
ipvar HOME_NET any# Set up the external network addresses. Leave as “any” in most situations
ipvar EXTERNAL_NET any

Then you need to tell the network card you want to monitor. Possible values are All or the name of the network card/s. In case of multiple name they must be inserted with quotation markes: “eth0, eth1”

vi /etc/sysconfig/snort

# line 15: change to the interface for monitoring (use your external interface)

INTERFACE=eth0

ATTENTION: take the name of the interface from your ifconfig

mkdir /usr/local/lib/snort_dynamicrules
chown snort. /usr/local/lib/snort_dynamicrules
touch /etc/snort/rules/white_list.rules /etc/snort/rules/black_list.rules

6 – start Snort

service snortd start

7 – what to see and where

Snort logs any problem in

/var/log/snort/eth0/alert.log

you will be able to find problem like

10/07-00:24:40.384156  [**] [1:25459:12] FILE-PDF Adobe Acrobat Reader incomplete JP2K image geometry exploit attempt [**] [Classification: Misc activity] [Priority: 3] {TCP} xx.xx.xx.xx:80 -> xx.xx.xx.xx:51334

One thought on “Monitor traffic with Snort – intrusion detection

  1. […] by Cisco. If you have a firewall build with a Linux box, it is quite simple to install on this box: how to install snort. I case you have a standard appliance (a standard firewall), you can not install any specific […]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

This site uses Akismet to reduce spam. Learn how your comment data is processed.