#!/usr/bin/perl # SECURE DOMAIN SCRIPT PROTECTOR # # This script protects any Perl script against unauthorised use. # Put it before the script but after the line "#!/usr/bin/perl". # Script reads "authoriseddomains.txt" file which includes authorised # domains, one domain per line. If calling URL does not match any # of the domains listed, gives an error and logs an error message. # # Created 30/09/2001 Last Modified 06/10/2001 # Created by : Mustafa Odabasi - modabasi@virgo.com.tr # Version 1.0.1b ############################################################################ # DEFINING DATE VARIABLE chop ($date = `/usr/bin/date`); # OPENING AUTHENTICATION FILE open(DOM,"authoriseddomains.txt") or die ("Can't open authoriseddomains.txt: $!"); # CONTROL PROSEDURE while (){ chomp; if ("$ENV{'HTTP_REFERER'}" =~ /$_/i){ $sonuc = 1; { } } if (eof(DOM)) { if ($sonuc != 1) { # LOGGING UNAUTHORISED ACCESS open(LOG,">> /var/log/scriptprotector.log") or die ("Can't open scriptprotector.log: $!"); print LOG "$date Calling URL: $ENV{'HTTP_REFERER'} Client: $ENV{'REMOTE_ADDR'} -----------------------------------------------\n"; close(LOG); # SHOW AN ERROR MESSAGE TO THE CLIENT print "Content-type: text/html\n\n"; print "AUTHORISATION FAILED
AUTHORISATION FAILED

$ENV{'HTTP_REFERER'}

is not authorised to use this script.

Remote address
$ENV{'REMOTE_ADDR'} logged.

$ENV{'SERVER_SIGNATURE'}
"; exit; } } } close(DOM); ############################################################################ # PROTECTION CODES END HERE, YOUR EXISTING SCRIPT CONTINUES AFTER THIS POINT ############################################################################