HTTP Protocol

The web is run on port 80. You are probably wondering what “port 80” is, right (whether you actually are or not is irrelevant)? Well, the answer is easy (not really). See, the Internet and the web are different. The Internet is the infrastructure (ie the physical wires, the server hardware, etc) and the web is the ideas and the software. I say ideas because before the web the Internet was a mess of wires and powerful computers using POP3 and SMTP for communication, FTP for file transfer, and TELNET for remote shell access, among others. Then the web came along, and Internet use spread to the home and all across the world. See, in plain terms, a web server broadcasts HTML to all connected clients on port 80, so port 80 is the “HTTP port.” HTTP is the protocol, or set of standards for port 80 and its software. The client software is your browser, (ie probably Internet Explorer but hopefully Firefox), and the server is something like Apache or IIS(uug). This relates to hacking, as you will see later, but first you need to know more about HTTP (the spaces before the are put in so this isn’t thought of as HTML).


If Apache is serving that, and Firefox picks it up, It will replace the , the , etc. They “close” the tag. Tag is a term for anything in s, and they must be opened (ie introduced) and closed (ie ). If you want to learn HTML tagging, just head over to our close friend Google and do a search.

Since you haven’t gotten to the programming section, and currently I have not even wrote it, I will show you a web server example in the simplest form I can think of that will work on any OS you are currently using. So the obvious choice is JAVA:

<br /> import*;<br /> import*;<br /> import java.util.*;</p> <p> public class jhttp extends Thread {<br /> Socket theConnection;<br /> static File docroot;<br /> static String indexfile = &#8220;index.html&#8221;;</p> <p> public jhttp(Socket s) {<br /> theConnection = s;<br /> }</p> <p> public static void main(String[] args) {<br /> int thePort;<br /> ServerSocket ss;<br /> // get the Document root</p> <p> try {<br /> docroot = new File(args[0]);<br /> }</p> <p> catch (Exception e) {<br /> docroot = new File(&#8220;.&#8221;);<br /> }</p> <p> // set the port to listen on</p> <p> try {<br /> thePort = Integer.parseInt(args[1]);<br /> if (thePort 65535) thePort = 80;<br /> } </p> <p> catch (Exception e) {<br /> thePort = 80;<br /> } </p> <p> try {<br /> ss = new ServerSocket(thePort);<br /> System.out.println(&#8220;Accepting connections on port &#8221;<br /> + ss.getLocalPort());<br /> System.out.println(&#8220;Document Root:&#8221; + docroot);</p> <p> while (true) {<br /> jhttp j = new jhttp(ss.accept());<br /> j.start();<br /> }</p> <p> }</p> <p> catch (IOException e) {<br /> System.err.println(&#8220;Server aborted prematurely&#8221;);<br /> }</p> <p> }</p> <p> public void run() {</p> <p> String method;<br /> String ct;<br /> String version = &#8220;&#8221;;<br /> File theFile;</p> <p> try {<br /> PrintStream os = new PrintStream(theConnection.getOutputStream());<br /> DataInputStream is = new DataInputStream(theConnection.getInputStream());<br /> String get = is.readLine();<br /> StringTokenizer st = new StringTokenizer(get);<br /> method = st.nextToken();</p> <p> if (method.equals(&#8220;GET&#8221;)) {<br /> String file = st.nextToken();<br /> if (file.endsWith(&#8220;/&#8221;)) file += indexfile;<br /> ct = guessContentTypeFromName(file);</p> <p> if (st.hasMoreTokens()) {<br /> version = st.nextToken();<br /> }</p> <p> // loop through the rest of the input li<br /> // nes </p> <p> while ((get = is.readLine()) != null) {<br /> if (get.trim().equals(&#8220;&#8221;)) break;<br /> }</p> <p> try {<br /> theFile = new File(docroot, file.substring(1,file.length()));<br /> FileInputStream fis = new FileInputStream(theFile);<br /> byte[] theData = new byte[(int) theFile.length()];<br /> // need to check the number of bytes rea<br /> // d here<br />;<br /> fis.close();<br /> if (version.startsWith(&#8220;HTTP/&#8221;)) { // send a MIME header<br /> os.print(&#8220;HTTP/1.0 200 OKrn&#8221;);<br /> Date now = new Date();<br /> os.print(&#8220;Date: &#8221; + now + &#8220;rn&#8221;);<br /> os.print(&#8220;Server: jhttp 1.0rn&#8221;);<br /> os.print(&#8220;Content-length: &#8221; + theData.length + &#8220;rn&#8221;);<br /> os.print(&#8220;Content-type: &#8221; + ct + &#8220;rnrn&#8221;);<br /> } // end try</p> <p> // send the file<br /> os.write(theData);<br /> os.close();<br /> } // end try</p> <p> catch (IOException e) { // can&#8217;t find the file<br /> if (version.startsWith(&#8220;HTTP/&#8221;)) { // send a MIME header<br /> os.print(&#8220;HTTP/1.0 404 File Not Foundrn&#8221;);<br /> Date now = new Date();<br /> os.print(&#8220;Date: &#8221; + now + &#8220;rn&#8221;);<br /> os.print(&#8220;Server: jhttp 1.0rn&#8221;);<br /> os.print(&#8220;Content-type: text/html&#8221; + &#8220;rnrn&#8221;);<br /> } </p> <p> os.println(&#8220;File Not Found&#8221;);<br /> os.println(&#8220;HTTP Error 404: File Not Found&#8221;);<br /> os.close();<br /> }</p> <p>}</p> <p>else { // method does not equal &#8220;GET&#8221;<br /> if (version.startsWith(&#8220;HTTP/&#8221;)) { // send a MIME header<br /> os.print(&#8220;HTTP/1.0 501 Not Implementedrn&#8221;);<br /> Date now = new Date();<br /> os.print(&#8220;Date: &#8221; + now + &#8220;rn&#8221;);<br /> os.print(&#8220;Server: jhttp 1.0rn&#8221;);<br /> os.print(&#8220;Content-type: text/html&#8221; + &#8220;rnrn&#8221;);<br /> }</p> <p>os.println(&#8220;Not Implemented&#8221;);<br /> os.println(&#8220;HTTP Error 501: Not Implemented&#8221;);<br /> os.close();<br /> }</p> <p>}</p> <p>catch (IOException e) {</p> <p>}</p> <p>try {<br /> theConnection.close();<br /> }</p> <p>catch (IOException e) {<br /> }</p> <p>}</p> <p>public String guessContentTypeFromName(String name) {<br /> if (name.endsWith(&#8220;.html&#8221;) || name.endsWith(&#8220;.htm&#8221;)) return &#8220;text/html&#8221;;<br /> else if (name.endsWith(&#8220;.txt&#8221;) || name.endsWith(&#8220;.java&#8221;)) return &#8220;text/plain&#8221;;<br /> else if (name.endsWith(&#8220;.gif&#8221;) ) return &#8220;image/gif&#8221;;<br /> else if (name.endsWith(&#8220;.class&#8221;) ) return &#8220;application/octet-stream&#8221;;<br /> else if (name.endsWith(&#8220;.jpg&#8221;) || name.endsWith(&#8220;.jpeg&#8221;)) return &#8220;image/jpeg&#8221;;<br /> else return &#8220;text/plain&#8221;;<br /> }</p> <p>}<br />

I learned the basics of JAVA web server programming from “JAVA Network Programming” by Elliotte Rusty Harold. Now you don’t need to know JAVA to be able to understand that, even though it might not seem like that at first. The important thing to look for when examining the code it the os.print(“”) commands. There is nothing fancy being used to get the data to the browser, you don’t have to mutate the data, its sending plain HTML via a simple command. The plain and simple truth is that the browser is doing the majority of the difficult stuff, when speaking about this simple server. But in complicated servers there is server-side scripting, etc. Webs are much more complicated than just a simple server and Internet Explorer, such as Flash and JAVA Applets (run on clients machine in browser) and server-side stuff like PHP and PEARL (displayed on clients browser as plain HTML but executed as scripting on the server). T

The code above is a good way to learn the HTTP standards, even though the program itself ignores most of the regulations. The web browser not only understands HTML but also knows that incoming connection starting with 404 means that the page is missing, etc. It also knows that when “image/gif” is returned the file is an image of type gif. These are not terms the stupid server made up. They are web standards. Generally speaking, there are two standards. There is the w3 standard (ie the real standard based on the first web servers and browsers) and the Microsoft standard (ie the Internet Explorer, IIS and NT standards). The standards are there so anyone can make a server or client and have it be compatible with (nearly) everything else.

Hiding your Connection

If you have a copy of Visual Basic 6, making a web browser is easy, thanks to Winsock and the code templates included, so I will not put in an example of that. Instead I will explain cool and potentially dangerous things you can do to keep yourself safe. I know those words put together doesn’t make sense (ie potentially dangerous and safe), but you will see in a moment. I’m talking about PROXIES. (anonymous proxy servers, to be exact).

You connect to the internet on port 80 through the proxy server, thus hiding your real IP. There are many obvious applications for this, but it is also the only really potentially dangerous thing so far, so I will restate what I have written at the top: Whatever you do with this info is your responsibility. I provide information and nothing more. With that said, there is nothing illegal about using an anonymous proxy server as long as it is free and you are harming no one by using it. But if you think you are completely safe using one, you are deadly wrong. They can simply ask the owners of the proxy what your IP is if they really want to find you. If you join a high anonymous server, the chance of them releasing your IP is pretty low for something like stealing music, but if you do something that would actually warrant jail time, they probably will be able to find you. is a good site for finding these servers.

The last trick related to web servers and port 80 is a simple one. First, find a free website host that supports PHP and use the following code:

<eml><br /> if ($password == &#8220;passwd&#8221;) {<br /> $fp = fopen(&#8220;http://&#8221;.$destfile,&#8221;r&#8221;);<br /> while (!feof($fp)) {<br /> $fd = fread($fp,4096);<br /> echo $fd;<br /> }<br /> fclose($fp);<br /> }<br /> exit;<br /> ?&gt;<br /> </eml>

If the address of this file is, to download the latest Fedora DVD you would go to the following address: &password=passwd

You can change “passwd” to whatever password you want.

This will make any onlookers think you are connected to You are still limited to the speed of your connection, but you are using the bandwidth of the web host

Whatever you do with the above information is solely your responsibility.

By Janet J

Leave a Reply