Module 16
Module 16
Ansh Bhawnani
IDS, Firewall and
Honeypot Concepts
Module 16
1. Firewalls
Module 16
IDS, Firewall and Honeypot Concepts
4
IDS, Firewall and Honeypot Concepts
5
2. Firewall
Architecture
Module 16
IDS, Firewall and Honeypot Concepts
▰ Bastion Host:
▻ Bastion host is a computer system designed and configured to
protect network resources from attack.
▻ Traffic entering or leaving the network passes through the firewall,
it has two interfaces:
▻ public interface directly connected to the Internet.
▻ private interface connected to the Intranet.
7
IDS, Firewall and Honeypot Concepts
8
IDS, Firewall and Honeypot Concepts
9
IDS, Firewall and Honeypot Concepts
10
IDS, Firewall and Honeypot Concepts
▰ DeMilitarized Zone:
▻ DMZ exposes an organization's external-facing services to an
untrusted network, while rest of the organization's network is
firewalled.
▻ DMZ is a network that serves as a buffer between the internal
secure network and insecure Internet.
▻ It can be created using firewall with three or more network
interfaces assigned with specific roles such as Internal trusted
network, DMZ network, and external un-trusted network.
11
IDS, Firewall and Honeypot Concepts
▰ Multi-homed Firewall:
▻ In this case, a firewall with two or more interfaces is present that
allows further subdivision of the network based on the specific
security objectives of the organization.
12
3. Types of Firewalls
Module 16
IDS, Firewall and Honeypot Concepts
15
IDS, Firewall and Honeypot Concepts
17
IDS, Firewall and Honeypot Concepts
▰ Application-Level Firewall
▻ Application-level gateways (proxies) can filter packets at the application
layer of the OSI model (or the application layer of TCP/IP).
▻ Incoming and outgoing traffic is restricted to services supported by proxy;
all other service requests are denied.
▻ Application-level gateways configured as a web proxy prohibit FTP,
gopher, telnet, or other traffic.
▻ Application-level gateways examine traffic and filter on application-
specific commands such as http:post and get.
18
IDS, Firewall and Honeypot Concepts
19
IDS, Firewall and Honeypot Concepts
▰ Application-Level Firewall
▻ Application-layer firewalls can function in one of two modes:
▻ Active application-level firewalls: They examine all incoming
requests, including the actual message that exchanged against
known vulnerabilities, such as SQL injection, parameter and cookie
tampering, and cross-site scripting. The requests deemed genuine
and allowed to pass through them.
▻ Passive application-level firewalls: They work similarly to an IDS, in
that they also check all incoming requests against known
vulnerabilities, but they do not actively reject or deny request if a
potential attack is discovered.
20
IDS, Firewall and Honeypot Concepts
22
IDS/IPS Systems
Module 16
1. Intrusion
Detection Systems
(IDS)
Module 16
IDS, Firewall and Honeypot Concepts
25
IDS, Firewall and Honeypot Concepts
26
IDS, Firewall and Honeypot Concepts
27
2. Ways to Detect an
Intrusion
Module 16
IDS, Firewall and Honeypot Concepts
▰ System Intrusions:
▻ The presence of new, unfamiliar files, or programs.
▻ Changes in file permissions.
▻ Unexplained changes in a file's size.
▻ Rogue files on the system that do not correspond to your master
list of signed files.
▻ Unfamiliar file names in directories.
▻ Missing files.
33
IDS, Firewall and Honeypot Concepts
▰ Network Intrusions:
▻ Repeated probes of the available services on your machines.
▻ Connections from unusual locations.
▻ Repeated login attempts from remote hosts.
▻ Arbitrary data in log files, indicating attempts to cause a DoS or to
crash a service.
34
IDS, Firewall and Honeypot Concepts
36
IDS, Firewall and Honeypot Concepts
37
IDS, Firewall and Honeypot Concepts
38
IDS, Firewall and Honeypot Concepts
39
4. IDS vs Firewalls
vs IPS
Module 16
IDS, Firewall and Honeypot Concepts
Philosophy Firewall is a network security IPS is a device that inspects It is a device or software
device that filters incoming and traffic, detects it, classifies and application that monitors a traffic
outgoing network traffic based then proactively stops malicious for malicious activity or policy
on predetermined rules traffic from attack. violations and sends alert on
detection.
Principle of working Filters traffic based on IP Inspects real time traffic and Detects real time traffic and
address and port numbers looks for traffic patterns or looks for traffic patterns or
signatures of attack and then signatures of attack and them
prevents on detection generates alerts
Configuration mode Layer 3 mode or transparent Inline mode, generally being in Inline mode, generally being in
mode layer 2 layer 2
Placement Inline at the Perimeter of Inline generally after Firewall Non-Inline through port span (or
Network via tap)
41
IDS, Firewall and Honeypot Concepts
Placement wrt each other Should be 1st Line of defense Should be placed after the Should be placed after firewall
Firewall device in network
Action on unauthorized traffic Block the traffic Preventing the traffic on Alerts/alarms on detection of
detection Detection of anomaly anomaly
Related terminologies > Stateful packet filtering > Anomaly based detection > Anomaly based detection
> permits and blocks traffic by > Signature detection > Signature detection
port/protocol rules > Zero day attacks > Zero day attacks
> Blocking the attack > Monitoring
> Alarm
42
IDS, Firewall and Honeypot Concepts
43
IDS, Firewall and Honeypot Concepts
44
IDS, Firewall and Honeypot Concepts
45
5. Honeypots
Module 16
Honeypots
▰ There is a whole spectrum of why you would want a honeypot, some of them
would be:
▻ Research Exploits
▻ Find Zero-Day Exploits
▻ Learn more about your actual system (if the honeypot is a copy of your
actual system)
▻ Learn about the types of attack that your real system is vulnerable to and
how to best protect it.
48
Honeypots
49
Honeypots
50
Honeypots
▰ The data types that honeypots capture from (or about) the attackers can
include, but is not limited to:
▻ The usernames, roles, and privileges that the attackers use
▻ The IP addresses of the network or host that are being using for the
attack
▻ What data is being accessed, altered or deleted
▻ The actual keystrokes the attackers type out, which lets administrators
see exactly what they are doing
51
Honeypots
▰ Honeypot Strategies
▻ Low-interaction method
▻ In this method you will be using fake data, folders, and databases
as bait with the intent of monitoring attacks to see what would
happen in a real-life data breaching scenario.
▻ Of course, they would have access to other peripheral information
sets like IP addresses, usernames, and passwords – over which
the administrators keep a keen eye.
▻ It only provides certain fake services but it’s no real operating
system that an attacker can operate on, were designed to
53
emulated vulnerable services
Honeypots
▰ Honeypot Strategies
▻ High-interaction method
▻ In this setup you would allow the attackers to interact with data, software
(including OS), services, and hardware that appear to be as realistic as
possible. The intent here is to gauge and capture the skills of the attackers.
▻ This setup is mostly used in research scenarios where the results of the
studies are used to improve the defense capabilities of anti-viruses and anti-
malware.
▻ Nothing in a high interaction honeypot is emulated, its all real. Therefore, a
higher complexity and maintenance is involved.
54
Honeypots
▰ False positives
▻ A honeypot alert is not fool-proof. When it comes to honeypot alerts,
beware of a different kind of false positive.
▻ For instance: an attacker can create a diversion, spoofing your
production system pretending that they are attacking the honeypot.
Meanwhile, your honeypot would detect these spoofed attacks as actual
attacks. This would drive your IT admins to investigate the wrong attack.
▻ Meanwhile, during this false alert, an attacker would be focusing on a
real attack against the production system.
55
Honeypots
58
Honeypots
59
Honeypots
▰ Honeytokens
▻ Honeytokens are files or data sets that would appear to be interesting to the
attacker but are actually fake replicas of the real deal.
▻ The honeytokens can also be embedded files or data sets in what would
otherwise appear to be a legitimate server or database. It makes it easy for
administrators to keep track of the data in case it is stolen –
▻ Examples of this sort of honeytoken include email addresses and usernames
or login IDs. If an attacker gains access to these pieces of information, it
would be easy to know which database they have breached which would, in
turn, help in figuring out how they managed to do it.
60
6. Intrusion
Detection Tool:
Snort
Module 16
IDS Systems
▰ Snort
▻ Snort is an open source network intrusion detection system, capable of
performing real-time traffic analysis and packet logging on IP networks.
▻ It can perform protocol analysis and content searching/matching, and is
used to detect a variety of attacks and probes, such as buffer overflows,
stealth port scans, CGI attacks, SMB probes, and OS fingerprinting
attempts.
▻ It uses flexible rules language to describe traffic that it should collect or
pass, as well as a detection engine that utilizes a modular plug-in
architecture.
62
IDS Systems
▰ Uses of Snort:
▻ Straight packet sniffer like tcpdump
▻ Packet logger (useful for network traffic debugging, etc.)
▻ Network intrusion prevention system
63
5. How Snort Works
Module 16
IDS Systems
65
6. Snort Rules
Module 16
IDS Systems
▰ Snort's rule engine enables custom rules to meet the needs of the network.
▰ Snort rules help in differentiating between normal Internet activities and
malicious activities.
▰ Snort rules must be contained on a single line, the Snort rule parser does not
handle rules on multiple lines.
▰ Snort rules with two logical parts:
▻ Rule header: Identifies rule's actions such as alerts, log, pass, activate,
dynamic, etc.
▻ Rule options: Identifies rule's alert messages.
67
IDS Systems
▰ Example:
▻ alert tcp any any -> 192.168.1.0/24 111 (content: "|00 01 86 a5|";msg:
"mountd access";)
▻ alert: Rule Action
▻ tcp: Rule Protocol
▻ ->: Rule Format Direction
▻ 192.168.1.0/24: Rule IP address
▻ 111: Rule Port
▻ content: "|00 01 86 a5|": Payload detection rule
68
▻ msg: "mountd access": Alert message
IDS Systems
▰ Rule Actions:
▻ The rule action tells Snort what to do when it finds a packet that matches
the rule criteria.
▻ alert - generate an alert using the selected alert method, and then log the packet
▻ log - log the packet
▻ pass - ignore the packet
▻ activate - alert and then turn on another dynamic rule
▻ dynamic - remain idle until activated by an activate rule, then act as a log rule
69
IDS Systems
▰ Protocols:
▻ The next field in a rule is the protocol. There are three IP protocols that
Snort currently analyzes for suspicious behavior, tcp, udp, and icmp. In
the future there may be more, such as ARP, IGRP, GRE, OSPF, RIP, IPX,
etc.
▻ tcp
▻ udp
▻ icmp
70
IDS Systems
72
IDS Systems
▰ Activate/Dynamic Rules
▻ Activate/dynamic rule pairs give Snort a powerful capability. You can now
have one rule activate another when it's action is performed for a set
number of packets. This is very useful if you want to set Snort up to
perform follow on recording when a specific rule "goes off". Activate
rules act just like alert rules, except they have a *required* option
field: "activates“
▻ For e.g, activate tcp !$HOME_NET any -> $HOME_NET 143 (flags: PA;
content: "|E8C0FFFFFF|\bin|; activates: 1; msg: "IMAP buffer overflow!";)
73
IDS Systems
▰ Rule Options
▻ Rule options form the heart of Snort's intrusion detection engine,
combining ease of use with power and flexibility.
▻ All Snort rule options are separated from each other using the semicolon
";" character. Rule option keywords are separated from their arguments
with a colon ":".
▻ For e.g., msg, logto, ttl, tos, id, fragbits, dsize, flag, resp, seq, ack, etc.
74
Evading IDS
Module 16
1. Payload
obfuscation
Module 16
Evading IDS
78
Evading IDS
▰ Polymorphism
▻ To obfuscate their attacks, attackers can use polymorphic shellcode to
create unique attack patterns. This technique typically involves encoding
the payload in some fashion (e.g., XOR-ing each byte with 0x95), then
placing a decoder in front of the payload before sending it.
▻ When the target executes the code, it runs the decoder which rewrites the
payload into its original form which the target then executes.
▻ Polymorphic attacks don't have a single detectable signature, making
them very difficult for detection.
▻ Shikata ga nai ("it cannot be helped") is a popular polymorphic encoder in
79
the Metasploit framework
2. Insertion Attacks
Module 16
Evading IDS
81
Evading IDS
▰ Methods:
▻ Fragmentation and small packets
▻ Overlapping fragments and TCP segments
▻ Protocol ambiguities
▻ Low-bandwidth attacks
82
3. Denial of Service
Module 16
Evading IDS
▰ Due to the fact that passive IDS are inherently fail-open, launching a denial-of-
service attack against the IDS on a network is a feasible method of
circumventing its protection.
▰ It can be done by exploiting a bug in the IDS, consuming all of the
computational resources on the IDS, or deliberately triggering a large number
of alerts to disguise the actual attack.
▰ If the attackers know the IP address of this centralized logging server, they can
launch a denial-of-service attack on that server so that the IDS won’t be able to
log any more events.
84
Evading IDS
85
Evading IDS
▰ Methods:
▻ CPU exhaustion
▻ Memory exhaustion
▻ Operator fatigue
86
4. Session Splicing
Module 16
Evading IDS
▰ Attacker splits the attack traffic in to many packets such that no single packet
triggers the IDS.
▰ It is effective against IDSs that do not reconstruct packet before checking
them against intrusion signatures.
▰ If attackers are aware of delay in packet reassembly, they can add delays
between packet transmissions to bypass the reassembly.
▰ IDS will stop working if the target host keeps session active for a time longer
than the IDS reassembly time.
▰ Any attack attempt after a successful splicing attack will not be logged by the
IDS.
88
Evading Firewalls
Module 16
1. SSH Tunneling
Module 16
Evading Firewalls
▰ SSH tunnelling is a somewhat like VPN. In VPN, you connect to a VPN server
and all your traffic is encrypted and gets routed through that server.
▰ The premise is same but instead of a VPN server you have your home PC or
router, acting as a server, for traffic routing and it takes few more steps to
setup.
▰ The client side computer will connect to an SSH server through port 22. Most
firewalls allow communication over port 22, as it is the port used by HTTPS
and. Also, SSH also uses the same port so most firewalls allow it.
▰ OpenSSH: Attackers use OpenSSH to encrypt and tunnel all the traffic from a
local machine to a remote machine to avoid detection by perimeter security
controls.
91
2. IP Spoofing
Module 16
Evading Firewalls
93
3. Source Routing
Module 16
Evading Firewalls
▰ When using source routing, the attacker designates the route a packet should
take through the network in such a way that the designated route should
bypass the firewall entirely, evading any restrictions the firewall has in place.
▰ Through the use of source routing, it is entirely possible for the attacker to
specify the route he wishes the packet to use, instead of leaving it up to the
routing protocol the organization has in place.
▰ This technique may also enable an attacker to reach a target host that is
normally unreachable from the location of the attacker. This may include
private RFC 1918 IP addresses that should not be present on the Internet.
▰ When combined with IP address spoofing, the attacker may have the ability to
use a spoofed source address and still receive a response. Source routing also
95
known as path addressing.
Evading Firewalls
96
4. ICMP Tunneling
Module 16
Evading Firewalls
▰ ICMP tunneling works by injecting arbitrary data into an echo packet sent to a
remote computer. The remote computer replies in the same manner, injecting
an answer into another ICMP packet and sending it back. The client performs
all communication using ICMP echo request packets, while the proxy uses
echo reply packets.
▰ These packets are not necessarily forwarded to the client, as the client could
be behind a translated address (NAT). This bidirectional data flow can be
abstracted with an ordinary serial line.
▰ ICMP tunneling is possible because RFC 792, which defines the structure of
ICMP packets, allows for an arbitrary data length for any type 0 (echo reply) or
8 (echo message) ICMP packets. 98
Evading Firewalls
99
Evading Firewalls
▰ Mitigations:
▻ DPI — Deep Packet Inspection
▻ Whereas the conventional packet inspections read the metadata of
the packet (mainly headers), Deep packet inspection reads the
contents of a packet that is going through it in real time.
▻ Most DPI tools rely on a signatures database — if there is no
signature relevant for ICMP messages, it won’t detect the ICMP
Tunnel.
▻ Even if there is a relevant signature at the database, the operator
should first configure it to be in an active mode.
100
5. HTTP Tunneling
Module 16
Evading Firewalls
102
Evading Firewalls
104
Evading Firewalls
▰ The client connects to the proxy server and requests tunneling by specifying the port and the host
computer it would like to connect to. The port is used to indicate the protocol being requested.[3]
▻ CONNECT streamline.t-mobile.com:22 HTTP/1.1
▻ Proxy-Authorization: Basic encoded-credentials
▰ If the connection was allowed and the proxy has connected to the specified host then the proxy will
return a 2XX success response.[3]
▻ HTTP/1.1 200 OK
▰ The client is now being proxied to the remote host. The client can communicate using any protocol
accepted by the remote host. In the example below, the client is starting SSH communications, as
hinted to, by the port number, in the initial CONNECT request.
▻ SSH-2.0-OpenSSH_4.3\r\n
▻ ...ggg 105
HACKING
Is an art, practised through a creative mind.
106