Lecture 5
Lecture 5
Disclaimer
• Some techniques and tools mentioned in this class
could be: Dangerous
– Illegal to use
Mail
server
Employees
External users
Reconnaissance Tools
• Tools that integrate Whois, ARIN, DNS interrogation
and many more services:
– Applications
– Web-based portals
• http://www.network-tools.com
Dangerous
At The End Of Reconnaissance
• Attacker has a list of IP addresses assigned to the
target network
• He has some administrative information about the
target network
• He may also have a few “live” addresses and some
idea about functionalities of the attached
computers
Phase 2: Scanning
• Detecting information useful for break-in
– Live machines
– Network topology
– Firewall configuration
– Applications and OS types
– Vulnerabilities
Network Mapping
• Finding live hosts
– Ping sweep
– TCP SYN sweep
• Map network topology
– Traceroute
• Sends out ICMP or UDP packets with increasing TTL
• Gets back ICMP_TIME_EXCEEDED message from
intermediate routers
Traceroute
www
1. ICMP_ECHO to www.victim.com
TTL=1
A R1 R2 R3 db
1a. ICMP_TIME_EXCEEDED
from R1
victim.com
Traceroute
www
2. ICMP_ECHO to www.victim.com
TTL=2
A R1 R2 R3 db
2a. ICMP_TIME_EXCEEDED
from R2
victim.com
Traceroute
www
3. ICMP_ECHO to www.victim.com
TTL=3
A R1 R2 R3 db
3a. ICMP_TIME_EXCEEDED
from R3
victim.com
Traceroute
www
4. ICMP_ECHO to www.victim.com
TTL=4
A R1 R2 R3 db
4a. ICMP_REPLY
from www.victim.com
victim.com
Traceroute
www
Repeat for db and mail servers
A R1 R2 R3 db
Dangerous
Defenses Against Network Mapping
And Scanning
• Filter out outgoing ICMP traffic
– Maybe allow for your ISP only
• Use Network Address Translation
(NAT) 3 .7 3
6 8 . 1 A
t 1 9 2 .1
u es
Req 3 .7 3
68 . 1
9 2 .1
Request 1.2.3
.4 NAT ep ly 1 B
R
box
Reply 1.2.3.4 1.2.3.4
8.9.10.11 C
D
• SAINT
– http://www.saintcorporation.com
• Nessus
– http://www.nessus.org
Defenses Against
Vulnerability Scanning
• Close your ports and keep systems patched
• Find your vulnerabilities before the attackers do
At The End Of Scanning Phase
• Attacker has a list of “live” IP addresses
• Open ports and applications at live machines
• Some information about OS type and version of live
machines
• Some information about application versions at
open ports
• Information about network topology
• Information about firewall configuration
Phase 3: Gaining Access
• Exploit vulnerabilities
– Exploits for a specific vulnerability can be downloaded
from hacker sites
– Skilled hackers write new exploits
What is a vulnerability?
What is an exploit?
Buffer Overflow Attacks
• Aka stack-based overflow attacks
• Stack stores important data on procedure call
TOS
s,buffer[10]
For X For X
Y R
X
Sniffing On a Hub
• Attacker can get anything that is not encrypted and
is sent to LAN
– Defense: encrypt all sensitive traffic
– Tcpdump
• http://www.tcpdump.org
– Snort
• http://www.snort.org
– Ethereal
• http://www.ethereal.com
Sniffing On a Switch
• Switch is connected by a separate physical line to
every machine and it chooses only one line to send
the message
A
For X
Y R
For
X X
Sniffing On a Switch – Take 1
• Attacker sends a lot of ARP messages for fake
addresses to R
– Some switches send on all interfaces when their table
overloads
A
For X
Y R
For
X X
Sniffing On a Switch – Take 2
• Address Resolution Protocol (ARP) maps IP
addresses with MAC addresses
2. Who has X? A
1. For X
Y R
3. I
do X
4. F
or
X
Sniffing On a Switch – Take 2
• Attacker uses ARP poisoning to map his MAC
address to IP address X
A
1. I have X, MAC(A)
( A)
AC
M A)
)
,
C(A
r Y C (
Fo A
7. ,M
MA
X
3. For X, MAC (A) . F or
e Y,
4
hav
Y R
2. I
6. F
or Y X
, MA
C( A
) 5. A sends this back
to R, to be sent to MAC(X)
8. A sends this back
to R, to be sent to MAC(Y)
Active Sniffing Tools
• Dsniff
– http://www.monkey.org/~dugsong/dsniff
– Also parses application packets
for a lot of applications
– Sniffs and spoofs DNS Dangerous
Spoofing DNS
• Attacker sniffs DNS requests, replies with his own
address faster than real server (DNS cache
poisoning)
• When real reply arrives client ignores it
• This can be coupled with man-in-the-middle attack
on HTTPS and SSH
Sniffing Defenses
• Use end-to-end encryption
• Use switches
– Statically configure MAC and IP bindings with ports
• Don’t accept suspicious certificates
What Is IP Spoofing
• Faking somebody else’s IP address in IP source
address field
• How to spoof?
– Linux and BSD OS have functions that enable superuser
to create custom packets and fill in any information
– Windows XP also has this capability but earlier Windows
versions don’t
IP Address Spoofing in TCP packets
• Attacker cannot see reply packets
Attacker M
1. SYN, IP Alice, SEQA
3. RESET
Guessing a Sequence Number
• Attacker wants to assume Alice’s identity
– He establishes many connections to Bob with his own
identity gets a few sequence numbers
– He disables Alice (DDoS)
– He sends SYN to Bob, Bob replies to Alice, attacker uses
guessed value of SEQB to complete connection – TCP
session hijacking
– If Bob and Alice have trust relationship (/etc/hosts.equiv
file in Linux) he has just gained access to Bob
– He can add his machine to /etc/hosts.equiv
echo “1.2.3.4” >> /etc/hosts.equiv
• How easy is it to guess SEQB?
Guessing a Sequence Number
• It used to be ISN=f(Time), still is in some Windows
versions
Guessing a Sequence Number
• On Linux ISN=f(time)+rand
Guessing a Sequence Number
• On BSD ISN=rand
Spoofing Defenses
• Ingress and egress filtering
• Prohibit source routing option
• Don’t use trust models with IP addresses
• Randomize sequence numbers
At The End of Gaining Access
• Attacker has successfully logged onto a machine
Phase 4: Maintaining Access
• Attacker establishes a listening application on a
port (backdoor) so he can log on any time with or
without a password
• Attackers frequently close security holes they find
Netcat Tool
• Similar to Linux cat command
– http://netcat.sourceforge.net/
– Client: Initiates connection to any port on remote machine
– Server: Listens on any port
– To open a shell on a victim machine Dangerous
On victim machine: nc –l –p 1234
/* This opens a backdoor */