System: Emulating an HTTP/1.1 Request using Telnet
It's actually very simple using Telnet to connect to a webserver and download HTML or other files.
First you need to connect to the server using an IP address or hostname:
$ telnet XXX.XX.XX.XXX 80
Then request the page you want. HEAD and GET are the most common options. HEAD will return information about the requested file/page, but not the content. GET will retrieve both the Header information as well as the content, terminated with 0.
Following the HEAD/GET command you need to specify HTTP/1.1. Then on the next line specify the Host domain name. HTTP/1.1 allows for multiple domains to be hosted at a single IP address so this is important. The User-Agent and other options can be specified on subsequent lines.
GET / HTTP/1.1<Enter> Host: www.example.com<Enter> User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)<Enter> <Enter>
The command is executed after a blank line is entered (press Enter twice).
Enter an IP address, Hostname and Request URI in the form below and it will make a HEAD request to the server in question and display the results:
Note: For security we've limited the inputs to this script. Only valid IPv4 IP addresses are accepted for the Server IP. The Hostname field accepts letters, numbers, hyphens and periods. The Request field also accepts the forward slash, and must (obviously) start with one.
If no output appears below then the server didn't respond within 5 seconds.
Requesting a secure (HTTPS) address
To request a page from a secure (SSL) server on port 443 you can use openssl instead of telnet. Other than that the method is the same:
$ openssl s_client -connect XXX.XX.XX.XXX:443 -crlf ... connection information will be displayed ... GET / HTTP/1.1<Enter> Host: www.example.com<Enter> <Enter>
This is useful for testing whether a web server certificate has been installed properly without having to update the DNS before you can check. The -crlf option will convert your <Enter> into "\r\n".
To open an SSL connection to a live website you should always connect using the domain name and not the ip address.