#! /usr/bin/perl -w #use strict; use warnings; use LWP::Simple; use Digest::MD5; my ($contenu); #%surveill = ( # "http://www.openbsd.org/errata.html" => "/home/hphil/hash_open", # "http://www.ac-creteil.fr" => "/home/hphil/hash_creteil" # ); #@surveill=("http://www.openbsd.org/errata.html" , "/home/hphil/hash_open", #foreach { # &verif ($URL,$last_md5); # } my $URL1="http://www.openbsd.org/errata.html"; my $last_md51="/home/hphil/hash_openbsd"; &verif ($URL1,$last_md51); #my $URL2="http://www.ac-creteil.fr"; #my $last_md52="/home/hphil/hash_creteil"; #&verif ($URL2,$last_md52); #########################verification de la page passée en param avec le fichier de hash sub verif { $contenu = get ($_[0]); #$hmac = 0; $hmac = Digest::MD5->new; $hmac->add($contenu); $resultat = $hmac->hexdigest; open(FICHIER_CONF,$_[1]) or die "problème de lecture sur $last_md5\n"; $ligne = ; chomp($ligne); print "last hash : --$ligne\n"; print "resultat : --$resultat\n"; if ($ligne ne $resultat) { print "\n alerte MODIF\n\n"; $from="serversalive\@ac-creteil.fr"; $to="pschwarz\@ac-creteil.fr."; $subject="Alerte : Modification de la page $-[0]"; $sendmailpath="/usr/sbin/sendmail"; open (SENDMAIL, "| $sendmailpath -t"); print SENDMAIL "Subject: $subject\n"; print SENDMAIL "From: $from\n"; print SENDMAIL "To: $to\n\n"; print SENDMAIL "_____________________________________ALERTE____________________________________________\n\n"; print SENDMAIL " La page $_[0] vient de changer, vous devriez aller y faire un tour.\n"; print SENDMAIL "_______________________________________________________________________________________\n\n"; close (SENDMAIL); }; close FICHIER_CONF; } #########################verification de la page passée en param avec le fichier de hash