HTTP Server in POSIX shell code


OK, so the poor thingie suffered from the SlashDot effect :)). This page isn't served by sh-httpd anymore. It will be when I have some time after the Easter to secure it a bit (because some people already tried to break in). I just wasn't ready - the server was written yesterday in an hour :)). Well, the source you can fetch below and I promise that there will be something more for you, real soon :) (not only in shell :). And, just a word of explanation:

This server and also the ones to follow are written just for pure fun, just to see "whether it will work or not" - there's no other purpose. I just believe that no one will try to take advantage of the holes that surely are and will be in that kind of software. It is not written to be used in real environments and it isn't exposed to the world for the fun of the script kiddies and wannabe hackers. I just believe that people on the Internet are sane enough NOT to spoil somebody else's fun.

Somebody on the Roxen Chat told us about someone else who wrote a HTTP server in PostScript. Well, I liked the idea,  so I decided to write one in shell script. At first I thought it was impossible, but in the end it took an hour to get it working :). The problem is that from the shell code one cannot reset the TCP connection properly, so some browsers will refuse to work (MSIE for example won't fetch the source code below). But hey, it works! :)

The source is here - it's ugly as hell, but it's a one-hour hack with half of the time spent in thinking "why in the hell Netscape doesn't show the page?" :)))

The following line is used in the inetd.conf to run this server:


8081    stream    tcp    nowait    nobody    /usr/local/sbin/sh-httpd

I'm crazy enough to work a bit on this one, so I'll add some features in the future :)) - it's fun, after all :)). And the next httpd to come will be written in sed (yah :)

The source code of the server, this page are released under the GPL, so do what you want with them :) - just let me know if you do something interesting :)

grendel@vip.net.pl

P.S. Heh, I just noticed that we've been SlashDotted :)) . Guess that means, I'll have to work on improving that beast :)

If you're not quite sure what the SlashDotted term means - see here for the defintion.