#!/usr/bin/perl # If necessary, change the above line so that it # references the location of Perl on your server. ################################################## # Password Generator Version 1.0.0 # # Created April 19, 2000 at 1:30 p.m. EST # # Copyright 2000 by Pear-Socam Softworks # # All rights reserved. # ################################################## # This "Perl Show Counter Script" is distributed # # as pearware. If you find this script useful, # # please send us something with a pear on it: a # # postcard, a pear-shaped eraser, etc. We're # # not picky. But please no perishables, such # # as actual pears. # # # # You may modify this script for your own needs, # # but please do not distribute modified versions # # without our permission. You may freely # # distribute unaltered versions, as long as it # # is distributed in its entirety, including # # these notices. # # # # This script may not be sold for profit. For # # inclusion as part of a compilation or # # collection of files, please contact us first. # # # # Use of this script is at your own risk. We # # make no warranties or guarantees regarding # # this script or its fitness for any particular # # purpose. By using this script, you agree to # # hold us harmless against any and all claims # # and indemnify us against any liability that # # arise as a result of its use. # ################################################## # CONFIGURATION ################################################## # REPLACE THESE DEFAULT VALUES WITH VALUES FOR # # YOUR NEEDS. BE SURE TO ENTER THEM IN THE SAME # # FORMAT AS THE DEFAULT VALUES. # ################################################## $size = 9; # Number of characters in password ################################################## # MODES: # # Set $mode to: # # 1 for generating one password per runtime # # # # 2 to run as a CGI, one password per runtime # # # # 3 for reading a file of user IDs and # # generating a tab-separated list of user # # IDs and passwords # ################################################## $mode = 1; ################################################## # CGI: # # If running as a CGI, change the value below to # # match your server's URL. # ################################################## $yourserver = "http://www.yourserver.com/"; ################################################## # IMPORTANT NOTE: If running as a CGI, this # # script must be called from a page that is # # server-parsed (SSI), typically a .shtml file. # ################################################## ################################################## # SECURITY: # # If running as a CGI, set $securecheck equal # # to 1. # # # # If not running as a CGI, set $securecheck # # equal to 0. # ################################################## $securecheck = 0; $origin = $ENV{'HTTP_REFERER'}; ################################################## # The following values need only be changed if # # running in Mode 3. # ################################################## $filename = "userids.txt"; # List of user IDs # one ID per line $export = "idandpwd"; # Name for the exported # file of user IDs and # passwords (appropriate # extension will be added) ################################################## # EXPORT MODES: # # Set $exportmode to: # # 1 for generating a delimited text file # # 2 for generating a HTML table file # ################################################## $exportmode = 1; ################################################## # DELIMITER: # # Change this value if you want to use a # # different delimiter in the export file (Mode 3 # # only). Default is tab-separated: "\t" # ################################################## $delimiter = "\t"; ################################################## # THIS IS THE END OF THE CONFIGURATION AREA. # ################################################## ################################################## # SECURITY CHECK # ################################################## # SECURITY CHECK # Makes sure the script is being run from your server. if ($securecheck == 1) { if ($origin =~ m#^$yourserver#) { print "Content-type: text/html\n\n"; print "

PERMISSION DENIED

"; } else { &main; } } else { &main; } # END SECURITY CHECK ################################################## # END OF SECURITY CHECK # ################################################## ################################################## # SUBROUTINES # ################################################## sub mode_one { $count = 0; while ( $count < $size ) { @range = (0 .. 9, 'a' .. 'z', 'A' .. 'Z'); print ("$range[rand @range]"); $count++; } print ("\n"); } # end sub mode_one sub mode_two { $count = 0; print "Content-type: text/html\n\n"; while ( $count < $size ) { @range = (0 .. 9, 'a' .. 'z', 'A' .. 'Z'); print ("$range[rand @range]"); $count++; } print ("\n"); } # end sub mode_two sub mode_three { open(IN, $filename); if ( $exportmode == 1 ) { open(OUT, ">>$export.txt"); &writeText; } elsif ( $exportmode == 2 ) { open(OUT, ">>$export.html"); &writeHTML; } else { print ("ERROR!\n"); } close(OUT); close(IN); } # end sub mode_three sub writeText { while (defined($line = )) { chomp($line); print OUT ("$line$delimiter"); $count = 0; while ( $count < $size ) { @range = (0 .. 9, 'a' .. 'z', 'A' .. 'Z'); print OUT ("$range[rand @range]"); $count++; } print OUT ("\n"); } } # end sub writeText sub writeHTML { print OUT ("\n\n\n"); print OUT ("\n"); print OUT ("\n\n"); print OUT ("User IDs and Passwords\n"); print OUT ("\n\n"); print OUT ("\n"); print OUT ("

\n\n"); print OUT ("\n\n\n\n\n"); while (defined($line = )) { chomp($line); print OUT ("\n\n\n\n\n"); } print OUT ("
USER IDPASSWORD
$line"); $count = 0; while ( $count < $size ) { @range = (0 .. 9, 'a' .. 'z', 'A' .. 'Z'); print OUT ("$range[rand @range]"); $count++; } print OUT ("
\n\n\n\n"); } # end sub writeHTML sub main { if ( $mode == 1 ) { &mode_one; } elsif ( $mode == 2 ) { &mode_two; } elsif ( $mode == 3 ) { &mode_three; } else { print ("ERROR!\n"); } } # end sub main ################################################## # END OF SUBROUTINES # ################################################## # EOF