Pular para o conteúdo principal

Making Linux an IPS device using SNORT

Prerequisites

To get the most from the article, you should have a basic knowledge of SNORT, Linux and a working Linux system on which you can practice the commands covered in this article. Also you should have some networking knowledge such as TCP/IP, iptables, etc.

What Is IPS (Intrusion Prevention System)?

Intrusion Detection System (IDS) is a device which monitors packets on your network. IDS reports attack behaviors based on security rules and signatures applied on the device. However IDS has certain disadvantages, such as high false positive rate, unable to stop Denial of Service (DoS) attack and intrusion from UDP protocols.
Intrusion Prevention System (IPS), on the other hand, not only has the ability of IDS, but also can drop malicious packets and close connection sessions in order to stop further attacks. IPS could achieve Real-time Interdiction by leveraging in-line deployment in the network topology. It analyzes all network traffic passing through system and takes actions to suspicious packets immediately.

Network deployment method of IDS and IPS

Due to the differences between IDS and IPS, the deployment of these two systems is designed according to their characteristics.
IDS usually plays the role of monitoring. IDS must be able to sniff the traffic which interests IDS while not compromise the overall network throughput. Following figure illustrates the typical way of deploying an IDS device on a network.
image
On the other hand, IPS must take immediate action to suspicious packets. The deployment need to enable IPS to look at each packet and deal with suspicious packet real-time. Typically making all traffic pass through IPS could achieve the deployment requirement. This is so-called in-line deployment.
  image

SNORT on Linux to Act as an IPS – The Idea behind It

Generally SNORT is sophisticated IDS software, which monitors network traffic to detect and analyze attacking behaviors according to predefined rules. SNORT sends alerts to network administrator while attacks or abnormal network activities are detected. However, the function of the system is limited to passively monitoring party. The protective action must rely on the administrator’s response.
Though SNORT is commonly used as an IDS, it has some enhanced capabilities could make it into an IPS. This article mainly illustrates how SNORT can act as an IPS device.
By using the following settings, SNORT becomes an IPS to take immediate action to suspicious traffics.
  • Network Deployment Method
    • In-line deployment: The inline deployment enable SNORT to look at each packet and deal with suspicious packet directly
  • Advanced Network Configuration
    • - iptables
  • SNORT Mode Configuration
    • - in-line mode
  • SNORT’s rule Actions
    • drop/reject/sdrop

The Actual Implementation – Lab Exercise

We are going to implement a basic IPS box step by step in this lab. This box has 2 interfaces acting as one inline segment and is connected between host A and host B. The following figure shows the topology. Moreover, we will play some packets from host A to host B to see if part of them will be dropped as we expect.
image 

Configure and run SNORT in inline mode

Please refer to the following article to see how to install SNORT: http://www.ibm.com/developerworks/web/library/wa-snort1/
Add following rule set to /etc/snort/rules/snort.rules, which allows any packet except tcp packet whose destination is port 23.
drop tcp any any -> any 23 (msg: "Drop telnet packets"; sid: 1000001)
pass ip any any -> any any
Edit /etc/snort/my-snort.conf as follows:
config daq_dir: /usr/lib64/daq
config daq: nfq
config daq_mode: inline
config policy_mode: inline 
output alert_full: stdout
include /etc/snort/rules/snort.rules
Run SNORT with the following command line options
$ snort -c /etc/snort/my-snort.conf -Q --alert-before-pass
Now, we can send an ICMP Ping packet from host A to host B. The ICMP Ping packets should be forwarded successfully because the ICMP packets are allowed in our SNORT rule set.
winson@VM-UBUNTU:~$ ping 1.0.67.2 -c 1
PING 1.0.67.2 (1.0.67.2) 56(84) bytes of data.
64 bytes from 1.0.67.2: icmp_req=1 ttl=64 time=0.838 ms
--- 1.0.67.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.838/0.838/0.838/0.000 ms
Then we can use telnet to send TCP packets destinating to port 23 and we should get a connection timed out message.
winson@VM-UBUNTU:~$ telnet 1.0.67.2
Trying 1.0.67.2...
telnet: Unable to connect to remote host: Connection timed out
We can also go to SNORT console to see these telnet packets are dropped by SNORT
[**] [1:1000001:0] <> Drop telnet packets [**]
[Priority: 0] 
05/03-17:34:41.995762 1.0.67.1:40145 -> 1.0.67.2:23
TCP TTL:64 TOS:0x10 ID:3913 IpLen:20 DgmLen:60 DF
******S* Seq: 0x310D692D Ack: 0x0 Win: 0x16D0 TcpLen: 40
TCP Options (5) => MSS: 1460 SackOK TS: 156788324 0 NOP WS: 5 

