Lec8 NetworkAttacks IP TCP
Lec8 NetworkAttacks IP TCP
Mobin Javed
• Eavesdropping
• DHCP-Spoo ng threats
fi
Lesson Plan
• IP Layer Threats
• Connection Termination
• Connection Hijacking
• Connection Spoo ng
1 Physical 3-bit
16-bit Identification Flags 13-bit Fragment Offset
8-bit Time to
Live (TTL) 8-bit Protocol 16-bit Header Checksum
IP = Internet Protocol
Payload
Network-Layer (IP) Threats
1 Physical
“Best Effort” is Lame! What to do?
• It’s the job of our Transport (layer 4) protocols to build
data delivery services that our apps need out of IP’s
modest layer-3 service
• #1 workhorse: TCP (Transmission Control Protocol)
• Service provided by TCP:
– Connection oriented (explicit set-up / tear-down)
o End hosts (processes) can have multiple concurrent long-lived
communication
– Reliable, in-order, byte-stream delivery
o Robust detection & retransmission of lost data
TCP “Bytestream” Service
Process A on host H1
Byte 0
Byte 1
Byte 2
Byte 3
Byte 80
Process B
on host H2
Byte 0
Byte 1
Byte 2
Byte 3
Byte 80
Bidirectional communication:
Process B on host H2
Byte 0
Byte 1
Byte 2
Byte 3
Byte 73
Process A
on host H1
Byte 0
Byte 1
Byte 2
Byte 3
Byte 73
(Link Layer Header)
TCP Header
(IP Header)
Ports are
associated Source port Destination port
with OS
processes Sequence number
Acknowledgment
HdrLen 0 Flags Advertised window
Data …
What combination of header elds
uniquely identi es a (bi-directional) TCP
connection?
The R
gateway
216.97.19.132
router
the In
resolver
Data …
TCP Header
Host B
TCP Header
y, A ck = x+1
um =
SYN + ACK, SeqN
A C K , Se q
Num = x
+ 1, Ack
=y+1
accept()
TCP Conn. Setup & Data Exchange
Client (initiator) Server
IP address 1.2.1.2, port 3344 IP address 9.8.7.6, port 80
SrcA=1.2.1
DstA=9.8.7 .2, SrcP=33
.6, DstP=80 44,
, SYN, Seq
=x
, SrcP=80,
SrcA=9.8.7.6 K , S e q = y, Ack = x+1
AC
.2 .1 .2 , D s tP =3344, SYN+
DstA =1
SrcA=1.2.1
DstA=9.8.7 .2, SrcP=33
.6, DstP=80 44,
, ACK, Ack
= y+1
SrcA=1.2.1
.2, SrcP=33
ACK, Seq= 44, DstA=9
x +1 , A c k = .8.7.6, DstP
y+1, Data= =
“GET /login 80,
.html
4,
D s tA = 1 .2 .1 .2, DstP=334 ”
.6 , SrcP=80 , … <html> …
S rc A = 9 .8 .7 = “ 2 0 0 O K
Data
S e q = y + 1 , Ack = x+16,
A CK,
TCP Threat: Disruption
SYN A
ACK
RST
ACK
SYN
Data
CK
A
time
...
SrcA=1.2.1
.2, SrcP=33
ACK, Seq= 44, DstA=9
x +1 , A c k = .8.7.6, DstP
y+1, Data= =
“GET /login 80,
.html
Attacker
IP address 6.6.6.6, port N/A
SrcA=9.8.7.6, SrcP=80,
DstA=1.2.1.2, DstP=3344, Spoofed
RST, Seq = y+1, Ack = x+16
Client
dutifully
removes
connection
TCP RST Injection
Client (initiator) Server
IP address 1.2.1.2, port 3344 IP address 9.8.7.6, port 80
...
SrcA=1.2.1
.2, SrcP=33
ACK, Seq= 44, DstA=9
x +1 , A c k = .8.7.6, DstP
y+1, Data= =
“GET /login 80,
.html
Attacker
IP address 6.6.6.6, port N/A
SrcA=9.8.7.6, SrcP=80,
DstA=1.2.1.2, DstP=3344, Spoofed
RST, Seq = y+1, Ack = x+16
Client ,
= 1 .2 .1 .2 , DstP=3344
rejects since = 9 .8 .7 .6 , SrcP=80, D s tA
2 0 0 O K … <html> …”
Src A ta=“
no active q = y + 1 , A c k = x+16, Da
A C K , Se
connection X
TCP Threat: Data Injection
ta2
ta
SYN A
ACK
y Da
y Da
ACK
SYN
Data
Nast
Nast
CK
A
time
...
SrcA=1.2.1
.2, SrcP=33
ACK, Seq= 44, DstA=9
x +1 , A c k = .8.7.6, DstP
y+1, Data= =
“GET /login 80,
.html
Attacker
IP address 6.6.6.6, port N/A
SrcA=9.8.7.6, SrcP=80,
DstA=1.2.1.2, DstP=3344,
ACK, Seq = y+1, Ack = x+16 Spoofed
Data=“200 OK … <poison> …”
Client
dutifully
processes
as server’s
response
TCP Data Injection
Client (initiator) Server
IP address 1.2.1.2, port 3344 IP address 9.8.7.6, port 80
...
SrcA=1.2.1
.2, SrcP=33
ACK, Seq= 44, DstA=9
x +1 , A c k = .8.7.6, DstP
y+1, Data= =
“GET /login 80,
.html
Attacker
IP address 6.6.6.6, port N/A
SrcA=9.8.7.6, SrcP=80,
DstA=1.2.1.2, DstP=3344,
ACK, Seq = y+1, Ack = x+16 Spoofed
Data=“200 OK … <poison> …”
Client
ignores
since already tA = 1 .2 .1 .2 , DstP=3344
,
SrcP=80, D s <html> …”
processed A = 9 .8 .7 .6 , 2 0 0 O K …
Src ta=“
q = y + 1 , A c k = x+16, Da
that part of A C K , Se
bytestream
TCP Threat: Blind Spoofing
• Is it possible for an attacker to inject into a TCP
connection even if they can’t see our traffic?
• YES: if somehow they can infer or guess the port
and sequence numbers
• Let’s look at a simpler related attack where the goal
of the attacker is to create a fake connection, rather
than inject into a real one
– Why?
– Perhaps to leverage a server’s trust of a given client as
identified by its IP address
– Perhaps to frame a given client so the attacker’s actions
during the connections can’t be traced back to the
attacker
Spoofing an Entire TCP Connection
Alleged Client (not actual) Server
IP address 1.2.1.2, port N/A IP address 9.8.7.6, port 80
Blind Attacker
SrcA=1.2.1.2, SrcP=5566, DstA=9.8.7.6,
DstP=80, SYN, Seq = z
, SrcP=80,
SrcA=9.8.7.6 K , S e q = y, Ack = z+1
AC
.2 .1 .2 , D s tP =5566, SYN+
DstA = 1
Attacker’s goal:
SrcA=1.2.1.2, SrcP=5566, DstA=9.8.7.6,
DstP=80, ACK, Seq = z+1, ACK = y+1
Blind Attacker
SrcA=1.2.1.2, SrcP=5566, DstA=9.8.7.6,
DstP=80, SYN, Seq = z
, SrcP=80,
SrcA=9.8.7.6 K , Se q = y, Ack = x+1
AC
.2 .1 .2 , D s tP =5566, SYN+
DstA = 1
Blind Attacker
SrcA=1.2.1.2, SrcP=5566, DstA=9.8.7.6,
DstP=80, SYN, Seq = z
, SrcP=80,
SrcA=9.8.7.6 K , S e q = y, Ack = z+1
AC
.2 .1 .2 , D s tP =5566, SYN+
DstA = 1
Blind Attacker
SrcA=1.2.1.2, SrcP=5566, DstA=9.8.7.6,
DstP=80, SYN, Seq = z
, SrcP=80,
SrcA=9.8.7.6 K , S e q = y, Ack = z+1
AC
.2 .1 .2 , D s tP =5566, SYN+
DstA = 1
Caching heavily 7 6
1 8
used to minimize authoritative DNS server
lookups (‘umass.edu’, ‘cs.umass.edu’)
dns.cs.umass.edu
requesting host
xyz.poly.edu gaia.cs.umass.edu
DNS Threats
• DNS: path-critical for just about everything we do
– Maps hostnames ⇔ IP addresses
– Design only scales if we can minimize lookup traffic
o #1 way to do so: caching
o #2 way to do so: return not only answers to queries, but additional info
that will likely be needed shortly
;; QUESTION SECTION:
;eecs.mit.edu. IN A
;; ANSWER SECTION:
eecs.mit.edu. 21600 IN A 18.62.1.6
;; AUTHORITY SECTION:
mit.edu. 11088 IN NS BITSY.mit.edu.
mit.edu. 11088 IN NS W20NS.mit.edu.
mit.edu. 11088 IN NS STRAWB.mit.edu.
;; ADDITIONAL SECTION:
STRAWB.mit.edu. 126738 IN A 18.71.0.151
BITSY.mit.edu. 166408 IN A 18.72.0.3
W20NS.mit.edu. 126738 IN A 18.70.0.160
dig eecs.mit.edu A
; ; <<>> DiG 9.6.0-APPLE-P2 <<>> eecs.mit.edu a
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19901
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3
;; QUESTION SECTION:
;eecs.mit.edu. IN A
;; ANSWER SECTION:
eecs.mit.edu. 21600 IN A 18.62.1.6
;; AUTHORITY SECTION:
mit.edu. 11088 This is dig identifying
IN NS its version and the
BITSY.mit.edu.
mit.edu. 11088 query it is attempting
IN NS to look up
W20NS.mit.edu.
mit.edu. 11088 IN NS STRAWB.mit.edu.
;; ADDITIONAL SECTION:
STRAWB.mit.edu. 126738 IN A 18.71.0.151
BITSY.mit.edu. 166408 IN A 18.72.0.3
W20NS.mit.edu. 126738 IN A 18.70.0.160
dig eecs.mit.edu A
; ; <<>> DiG 9.6.0-APPLE-P2 <<>> eecs.mit.edu a
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19901
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3
;; QUESTION SECTION:
;eecs.mit.edu. IN A
;; ANSWER SECTION:
eecs.mit.edu. 21600 IN A 18.62.1.6
;; AUTHORITY SECTION:
mit.edu. 11088 Status values
IN NS returnedBITSY.mit.edu.
from the remote
mit.edu. 11088 name server
IN NSqueried by dig
W20NS.mit.edu.
mit.edu. 11088 IN NS STRAWB.mit.edu.
;; ADDITIONAL SECTION:
STRAWB.mit.edu. 126738 IN A 18.71.0.151
BITSY.mit.edu. 166408 IN A 18.72.0.3
W20NS.mit.edu. 126738 IN A 18.70.0.160
dig eecs.mit.edu A
; ; <<>> DiG 9.6.0-APPLE-P2 <<>> eecs.mit.edu a
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19901
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3
;; QUESTION SECTION:
;eecs.mit.edu. IN A
;; ANSWER SECTION:
eecs.mit.edu. 21600 Including
IN a 16-bit
A transaction identifier that
18.62.1.6
enables the DNS client (dig, in this case) to
;; AUTHORITY SECTION: match up the reply with its original request
mit.edu. 11088 IN NS BITSY.mit.edu.
mit.edu. 11088 IN NS W20NS.mit.edu.
mit.edu. 11088 IN NS STRAWB.mit.edu.
;; ADDITIONAL SECTION:
STRAWB.mit.edu. 126738 IN A 18.71.0.151
BITSY.mit.edu. 166408 IN A 18.72.0.3
W20NS.mit.edu. 126738 IN A 18.70.0.160
dig eecs.mit.edu A
; ; <<>> DiG 9.6.0-APPLE-P2 <<>> eecs.mit.edu a
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19901
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3
;; QUESTION SECTION:
;eecs.mit.edu. IN A
;; ANSWER SECTION:
eecs.mit.edu. 21600 IN A 18.62.1.6
;; AUTHORITY SECTION:
mit.edu. 11088 IN NS BITSY.mit.edu.
mit.edu. 11088 IN NS W20NS.mit.edu.
mit.edu. 11088 IN NS STRAWB.mit.edu.
The name server echoes back the question
that it is answering as the first part of its reply
;; ADDITIONAL SECTION:
STRAWB.mit.edu. 126738 IN A 18.71.0.151
BITSY.mit.edu. 166408 IN A 18.72.0.3
W20NS.mit.edu. 126738 IN A 18.70.0.160
dig eecs.mit.edu A
; ; <<>> DiG 9.6.0-APPLE-P2 <<>> eecs.mit.edu a
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: “Answer”
QUERY, tells
status:
us the NOERROR, id: 19901
IP address associated with
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3
eecs.mit.edu is 18.62.1.6 and we can cache the
result for 21,600 seconds
;; QUESTION SECTION:
;eecs.mit.edu. IN A
;; ANSWER SECTION:
eecs.mit.edu. 21600 IN A 18.62.1.6
;; AUTHORITY SECTION:
mit.edu. 11088 IN NS BITSY.mit.edu.
mit.edu. 11088 IN NS W20NS.mit.edu.
mit.edu. 11088 IN NS STRAWB.mit.edu.
;; ADDITIONAL SECTION:
STRAWB.mit.edu. 126738 IN A 18.71.0.151
BITSY.mit.edu. 166408 IN A 18.72.0.3
W20NS.mit.edu. 126738 IN A 18.70.0.160
dig eecs.mit.edu A
; ; <<>> DiG 9.6.0-APPLE-P2 <<>> eecs.mit.edu a
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19901
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3
;; QUESTION SECTION:
;eecs.mit.edu. IN A
;; ANSWER SECTION:
eecs.mit.edu. 21600 IN A 18.62.1.6
;; AUTHORITY SECTION:
mit.edu. 11088 IN NS BITSY.mit.edu.
mit.edu. 11088 IN NS W20NS.mit.edu.
mit.edu. In general,
11088 a single
IN Resource NS Record (RR) like this
STRAWB.mit.edu.
includes, left-to-right, a DNS name, a time-to-live, a
;; ADDITIONAL SECTION:family (IN for our purposes - ignore), a type (A here,
STRAWB.mit.edu. which stands for
126738 IN“Address”),
A and an 18.71.0.151
associated value
BITSY.mit.edu. 166408 IN A 18.72.0.3
W20NS.mit.edu. 126738 IN A 18.70.0.160
dig eecs.mit.edu A
; ; <<>> DiG 9.6.0-APPLE-P2 <<>> eecs.mit.edu a
;; global options: +cmd
;; Got answer: “Authority” tells us the name servers responsible for the
;; ->>HEADER<<- opcode:answer.
QUERY,Each RR gives
status: the hostname
NOERROR, id: of19901
a different name
server1,
;; flags: qr rd ra; QUERY: (“NS”) for names
ANSWER: 1, inAUTHORITY:
mit.edu. We 3,
should cache each 3
ADDITIONAL:
record for 11,088 seconds.
;; QUESTION SECTION:
;eecs.mit.edu. If the “Answer”
IN had beenA empty, then the resolver’s next
step would be to send the original query to one of these
;; ANSWER SECTION: name servers.
eecs.mit.edu. 21600 IN A 18.62.1.6
;; AUTHORITY SECTION:
mit.edu. 11088 IN NS BITSY.mit.edu.
mit.edu. 11088 IN NS W20NS.mit.edu.
mit.edu. 11088 IN NS STRAWB.mit.edu.
;; ADDITIONAL SECTION:
STRAWB.mit.edu. 126738 IN A 18.71.0.151
BITSY.mit.edu. 166408 IN A 18.72.0.3
W20NS.mit.edu. 126738 IN A 18.70.0.160
dig eecs.mit.edu A
; ; <<>> DiG 9.6.0-APPLE-P2 <<>> eecs.mit.edu a
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19901
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3
;; QUESTION SECTION:
;eecs.mit.edu. IN A
“Additional” provides extra information to save us from making
;; ANSWER SECTION:separate lookups for it, or helps with bootstrapping.
eecs.mit.edu. 21600 IN A 18.62.1.6
Here, it tells us the IP addresses for the hostnames of the name
servers. We add these to our cache.
;; AUTHORITY SECTION:
mit.edu. 11088 IN NS BITSY.mit.edu.
mit.edu. 11088 IN NS W20NS.mit.edu.
mit.edu. 11088 IN NS STRAWB.mit.edu.
;; ADDITIONAL SECTION:
STRAWB.mit.edu. 126738 IN A 18.71.0.151
BITSY.mit.edu. 166408 IN A 18.72.0.3
W20NS.mit.edu. 126738 IN A 18.70.0.160