Category: | Utility Scripts |
Author/Contact Info | sflitman - Stephen Flitman - sflitman >!< xenoscience.com |
Description: | This is a quickie script to clean infected zip files using clamscan. It's definitely meant for unix/linux platform and expects clamscan 0.94 which with the indicated switches will print out each infected file on a line by itself with whatever virus it found. Note that this script will also delete zipped emails or mailboxes which clamscan identified as containing Phishing, etc., as it does not distinguish what type of unwanted byte sequences are reported by clamscan. This is to get around a deficiency in ClamAV noted by many that it does not identify the actual bad actor(s) in an archive, just that the archive as a whole is infected (and not multiply-infected, which is of course possible). |
#!/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; |
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: cleanzip
by Anonymous Monk on Oct 20, 2008 at 12:56 UTC | |
Re: cleanzip
by graff (Chancellor) on Oct 21, 2008 at 02:11 UTC | |
by sflitman (Hermit) on Oct 26, 2008 at 00:09 UTC |