Dirty and Quickie deep linking prevention

Christos Ricudis ricudis at itc.auth.gr
Fri Sep 25 16:40:28 EEST 2009


Exete bare8ei na linkarei olo to sympan to directory sas me tis 
452973493 lolcats apo diafora hli8ia forums?

Taiste tous ena Cthulhu Goatse!

mod_perl required. Modify it to suit your site.

apache.conf :

PerlModule Perlomodula::Taisthri
PerlTransHandler Perlomodula::Taisthri

Taisthri.pl :

package Perlomodula::Taisthri;

use strict;
use Apache2::RequestRec ();
use Apache2::Log ();
use APR::Table ();
use Apache2::Const -compile => qw(DECLINED);

sub handler {
  my $r = shift;

  my $kot=$r->uri();
  my $lala=$r->headers_in->{Referer} || '';
  my $isimage=0;
  my $islinked=0;

  if 
(!($lala=~m/.*(localhost|myserver|127.0.0.1|192.168|mydomain.com).*/i)) {
    $islinked=1;
  }

  if ($kot=~m/(.*)\/pictures\/lolcats\/(.*)\.jpg/i) {
    $isimage=1;
  }

  if (($islinked==1)&&($isimage==1)) {
    $r->uri("/cthulhu-goatse.jpg");
    $r->log_error("Bad referer $lala linked to $kot, fed him a 
goatse-cthulhu");
  }

  return Apache2::Const::DECLINED;

}
1;                       




More information about the Linux-greek-users mailing list