What Everybody Ought to Know About Session Hijacking
Friday, 1 March 2013
When comes to hacking, most of the people think that they are safe now and are aware of many hacking techniques like phishing , key-logging and other amateur hacking tricks.
But many would have fallen into a trap called Session Hijacking which they would have never realized so far…..
What is Session Hijacking?
Websites are prone to Session hijacking when it uses any login system for authentication.
Sessions are usually created on the server side of the web, to hold a status whether a user is currently logged in to the site and he is currently active.
This provision is generally given to all sites by web developers. But, the intruders use this technique for their favour.
Sessions generally uses cookies to save its information. Cookie is a piece of text stored on user computer by websites visited by the user.
This stored cookie is used by webserver to identify and authenticate the user while login.
So, if this cookie gets stolen by hackers and injected into their browser, they can imitate our identity to web-server and enter our Email account easily. This is called Session Hijacking or Cookie stealing hack of an user ID in a Web application.
Session Hijacking too can be done in Network level which is explained below …
How does an attacker go about hijacking a session in a network ? The hijack can be broken down into four broad phases.
1.Tracking the connection :
The attacker will wait to find a suitable target and host. He use a network sniffer to track the victim and host or identify a suitable user by scanning with a scanning tool such as nmap to find a target with a trivial TCP sequence prediction.
This is done to ensure that because the correct sequence and acknowledgement numbers are captured, as packets are checked by TCP through sequence and/or acknowledgement numbers.
These will later be used by the attacker in crafting his own packets.
2.Desynchronizing the connection
A desynchronized state is when a connection between the target and host is in the established state; or in a stable state with no data transmission; or the server’s sequence number is not equal to the client’s acknowledgement number; or the clients sequence number is not equal to the server’s acknowledgement number. To desynchronize the connection between the target and host, the sequence number or the acknowledgement number (SEQ/ACK) of the server must be changed. This can be done if null data is sent to the server so that the server’s SEQ/ACK numbers will advance; while the target machine will not register such an increment.
The desynchronizing is preceded by the attacker monitoring the session without interference till an opportune moment, when he will send a large amount of ” null data” to the server. This data serves only to change the ACK number on the server and does not affect anything else. The attacker does likewise to the target also. Now both the server and target are desynchronized.
3.Resetting the connection
Another approach is to send a reset flag to the server and tearing down the connection on the server side. This is ideally done in the early setup stage. The goal of the attacker is to break the connection on the server side and create a new one with different sequence number.
The attacker listens for a SYN/ACK packet from the server to the host. On detecting the packet, he sends an RST to the server and a SYN packet with exactly the same parameters such as port number but a different sequence number.
The server on receiving the RST packet, closes connection with the target, but initiates another one based on the SYN packet – with a different sequence number on the same port. Having opened a new connection, the server sends a SYN/ACK packet to the target for acknowledgement.
The attacker detects (but does not intercept) this and sends back an ACK packet to the server. Now, the server is in the established state.
The target is oblivious to the conversation and has already switched to the established state when it received the first SYN/ACK packet from the server. Now both server and target are in desynchronized but established state.
This can also be done using a FIN flag, but this will cause the server to respond with an ACK and give away the attack through an ACK storm.
This results due to a flaw in this method of hijacking a TCP connection. When receiving an unacceptable packet the host acknowledges it by sending the expected sequence number and using its own sequence number.
This packet is itself unacceptable and will generate an acknowledgement packet which in turn will generate an acknowledgement packet, thereby creating a supposedly endless loop for every data packet sent.
The mismatch in SEQ/ACK numbers results in excess network traffic with both the server and target trying to verify the right sequence. Since these packets do not carry data they are not retransmitted if the packet is lost.
However, since TCP uses IP the loss of a single packet puts an end to the unwanted conversation between the server and target on the network.
The desynchronizing stage is added in the hijack sequence so that the target host is kept in the dark about the attack.
Without desynchronizing, the attacker will still be able to inject data to the server and even keep his identity by spoofing an IP address. However, he will have to put up with the server’s response being relayed to the target host as well.
4.Injecting the attacker’s packet
Now that the attacker has interrupted the connection between the server and target, he can choose to either inject data into the network or actively participate as the “man in the middle”, and pass data from the target to the server, and vice versa, reading and injecting data as he sees fit.
Illustration:
- Ram opens a telnet session to Noor and starts doing some work.
- Badhri observes the connection between Ram and Noor using a sniffer that is integrated into his hijacking tool. Badhri makes a note of Ram’s IP address and his hijacking software samples the TCP sequence numbers of the connection between Ram and Noor.
- Badhri launches a DoS attack against Ram to stop Ram doing further work on Noor and to prevent an ACK storm from interfering with his attack.
- Badhri generates spoofed packets with the correct TCP sequence numbers and connects to Noor.
- Noor thinks that he is still connected to Ram.
- Ram notices a lack of response from Noor and blames it on the network.
- Badhri finds himself at a root prompt on Noor. He issues some commands to make a backdoor and uses the sniffer to observe the responses from Noor.
- After covering his tracks, Badhri logs out of Noor and ceases the DoS attack against Ram.
- Ram notices that his connection to Noor has been dropped.
- Badhri uses his backdoor to get directly into Noor.
-Hope this article gave you a clear idea on session hijacking.
Thank you.
Posted by
droided.dev
at
06:20
0 comments:
Subscribe to:
Post Comments (Atom)