[**] [1:1000001:0] <> Drop telnet packets [**]
[Priority: 0] 
05/03-17:34:44.985455 1.0.67.1:40145 -> 1.0.67.2:23
TCP TTL:64 TOS:0x10 ID:3914 IpLen:20 DgmLen:60 DF
******S* Seq: 0x310D692D Ack: 0x0 Win: 0x16D0 TcpLen: 40
TCP Options (5) => MSS: 1460 SackOK TS: 156788625 0 NOP WS: 5 

 [**] [1:1000001:0] <> Drop telnet packets [**]
[Priority: 0] 
05/03-17:34:50.995668 1.0.67.1:40145 -> 1.0.67.2:23
TCP TTL:64 TOS:0x10 ID:3915 IpLen:20 DgmLen:60 DF
******S* Seq: 0x310D692D Ack: 0x0 Win: 0x16D0 TcpLen: 40
TCP Options (5) => MSS: 1460 SackOK TS: 156789226 0 NOP WS: 5 
Now it is a Linux box with basic IPS capabilities. You can try to write more complicated SNORT rules to make it more powerful.

Reference

Comentários

Postagens mais visitadas deste blog

Upgrading Iomega ix2-200 to Cloud Edition

You just got your ix2-200 from eBay and there are no disks inside the NAS. Or you have a brand new ix2-200 -yet you could not afford Cloud Edition. No problem. With just a USB stick and a SATA adapter or desktop PC, you will easily upgrade your ix2-200 to ix2-200 Cloud Edition. Not only your ix2-200 will have a brand new interface and Cloud options, but also will become Mac OS X Lion compatible! What do we need? Decrypted! ix2-200 Cloud Edition Firmware 3.1.12.47838 S endSpace or RapidShare * USB Flash Drive with at least 2 GB capacity and LED indicator** SATA to USB adapter or desktop PC Toothpick or paperclip Preparing Hard Drives Preparing hard drives is the first step because you have to wipe all the data inside the hard drives and make them just like brand new. We used 2 x Seagate 2 TB 5900 RPM Drives. Backup any files if you have and then remove both disks from ix2-200 and attach them to SATA to USB adapter or your desktop PC's SATA port. Using

Cuckoo com Vmware Esxi

Cuckoo is an open-source malware analysis platform using sandboxing technology. The tool allows people like us to analyze malicious binaries in an isolated environment. Since Cuckoo is commonly used with Oracle VirtualBox as its virtualization platform, a majority of online documentation is focused on configuration using VirtualBox. PlantainStan and I decided to test running Cuckoo on ESXi and document our success. This guide will help with the basic configuration of ensuring Cuckoo properly interacts with ESXi. We will continue to update this post as we make continue to make an even more baller Cuckoo environment! Note: In order to successfully interact with vSphere's API, you will need the VMWare ESX Standard license. API functionality is required for Cuckoo to work with ESX. Configure ESX Since this guide is not a "how to" on installing ESXi, we will assume that you have successfully installed the hypervisor on your system. There

CentOS7 with Snort Barnyard2 Snorby PulledPork SElinux

This post is about how to install Snort "stack" on CentOS7 with potentially all the latest libs an stuff. Here I will install and configure everything to run Snort as IDS. I will write another post shortly how to run it as IPS - INLINE. System details: [ root@nfsec-ids-01 ~ ] # cat /etc/redhat-release CentOS Linux release 7.3.1611 ( Core ) [ root@nfsec-ids-01 ~ ] # uname -a Linux nfsec-ids-01.nfsec.co.uk 3.10.0-514.2.2.el7.x86_64 #1 SMP Tue Dec 6 23:06:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux Snort 2.9.9.0 Installation of snort is very basic: yum install https://www.snort.org/downloads/snort/daq-2.0.6-1.centos7.x86_64.rpm yum install https://www.snort.org/downloads/snort/snort-2.9.9.0-1.centos7.x86_64.rpm Register at Snort and download registered rule set: mkdir /usr/local/src/snortrules cd /usr/local/src/snortrules wget https://www.snort.org/rules/snortrules-snapshot-2990.tar.gz?oinkcode = < oinkcode > tar -zxvf snort