#! /usr/bin/perl # Remember that CGI programs have to close out the HTTP header # (with a pair of newlines), after giving the Content-type: # and any other relevant or available header information. # Unlike CGI programs running under Apache, CGI programs under Boa # should understand some simple HTTP options. The header (and the # double-newline) should not be printed if the incoming request was # in HTTP/0.9. Also, we should stop after the header if # REQUEST_METHOD == "HEAD". Under Apache, nph- programs also have # to worry about such stuff. # Feb 3, 2000 -- updated to support POST, and avoid passing # Malicious HTML Tags as described in CERT's CA-2000-02 advisory. if ($ENV{"SERVER_PROTOCOL"} ne "HTTP/0.9") { print "Content-type: text/html; charset=ISO-8859-1\r\n\r\n"; } exit 0 if ($ENV{"REQUEST_METHOD"} eq "HEAD"); print "Boa CGI test\n"; print "

Boa CGI test

\n\n"; $now=`date`; chomp($now); print "Date: $now\n"; print "

\n"; print "Method: $ENV{\"REQUEST_METHOD\"}\n"; print "

\n"; print "\n"; print ""; print ""; print "\n"; print ""; print "
Basic GET Form:
"; print "
\n\ \ \ \
"; print "
Basic POST Form:
"; print "
\n\ \ \ \
"; print "
Sample ISINDEX form:
\n"; print "$ENV{\"SCRIPT_NAME\"}?param1+param2+param3\n"; print "
\n"; print "

Query String: $ENV{\"QUERY_STRING\"}\n"; # arguments list print "

\nArguments:\n

    \n"; if ($#ARGV >= 0) { while ($a=shift(@ARGV)) { $a=~s/&/&/g; $a=~s//>/g; print "
  1. $a\n"; } } print "
\n"; # environment list print "

\nEnvironment:\n

\n"; if ($ENV{REQUEST_METHOD} eq "POST") { print "Input stream:

\n";
    while () {
	s/&/&/g;
	s//>/g;
        print "$_";
    }
    print "

\n"; } else { print "No input stream: (not POST)

"; } print "id: ", `id`, "\n

\n"; if ($ENV{"QUERY_STRING"}=~/ident/ && $ENV{"REMOTE_PORT"} ne "") { # Uses idlookup-1.2 from Peter Eriksson # ftp://coast.cs.purdue.edu/pub/tools/unix/ident/tools/idlookup-1.2.tar.gz # Could use modification to timeout and trap stderr messages $a="idlookup ". $ENV{"REMOTE_ADDR"}." ".$ENV{"REMOTE_PORT"}." ".$ENV{"SERVER_PORT"}; $b=qx/$a/; print "ident output:

\n$b
\n"; } print "\nBoa http server\n"; print "\n"; exit 0;