Intrusion Detection and Prevention
Intrusion Detection and Prevention
Packet Capture
The first step in understanding how an IDS works is to understand packet capture. The best way to do this is to grab some packets with TCPdump. TCPdump is built upon BPF which takes a filter and compiles it into machine code that is used to filter in packet stream for only those packets that you're interested in.
TCPdump
There are a lot of command line options for TCPdump. Here's a common way in which it is run: tcpdump -i le0 -n -c 10 -s0 -i le0 -n -c 20 -s0 capture packets from the eth0 interface do not resolve IP addresses stop after capturing 10 packets capture packets with "full snap length"
Other commonly use command line options include -X, -w filename, -r filename
Snort
Snort is one of the most commonly used Intrusion Detection Systems in use today. It's so popular because it's free, it's very good at what it does and it's well supported. You can even buy commercial versions from SourceFire. It's also very well documented.
Snort Rules
Let's look at an example rule and take it apart:
alert ip $EXTERNAL_NET $SHELLCODE_PORTS -> $HOME_NET any (msg:"SHELLCODE Linux shellcode"; content:"|90 90 90 E8 C0 FF FF FF|/bin/sh"; reference:arachnids,343; classtype:shellcode-detect; sid:652; rev:9;)
Snort Rules
Let's make that a little more readable and examine it:
alert ip $EXTERNAL_NET $SHELLCODE_PORTS -> $HOME_NET any ( msg:"SHELLCODE Linux shellcode"; content:"|90 90 90 E8 C0 FF FF FF|/bin/sh"; reference:arachnids,343; classtype:shellcode-detect; sid:652; rev:9; )
1.Point a browser at www.snort.org 2.Create a new snort.org account (click on Not Registered?) 3.Wait for the email to come back... 4.Log in using your snort.org account and generate an oinkmaster code 5.You'll get a really long hex string for your oinkmaster code 6.Go back to the Linux victim, point a browser at the pfSense console and log in 7.Go to Packages -> Snort -> and enter your code 8.Go to Packages -> Snort -> Update Rules and wait for snort to update itself 9.You are now running snort with (relatively) up to date rules
Questions?
Packet Capture
The first step in understanding how an IDS works is to understand packet capture. The best way to do this is to grab some packets with TCPdump. TCPdump is built upon BPF which takes a filter and compiles it into machine code that is used to filter in packet stream for only those packets that you're interested in.
u Q n s e ? tio