#!/usr/bin/perl ############################################################################### # # # IPFire.org - A linux based firewall # # Copyright (C) 2007 Michael Tremer & Christian Schmidt # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation, either version 3 of the License, or # # (at your option) any later version. # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with this program. If not, see . # # # ############################################################################### use CGI qw(param); # enable only the following on debugging purpose use warnings; use CGI::Carp 'fatalsToBrowser'; $swroot="/var/ipfire"; &readhash("$swroot/ethernet/settings", \%netsettings); my $TITLE_VIRUS = "SquidClamAv Virus detection"; my $url = param('url') || ''; my $virus = param('virus') || ''; my $source = param('source') || ''; $source =~ s/\/-//; my $user = param('user') || ''; # Remove clamd infos $virus =~ s/stream: //; $virus =~ s/ FOUND//; print "Pragma: no-cache\n"; print "Cache-control: no-cache\n"; print "Connection: close\n"; print "Content-type: text/html\n\n"; print < ACCESS MESSAGE
$TITLE_VIRUS END ; if (!($virus eq "")) { print < $virus found END ; } print < Access to the requested page has been denied END ; if (!($url eq "")) { print <URL: $url END ; } if (!($source eq "")) { print <Client IP address: $source END ; } print <

Please contact the Network Administrator if you think there has been an error

Web Filtering by IPFire
END ; sub readhash { my $filename = $_[0]; my $hash = $_[1]; my ($var, $val); if (-e $filename) { open(FILE, $filename) or die "Unable to read file $filename"; while () { chop; ($var, $val) = split /=/, $_, 2; if ($var) { $val =~ s/^\'//g; $val =~ s/\'$//g; # Untaint variables read from hash $var =~ /([A-Za-z0-9_-]*)/; $var = $1; $val =~ /([\w\W]*)/; $val = $1; $hash->{$var} = $val; } } close FILE; } }