#!/usr/bin/perl # +-------------------------------------------+ # | council_password.cgi -- Password | # | protection | # | CGI script | # | Author : Unknown | # | Created On : Unknown | # | Last Modified By : Ryan William Facer | # | Last Modified On : Thursday July 30, 1998 | # | Update Count : 2 | # | E-Mail : cattails@cattails.ca | # +-------------------------------------------+ # | 1. Renamed everything to council | # | 2. Change title to Council | # +-------------------------------------------+ # Set Variables $passwd = "com2"; # The password you want $login = "council"; # The username you want $protected = "http://www.secretan.com/wwwboard/council_discuss.html"; # The URL of the protected page $cgiurl = "http://www.secretan.com/cgi/council_password.cgi"; # The URL of the script. $log = "0"; # 1 to log unsuccessfull attempts to get passed the script, anything else # to not log the attempts $logfile = "council.log"; # The file to log unsuccessfull attempts to get through. must be chmod 777 $bodycolor = ""; # The tag and whatever attributes you want to give it, you can # also include a or or # and anything else you want at the top. note that all quotes (") need # to have a \ in front of them (\") $title = "Higher Ground Community Council Discussion Forum Password Protection"; # The Title of the page. # # Done Setting Variables ########################################## if ($ENV{QUERY_STRING} eq "about"){ &about; }; # if if ($ENV{REQUEST_METHOD} eq "GET"){ &get_login; } else { &parse_form; }; # if $password = $input{'password'}; $username = $input{'username'}; if ($username eq $login) { if ($password eq $passwd){ print "Location: $protected\n\n"; } else { &error; }; # if } else { &error; }; # if sub parse_form { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); if (length($buffer) < 5) { $buffer = $ENV{QUERY_STRING}; }; # if @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $input{$name} = $value; }; # foreach }; # parse_form sub get_login{ print "Content-type: text/html\n\n"; print "$title\n"; print "$bodycolor\n"; print "

Welcome to the Higher Ground Community Council Password Protection




\n"; print "
\n"; print ""; print "\n"; print "\n"; print "
Login
User Name:
Password:
\n"; print "\n"; print "
\n"; print "

\n"; exit; }; # get_login sub error{ print "Content-type: text/html\n\n"; print "Access Error!\n"; print "$bodycolor\n"; print "

Ooops! Sorry, but the password you just entered is incorrect.

\n"; print "

Please pause, smell the roses and try again.

\n"; print "\n"; # print "

Access Error! - Please Go back and re-enter your username and password


\n"; # print "

Your IP Has Been Logged.

\n"; print "
\n"; if ($log eq '1'){ read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); open(LOG,">>$logfile") || die $!; print LOG "$ENV{REMOTE_HOST} tryed to get by the script.\n"; print LOG "using $ENV{HTTP_USER_AGENT}.\nPassword: $password\n"; print LOG "Username: $username\n\n"; close(LOG); }; # if exit; }; # error sub about{ print "Content-type: text/html\n\n"; print "Protect-A-Page v1.0\n"; print "

Protect-A-Page v1.0


\n"; print "Protect-A-Page v1.0 is just a simple way to password protect\n"; print "web pages with a CGI script.

Written By:\n"; print "

Protect-A-Page may be obtained from\n"; print "The Wiltered Realm\n"; print "in the \"Scripts\" section of the page, along with\n"; print "all of the other scripts I've released.\n"; print "
Go Back"; print "

"; exit; }; # about