______________________________________________________________ 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!
Yahoo! Auctions
Pokemon, cars, 'N Sync
Yahoo! MessengerYahoo! Mail
free email for life
advanced search
Shopping - Auctions - Yellow Pages - People Search - Maps - Travel - Classifieds - Personals - Games - Chat - Clubs
Mail - Calendar - Messenger - Companion - My Yahoo! - News - Sports - Weather - TV - Stock Quotes - more...
Yahoo! Shopping - Thousands of stores. Millions of products.
· Apparel
· Bath/Beauty
· Computers
· Electronics
· Flowers
· Sports
· Music
· Video/DVD
· Eddie Bauer
· Ashford
· Toys R Us
· Nordstrom
· 'N Sync
· Digital cameras
· Pokemon
· MP3 players
Arts & Humanities
Literature, Photography...

Business & Economy
Companies, Finance, Jobs...

Computers & Internet
Internet, WWW, Software, Games...

College and University, K-12...

Cool Links, Movies, Humor, Music...

Elections, Military, Law, Taxes...

Medicine, Diseases, Drugs, Fitness...
News & Media
Full Coverage, Newspapers, TV...

Recreation & Sports
Sports, Travel, Autos, Outdoors...

Libraries, Dictionaries, Quotations...

Countries, Regions, US States...

Animals, Astronomy, Engineering...

Social Science
Archaeology, Economics, Languages...

Society & Culture
People, Environment, Religion...
In the News
·Reno says Elian to be returned to father
·Zimba bwe land seizures continue
·The Masters, MLB, NBA
·Y! Tax Center - tax guide, online filing, and more
·Y! Business Marketplace - products for all industries
·Free 56K Internet Access
·Yahoo! Bill Pay - free 3-month trial
Inside Yahoo!
·Y! Movies - showtimes, reviews, info
·Yahoo! Photos - upload, share, and print pictures
·Play free Fantasy Baseball
·Yahoo! GeoCities - build your free home page
World Yahoo!sEurope : Denmark - France - Germany - Italy - Norway - Spain - Sweden - UK & Ireland
Pacific Rim : Asia - Australia & NZ - China - Chinese - HK - Japan - Korea - Singapore - Taiwan
Americas : Argentina - Brazil - Canada - Mexico - Spanish
Yahoo! Get LocalLA - NYC - SF Bay - Chicago - more...    
OtherAutos - Careers - Digital - Entertainment - Event Guide - Greetings - Health - Invites - Net Events
Message Boards - Movies - Music - Real Estate - Small Business - Y! Internet Life - Yahooligans!
Yahoo! prefers
How to Suggest a Site - Company Info - Privacy Policy - Terms of Service - Contributors - Openings at Yahoo!

Copyright © 2000 Yahoo! Inc. All rights reserved.
Copyright Policy

The get method gives the HTML source of the document requested.It seems just as if you are seeing the source by clicking View> Source. Similiarly you can see what happens when you issue the 'PUT' and 'Head' methods.Just replace 'Get' with the Method that you want to use.For Example, head / http/1.1 and put/ http/1.1 **************** Hacking Truth: Let's go back to the response that we got from the HTTP daemon once the HTTP Get method was okayed at Yahoo.The first line of the response was: HTTP/1.0 200 OK Now what does this 200 signify? Well the '200' is called the status code.Whenever you give the server a HTTP command, it processes the command and accrodingly displays a status code.A status code is a 3 digit code in the form of xxx. Status codes start from 1xx to 5xx.I am not sure what the 1xx series signifies as they are rarely used.The 2xx series signify a succssful completion of the HTTP command given.The 3xx series signify errors due to moving of documents.The 4xx series signify errors caused at browser side and finally the 5xx series signify errors at the server side. The most common status code that you come across, but may not have ever see is the 200 OK status code.Each time you are able to see a page on the browser successfully, the browser has been sent this status code by the HTTP daemon. The most common errors that you might come across and actually see would be the 404 Error---Not Found. This error emssage means that the Url that you tying to access is not found, it has either been moved or has been deleted or the linking of the web pages itself has not been done properly.I can go to the up directory to look for the exact new changed URL. *************** Ankit Fadia ankit@bol.net.in To receive more tutorials on Hacking, Perl, C++ and Viruses/Trojans join my mailing list: Send an email to programmingforhackers-subscribe@egroups.com to join it. Visit my Site to view all tutorials written by me at: http://www.crosswinds.net/~hackingtruths