#! /usr/bin/perl
use DBI;
use File::Find;
use Archive::Zip;

sub autodelete {
  $dir = $_[0];
# my $dir = '.';
  ##### /autorun.inf delete ########
  opendir(H_DIR,$dir) || die "no $dir: $!";
  while ($file = readdir(H_DIR)) {
    $filename = $file;
    $filename =~ s#.*/##;
    $filename =~ s/([a-zA-Z])/\L$1\E/g;
    if ( "autorun.inf" eq $filename ){
    print "$file<br>\n";
       unlink $dir."/".$file;
    }
  }
  closedir(H_DIR);
  ##### other delete ########
  find( \&wanted, ($dir) );
}
sub wanted {
  my $file = $File::Find::name;
  if ( $file =~ /\.(exe|com|cmd|bat|scr|pif|vbs|vbe|js|jse|wsf|wsh)$/i ){
  ##### execute file ########
    print "execute: $file<br>¥n";
     unlink $file;
  }
  if ( $file =~ /\.(zip)$/i ){
  ##### zip file ########
#    print "zip: $file¥n";
    if ( my $zip = Archive::Zip->new( $file )) { ;
      foreach $archived ($zip->memberNames) {
#        print "zipped: $archived<br>\n";
         if ( $archived =~ /\.(exe|com|cmd|bat|scr|pif|vbs|vbe|js|jse|wsf|wsh)$/i ){
           print "zipexecute: $file:$archived<br>¥n";
            unlink $file;
         }
      }
    }
  }
}

 if (@ARGV < 1) {
    die "must mount point\n";
}

$mountpoint = shift @ARGV;

autodelete($mountpoint);


