Firewall Penetration Testing
Firewall Penetration Testing
Module XXI
EC Council
EC-Council Firewall Penetration
Testing
Penetration Testing Roadmap
Start Here
Information Vulnerability External
Gathering Analysis Penetration Testing
Fi
Firewall
ll Router and Internal
Switches Network
Penetration Testing
Penetration Testing Penetration Testing
Cont’d
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Penetration Testing Roadmap
(cont d)
(cont’d)
Cont’d
Physical Database VoIP
S
Security
i P
Penetration
i testing
i P
Penetration
i T Testing
i
Penetration Testing
Virus and
Vi d VPN
Trojan War Dialing
Penetration Testing
Detection
End Here
Telecommunication
Data Leakage Security Email Security
And Broadband
Penetration Testing Patches Penetration Testingg
Communication
Penetration Testing
Penetration Testing
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
What is a Firewall?
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
What Does a Firewall Do?
It routes p
packets between the networks.
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Packet Filtering
Address filtering:
Network filtering:
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
What Can't a Firewall Do?
Policies involving the use and misuse of passwords and user accounts
must be strictly enforced.
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
How Does a Firewall Work?
A firewall may allow all traffic through unless it meets certain criteria, or
i may d
it deny all
ll traffic
ffi unless
l iit meets certain
i criteria.
i i
They may also use complex rule bases that analyze the application data
to determine if the traffic should be allowed through.
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Firewall Operations
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Firewall Logging Functionality
Syslog-based
y gb logging
gg g environments supplies
pp
inputs to IDS and forensic analysis project.
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Firewall Policy
Firewall installations along with systems and other resources should be audited
on a regular basis.
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Firewall Implementation
An appliance-based firewall:
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Build a Firewall Ruleset
Most firewall p
platforms use rulesets as their common system
y for
implementing security controls.
The contents of the firewall ruleset will establish the functionality of the
firewall.
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Maintenance and Management of
Firewall
The two mechanisms used by commercial firewall platforms for configuring and
maintenance are:
• Command line interface (CLI) configuration.
• Graphical user interface (GUI) configuration.
For web-based
F b b d iinterfaces,
t f security
it iis provided
id d th
through
hSSecure S
Socket
k tLLayer
(SSL) encryption, along with user id and password.
For non
non-web
web interfaces, security is implemented through custom transport
encryption.
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Maintenance and Management of
Firewall (cont
(cont’d)
d)
By monitoring the firewall, you can find suspicious activities like port
scans or h
half
lf scans.
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Hardware Firewall
Public
Network
Hardware
Firewall
Private Local Area Network
Usually part
of a TCP/IP
Router
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Software Firewall
Public
Network
Computer
with Firewall
Private Local Area Network
Software
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Types of Firewall
Packet filters
Application
pp cat o level
e e gate
gateways
ays
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Packet Filtering Firewall
Packet filtering firewalls work at the network level of the OSI model (or the IP layer of
TCP/IP).
The advantage of packet filtering firewalls is their low cost and low impact on network
performance.
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
IP Packet Filtering Firewall
: = Disallowed
; = Allowed
All d
5 Application
Traffic is filtered based on
4 TCP specified rules, including
source and destination IP
3 Internet Protocol (IP) :; address, packet type, and
2 Data Link port number.
1 Physical Unknown traffic is only
allowed up to level 3 of the
network stack.
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Circuit Level Gateway
Circuit level gateways work at the session layer of the OSI model, or the TCP
layer of TCP/IP.
TCP/IP
They h
Th have th
the advantage
d t off hidi
hiding iinformation
f ti about
b t th
the private
i t network
t k th
they
protect.
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
TCP Packet Filtering Firewall
: = Disallowed
; = Allowed
All d
5 Application
Traffic is filtered based on
4 TCP :; specified session rules, such
as when a session is
3 Internet Protocol (IP)
initiated by a recognized
2 Data Link computer.
1 Physical Unknown traffic is only
allowed up to level 4 of the
network stack.
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Application Level Firewall
Because they examine packets at application layer, they can filter application
specific commands such as http:post and get.
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Application Packet Filtering
Firewall
: = Disallowed
; = Allowed
All d
5 Application :; Traffic is filtered based on
4 TCP specified application rules,
such as specified
3 Internet Protocol (IP)
applications (such as a
2 Data Link browser) or a protocol, such
as FTP,
FTP or combinations
combinations.
1 Physical
Unknown traffic is only
allowed up to the top of
network stack.
stack
Incoming Traffic Allowed Outgoing Traffic
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Stateful Multilayer Inspection
Firewall
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Multilayer Inspection Firewall
: = Disallowed
; = Allowed
All d
5 Application :; Traffic is filtered at three
4 TCP :; levels, based on a wide
range of specified
3 Internet Protocol (IP) : ;
application, session and
2 Data Link packet filtering rules.
1 Physical Unknown traffic is allowed
up to level 3 of the network
stack.
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Steps for Conducting Firewall
Penetration Testing
• Locate the firewall
1
Craft an SYN packet using Hping or any other packet crafter send it to
the firewall.
Tools:
• hping2 www.xsecurity.com –c2 –S –p23 –n
• ICMP Unreachable type 13 from 10.10.2.3
10 10 2 3
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Step 2: Traceroute to Identify
the Network Range
Tool:
• tracert www.xsecurity.com
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Step 3: Port Scan the Firewall
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Step 4: Grab the Banner
Example:
• Symantec
y Enterprise
p Firewall 8.0 HTTP Proxyy
• C:\>nc -nvv 10.0.0.1 80
• HEAD / HTTP/1.0
• HTTP/1.1 503 Service Unavailable
• MIME-Version: 1.0
• Server: Simple, Secure Web Server 1.1
• Date: Tue, 12 Dec 2005 19:08:35 GMT
• Connection: close
• Content-Type: text/html
• <HTML>
• <HEAD><TITLE>Firewall Error: Service
Unavailable</TITLE></HEAD>
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Step 5: Create Custom Packets and
Look for Firewall Responses
Creating custom packets that are sent towards the firewall can elicit
unique responses from the firewall.
fire all
Example:
• hping 10.0.0.5 –c 2 –S –p 23 –n
• HPING 10.0.0.5 (eth0 10.0.0.5 ): S set, 40 data bytes
• 60 by
bytes from 10.0.0.5
5 : flags=RA
g seg=0
g ttl=5959 id=0 win=0
time=0.4 ms
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Step 6: Test Access Control
Enumeration
Use Nmap to enumerate the firewall access control list.
Example:
p
• #nmap –sA 192.168.0.1
• Interesting ports on 192.168.0.1:
• (The 65530 ports scanned but not shown below are in state: filtered)
• PORT STATE SERVICE
• 110/tcp UNfiltered pop-3
• 13701/tcp UNfiltered VeritasNetbackup
• 13711/tcp UNfiltered VeritasNetbackup
• 13721/tcp UNfiltered VeritasNetbackup
• 13782/tcp
8 / UNfiltered
UNfil dVVeritasNetbackup
i N b k
• Nmap run completed -- 1 IP address (1 host up) scanned in 12205.371 seconds
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Step 7: Test to Identify Firewall
Architecture
Hping2
p g is a tool for custom p
packet crafting.
g
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Step 8: Testing Firewall Policy
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Step 9: Test Firewall Using
Firewalking Tool
Firewalk can be used to discover open ports behind a firewall and it can be used for access
control list discovery.
discovery
Traceroute to any machine behind the firewall or the router before the firewall.
Once the hop count of the router is known, we can change our TTL value for our IP packet to
be 1 more than the hop count of the router & perform a port scan on the firewall.
Thus, if a “TTL exceeded error” comes back, the port on the firewall is open.
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Step 10: Test for Port Redirection
If yyou cannot g
get direct access to a p
port,, then use p
port redirection.
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Firewall Identification
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Step 11: Testing the Firewall from
Both Sides
Examine the firewall by simultaneously testing both sides of the firewall.
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Step 11: Testing the Firewall from
Both Sides (cont
(cont’d)
d)
The following are the steps to be performed for testing the
fi
firewall
ll ffrom b
both
th sides:
id
Step1: Test whether (possibly using tunneled protocols) unauthorized connections from the internal
network
t k to
t the
th Internet
I t t can b
be created.
t d
Step2: Execute a vulnerability scanner on the hosts of the firewall system (i.e., firewall host, internal
router, externall router)) ffrom iinside.
id
Step3: Identify the firewall rules by using appropriate firewall tools (Like firewalking from both sides).
sides)
Step4:
p4 Check for the reaction of the firewall to fragmented
g and spoofed
p p
packets that can be g
generated
using a packet generator.
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Step 12: Overt Firewall Test from
Outside
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Step 12: Overt Firewall Test
from Outside (cont
(cont’d)
d)
The following are the steps to be performed for overt firewall
testing
i from
f outside:
id
Step1:
p Execute a vulnerabilityy scanner on the hosts of the firewall
system (i.e., firewall host, internal router, external router)
Step3: Try to reach the systems that are behind the firewall
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Step 13: Test Covert Channels
I t ll a b
Install backdoor
kd on a victim
i ti machine
hi iinside
id th
the network.
t k
Tool:
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Step 14: Covert Firewall Test
from Outside
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Step 14: Covert Firewall Test
from Outside (cont
(cont’d)
d)
The following are the steps to perform testing for covert
firewall from outside:
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Step 15: Test HTTP Tunneling
T l
Tools:
HTTPORT
HTTHOST
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Step 16: Test Firewall Specific
Vulnerabilities
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Document Everything
D
Document the
h ffollowing:
ll i
• Firewall logs.
• Tools output.
output
• Your analysis.
• Recommendations (if any).
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited
Copyright © by EC-Council
EC-Council All Rights Reserved. Reproduction is Strictly Prohibited