Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

AntiVirus Signature Updater

by linebacker (Scribe)
on Jul 09, 2002 at 22:57 UTC ( #180647=snippet: print w/replies, xml ) Need Help??
Description: Big time thanks to rincew, grinder,jeffa,jwest,mt2k, hofmator,kvale,atoplc,fruiture, (if I forgot you and you helped me, I don't mean it as an insult. Just lost track). As a novice, while attempting to write this code, I was urged by many colleagues to use a different language (Java or Korn Shell). But I stuck with Perl and thanks to you all, now have a working program that does exactly what I hoped for!

If it wasn't for this site, I would not continue to work so hard at continuing my Perl education. I thank you for that.

I manage several (6) AV Servers (Norton AV Corporate Edition). These servers push AV Defs and schedule scans on the 897 managed clients.

We only use a 'trusted' source for AV Sig updates. While this trusted source provides a weekly 'liveupdate', Symantec releases new 'all inclusive' updates almost daily and the trusted source posts those almost immediately but holds on to the 'liveupdates' for about a week or so.

Many of the subscribers of the systems complained that 'MY' updates (the liveupdates) were always behind. So...I set about automating the all inclusive updates.

From a *NIX machine (Solaris or Linux) I update from the trusted site, twice daily. I then have an AT script on the AV Servers that ftp's, executes and distributes the avdefs.exe file once per day.

At least, that is my concept. This of course has to go into my production lab for a week, then I can roll it out for real

Here is my code. Thank you all very much for helping me to accomplish what probably sounds like a very trivial task, but for me is a major milestone.

#!/usr/bin/perl -w

use strict;
use Net::FTP;
use Mail::Mailer;

my $host = 'www.trustedftpsite.org';
my $user = 'anonymous';
my $pass = 'updatepuller@avtrustingclient.org';
my $remote_dir = '/pub/antivirus/NAV/signatures';
my $destination_dir = 'current-sig';
my $type = 'sendmail';
my $mailprog = Mail::Mailer->new($type);

my @lupd = ();
  if(-e "./lastupdate.txt") {
    open(LASTUPDATE,"./lastupdate.txt")
      or die "Error while opening lastupdate.txt ($!)";
    chomp( @lupd = <LASTUPDATE> );
    close(LASTUPDATE)
      or die "Error while closing lastupdate.txt ($!)";
  }

my %haveit;
  @haveit{ @lupd } = (1) x @lupd;

my $ftp = Net::FTP->new($host, Debug => 1);
   $ftp->login($user,$pass)
      or die "Could not connect to ftp server ($!)";

my @listing = grep /x86\.exe$/i, $ftp->ls($remote_dir);
my @newupdate;

$ftp->type("I");
    for my $file (@listing) {
      next if $haveit{$file};
      if ($ftp->get($file, "$destination_dir/avdefs.exe")) {
        mailer($file);
        push @newupdate, $file;  
      }
    }

    $ftp->quit;

open(NEWUPDATE,">>./lastupdate.txt")
    or die "Couldn't open lastupdate.txt for appending ($!)";
  print NEWUPDATE map "$_\n", @newupdate;
  close(NEWUPDATE)
    or die "Closing lastupdate.txt failed ($!)";

sub mailer {
my $file = shift;
my %headers = (
    'To' => 'iwannaknow@trustingclient.org',
    'From' => 'Antivirusupdater@yournewdefs.com',
    'Subject' => 'New AntiVirus Signatures brought down'
               );
$mailprog->open(\%headers);
    print $mailprog "The Latest AntiVirus signature is $file.\n";
$mailprog->close;
           }
Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://180647]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2019-10-20 21:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?