Saturday, September 15, 2007, 10:31 AM -
Tips and Tricks
As promised in my post on
Thoughts on password management here is a step by step guide on how someone can capture your login id and password while you login into a website that does not support HTTPS (HTTP over SSL).
A little basics first. HTTP protocol is based on clear text interchange of data. It is an application layer protocol with TCP and IP in the underlying layer. It means that anybody who can capture a HTTP packet traveling over an Ethernet network can read all information you sent.
When you type
http://blog.netotto.com/index.php, your browser sends the following request:
GET / HTTP/1.1\r\n
Request Method: GET
Request URI: /index.php
Request Version: HTTP/1.1
Accept: */*\r\n
Accept-Language: en-us\r\n
Accept-Encoding: gzip, deflate\r\n
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n
Host: blog.netotto.com\r\n
Connection: Keep-Alive\r\n
This is a HTTP GET request, the important part is just the
GET and the
Host lines. The server responds to this again in clear text, that your browser can understand. Here is how it looks:
HTTP/1.1 200 OK\r\n
Request Version: HTTP/1.1
Response Code: 200
Date: Sat, 15 Sep 2007 10:41:22 GMT\r\n
Server: Apache/2.0.54 (Unix) PHP/4.4.7 mod_ssl/2.0.54 OpenSSL/0.9.7e mod_fastcgi/2.4.2 DAV/2 SVN/1.4.2\r\n
X-Powered-By: PHP/5.2.3\r\n
Expires: Thu, 19 Nov 1981 08:52:00 GMT\r\n
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\n
Pragma: no-cache\r\n
Vary: Accept-Encoding\r\n
Content-Encoding: gzip\r\n
Content-Length: 6611\r\n
Keep-Alive: timeout=2, max=100\r\n
Connection: Keep-Alive\r\n
Content-Type: text/html\r\n
\r\n
Content-encoded entity body (gzip): 6611 bytes -> 26607 bytes
This is followed by the HTML page (index.html) in clear text.
If you are at the login page of a non-secure web page your login and passwords can easily be read by somebody on the network. All you need is a network packet capturing tool.
On an Ethernet, the electrical signals (to which your HTTP packet finally resolves to while traveling on the wire) is actually readable by all the computers in your Ethernet LAN. The network card in normal operation mode (called non-promiscuous mode) does not read packets that are destined for somebody else.
A packet capturing tool like
Ethereal can ask your network card to be in
promiscuous mode and read all packets. These includes packets destined for other machines in your LAN.
You can download and install Ethereal for Windows from the
Ethereal Download Page and install it and follow the following steps to convince yourself that sending data over a non-secure channel (a non HTTPS website for example) is very un-safe.
Lets jump straight into the steps:
In this example, I have installed Ethereal on the same computer from where I will be attempting to login to a non-ssl website like
www.youtube.com . You can however run the Browser and Ethereal on different computers in your LAN which are in the same subnet (Eg: Browser on your computer at office and Ethereal on your colleague's computer).
1. Open the youtube login page (
http://youtube.com/login?next=/index) in your browser. Note: its http and not https. I type in "shuva" and password as "testpassword"
2. Start Ethereal (I am using version 0.99.0)
3. Lets configure it so that it captures only HTTP packets. We dont want to capture hundreds of other packets. From the menu bar, select Capture--->Options. In the Options dialog box, choose the correct n/w interface if you have more than one. I have something like "Intel Pro/100 VE". In the capture filter type in "tcp port http". This means we will capture only http packets.
4. Click the start button to start the capture.
5. Click on the login button on your browser.
6. Back to Ethreal, click the stop button on the popped up dialog box.
The Ethereal window is divided into 3 parts,
the upper part listing the packets,
the middle part showing the selected packet in human readable form and properly divided into the layers (HTTP/TCP/IP/Ethernet/Frame) and
the lower part showing the raw bytes of the selected packet.
In the upper part, where you many lines with lots of IP addresses, search for the line that has "
HTTP" and "
POST /login?"
In the middle part click on "+" sign that says "Line-based text data". There is your login and the password. Just above the "Line-based text data" is the HTTP request that you sent to youtube.
Here is a screen shot:

Below is the HTTP request that went through the network:
POST /login?next=/index HTTP/1.1\r\n
Request Method: POST
Request URI: /login?next=/index
Request Version: HTTP/1.1
Host: youtube.com\r\n
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6\r\n
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n
Accept-Language: en-us,en;q=0.5\r\n
Accept-Encoding: gzip,deflate\r\n
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n
Keep-Alive: 300\r\n
Connection: keep-alive\r\n
Referer: http://youtube.com/login?next=/index\r\n
Cookie: dkv=; GEO=a78121630c1e9382b3cf8d384cd0d399cxYAAABJTixhcCxoeWRlcmFiYWQsLCwsLC0x; LOCALE_PREFERENCE=86d1d09eefe6b79b4068000ce05518a4dAUAAABlbl9VUw==; LOGIN_INFO=; VISITOR_INFO1_LIVE=D6Jub46OfWo; use_hitbox=72c46ff6cbcdb7c5585c36411b6
Content-Type: application/x-www-form-urlencoded\r\n
Content-Length: 93\r\n
\r\n
current_form=loginForm&next=%2Findex&username=shuva&password=testpassword&action_login=Log+In
Disclaimer: My selection of youtube.com for this demo is not to prove that youtube.com is unsafe. I just wanted a very well known website. My intention of writing this article is not to encourage people to read somebody's else packet from the network but to demonstrate to users that visits to non-secure sites are not safe and you should therefore never select a password for such sites which you are reusing for a secure site like your email or banking sites. Relevant posts:
1.
Thoughts on password management.2.
Storing all your password safely.