#!/usr/bin/perl # Secure Area - Spaceports Security Script # Allows you to add or edit .htaccess and .htpasswd files in your directories using a simple form # Important note: Use this script with caution, and never leave it in a publically accessible directory # Adapted from Floyd Morrissette's access3.cgi ( http://www.newwebsite.com - Floyd@NewWebSite.com) # By Wysardry ( http://io.spaceports.com/~wysardry - wysardry@r67.net) # With permission from Floyd Morrissette # This script is provided free of charge, but please keep the credits intact use CGI; use CGI::Carp qw/fatalsToBrowser/; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @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; $value =~ s/~!/ ~!/g; $FORM{$name} = $value;} # Change the following variable to the path the form should use to call this script on your system # No trailing / $action = "http://cgi-bin.spaceports.com/~username/access"; # Change the following variable to the absolute path to your root directory # No trailing / $base = "/home/username/public_html"; # You should not need to edit anything below this line as long as the filename is access3w.cgi # Just run the script from your browser and fill out the form $path = $base.$FORM{'path'}; $name = $FORM{'name'}; $password = $FORM{'password'}; $newpass = crypt($password, tnnntv); print "Content-type: text/html\n\n"; if ($FORM{'submit'} eq "Enter") { &encrypt }else{ &form } sub form{ print "\n
\n