#!/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 authoriseddomain +s.txt: $!"); # CONTROL PROSEDURE while (<DOM>){ 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 script +protector.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 "<html><head><title>AUTHORISATION FAILED</title></head> <body bgcolor=white> <br><center><b><font face=\"Arial\" color=red size=\"3\">AUTHORISATION + FAILED</font> <br><br><font face=\"Arial\" color=blue size=\"3\">$ENV{'HTTP_REFERER' +}</font> <br><br><font face=\"Arial\" color=red size=\"3\">is not authorised to + use this script. <br><br>Remote address </font><font face=\"Arial\" color=blue size=\"3 +\">$ENV{'REMOTE_ADDR'}</font> <font face=\"Arial\" color=red size=\"3 +\">logged. <br><br>$ENV{'SERVER_SIGNATURE'} </b></font></center> </body></html>"; exit; } } } close(DOM); ###################################################################### +###### # PROTECTION CODES END HERE, YOUR EXISTING SCRIPT CONTINUES AFTER THIS + POINT ###################################################################### +######
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Script protector from a 'very' newbie.. (boo)
by boo_radley (Parson) on Oct 06, 2001 at 08:38 UTC | |
|
Re: Script protector from a 'very' newbie..
by jj808 (Hermit) on Oct 06, 2001 at 12:33 UTC | |
|
Re: Script protector from a 'very' newbie..
by Chady (Priest) on Oct 06, 2001 at 14:21 UTC |