______________________________________________________________ HTTP Torn Apart, By Ankit Fadia. ankit@bol.net.in ______________________________________________________________ Published on BSRF - http://blacksun.box.sk Secret subliminal message: visit BSRF, NOW!! What exactly happens when you type a URL(Uniform Resource Locator) in the location bar of the browser? Well firstly the browser performs a DNS queiry and converts the human readable domain name (like hotmail.com) into a machine readable IP address. Once the browser gets the IP address of the host, it connects to Port 80(The HTTP daemon by default runs on Port 80) of the remote host and asks the host for a particular document or page with the help of HTTP commands. HTTP or HyperText Transfer Protocol is the protocol used by browsers to communicate with hosts i.e. to ask for a particular file at a specific URL or to send or post data to the server.We are never aware of this process which occurs in the background. Now in this section we will learn to do manually what the browser does automatically.When the browser asks for a file at a specific URL it is said to 'request' for information. Now before we move on, let's see what a typical request looks like. A typical HTTP request would be something like the below: get url HTTP/1.1 Let's see what the specific parts of a typical request stands for.The first word i.e. the 'get' part is called the method.There are 3 types of methods-: The Get method The 'get' method is the most common method which is widely used.It is with the 'get' method that the browsers request for pages or douments.In this kind of method you are the client(browser) and request for a page from the server which is the host you are connected to. The Post Method The 'post' method is used to upload files to the server.This kind of method is used say when you upload your website by using not the FTP service but by straightaway uploading files through a HTML page.In this method there is a reversal of roles and now you become the server and the host you are connected to becomes the client. The Head Method The 'head' method is the least popular method and not many people know about it.Although not widely used, it is still a part of HTTP methods. You would use the 'head' method say when you want to make sure that a particualar file exists at a particular URL without downloading the entire file.This method just downloads the header info of a particular file and not the entire file. All this might seem a bit weird, but I suggest that you just understand the basic difference between the various methods and then move on. Anyway coming back to the various parts of a HTTP request.The first part as you now know is the method, now the second part is the URL that you are requesting.Say for example I want to request the contacts.htm file then the HTTP request would look something like: get /contacts.htm HTTP/1.1 Now you may ask where the first '/' has come from. Now to understand that you need to look at the URL that you type into the Location bar of the browser.Say for example, the HTML file that you are requesting is http://www.microsoft.com/windows.htm then the URL would be what is left after removing the http:// and the domain name i.e. www.microsoft.com. Hence the URL is /windows.htm Now what will the URL be if you want to request for Yahoo homepage? Normally you write http://www.yahoo.com in the location bar to access Yahoo's homepage. Now if we remove the http:// and also the domain name(www.yahoo.com) then what is left? Nothing. This means the URL of the HTTP request is '/'. Hence the HTTP request now looks like. get / HTTP/1.1 The third part of the HTTP request is pretty self explanatory.The HTTP/1.1 specifies the version of the HTTP service used by the browser.So say if a server is running HTTP/1.1 and a browser which is running HTTP/1.0 requests a page then the server will send the page in terms of HTTP/1.0 only removing the enhancements of HTTP/1.1 So now that you know what a normal HTTP request sent by your browser looks, let's find out how we can do this manually.This too requires Telnet.Now you know how important the Telnet client is in a Hacker's armoury.So launch your Telnet client and connect to Port 80(As the HTTP daemon runs on Port 80) of any host.If the host you are trying to connect to does not have a website i.e does not have Port 80 open, then you would get a Error Message.If the connection is successful then the Title bar of your Telnet client will show the host address you are connected to and it will be ready for user input. The HTTP daemon is not as boring as it seems to be till now.Infact it is very very interesting.Once telnet is ready for input just type h (or any other letter) and hit enter twice. *********** Hacking Truth: After each HTTP command one has to press Enter Twice to send the command to the server or to bring about a response from a server.It is just how the HTTP protocol works. ********** Now as 'h' or any other command that you typed is not a valid HTTP command, the server will give you an error message, something like the below: HTTP/1.1 400 Bad Request Server: Netscape-Enterprise/3.5.1 The server replies with the version of HTTP it is running(not so important), it gives us an error message and the error code associated with it(again not so important), but it also gives us the OS name and OS version, it is running.Wow!!! It gives hackers who want to break into their server the ultimate piece of information which they require. Anyway now let's see what happens when we give a normal authentic request requesting for the main page of Yahoo.So after I telnet to Port 80 of www.yahoo.com I give the command: get / http/1.1 (requesting for the Yahoo Homepage) HTTP/1.0 200 OK Content-Length: 12085 Content-Type: text/html (No OS name,interesting, well Yahoo being a Top Web Company has configured their server to not display the OS name and Version when an HTTP request is encountered.)
Yahoo! prefers |
Copyright © 2000 Yahoo! Inc. All
rights reserved.
Copyright
Policy