Network Security 2
Network Security 2
HTTP
HTTP
client
client
HTTP hdr
TCP
TCP
TCP hdr
IP
IP
IP hdr
Ethernet
Ethernet
driver
driver
Eth. hdr tr.
Ethernet
Demultiplexing
HTTP …
DNS …
FTP
SNMP
SMTP demuxing based on
the port number
in the TCP or UDP
header
TCP
TCP UDP
UDP
IGMP
IGMP
ICMP
ICMP demuxing based on the
protocol id in the IP header
IP
IP
RARP
RARP
ARP demuxing based on frame type
ARP in the Ethernet header
Ethernet
Ethernet
driver
driver
Names and Addresses
Hardware (MAC) Addresses
► Every interface has a unique and fixed
hardware address too
► Used by the data link layer
► In case of Ethernet, it is 48 bits long
► Mapping between IP addresses and MAC
addresses are done by ARP
Host Names
► Human readable, hierarchical names, such as
www.aumc.edu.pk
► Every host may have several names
► Mapping between names and IP addresses is done
by the Domain Name System (DNS)
Address Resolution Protocol
ARP – Address Resolution Protocol
► Mapping from IP addresses to MAC addresses
Request 08:00:20:03:F6:42 00:00:C0:C2:9B:26
.1 .2 .3 .4 .5
192.168.0
Reply
08:00:20:03:F6:42 00:00:C0:C2:9B:26
.1 .2 .3 .4 .5
192.168.0
192.168.0
arp req | target IP: 192.168.0.5 | target eth: ?
Reply
08:00:20:03:F6:42 00:34:CD:C2:9F:A0 00:00:C0:C2:9B:26
.1 .2 .3 .4 .5
192.168.0
Store data
SYNS, ACKC
Wait
ACKS
Connected
TCP Sequence Numbers
► TCP uses ISN (Initial Sequence Number) to order the incoming
packets for a connection
► Sequence numbers are 32 bits long
► The sequence number in a data segment identifies the first byte
in the segment
► Sequence numbers are initialized with a “random” value during
connection setup
► The RFC suggests that the ISN is incremented by one at least
every 4 s
TCP SYN Attack
► Anattacker can impersonate a trusted host
(e.g., in case of r commands, authentication is
based on source IP address solely)
This can be done guessing the sequence number in
the ongoing communication
The initial sequence numbers are intended to be
more or less random
TCP SYN Attack
► In Berkeley implementations, the ISN is incremented by
a constant amount
128,000 once per second, and
further 64,000 each time a connection is initiated
► RFC 793 specifies that the 32-bit counter be
incremented by 1 about every 4 s
the ISN cycles every 4.55 hours
► Whatever! It is not hopeless to guess the next ISN to
be used by a system
Launching a SYN Attack
► The attacker first establishes a valid
connection with the target to know its ISN.
► Next it impersonates itself as trusted host T
and sends the connection request with ISNx
► The target sends the ACK with its ISNs to the
trusted host T
► The attacker after the expected time sends
the ACK with predicted ISNs’
Launching a SYN Attack
SRC_IP = T, nasty_data
What about the ACK for T?
► If the ACK is received by the trusted host T
It will reject it, as no request for a connection was made by it
RST will be sent and the server drops the connection
BUT!!!
► The attacker can either launch this attack when T is down
► Or launch some sort of DoS attack on T
So that it can’t reply
TCP SYN Attack – How to Guess ISNS?
attacker server
SYN = ISN
X
, ACK (ISN X)
SN S
SYN = I
S YN = I S t
NX ’, SRC
_I P=T
SYN = IS
NS ’, ACK
( IS N )
ACK(ISN X
S ’), SRC_
IP =T
Source
Destination
Source A Destination
Source B Destination
user
user
interface
interface
user
server
protocol
protocol control connection protocol
protocol
interpreter
interpreter (FTP commands and replies) interpreter
interpreter
data
data data
data
data connection
transfer
transfer transfer
transfer
function
function function
function
…
FTP – File Transfer Protocol
client server
% ftp www.aumc.edu.pk <TCP connection setup to port 21 of www.aumc.edu.pk >
“220 www.aumc.edu.pk FTP server (version 5.60) ready.”
Connected to www.aumc.edu.pk
Name: abc
“USER abc”
“331 Password required for user abc.”
Password: pswd
“PASS pswd”
nt rol
P co ion
FT nect
con
FTP Server
Attacker Victim to be
scanned
Telnet
Telnet
Telnetclient Telnet
client Telnetserver
server login
loginshell
shell
kernel kernel
terminal
terminal pseudo-
pseudo-
TCP/IP
TCP/IP TCP/IP
TCP/IP
driver
driver terminal
terminal
driver
driver
TCP connection
user
Telnet Session Example
Connected to ahost.com.pk
Escape character is ‘^]’.
<Telnet option negotiation>
“Login:”
Login: s
“s”
Login: st
“t”
… …
Login: student
“t”
“Password:”
Password: c
“c”
… …
Password: cab123
“3”
user
user mails to
agent
agent be sent
user
local
local SMTP relay
relay
MTA
MTA MTA
MTA
relay
relay
MTA
MTA
SMTP
receiving host
local
local SMTP relay
relay
MTA
MTA MTA
MTA
user
user user
agent
agent mailbox
user
SMTP
► SMTP is a text (ASCII) based protocol
► MTA transfers mail from the user to the
destination server
► MTA relays are used to relay the mail from
other clients
► MTAs use SMTP to talk to each other
► All the messages are spooled before sending
SMTP Message Flow
sending MTA (mail.aumc.edu.pk) receiving MTA (smtp.yahoo.com)
<TCP connection establishment to port 25>
“HELO mail.aumc.edu.pk.”
“250 smtp.yahoo.com Hello mail.aumc.edu.pk., pleased to meet you”
“MAIL from: [email protected]”
“250 [email protected]... Sender ok”
“RCPT to: [email protected]”
“250 student2@yahoo… Recipient ok”
“DATA”
“354 Enter mail, end with a “.” on a line by itself”
<message to be sent>
.
“250 Mail accepted”
“QUIT”
“221 smtp.yahoo.com delivering mail”
70
SMTP Security Problems
► Designed in an era where internet security was
not much of an issue
No security at the base protocol
► Designed around the idea of “cooperation” and
“trust” between servers
Susceptible to DoS attacks
►Simply flood a mail server with SMTP connections
or SMTP instructions.
SMTP Security Problems
► SMTP does not provide any protection of e-mail
messages
Does not ask sender to authenticate itself.
Messages can be read and modified by any
of the MTAs involved
Fake messages can easily be generated (e-
mail forgery)
Does not check what and from whom it is
relaying the message
SMTP Security Problems Example
% telnet frogstar.hit.com.pk 25
Trying...
Connected to frogstar.hit.com.pk.
Escape character is ‘^[’.
220 frogstar.hit.com.pk ESMTP Sendmail 8.11.6/8.11.6;
Mon, 10 Feb 2003 14:23:21 +0100
helo abcd.com.pk
250 frogstar.hit.com.pk Hello [152.66.249.32], pleased to meet you
mail from: [email protected]
250 2.1.0 [email protected]... Sender ok
rcpt to: [email protected]
250 2.1.5 [email protected]... Recipient ok
data
354 Enter mail, end with "." on a line by itself
Your fake message goes here.
.
250 2.0.0 h1ADO5e21330 Message accepted for delivery
quit
221 frogstar.hit.com.pk closing connection
Connection closed by foreign host.
%
Be Careful, Though!
Return-Path: <[email protected]>
Received: from frogstar.hit.com.pk ([email protected]
[152.66.248.44])
by mail.ebizlab.hit.com.pk (8.12.7/8.12.7/Debian-2)
with ESMTP id h1ADSsxG022719
for <[email protected]>; Mon, 10 Feb 2003 14:28:54 +0100
Received: from abcd.com.pk ([152.66.249.32])
by frogstar.hit.com.pk (8.11.6/8.11.6) with SMTP id h1ADO5e21330
for [email protected]; Mon, 10 Feb 2003 14:25:41 +0100
Date: Mon, 10 Feb 2003 14:25:41 +0100
From: [email protected]
Message-Id: <[email protected]>
To: undisclosed-recipients:;
X-Virus-Scanned: by amavis-dc
Status:
IP IP of
of n s in e
n du.p k name
namesrv srv
si
20 na ininpk
pk
2. um
83 c.e
. 17 du
. pk
3. name
61 namesrv
srv
ininedu.pk
A single DNS reply may include several edu.pk
???????????????
???????????????
????