#!/usr/bin/perl # Written by Stephen S. Flitman, MD # Copyright (C) 2008 Xenoscience, Inc. # Released under GPL v3 # 101908 clean up infected zip files use strict; my $CLAMSCAN=`which clamscan`; chomp $CLAMSCAN; die "Where's clamscan?" unless $CLAMSCAN; my $ZIP=shift @ARGV; my $TMP=$ZIP; $TMP=~s!/!_!g; $TMP="/tmp/$TMP.dir"; system "unzip $ZIP -d $TMP"; my $BADFILES=`$CLAMSCAN --recursive --infected --no-summary $TMP`; unless ($BADFILES) { print "No viruses found in $ZIP\n"; exit; } my (@BADFILES,$BADFILE,$RESULT); @BADFILES=split(/\n/,$BADFILES); for $BADFILE (@BADFILES) { if ($BADFILE=~s/:.*FOUND$//) { $BADFILE=substr($BADFILE,length($TMP)+1); print "File to delete is '$BADFILE'\n"; $RESULT=`zip -d $ZIP "$BADFILE"`; print $RESULT; } else { print "Nothing to do for $BADFILE"; } } system "rm -r $TMP"; exit;