[Home] [Credit Search] [Category Browser] [Staff Roll Call] | The LINUX.COM Article Archive |
Originally Published: Tuesday, 16 October 2001 | Author: Shashank Pandey |
Published to: enchance_articles_security/Advanced Security Articles | Page: 1/1 - [Std View] |
Intrusion Detection Systems for the Uninitiated, Part 2; Installing and Configuring Snort
Shashank Pandey returns to Linux.com with part two of his popular series on IDS: Intrusion detection Systems for Linux. Quizzing PortSentry in his last article, in today's Pandey cast a sharp eye over working with snort. And remember in some primitive parts of the world you have to pay for information like this! Can you imagine?
|
Snort uses 'rules' (specified in 'rule' files) to know which traffic to allow and which to stop. In fact it's so flexible it allows you to write new rules and abides by them (see http://www.snort.org/writing_snort_rules.htm). It also has a 'detection engine' that utilizes a modular plugin architecture whereby specific plugins can be added or removed from the 'detection engine' to alter its capability.
An important aspect of any IDS is its 'alerting mechanism'. Snort attracts attention in a variety of ways, in that it can alert about the attacks/probes through syslog, has a real-time (as the attacks/probes take place) alerting capability as well, incorporating alerting mechanisms for syslog, a user specified file, a UNIX socket, or WinPopup messages to Windows clients using Samba's smbclient.
Snort can run in three modes :
This article will talk in detail about the Snort installation, architecture, rules and how to run them.
So here we go.
Snort should also compile on:
AIX, IRIX, HPUX, Tru64
Having downloaded Snort, untar the archive with the following command.
root @lord]# tar -zxvf snort-1.7.tar.gz
This should untar Snort into a directory named snort-1.7. The next thing to do is installing the libpcap(dependency). Untar the libpcap archive you downloaded, using the tar command with the similar switches as above. Enter the libpacp directory and carry out the following steps.
root @lord]# ./configure
root @lord]# make
because we don't need any binaries for now, there is no need for a 'make install'. In factm even if you do install a binaries, no problem.
Now, we'll compile Snort. Change to the directory that Snort is in and issue the following commands.
root @lord]# make
root @lord]# make installroot @lord]# ./configure --with-libpcap-includes=/path/to/libpcap/
{* in my case it was : root@lord ./configure --with-libpcap-includes=/home/dood/libpcap }
Ok, cute. Snort should now be installed on your machine!
root @lord]#mkdir /var/log/snort
As always, do this :
root @lord]# whereis snort
to confirm where snort is installed!
Alerting mechanism send alerts to syslog, a normal file, Unix sockets or a database. Optionally, you may turn off alerting completely during testing or penetration studies.
By default, all the alerts are stored in: /var/log/Snort/alerts
file.
Now, what we'll do here is, we'll discuss the concepts and then commands in proper detail.
Let us start with a simple command that makes Snort display all the command switches and then exit.
root@lord snort -?The output of the command is as follows. -*> Snort! <*- Version 1.7 By Martin Roesch (roesch@clark.net, www.snort.org) USAGE: snort [-options] Options: -A Set alert mode: fast, full, or none (alert file alerts only) 'unsock' enables UNIX socket logging (experimental). -a Display ARP packets -b Log packets in tcpdump format (much faster!) -c Use Rules File -C Print out payloads with character data only (no hex) -d Dump the Application Layer -D Run Snort in background (daemon) mode -e Display the second layer header info -F Read BPF filters from file -g Run snort gid as 'gname' user or uid after initialization -h Home network = -i Listen on interface -l Log to directory -n Exit after receiving packets -N Turn off logging (alerts still work) -o Change the rule testing order to Pass|Alert|Log -O Obfuscate the logged IP addresses -p Disable promiscuous mode sniffing -P set explicit snaplen [sp? -ed.] of packet (default: 1514) -q Quiet. Don't show banner and status report -r Read and process tcpdump file -s Log alert messages to syslog -S
Gosh! So many switches?! If you are wondering, I will just discuss a few good ones and leave the other simpler ones for you to explore yourself. But before that, we will speed through some snort fundamentals
Sniffer Mode: When in this mode, Snort reads and decodes all packets from the network(passing though your ethernet card) and dumps them to the stdout(your screen!).
To put Snort into straight sniffing mode(use '-v' verbose switch.) :
root @lord]# ./snort -v
Note: This will dump the packet headers only.
To see the headers + the packet payloads :
root @lord]#./snort -v -d
To print a dump of the raw bytes in the entire packet :
root @lord]# ./snort -X
Tip: To test it on localhost : do this :
root @lord]#./Snort -v -d -i lo
from one console and 'telnet/ftp' to your localhost from another console. Ta-da! You can see all those packets transferred between localhost and ur telnet client in the sniffer window. Cute?
root @lord]# Snort -l < directory to log packets to >
Now consider a typical snort command for packet analysis:
root @lord]# snort -v -d -e -i eth0 -h 192.168.3.0/24
Here, we are considering the a class C subnet with host I.P s ranging from 192.168.3.0-192.168.3.255(subnet-mask:255.255.255.255)
Let's see the dissection of the above mentioned command to know what it means:
'-v ' : sends a verbose response to your console.
'-d ' : dumps the decoded application layer data
'-e ' : shows the decoded ethernet headers.
'-i ' : specifies the interface to be monitored for packet analysis.
'-h' : specifies Network to be managed in the form of network-address/CSIDR-subnet
Now, in the next example we will make Snort generate alerts:
To generate alerts, use the '-A' switch .
-A - Alert using the specified alert-mode.
Snort alert modes include but not limited to:
. The command will then change to the following.
root @lord]# snort -v -d -e -i eth0 -h 192.168.3.0/24 -A fast
To send alert messages to the syslog daemon, use the '-s' switch instead. Alerts will appear in /var/log/secure or /var/log/messages ,most likely :
root @lord]# snort -v -d -e -i eth0 -h 192.168.3.0/24 -s
Until now all the packets sniffed and analyzed were just dumped to your screen. To have Snort dump the packets sniffed and analyzed to your logs, you will use the "-l" switch. And then the directory name i.e /var/log/snort:
root @lord]#snort -v -d -e -i eth0 -h 192.168.3.0/24 -A full -l /var/log/snort
To log packets in tcpdump format and produce minimal alerts , use the '-b' command switch
root @lord]#snort -b -i eth0 -A fast -h 192.168.3.0/24 -s -l /var/log/snort
In the above mentioned commands, Snort logs all the packets on your network segment that might leave you with a confusing mess. If you want to log only certain types of packets depending on the rules you write , use the '-c' command switch.
root @lord]# snort -b -i eth0 -A fast -h 192.168.5.0/24 -s -l /var/log/snort -c /snort-rule-file
"Writing Snort Rules : How to Write snort Rules and Keep your Sanity" (http://www.snort.org/writing_snort_rules.htm) by Martin Roesch. Ok. So, we go on.
Since there are already beautifully written articles and papers by some very knowledgeable people on this issue, I will do them the honor of just providing a pointer to the relevant URLs.
Articles : ++++++ >``Insertion, Evasion, and Denial of Service: Eluding Network Intrusion Detection'' paper of January 1998. ( http://secinf.net/info/ids/idspaper/idspaper.html ) > "A look at whisker's anti-IDS tactics " (www.wiretrip.net) Tools : +++++ > Fragrouter(http://www.anzen.com/research/nidsbench) > Whisker((www.wiretrip.net))
To summarize most of the techniques described in these articles (and on which the tools work) deal with wily packet-games or changing the URL pattern to execute a malicious command.
These tools are used by security experts and crackers worldwide to fool IDSs. So learn to use them on your network/IDS before the baddies do.
Also, check out the snort.org downloads section for tools that assist snort in performing better. These guys have also got a snort discussion forum, a resource if you have any queries or problems with Snort.
The developers of Snort and the author(s) of the Snort web site. Many of the examples and some documentation were reproduced in part and can be directly attributed to the developer's information as posted on the Snort web site (http://www.snort.org/) and also in the readme's accompanying the snort distribution.
-Simon Hayes (Chief Editor) and the editorial team of Linux.com: for polishing my articles J
-To YOU (for still being awake!)
Your mails and comments are more than welcome, as always .
I hope we had a good time, guys ;-)