Skip to content

Instantly share code, notes, and snippets.

@ankurs
Created June 4, 2009 08:50
Show Gist options
  • Save ankurs/123522 to your computer and use it in GitHub Desktop.
Save ankurs/123522 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use File::Glob ':glob';
use strict;
my $dir =$ARGV[0];
my @dir;
my @virus;
push @dir,$dir;
foreach(@dir)
{
my @in =<$_/*>;
foreach (@in)
{
if (-d $_)
{
push @dir,$_;
my @file = split /\//, $_;
my $file = pop @file;
my $filepath = join "\/",@file;
$file = $filepath."/".$file."/".$file.".exe";
push @virus, $file if (-e $file);
}
}
}
my $count=0;
foreach (@virus)
{
my $try = unlink $_;
if ($try)
{
print "$_ deleted\n";
$count+=1;
}
else
{
warn "could not remove file $_ : $!";
}
}
print $count." viruses deleted \n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment