#!/usr/bin/perl # dailyupdate.pl # Auto Update Daily DAT files from NAI uvscan for *nix # By: Brian K. West # Version 1.0.3 # # This is used for Daily Dat file from NAI for early prevention. # This version will email the admin when the DAT files are updated! # I have also done some touchups to make the code cleaner. # Also: $adminemail = "user\@domain.com"; you must escape the "@" # use LWP::Simple; use Archive::Zip; # Settings $location = "http://download.nai.com/products/mcafee-avert/daily_dats/DAILYDAT.ZIP"; $tmpdir = "/tmp"; $uvscandir = "/usr/local/uvscan"; $mailprog = "/bin/mail"; $adminemail = "brian\@bkw.org"; $check = head("$location"); if($check) { # Lets grab the next version if its ready! print "Downloading DAILYDAT.ZIP ...\n"; $datfile = mirror("$location", "$tmpdir/DAILYDAT.ZIP"); if($datfile == "404") { print "No Daily Dat Update avaliable!\n"; exit; } if($datfile == "304") { print "You have the latest Daily Dat file installed!\n"; exit; } } else { print "No Daily Dat Updates avaliable!\n"; exit; } my $zip = Archive::Zip->new("$tmpdir/DAILYDAT.ZIP") || die("error"); my @list = $zip->memberNames(); my $file; print "Extracting DAILYDAT.ZIP to $uvscandir ...\n"; foreach $file (@list) { if (!($file =~ /.*\/$/)) { my $data = $zip->contents($file); $file = lc($file); my $newpart = "$tmpdir/$file"; print "Installing: $file\n"; open(OUTPART, ">$uvscandir/$file"); print(OUTPART $data); close(OUTPART); } } #unlink("$tmpdir/DAILYDAT.ZIP"); $check = `$uvscandir/uvscan --version | $mailprog -s \"Virus Scan Daily DAT Updated\" $adminemail`; print "Daily Dat Installed!\n";