Mitigation of Dos and Port Scan Attacks Using Snort
Mitigation of Dos and Port Scan Attacks Using Snort
net/publication/335803817
CITATION READS
1 2,211
2 authors, including:
Alka Gupta
University of Jammu
12 PUBLICATIONS 15 CITATIONS
SEE PROFILE
All content following this page was uploaded by Alka Gupta on 03 January 2020.
Keywords: NIDS, Snort v2.X, D-ITG, Scapy, DoS attacks, flooding, Port Scan.
Although Network attacks exist from a long time, but there 1.2 Scapy
still exists a risk as hackers invent new techniques to Scapy is a packet crafting and manipulation tool written
perform these attacks all over again [4]. This paper describes in Python language by Philippe Biondi [8]. It is a very
existing taxonomies for understanding different DoS and flexible tool which gives users a platform to craft their own
Port Scan attacks and then mitigating them by an open packets and study their behaviour in the network. User is
source IDS Snort. We have set-up a real network to analyse free to put any value that is required in any field of network
the efficiency of Snort in detecting attacks on a busy server layer and stack them as per desire. It has the ability to forge,
machine. We have developed our own custom rules for encode or decode packets, capture them from the network,
Snort as per the generated traffic. Scapy has been used to send them to the network, match requests and replies and
perform the attacks and D-ITG has been used to generate the many more. It can be used to perform other tasks like trace
traffic which emulates the real-time traffic scenario at the routing, probing, scanning, network discovery and
servers. performing DoS attacks. We have used Scapy to generate
DDoS and DoS attacks in the network at different speeds.
An intrusion detection system (IDS) is a software
application that monitors network or system activities for 1.3 D-ITG
intrusion attempts, produces alerts and logs information D-ITG (Distributed Internet Traffic Generator) is traffic
about them for the administrator. An intrusion prevention generating platform which can be used to produce IPv4 and
system (IPS) is an IDS with an additional capability of IPv6 packets [9] at application, transport and network layer.
blocking intrusions by either dropping the malicious packets, It replicates different application-level protocols to generate
blocking the malicious IP address or resetting the connection traffic as per stochastic models of inter Departure Time
[5]. An IPS acts faster on the threat whereas IDS only gets a (IDT) and packet sizes (PS) for different time intervals. It
copy of the network traffic and merely creates an alert for has been experimentally proved that D-ITG can generate a
evaluation by the administrator (when the packet is probably packet rate of 75000, where size of each packet is 1024
already delivered) [6]. Collectively they are known as bytes [10].
Intrusion detection and prevention system (IDPS). A good
IDS is defined by its ability to identify true attacks, less In this paper, we have suggested a set of new modified
number of false alerts and low value of drop packets [7]. custom rules for Snort v2.9.11.1 and also tested their ability
to mitigate network attacks in a network of 1GBps. We have
1.1 Snort 2.X designed a real-time network to measure the performance.
Snort is a free and open source network IDPS software. It The paper is organized as follows, Section I contains the
performs many functions from protocol analysis to content introduction of intrusion detection system Snort versions
/matching, and can detect a variety of attacks and probes. It 2.9.9.0 and traffic generator D-ITG and Scapy. Section II
was initially launched as a lightweight cross-platform packet contain the related work done by other researchers to
sniffer and was later upgraded to an IDS in 2003. Snort 2.X evaluate the performance of Snort under different network
is a single-threaded user-level application which uses deep attacks, Section III contain the experiment plan, Section IV
packet inspection (DPI) for examining packets wherein it contains the proposed rules and observations regarding the
first inspects the packet header for any malicious content and behaviour of Snort under attack in real-time network,
then goes on to examine the packet payload [7] . It is a Section V discusses and infers the results obtained and
developmental open source software and its latest stable finally Section VI concludes the research work.
release is 2.9.9.11. It is easy to configure, install and use and
has around 5 million downloads till date. It works well in II. RELATED WORK
Windows, Linux and FreeBSD opera ting systems. The three
operating modes of Snort are: C. chen in [11] has proposed a statistical model based on
two-sample t-test for Distributed DoS evaluation. It
● Packet sniffer; displays the real time network traffic. identifies the difference between incoming SYN arrival rate
● Packet logger; saves the network traffic to the disk for (SAR) and normal SAR and counting the SYN and ACK
traffic debugging later. packets send and received by the host. The method involves
● Network intrusion detection and prevention; matches low computation overhead and has lower value of false
the network traffic against signatures and performs the negatives and false positives. It follows three main
specified actions. approaches: packet marking, proactive and reactive. In
Snort checks the incoming packet against all its rules and if Packet marking, suspicious packets are marked with some
the rule matches, an alert is generated and logged onto the bits at distributed routers, and then separate them if they are
disk and if specified, some preventive actions are also taken. exceeding thresholds. However, this counting and reacting
method will become computationally intensive when
deployed on a server receiving a huge number of legitimate In [17], performance comparison of FireCol and Snort-with
requests per second. modified rule set is presented. Snort rules are modified to
more generalized rules so that even if one less condition is
In [12], a procedure to improve the detection ability of met, an alert of low priority is generated. The idea is that a
Snort has been suggested for network probe attack. They packet with a small difference from known attack packet can
have first evaluated and studied the behaviour of Snort for be a variation of the attack. Results showed that new
detecting attack traffic of MIT-DARPA 1999 dataset and generalized rules have low overhead but require more time
then used this information to propose new improved rules to process the same number of packets in comparison to
that would increase the detection ability of Snort and reduce FireCol. Snort based IDS proved out to be a feasible and
the number of false positives. They showed that with the efficient system for thwarting DoS attacks but has a greater
new improved rules, Snort showed more accurate results. number of false alarms.
However they have checked the accuracy on DARPA 1999
dataset only and no real time traffic and attack scenarios M. Gandhi et.al. in [18] have created a signature based IDS
were considered. for identifying network attacks. The IDS works in
promiscuous mode to capture all the network traffic and
In [13], FireCol is proposed and tested to detect DDOS compare it with Snort signatures to identify intrusions and
attacks. A FireCol consists of multiple IPSs and is placed report them to the entire network. The IDS can be operated
near the attacking source and as far as possible from the in both HIDS and NIDS mode and was tested for four DoS
victim host in order to reduce the delay in detection. It was and Port Scan attack. They have not explained any test
evaluated on real time data and DARPA-99 dataset. FireCol statistics and no work is done to validate the proposed IDS.
shows good detection ability and is robust with less In [19] different techniques like signature detection,
computational and communication overhead. However, the anomaly detection and mining based classification are used
tested it on age-old DARPA-99 dataset and the rules used for DoS attack detection and mitigation. Four detection
are not specified. systems viz. Snort, Phad, Madam and Multops are compared
and evaluated. Snort showed best detection rate for known
Rule based methods like Fuzzy Inference System (FIS) and DoS vulnerabilities but performed poorly for unknown DoS
Decision Trees (DT) are suggested for signature based vulnerability and DoS flood attacks. Snort has low false
analysis in [14]. A test bed is prepared to generate DDoS alarm rate but requires more time to write alerts and get
attack in real time for Network, Transport and Application them examined manually. The paper does not talk about the
layers. The attacks are detected using Snort by adding behaviour of Snort on receiving high speed traffic and
custom rules to its rule-set in order to reduce the false dropping of packets.
positive rate. The datasets like KDD cup 99 and Shonlaus
Truncated Command Sequences (STCS) are used for Our work is different from all the previous work for various
performance evaluation. They have developed an IDS reasons: (1) Researchers have tested their rules on age-old
ensemble tool which generates, detects and classifies real DARPA data set whereas we have tested them on a real
time attacks. The rules generated are specific to their test network (2) Packet c rafting tool Scapy has never been used
network and are not applicable in all network attack to perform the attacks. (3) The traffic rate at which the
scenarios. experiments are carried out is high as compared to the
related work. (4) The proposed rules are not limited to our
Simulation of DoS attack using UDP flooding has been own network but can be reutilized for other networks as
presented in [15] and methods and tools to mitigate them well. (5) A total of 15 attacks including both DoS and Port
have been proposed. UDP based flooding attacks like fraggle Scan attacks are evaluated in this paper
etc. have been simulated and methods have been suggested
to mitigate them using IDS Snort and firewall. They have III. EXPERIMENTAL SET-UP
used UDP Flooder tool to generate huge amount of UDP
packets for Windows OS. They have not simulated other We aim to evaluate Snort in host-based intrusion detection
DoS attacks based on TCP and ICMP which form a major mode by analysing its performance for different network
proportion of network attacks. attacks on Ubuntu 16.04 server in a high speed network.
Snort v2.9.11.1 is installed in its default configurations and
In [16], authors have emulated four common DoS attacks later custom rules are added to it for evaluation. D-ITG is
using network packet generator tools and have detected them used to generate high-speed traffic to emulate the traffic
using Snort with their custom rules in their lab environment. available to server. We are using two dedicated machines for
The have performed Land, SYN flood, Smurf and UDP traffic generation using D-ITG. Attacks are performed using
flood attacks using visual packet builder and Frameip tools. Scapy. Two attackers are used to perform the attack so that a
large number of attack packets are generated and tests are have been added in Snort Database to help identify attacks in
performed accurately. Figure 1 shows our experimental set- a high speed network of 1 Gbps. Attack traffic along with
up for performing network attacks. The system description normal network traffic was send using Scapy and D-ITG
and specifications are enlisted in table 1. respectively for 60 sec. Two types of network attacks are
considered i.e. DoS based attacks and Port Scan attacks.
Table 1. System Specifications The TCP is one of the main protocols of the Internet and
Machine Description Specifications provides reliable, ordered, and error-checked delivery
Traffic Dell Intel(R) core(TM) i3- Ubuntu with D-ITG
generator 1 3110M CPU @ 2.40GHz, 8 traffic generator packets between hosts communicating via an IP network. To
and 2 GB RAM establish a reliable connection between the hosts, a three-
Attacker 1 Hp Intel(R) core(TM) i5- Ubuntu with Scapy- way handshake [20] is used. (1) Client sends a SYN packet
and 2 3210M CPU @ 2.40GHz, 8 python to the server and sets the segment's sequence number to any
GB RAM
Snort Hp Intel(R) core(TM) i7- Ubuntu 16.04 server
random value (say X). (2) Server responses to the packet
v2.9.9.0 4770M CPU @ 2.40GHz, 8 with a SYN-ACK. The acknowledgment number is one
GB RAM more than the received segment sequence number (X+1) and
then server assigns another random sequence number to the
3.1. Evaluation parameters packet (say Y) (3) Client sends an ACK back to the server
Three evaluation parameters are used to evaluate the and its sequence number is set to the received
detection ability of Snort, after the addition of new rules to acknowledgement value (X+1) and the acknowledgement
its database, under attacks the parameters are: number is set to one more than the received sequence
number (Y+1). Some of the TCP based DoS attacks exploit
1. Snort Efficiency: It gives the value of number of packets the three-way handshake mechanism to perform the attack.
analysed per second. More the Snort Efficiency more is
its ability to detect attacks. It is measured in kilo packets 1) SYN-flood
analysed per second (kpps), using the formula It is a denial of service attack in which attacker sends a huge
number of TCP SYN packets from one or many spoofed
Snort efficiency = . source addresses to the server [21]. Server tries to respond
to these SYN packets by sending ACK-SYN packets to the
2. Undetected Attack Packets Percentage: It gives the spoofed IP addresses, which would not respond back with
value of attack packets that are not checked by Snort and expected Acknowledgements. This results in a half-open
are dropped by it. These packets go undetected and so connection and all these waiting connections are stored in a
more the undetected attack packet percentage, less is the queue for some time. When the number of waiting
performance of Snort. It is calculated using the formula connections exceed the queue limit, all subsequent SYN
requests are dropped leading to denial of service to
authorized users. The aim of the attack is to utilize enough
*100
server resources to make the system unresponsive to
authorized user requests.
3. CPU Utilization: It gives the percentage of CPU utilized
under attack. We have used Scapy to generate a number of SYN packets
with spoofed source addresses. Snort is used to monitor the
IV. PROPOSED SYSTEM traffic and is the number of SYN packets received by it
A new set of custom rules is proposed for Snort v2.9.11.1 exceed 2500 packets per second [22] , an alert is generated.
for identifying various network attack. A total of 15 rules
Snort rule: requests exceed 1500 per second. For testing, an Ubuntu
alert tcp !$HOME_NET any -> $HOME_NET 80 (flags: S; mail server is used on which Snort is installed.
msg: "Possible DDoS TCP attack"; flow: stateless; Snort rule:
detection_filter: track by_dst, count 150000, seconds 60; alert tcp !$HOME_NET any -> $HOME_NET 80 (flags:S;
sid:10000001; rev:001;) msg:"Possible http flood attack"; flow:established;
Scapy statement to generate attack: content:"GET"; nocase; http_method; detection_filter: track
send (IP (dst = "192.170.1.120", src = RandIP()) / TCP ( by_dst, count 90000, seconds 60; sid:10000004; rev:001;)
dport=80, flags="S"), loop=1) Attack statement:
send ( IP (dst = ”192.170.1.117”, src = RandIP() )/ TCP
2) Land attack (dport=80)/ “GET /HTTP/1.0\r\n\r\n”, loop=1)
It is another denial of service attack where the attacker sends
a SYN packet with spoofed source address as that of 5) TCP reset attack
destination. Thus, in such a packet both the source address After a successful TCP three way handshake is established,
as well as the destination address are the same [21]. These RST or FIN packets are exchanged between server and client
attacks are performed on some older TCP/IP to either restart or close the TCP-SYN session between
implementations. On receiving such packets, the host system them. The attacker utilizes this idea and sends a large
gets locked up and has to be physically turned on again. For number TCP RESET packets to the target server. The server
detecting such attacks by Snort a keyword sameip is used in when receive a large number of spoofed RESET packets,
the rule which checks for same source and destination which do not belong to any of its current sessions, tries to
values. process the invalid requests wasting its resources on them.
Snort rule: The attack tries to exhaust the server‟s resources making it
alert tcp any any -> $HOME_NET any (sameip; unavailable to process legitimate requests. An IDS can
msg:"LAND attack"; sid:10000002; rev:001;) detect such packets by searching for reset packets to the
Attack statement: server that do not belong to any established TCP connection
send (IP (dst = "192.170.1.120", src = ”192.170.1.120”) / Snort rule:
TCP(dport = RandShort() ), loop=1) alert tcp any any -> $HOME_NET 80 (flags:R;
msg:"Possible DDoS TCP attack"; flow:stateless;
3) Mail bomb attack sid:10000005; rev:001;)
In this type of attack, the attacker sends a flood of e-mails to Attack statement:
the victim server so that server's mail queue is overloaded send (IP (dst = "192.170.1.120", src = RandIP() ) /
causing system failure. For detecting a mail bomb attack, TCP(dport = 80, flags = "R"), loop=1)
IDS may look for thousands of mail messages coming from
or sent to a particular user within a short period of time. The 6) Christmas tree attack
rule shown below fires when the number of mails coming to This attack is done using a Christmas tree packet in which
SMTP port 25 for established TCP sessions exceed 1000 e- all three FIN, URG, and PUSH flags are set. A large number
mails per second. of Christmas tree packets when send to the server utilizes all
Snort rule: the server resources as they require much more processing
alert tcp any any - $SMTP_SERVER 25 (msg: "Possible than normal packets [23]. The server may get exhausted and
Mail Bomb attack"; flags:A+; flow:established; is unavailable for legitimate requests. By observing how the
detection_filter: track by_dst, count 60000, seconds 60; server responds to such an odd packet, inferences can also be
sid:1000003; rev:001;) made regarding the server‟s operating system.
Attack statement: Snort rule:
send (IP(dst = "192.170.1.120", src = RandIP() ) / TCP(dport alert tcp !$HOME_NET any -> $HOME_NET 80
= 25, flags = "AS"), loop =1) (flags:FPU; msg:"Possible christmas tree DoS attack";
flow:stateless; sid:10000006; rev:001;)
4) HTTP flooding Attack statement:
In HTTP flooding, first the attacker establishes a connection send (IP(dst="192.170.1.120", src=RandIP() ) / TCP (dport
with the server using three-way handshaking and then floods = 80, flags = "FPU"), loop=1)
the server with numerous http requests. The attacker intends
to exhaust the server side resources like I/O bandwidth, 7) UDP flood
memory and CPU by sending numerous valid and invalid It is a DoS attack in which a flood of spoofed UDP packets
„GET‟ requests to the server. Snort rule checks for the is send by the attacker to random ports of the victim server.
number of GET requests received by the server for an As UDP is a connectionless protocol, so no three-way
established TCP session. Our rule fires when the number of handshaking is required like TCP. On receiving a UDP
packet on a particular port, the server determines which 10) Ping of Death
application is running on that port and if no application is It is a denial of service attack that affects many operating
available, an ICMP packet of destination unreachable is send systems. It is launched by sending large sized ICMP ping
to the spoofed source address. If a large number of UDP packets to the victim. The size of the packet is larger than
packets are received by the victim, system‟s performance 65536 bytes, which is more than IP specification limit and
goes down and it may become unavailable. Snort rule fires if will either crash, hang or reboot the victim machine. To
number of UDP packets per second is more than 1500. identify such packets using Snort we measure the size of
ICMP packet using dsize and if it‟s larger than 65535, the
Snort rule: rule fires.
alert udp !$HOME_NET any -> $HOME_NET !53 (msg:
"UDP-FLOOD detected"; flow: stateless; detection_filter: Snort rule:
track by_dst, count 90000, seconds 60; sid:10000008; alert icmp !$HOME_NET any -> $HOME_NET any
rev:001;) (msg:"ping of death detected"; dsize: >65535; itype: 8;
Attack statement: icode:0; sid:10000011; rev:001;
send (dst = “192.170.1.120”, src = RandIP() )/ UDP(dport = Attack statement:
RandShort() ), loop=1) send (fragment (IP(dst = ”192.170.1.120”) / ICMP()/
(”X”*60000), loop=1)
8) DNS flood
It is one of the toughest DDoS attacks to detect and prevent. 11) Smurf Attack
The attacker sends a large amount of DNS requests from In the "smurf" attack, a large amount of ICMP echo requests
spoofed IP addresses to DNS server. The request packets (ping) packets are send to the broadcast IP address of the
emulate a real DNS request are difficult to be differentiated network with spoofed source IP address of the intended
from legitimate ones. In order to serve all the incoming DNS victim. Every host machine present in the subnet of that
requests, the server exhausts its resources. The attack broadcast address will receive these the ICMP echo requests
consumes all available I/O bandwidth of the server until it is and reply to the victim host with ICMP echo reply. The
completely exhausted. Snort rule fires when the number of attacker amplifies the attack by using the broadcast address
DNS requests to DNS server exceed 1000 per second. which multiplies the traffic by the factor of active hosts in
the subnet. The maximum possible amplification factor is
Snort rule: 255 [21]. The Smurf attack can be identified by monitoring
alert udp !$HOME_NET any -> $HOME_NET 53 the number of 'echo replies' being sent to the victim machine
(msg:"DNS FLOOD"; detection_filter: track by_dst, count from many different places in a small time span.
60000, seconds 60; sid:10000009; rev:001;)
Attack statement: Snort rule:
send (IP (dst = "192.168.5.1")/ UDP() / DNS (rd =1, qd = alert icmp any any -> 192.170.1.120 any (msg:"Smurf
DNSQR(qname="www.jammuuniversity.in")), loop=1) Attack"; itype:0; detection_filter: track by_dst, count 50000,
seconds 60; sid:10000012; rev:001;)
9) ICMP flood Attack statement:
An ICMP flood attack is executed by overloading the victim send ((IP(dst=”192.170.1.255”, src = ”192.170.1.120”) /
server with thousands of ICMP ping requests from spoofed ICMP(), loop=1)
IPs. The victim would then use all of its resources in
replying to these ping message until it can no longer process 4.2. Port Scan attacks
any valid request. Snort rule can detect this attack by A Port Scan attack is aimed to find out what ports are open
counting the number of ICMP ping packets received per on the victim machine. The attacker sends a number of
second. If the number of ping requests exceed 1500 per packets to the victim machine by varying the destination port
second, the rule fires. to find out what services are running on which port and also
to get an idea of the victim‟s operating system [12]. Attacker
Snort rule: may send TCP packets (with different flag values of the
alert icmp !$HOME_NET any -> $HOME_NET any header) and observe the response of the victim, to know if a
(msg:"ICMP-FLOOD"; itype:8; detection_filter: track particular port is listening or not .A summary of TCP/IP
by_dst, count 90000, seconds 60; sid:10000010; rev:001;) implementation rules followed by host machines on
Attack statement: receiving flagged TCP packets prior three way handshake is
send (IP(dst = "192.170.1.120", src = RandIP() ) / ICMP( shown in table 2. We have performed four Port Scan attacks.
type= 8 ), loop=1)
various packets received, analysed and dropped by Snort are up with the high rate of attack traffic. Figure 3 shows the
recorded in table 3 and 4. The attacks packets that are variation in undetected attack packets percentage for various
dropped (excluding normal packets that are dropped) are attacks except Ping of Death.
also calculated to give a clear indication of the performance
of the rule. We have compared the performance of Snort for Snort efficiency lies in the range of 35 – 56 for all the
server under attack with that of server under normal traffic attacks with the minimum for that of Ping of Death and
with no attack packets. maximum for normal Traffic as in figure 2. This indicates
that Snort performance is not affected to a greater extent
DoS based attacks: even under attack and performs well in all the attacks except
From table 3 we can deduce that the rules performed very ping of death.
well for SYN-flood, TCP reset, Xmas tree, UDP flood, DNS
flood, ICMP flood and smurf attacks as their values of From figure 4, we can see that the CPU utilization is more
Undetected Attack Packets percentage is less than 0.2%. It under attack than under normal traffic. Also it is maximum
performed well for Land attack, Mail bomb and HTTP flood for Ping of Death and minimum for TCP reset. For all
also but its performance was very low for Ping of Death as others, it is in the range of 53-63%. The main aim of the
90% of the packets were undetected. The reason for this attack is to exhaust the server resources like CPU and if IDS
behaviour in case of Ping of Death is that Snort takes more is also installed on the same machine than it may get less
time in reassembling of fragments and so is not able to cope CPU time leading to undetected packets.
Table 3. Observations for DoS attacks
Attack Undetected
S. Packets Packets Packets Attack Snort CPU
Attack Type Packets Attack Packets
No. Received Analysed Dropped Packets Send Efficiency Utilization
dropped Percentage
1. SYN-flood 2885307 2885005 302 226889 302 48.08 0.133105 63.3
2. Land attack 2779301 2770950 8351 213351 3351 46.18 1.570651 53.43
3. Mail bomb 3080683 3068787 11896 206117 6551 51.15 3.178292 62.5
4. HTTP flood 3105515 3102916 2599 214219 2289 51.72 1.068533 58.4
5. TCP reset 2996648 2996152 496 2114278 0 49.94 0 45.43
6. Xmas tree 3137510 3137205 305 227979 10 52.29 0.004386 59.65
7. UDP flood 2837670 2837347 323 219404 326 47.29 0.148584 58.083
8. DNS flood 2780308 2778606 1702 174794 1477 46.31 0.844995 57
9. ICMP flood 2916154 2916154 0 221998 0 48.6 0 57.18
10. Ping of death 2342191 2107802 234389 254103 230003 35.13 90.51566 70.3
11. Smurf 2486160 2485891 269 254257 269 41.43 0.105798 58.82
12. Normal traffic 3403692 3403692 0 0 0 56.73 0 39
58 56.73
3 46
2.5 ACK scan FIN scan Null scan FTP normal
bounce traffic
2 Portscan Attacks
1.57
1.5 Figure 5. Comparison of Snort efficiency for
1.07 different Port Scan attacks
1 0.84
0.5 2
0.13 0 0 0.15 0 0.11 1.65
Undetected Attack
0
1.5
Packets (%)
53.43 70
50 45.43
61.37 55.77
60
39
40 50
39
30 40
30
20
20
10 10
0 0
ACK scan FIN scan Null scan FTP normal
bounce traffic
Portscan Attacks
DoS Attacks Figure 7. CPU utilization for different Port Scan
Figure 4. CPU utilization for different DoS attacks attacks
AUTHORS PROFILE
Dr. Lalit Sen Sharma has obtained Master
of Science in Mathematics and MCA from
Guru Nanak Dev University, Amritsar
(India). He has also obtained Doctorate of
Philosophy (PhD) from Guru Nanak Dev
University in 2008. Currently, he is working
as a Professor and Head of Department in
the department of Computer Science and Information
Technology in University of Jammu, India. He has been
teaching to postgraduate students of computer applications
for fifteen years. He is a member of Indian Science Congress
Association, Institute of Electronics and Communication
Engineer, India and National HRD network, India.