16.01.2015 Views

Hacking

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

From /etc/services<br />

finger 79/tcp # Finger<br />

finger 79/udp<br />

http 80/tcp www www-http # World Wide Web HTTP<br />

HTTP exists in the application layer—the top layer—of the OSI model.<br />

At this layer, all of the networking details have already been taken care of by<br />

the lower layers, so HTTP uses plaintext for its structure. Many other<br />

application layer protocols also use plaintext, such as POP3, SMTP, IMAP,<br />

and FTP’s control channel. Since these are standard protocols, they are all<br />

well documented and easily researched. Once you know the syntax of these<br />

various protocols, you can manually talk to other programs that speak the<br />

same language. There’s no need to be fluent, but knowing a few important<br />

phrases will help you when traveling to foreign servers. In the language of<br />

HTTP, requests are made using the command GET, followed by the resource<br />

path and the HTTP protocol version. For example, GET / HTTP/1.0 will request<br />

the root document from the webserver using HTTP version 1.0. The request<br />

is actually for the root directory of /, but most webservers will automatically<br />

search for a default HTML document in that directory of index.html. If the<br />

server finds the resource, it will respond using HTTP by sending several<br />

headers before sending the content. If the command HEAD is used instead of<br />

GET, it will only return the HTTP headers without the content. These headers<br />

are plaintext and can usually provide information about the server. These<br />

headers can be retrieved manually using telnet by connecting to port 80 of a<br />

known website, then typing HEAD / HTTP/1.0 and pressing ENTER twice. In the<br />

output below, telnet is used to open a TCP-IP connection to the webserver at<br />

http://www.internic.net. Then the HTTP application layer is manually<br />

spoken to request the headers for the main index page.<br />

reader@hacking:~/booksrc $ telnet www.internic.net 80<br />

Trying 208.77.188.101...<br />

Connected to www.internic.net.<br />

Escape character is '^]'.<br />

HEAD / HTTP/1.0<br />

HTTP/1.1 200 OK<br />

Date: Fri, 14 Sep 2007 05:34:14 GMT<br />

Server: Apache/2.0.52 (CentOS)<br />

Accept-Ranges: bytes<br />

Content-Length: 6743<br />

Connection: close<br />

Content-Type: text/html; charset=UTF-8<br />

Connection closed by foreign host.<br />

reader@hacking:~/booksrc $<br />

208 0x400

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!