Ip Spoofing Technology
Ip Spoofing Technology
ABSTRACT
Key fingerprint = AF19 FA27 2F94 998D FDB5 DE3D F8B5 06E4 A169 4E46
IP spoofing is a method of attacking a network in order to gain
unauthorized access. The attack is based on the fact that Internet communication
between distant computers is routinely handled by routers which find the best
route by examining the destination address, but generally ignore the origination
address. The origination address is only used by the destination machine when it
responds back to the source.
-1-
IP Spoofing Seminar Report
CONTENTS
1. Introduction 1
2. TCP/IP Protocol Suite 2
2.1 Internet Protocol. 2
2.2 Transmission Control Protocol 3
2.3 Consequences of the TCP/IP Design 5
3. Spoofing Attacks 6
3.1 Non-Blind Spoofing 6
3.2 Blind Spoofing 6
3.3 Man In The Middle Attack 7
3.4 Denial of Service Attack 11
4. Mechanism of the Attack 12
5. Methods to Prevent IP Spoofing 19
5.1 Packet Filtering 19
5.2 Filtering at the Router 21
5.3 Encryption and Authentication 21
5.4 Be Un-trusting and Un-trustworthy 22
5.5 Cryptographic Methods 22
5.6 Initial Sequence Numbering Randomizing 22
6. Applications of IP Spoofing 23
6.1 Asymmetric Routing (Splitting Routing) 23
6.2 SAT DSL 24
6.3 NAT 27
6.4 IP Masquerade 28
6.5 Services Vulnerable to IP Spoofing 30
6.6 TCP and IP Spoofing Tools 30
7. Conclusion 31
8. References
-2-
IP Spoofing Seminar Report
1. INTRODUCTION
Criminals have long employed the tactic of masking their true identity,
from disguises to aliases to caller-id blocking. It should come as no surprise then,
that criminals who conduct their nefarious activities on networks and computers
should employ such techniques. IP spoofing is one of the most common forms of
on-line camouflage. In IP spoofing, an attacker gains unauthorized access to a
computer or a network by making it appear that a malicious message has come
from a trusted machine by “spoofing” the IP address of that machine. In the
subsequent pages of this report, we will examine the concepts of IP spoofing: why
it is possible, how it works, what it is used for and how to defend against it.
-3-
IP Spoofing Seminar Report
-4-
IP Spoofing Seminar Report
-5-
IP Spoofing Seminar Report
must first build a connection - via the 3-way handshake (SYN-SYN/ACK-ACK) -
then update one another on progress - via sequences and acknowledgements. This
“conversation”, ensures data reliability, since the sender receives an OK from the
recipient after each packet exchange.
As you can see above, a TCP header is very different from an IP header.
We are concerned with the first 12 bytes of the TCP packet, which contain port
and sequencing information. Much like an IP datagram, TCP packets can be
manipulated using software. The source and destination ports normally depend on
the network application in use (for example, HTTP via port 80). What's important
for our understanding of spoofing are the sequence and acknowledgement
numbers. The data contained in these fields ensures packet delivery by
determining whether or not a packet needs to be resent. The sequence number is
the number of the first byte in the current packet, which is relevant to the data
stream. The acknowledgement number, in turn, contains the value of the next
expected sequence number in the stream. This relationship confirms, on both ends,
that the proper packets were received. It’s quite different than IP, since transaction
state is closely monitored.
-6-
IP Spoofing Seminar Report
Now that we have an overview of the TCP/IP formats, let's examine the
consequences. Obviously, it's very easy to mask a source address by manipulating
an IP header. This technique is used for obvious reasons and is employed in
several of the attacks discussed below. Another consequence, specific to TCP, is
sequence number prediction, which can lead to session hijacking or host
impersonating. This method builds on IP spoofing, since a session, albeit a false
one, is built. We will examine the ramifications of this in the attacks discussed
below.
-7-
IP Spoofing Seminar Report
3. SPOOFING ATTACKS
There are a few variations on the types of attacks that successfully employ
IP spoofing. Although some are relatively dated, others are very pertinent to
current security concerns. IP-spoofing consists of several steps, which I will
briefly outline here, then explain in detail. First, the target host is chosen. Next, a
pattern of trust is discovered, along with a trusted host. The trusted host is then
disabled, and the target's TCP sequence numbers are sampled. The trusted host is
impersonated, the sequence numbers guessed, and a connection attempt is made to
a service that only requires address-based authentication. If successful, the
attacker executes a simple command to leave a backdoor.
This type of attack takes place when the attacker is on the same subnet as
the victim. The sequence and acknowledgement numbers can be sniffed,
eliminating the potential difficulty of calculating them accurately. The biggest
threat of spoofing in this instance would be session hijacking. This is
accomplished by corrupting the data stream of an established connection, then re-
establishing it based on correct sequence and acknowledgement numbers with the
attack machine. Using this technique, an attacker could effectively bypass any
authentication measures taken place to build the connection.
-8-
IP Spoofing Seminar Report
Usually the attacker does not have access to the reply, and abuses trust
relationship between hosts. For example:
Host C sends an IP datagram with the address of some other host (Host A)
as the source address to Host B. Attacked host (B) replies to the legitimate host
(A)
-9-
IP Spoofing Seminar Report
This is not easy in the Internet because of hop-by-hop routing, unless you
control one of the backbone hosts or source routing is used. This can also be done
combined with IP source routing option. IP source routing is used to specify the
route in the delivery of a packet, which is independent of the normal delivery
mechanisms. If the traffic can be forced through specific routes (=specific hosts),
and if the reverse route is used to reply traffic, a host on the route can easily
impersonate another host. The attack procedure could be:
-10-
IP Spoofing Seminar Report
Thus, when two hosts are desynchronized enough, they will discard
(ignore) packets from each other. An attacker can then inject forged packets with
the correct sequence numbers (and potentially modify or add commands to the
communication). Obviously, this requires the attacker to be located on the
communication path between the two hosts so that he may eavesdrop, in order to
replicate packets being sent. The key to this attack is creating the desynchronized
-11-
IP Spoofing Seminar Report
state. Joncheray describes two possible ways to do this: one is during the three-
way handshake, and the other is in the middle of an established connection.
Note that "ignored" packets may actually generate ACKs, rather than
being completely ignored. When the other end receives packets with incorrect
sequence numbers, it replies with an ACK packet containing the sequence number
it is expecting. But the receiver of these ACK discards them, as they have the
wrong sequence numbers! The receiver then sends its own ACK to notify the
sender... Thus, a large number of ACKs are generated in this attack. This
"signature" of the attack could be used to detect connection hijacking.
-12-
IP Spoofing Seminar Report
The attacker then replicates new packets, with the correct sequence
numbers, whenever A and B try to communicate. In doing so, the attacker may
also modify the messages or inject his own.
-13-
IP Spoofing Seminar Report
Generally the attack is made from the root account on the attacking host
against the root account on the target. If the attacker is going to all this trouble, it
would be stupid not to go for root. (Since root access is needed to wage the attack,
this should not be an issue.)
One often overlooked, but critical factor in IP-spoofing is the fact that
the attack is blind. The attacker is going to be taking over the identity of a trusted
host in order to subvert the security of the target host. The trusted host is disabled
using the method described below. As far as the target knows, it is carrying on a
-14-
IP Spoofing Seminar Report
conversation with a trusted pal. In reality, the attacker is sitting off in some dark
corner of the Internet, forging packets purportedly from this trusted host while it is
locked up in a denial of service battle. The IP datagrams sent with the forged IP-
address reach the target fine (recall that IP is a connectionless-oriented protocol--
each datagram is sent without regard for the other end) but the datagrams the
target sends back (destined for the trusted host) end up in the bit-bucket. The
attacker never sees them. The intervening routers know where the datagrams are
supposed to go. They are supposed to go the trusted host. As far as the network
layer is concerned, this is where they originally came from, and this is where
responses should go. Of course once the datagrams are routed there, and the
information is demultiplexed up the protocol stack, and reaches TCP, it is
discarded (the trusted host's TCP cannot respond-- see below). So the attacker has
to be smart and *know* what was sent, and *know* what reponse the server is
looking for. The attacker cannot see what the target host sends, but she can
*predict* what it will send; that coupled with the knowledge of what it *will*
send, allows the attacker to work around this blindness.
After a target is chosen the attacker must determine the patterns of trust
(for the sake of argument, we are going to assume the target host *does* in fact
trust somebody. If it didn't, the attack would end here). Figuring out who a host
trusts may or may not be easy. A 'showmount -e' may show where file systems
are exported, and rpcinfo can give out valuable information as well. If enough
background information is known about the host, it should not be too difficult. If
all else fails, trying neighboring IP addresses in a brute force effort may be a
viable option.
Once the trusted host is found, it must be disabled. Since the attacker is
going to impersonate it, she must make sure this host cannot receive any network
traffic and foul things up. There are many ways of doing this, the one I am going
to discuss is TCP SYN flooding.
-15-
IP Spoofing Seminar Report
-16-
IP Spoofing Seminar Report
The attacking host sends several SYN requests to the TCP port she desires
disabled. The attacking host also must make sure that the source IP-address is
spoofed to be that of another, currently unreachable host (the target TCP will be
sending it's response to this address. (IP may inform TCP that the host is
unreachable, but TCP considers these errors to be transient and leaves the
resolution of them up to IP (reroute the packets, etc) effectively ignoring them.)
The IP-address must be unreachable because the attacker does not want any host
to receive the SYN/ACKs that will be coming from the target TCP (this would
result in a RST being sent to the target TCP, which would foil our attack). The
process is as follows:
1 Z(x) ---SYN---> B
Z(x) ---SYN---> B
Z(x) ---SYN---> B
Z(x) ---SYN---> B
Z(x) ---SYN---> B
...
-17-
IP Spoofing Seminar Report
2 X <---SYN/ACK--- B
X <---SYN/ACK--- B
...
3 X <---RST--- B
At
(1) the attacking host sends a multitude of SYN requests to the target (remember
the target in this phase of the attack is the trusted host) to fill its backlog queue
with pending connections.
(2) The target responds with SYN/ACKs to what it believes is the source of the
incoming SYNs. During this time all further requests to this TCP port will be
ignored. Different TCP implementations have different backlog sizes. BSD
generally has a backlog of 5 (Linux has a backlog of 6). There is also a 'grace'
margin of 3/2. That is, TCP will allow up to backlog*3/2+1 connections. This
will allow a socket one connection even if it calls listen with a backlog of 0.
Now the attacker needs to get an idea of where in the 32-bit sequence number
space the target's TCP is. The attacker connects to a TCP port on the target
(SMTP is a good choice) just prior to launching the attack and completes the
-18-
IP Spoofing Seminar Report
three-way handshake. In this process, the attacker will save the value of the ISN
sent by the target host. Often times, this process is repeated several times and the
final ISN sent is stored. The attacker needs to get an idea of what the RTT (round-
trip time) from the target to her host is like. (The process can be repeated several
times, and an average of the RTT's is calculated.) The RTT is necessary in being
able to accurately predict the next ISN. The attacker has the baseline (the last ISN
sent) and knows how the sequence numbers are incremented (128,000/second and
64,000 per connect) and now has a good idea of how long it will take an IP
datagram to travel across the Internet to reach the target (approximately half the
RTT, as most times the routes are symmetrical). After the attacker has this
information, she immediately proceeds to the next phase of the attack (if another
TCP connection were to arrive on any port of the target before the attacker was
able to continue the attack, the ISN predicted by the attacker would be off by
64,000 of what was predicted). When the spoofed segment makes its way to the
target, several different things may happen depending on the accuracy of the
attacker's prediction:
If the sequence number is EXACTLY where the receiving TCP
expects it to be, the incoming data will be placed on the next available
position in the receive buffer.
If the sequence number is LESS than the expected value the data byte is
considered a retransmission, and is discarded.
If the sequence number is GREATER than the expected value but still
within the bounds of the receive window, the data byte is considered to be a
future byte, and is held by TCP, pending the arrival of the other missing
bytes. If a segment arrives with a sequence number GREATER than the
expected value and NOT within the bounds of the receive window the
segment is dropped, and TCP will send a segment back with the *expected*
sequence number.
Here is where the main thrust of the attack begins:
1 Z (b) ---SYN---> A
2 B <---SYN/ACK--- A
3 Z (b) ---ACK---> A
-19-
IP Spoofing Seminar Report
4 Z (b) ---PSH---> A
The attacking host spoofs her IP address to be that of the trusted host
(which should still be in the death-throes of the D.O.S. attack) and sends its
connection request to port 513 on the target (1). At 2), the target responds to the
spoofed connection request with a SYN/ACK, which will make its way to the
trusted host (which, if it *could* process the incoming TCP segment, it would
consider it an error, and immediately send a RST to the target). If everything goes
according to plan, the SYN/ACK will be dropped by the gagged trusted host.
After (1), the attacker must back off for a bit to give the target ample time to send
the SYN/ACK (the attacker cannot see this segment). Then, at (3) the attacker
sends an ACK to the target with the predicted sequence number (plus one, because
we're ACKing it). If the attacker is correct in her prediction, the target will accept
the ACK. The target is compromised and data transfer can commence (4).
Generally, after compromise, the attacker will insert a backdoor into the
system that will allow a simpler way of intrusion. (Often a `cat + + >> ~/.rhosts` is
done. This is a good idea for several reasons: it is quick, allows for simple re-
entry, and is not interactive. Remember the attacker cannot see any traffic coming
from the target, so any responses are sent off into oblivion.)
-20-
IP Spoofing Seminar Report
-21-
IP Spoofing Seminar Report
-22-
IP Spoofing Seminar Report
Another problem is that many ISPs do not have the technical ability to
arrange packet filtering to block packets with spoofed source addresses. Also,
packet filtering reduces equipment performance.
If your site has a direct connection to the Internet, you can use your router
to help you out. First make sure only hosts on your internal LAN can participate
in trust-relationships (no internal host should trust a host outside the LAN). Then
simply filter out *all* traffic from the outside (the Internet) that purports to come
from the inside (the LAN).
-23-
IP Spoofing Seminar Report
Since the sequence numbers are not chosen randomly (or incremented
randomly) this attack works. Bellovin describes a fix for TCP that involves
partitioning the sequence number space. Each connection would have it's own
separate sequence number space. The sequence numbers would still be
incremented as before, however, there would be no obvious or implied
relationship between the numbering in these spaces. Suggested is the following
formula:
ISN=M+F(localhost,localport,remotehost,remoteport)Where M is the 4
microsecond timer and F is a cryptographic hash. F must not be computable from
the outside or the attacker could still guess sequence numbers. Bellovin suggests
F be a hash of the connection-id and a secret vector (a random number, or a host
related secret combined with the machine's boot time).
-24-
IP Spoofing Seminar Report
6. APPLICATIONS OF IP SPOOFING
-25-
IP Spoofing Seminar Report
-26-
IP Spoofing Seminar Report
First we make the request (1) (using our Internet connection) to the Sat-
Server, after it retrieves out info from Internet (2) it will send it to Satellite (3); in
the end we would receive data from the satellite(4) to our home using a parabolic
antenna and a Sat Card.
-27-
IP Spoofing Seminar Report
DSL connection setup. With certain setup and an IP address spoofing
technique, a user can connect to AOL DSL ISP, and download as much data as
he wants using this connection without paying any cent. This picture depicts
such setup and how the attack works.
1. On first network interface, the user dials for a DSL connection to T-Online or
other ISPs using his account. The user can send and receive data with this
connection.
2. On second network interface, the user dials to AOL DSL ISP using a free
public account to establish a DSL connection that goes one way from ISP to
user.
3. Before the user sends packet through T-Online connection, he spoofs the
source IP address of the packet into the IP address of the second network
interface (which is connected to AOL DSL)
4. And so he sends requests through T-Online connection, and receives response
through AOL DSL connection. This way the user only needs to pay for every
bits he sends to T-Online, and get for free every bits he receives from AOL
DSL, which would have cost a lot more than the cost for sending bits, because
people usually spend more time downloading from the internet instead of
sending data to the internet.
-28-
IP Spoofing Seminar Report
6.3 NAT
• Multiple Servers
Sometimes you want to change where packets heading into your network
will go. Frequently this is because (as above) you have only one IP address, but
you want people to be able to get into the boxes behind the one with the `real' IP
address. If you rewrite the destination of incoming packets, you can manage this.
This type of NAT was called port-forwarding. A common variation of this is load-
sharing, where the mapping ranges over a set of machines, fanning packets out to
them.
-29-
IP Spoofing Seminar Report
• Transparent Proxying
Sometimes you want to pretend that each packet which passes through
your Linux box is destined for a program on the Linux box itself. This is used to
make transparent proxies: a proxy is a program which stands between your
network and the outside world, shuffling communication between the two. The
transparent part is because your network won't even know it's talking to a proxy,
unless of course, the proxy doesn't work. NAT has two different types: Source
NAT (SNAT) and Destination NAT (DNAT). Source NAT is when you alter the
source address of the first packet: i.e. you are changing where the connection is
coming from. Source NAT is always done post-routing, just before the packet
goes out onto the wire. Masquerading is a specialized form of SNAT.
Destination NAT is when you alter the destination address of the first
packet: i.e. you are changing where the connection is going to. Destination NAT is
always done before routing, when the packet first comes off the wire. Port
forwarding, load sharing, and transparent proxying are all forms of DNAT.
Fig. NAT
-30-
IP Spoofing Seminar Report
6.4 IP Masquerade
-31-
IP Spoofing Seminar Report
Fig. IP Masquerading
-32-
IP Spoofing Seminar Report
4) hunt
hunt is a sniffer which also offers many spoofing functions.
5) dsniff
dsniff is a collection of tools for network auditing and penetration
testing. dsniff, filesnarf, mailsnarf, msgsnarf, urlsnarf, and webspy
passively monitor a network for interesting data (passwords, e-mail,
files, etc.). arpspoof, dnsspoof, and macof facilitate the interception of
network traffic.
-33-
IP Spoofing Seminar Report
7. CONCLUSION
-34-
IP Spoofing Seminar Report
8. REFERENCES
Following the Journey of a Spoofed Packet
http://www.scs.carleton.ca/~dlwhyte/whytepapers/ipspoof.htm
NAT and Networks
http://www.suse.de/~mha/linux-ip-nat/diplom/node4.html
Asymmetric routing - Jani Lakkakorpi
http://keskus.hut.fi/tutkimus/ipana/paperit/QoSR/S130-QoSR-asymmetric.pdf
TCP/IP protocol suite - Thomas Toth
http://www.infosys.tuwien.ac.at/Teaching/Courses/InetSec/slides/slides2.pdf
Security problems in the TCP/IP protocol suite, S.M. Bellovin, AT&T Bell
Laboratories, Murray Hill, New Jersey 07974
http://www.research.att.com/~smb/papers/ipext.pdf
Linux 2.4 NAT HOWTO
http://www.netfilter.org/unreliable-guides/NAT-HOWTO/
Linux IP Masquerade HOWTO
http://www.tldp.org/HOWTO/IP-Masquerade-HOWTO/index.html
Linux 2.4 Advanced Routing HOWTO
http://www.linuxdocs.org/HOWTOs/Adv-Routing-HOWTO.html
Introduction To Network Address Translation (NAT)
http://www.firewall.cx/nat-intro.php
Network Address Translation (NAT/ PAT/ IP Masquerading)
http://home.t-online.de/home/TschiTschi/ip_masquerading.htm
Attacks over the internet
http://zork.net/~phil/Cracking/Internet.html
IP spoofing
http://bear.cba.ufl.edu/teets/projects/ISM6222F102/perryna/index.html
-35-