By Farha Ali, Lander University: IP Spoofing
By Farha Ali, Lander University: IP Spoofing
By Farha Ali, Lander University: IP Spoofing
Spoofing an IP Datagram
IP packets are used in applications that use the Internet as their communications
medium. Usually they are generated automatically for the user, behind the
scenes; the user just sees the information exchange in the application. These IP
packets have the proper source and destination addresses for reliable exchange of
data between two applications. The IP stack in the operating system takes care of
the header for the IP datagram. However, you can override this function by
inserting a custom header and informing the operating system that the packet
does not need any headers. You can use raw sockets in UNIX-like systems to
send spoofed IP datagrams, and you can use packet drivers such as WinPcap on
Windows . Some socket programming knowledge is enough to write a program
for generating crafted IP packets. You can insert any kind of header, so, for
example, you can also create Transmission Control Protocol (TCP) headers. If
you do not want to program or have no knowledge of programming, you can use
tools such as hping, sendip, and others that are available for free on the Internet,
with very detailed documentation to craft any kind of packet. Most of the time,
you can send a spoofed address IP packet with just a one-line command.
Scanning
An attacker generally wants to connect to a host to gather information about open
ports, operating systems, or applications on the host. The replies from the victim
host can help the attacker in gathering information about the system.
These replies might indicate open ports, the operating system, or several
applications running on open ports. For example, a response for connection at
port 80 indicates the host might be running a Web server. The hacker can then try
to telnet to this port to see the banner and determine the Web server version and
type, and then try to exploit any vulnerability associated with that Web server. In
the scanning case, attackers want to examine the replies coming back from the
host, so they need to see the returned packet. If the spoofed address is actually an
address of a host on the attacker's subnet, then the attacker can use a sniffer to see
the packets.
Sequence-Number Prediction
If you establish the connection between two hosts by using TCP, the packets
exchanged between the two parties carry sequence numbers for data and
acknowledgments. The protocol uses these numbers to determine out-of-order
and lost packets, thus ensuring the reliable delivery to the application layer as
promised by TCP. These numbers are generated pseudo-randomly in a manner
known to both the parties. An attacker might send several spoofed packets to a
victim to determine the algorithm generating the sequence numbers and then use
that knowledge to intercept an existing session. Again it is important for the
attacker to be able to see the replies.
Denial of Service
The connection setup phase in a TCP system consists of a three-way handshake .
This handshake is done by using special bit combinations in the "flags" fields. If
host A wants to establish a TCP connection with host B, it sends a packet with a
SYN flag set. Host B replies with a packet that has SYN and ACK flags set in the
TCP header. Host A sends back a packet with an ACK flag set, finishing the
initial handshake. Then hosts A and B can communicate with each other, as
shown in Figure 2.
Figure 2: A Normal TCP Connection Request from A to B
The three-way handshake must be completed in order to establish a connection.
Connections that have been initiated but not finished are called half-open
connections. A finite-size data structure is used to store the state of the half-open
connections. An attacking host can send an initial SYN packet with a spoofed IP
address, and then the victim sends the SYN-ACK packet and waits for a final
ACK to complete the handshake. If the spoofed address does not belong to a
host, then this connection stays in the half-open state indefinitely, thus occupying
the data structure. If there are enough half-open connections to fill the state data
structure, then the host cannot accept further requests, thus denying service to the
legitimate connections (Figure 3).
Flooding
In this type of attack an attacker sends a packet with the source address of the
victim to multiple hosts. Responses from other machines flood the victim. For
example, if an attacker uses the IP address of source A and sends a broadcast
message to all the hosts in the network, then all of them will send a reply back to
A, hence flooding it. The well-known Smurf and fraggle attacks used this
technique.
Another method is to check the Time to Live (TTL) value of the packet, and then
send a request to the spoofed host. If the reply comes, you can compare the TTL
of both packets. Most probably the TTL values will not match. But of course it is
also possible that these TTL values are the same but the packet is coming from a
different source, and conversely. Packets generated by different operating
systems differ slightly in values of certain fields; for example, in Internet Control
Message Protocol (ICMP) ping packets, you can examine the data payload to
determine the operating system. Windows fills the packet with letters of the
alphabet, whereas Linux puts numbers in the data portion. If the suspicious
packet does not have the same characteristics as the legitimate packet, that is
evidence it was not sent from the IP address that is in its source address field.
You can also use IP identification numbers to determine whether a packet is
actually coming from the said source. For legitimate packets the IP ID is close in
value, but this method is not reliable because the attacker can ping the said
source and determine the IP ID that it is using, and then craft packets that will
seem legitimate. In all these techniques we are trying to determine only whether
or not a packet is spoofed, and taking all these steps for all packets would be
prohibitive from an overhead standpoint. Thus you should either randomly check
packets or determine some suspicious activity that would trigger further
investigation for spoofed-packet detection. The next section addresses measures
you can take to trace a spoofed packet back to its real source.
When a node detects that it is a victim of flood attack, it can inform the Internet
Service Provider (ISP). In flood attacks the ISP can determine the router that is
sending this stream to the victim, and then it can determine the next router, and
so on. It reaches either to the source of the flood attack or the end of its
administrative domain; for this case it can ask the ISP for the next domain to do
the same thing. This technique is useful only if the flood is ongoing.
As mentioned earlier, a router has an idea of the IP addresses that should be
arriving at its interfaces. If it sees any packet that does not seem to belong to the
address range for its interface, it can log the packet as suspicious. Appropriately
timed broadcasts among different domains to detect spoofed packets can help
administrators of different networks trace spoofed IP packets back to their
source.
Conclusion
IP spoofing is a difficult problem to tackle, because it is related to the IP packet
structure. IP packets can be exploited in several ways. Because attackers can hide
their identity with IP spoofing, they can make several network attacks. Although
there is no easy solution for the IP spoofing problem, you can apply some simple
proactive and reactive methods at the nodes, and use the routers in the network to
help detect a spoofed packet and trace it back to its originating source.
References
[1] Alaaeldin A. Aly, "Tracking and Tracing Spoofed IP Packets to Their
Sources," Proceedings of 6th annual conference, UAEU April 2005.
[2] S.J. Templeton and K.E. Levitt, "Detecting Spoofed Packets," DARPA
Information Survivability Conference and Exposition, 2003.