Httpd Written In Postscript? Shell?
eMBee writes: "You thought the kernel-httpd is weird?
then look at these: a shell script, and another one in Postscript." Ya know, this kinda stuff gives me faith in humanity. Faith that we've evolved too far: it's time to back-up to, say ... using bone chips as knives ;)
YDD
until... web browser include http servers in their scripting language... so warez kiddies can setup their own http servers really easily, hell.. it happened with xmms and icecast.. ;)
"To install it, run from inetd:"
/usr/bin/gs gs -dNODISPLAY -q \
/home/pugo/src/postscript/pshttpd/pshttpd.ps
= == % PS-HTTPD V1.0 % = ==== /get_file % read file /infile /buff 2048 string def { % loop infile buff readstring { stdout exch writestring /read_command % read /command { /stdin (%stdin) (r) file def /inbuff 256 string def /command exch def } def /concatstr % (a) (b) -- (ab) { /beta exch def /alfa /buffer 1024 string def alfa buffer copy pop buffer alfa length beta putinterval buffer (\000) /hitcount { /hitfile (/usr/local/psweb/hits) (r) file def /hits 16 /hitfile (/usr/local/psweb/hits) (w+) file def cvi 1 /print_header { stdout (HTTP/1.0 200 /parse_result { command token { (GET) eq { ( ) search { root exch /filename exch def pop pop % define filename and clean stack filename /filename exch def } if % /infile exch (r) file def % open file print_header get_file } if } if } if } def % Init /stdout (%stdout) (w) file def /command () def % Root-path (root of WWW-pages)
8080 stream tcp nowait nobody
Here's the source, in case the server gets PSDotted:
%! %================================================
Copyright 2000 Anders Karlsson, pugo@pugo.org % License: GNU General Public License
%==============================================
and send it to %stdout {
} { stdout exch writestring infile closefile exit } ifelse } bind loop } def
command from stdin and define it to
stdin inbuff readline pop
exch def
search pop exch pop exch pop } def
string def hitfile hits readstring pop hitfile closefile
add hits cvs hitfile exch writestring hitfile closefile } def
OK\n\n) writestring % stdout (Server: PS-HTTPD/1.0\n) writestring % stdout (Content-type:
text/html\n) writestring } def
concatstr % build path
filename length 1 sub 1 getinterval (/) eq { filename (index.html) concatstr
add index.html filename (..) search { stdout (4711 Stupid user error!\n\n) writestring quit } if pop
filename
environment
/root (/usr/local/psweb) def %% Uncomment this and place a file named "/usr/local/psweb/hits" %%
(you can change the path in hitcount above) containing only a "0" to %% get a hitcount % % hitcount
% add one to the hitcount % Read a command from the server read_command parse_result quit
"... it's time to back-up to, say ... using bone chips as knives"
:-)
Funny you should mention that - a lot of very delicate eye-surgery these days is done with glass or obsidian knives because at the small sizes needed they're a lot sharper than steel. The blades are flaked by Aleuts, who've been fashioning such knives for centuries, because they're the only ones who still have the skills to do it (incidentally making some of the most dangerous water-based weaponry in the world).
OK, it's mostly off-topic, but it's still damned cool
Some years ago, somebody set out to implement various things using only dd and sh. Their accomplishments included a text editor, a web server and -- to prove a point -- a Turing machine. The things could be found on the now non-existant http://dd.sh/ (fantastic, eh? :) but are now located on http://www.assurdo.com/dd.sh/. These things warm my heart. *happy sigh*
Few people realise that PostScript is a full programming language, not just a page description language for printers (for the uninitiated, it's similar to Forth -- remember the Jupiter Ace?). I used to have a ray tracing program that someone had written in PostScript (in under 2K as well!). Of course, performance wasn't too great...
"The invisible and the non-existent look very much alike." -- Delos B. McKown
At the asmutils page. 586 bytes standalone executable. Make that!
Best regards,
The Anonymous Coward from Estern Europe
While we're talking about HTTPD's written in various languages, the W3 Consortium has written a free (as in speech) HTTPD entirely in Java for maximal portability: Jigsaw (see also the Jigsaw test site — that is, let's see how Jigsaw reacts to being slashdotted:-).
As you can guess, Jigsaw is fully HTTP/1.1 compliant (last time I checked, Apache still had some problems with that). While it's certainly much less efficient than Apache, it's probably also more flexible, modular and reusable. Personaly I haven't given it more than a cursory glance: I wonder if some people have tried it more thoroughly and would care to review its pros and cons?
It's too easy. Try this for example:
#! /bin/sh
# Set the following to the location of Apache:
APACHE_LOC=/opt/apache/bin/httpd
exec $APACHE_LOC "$@"
exit 1
"What I look forward to is continued immaturity followed by death."
Despite the funny things about it, I like these 'senseless' projects of programming. They sometimes show up possibilities nobody ever expected.
A good example is 'The Towers of Babylon' programmed on the editor VI.
About ten years ago I 'programmed' a Texas Instuments 53 pocket calculator. With just 32 commands and almost no memory (one number could be stored) I was able to program the square root function. OK, it was about 20 times slower and also not as accurate as the square root key of the calculator, but, hey!, it worked! ;o)
Actually I'm messing around with CGI and WAP. Right now I'm focussing on a script that sends a 'whois' query to a bot placed in the IRCnet and displays it on the mobile phone. No one I talked to thought this script has any sense. Well, I'm not sure, but it's fun to program!
bash-httpd
But writing one is postscript is cool. :)
Hi,
/.ted page.
Some time ago someone posted on slashdot about an Atari 800 server. I was one of the lucky to get through the "slashdot effect", and I saw the source code of this thing. It was in BASIC. It first redirected the output, and then it went like:
40 PRINT ""
50 PRINT "This page serverd by Atari"
...ertc.
Great.
Haven't figured out yet how Postscript should be executable, though. This time I haven't yet get through the
It's... It's...
"We can confirm that Debian does *not* ship the version with the trojan horse. Our version predates it." [CA-2002-28]
Hi,
It should, then, be so damn easy to embed a virus in a PostScript document, right? Or am I being paranoia? (Or has it been done n times before, and didn't I notice?)
(BTW at my last post (just above) the HTML tags have fallen away cause I had Extrans on. I don't understand: if I want these tags to work (like here) they never do. Whatever.)
It's... It's...
"We can confirm that Debian does *not* ship the version with the trojan horse. Our version predates it." [CA-2002-28]
Way back then, there was an entire computer system type that run LISP as its machine language. They had an entire LISP OS, and even a windowing system. Everything written in LISP. History repeats... Soon, all our programs will be scriptable with guile...
As with Pugo - he's a real freak (I know him personally)...
--The knowledge that you are an idiot, is what distinguishes you from one.
--The knowledge that you are an idiot, is what distinguishes you from one.
Man, trying to secure a httpd written in sh is gonna suck. Just for starters, try:/ ../../../../etc/passwd
http://jester.vip.net.pl:8081/../../../../../..
It also appears you can execute arbitrary commands by changing your reverse DNS to contain the command and '|', ';' and/or '&'.
There is a good reason not to write CGI scripts in shell, and an even better one not to write a whole httpd!
OOPS, a typo. :-)
Httpd can be written in something more primitive than Postscript or shell script, let alone Lisps. All we have to do is get OOG the Caveman to write it up in simple grunts and groans. Throw in a few cave paintings and it'll even have a state of the art GUI!
Then caveman shall once again rule the world. Don't forget to pay him in dead sabre-tooth carcasses and mammoth skins!
-- "I can't tell the future, I just work there." -- The Doctor
I used a Lisp machine at MIT in the late 1970s.
There were a lot of really cool things about it, but it was way ahead of its time in terms of computing power. The mouse action was so sluggish it gave me an intense prejudice against GUIs which lived on for decades.
D
----
Because building good things is not limited to the likes of folks who think everything has to be re-written from scratch just becuase we have fancy new tools.
Shell scripts and their bretheren (perl, tcl/tk, python) are great glue-ware for folks who are smart enough to realize that the wheel does not need to be redesigned every few years. I can glue together existing command line tools using a few well-written lines of script to perform complex tasks that the original developers of CLI tools could not imagine.
I am thankful that CLI tool builders use stdin and stdout so that my tools can feed and be fed.
In short, people still pulling out their visual IDE tools are the people that are holding the information revoltion back. We must embrace the existing technologies and tools that make our life easier rather than waste our time building everything from scratch, simply because they are old.
I heard about a company who wrote a graphical interface to a 4 bit operating system and called the whole thing NT Server!
You can't handle the truth.
Indeed. All too often, we see the Recursive Slashdot Problem... slashdotters attract more people to slashdot, and so slashdot slashdots more sites causing more slashdotters to come to slashdot, with the slashdot effect that slashdot becomes slashdotted because of the slashdot effect caused by slashdotters endlessly slashdotting on slashdot and slashdotting more sites bringing more slashdotters to the slashdotted slashdot...
Gah, I lost my train of thought ... my brain got slashdotted! :-P
Poll Mastah
Beleive it or not there is a point to coding things in shell script... speed of development.
My first version of mp3 server was written in less than an hour using bash and a few unix commands. Sox would record from the sound card, pipe the pcm audio to l3enc which would write an mp3 stream to a file. Meanwhile netcat would listen for connections and start 'tail -f mp3file' to send the 'live' data to the client.
Mp3 streaming in the days before winamp was even capable of recieving mp3 streams, never mind sending them to shoutcast.
What is the best language to implement HTTPD in?
Poll Mastah
http://www3.l0pht.com/~dildog/webserver.doc
Note that you can upload files, download them, execute programs, and change file attributes by clicking on them in the directory list. The webserver shuts down when they close the document though, since I didn't bother to try to make the tool any more insidious than it was already.
Have fun.
dang sed s/slashdot/geek on this post and JonKatz has a new article:)
Andrew Tridgell metioned at a Canberra Linux User Group meeting a few years ago that at first, when the SAMBA project website consisted of one page, it was served by a "cat foo" line in inetd.conf on some machine at ANU; foo was a file containing some http response headers and the page. He figured this would be simpler than installing and configuring apache. I don't think you can get much simpler than that.