#!/usr/bin/perl -w # Deletes from Exim's queue messages containing potentially executable # attachments. Usage: # 1) ./attach-en.pl # Shows the message ids, but doesn't delete them # 2) ./attach-en.pl --delete # Deletes the messages ############################################################################### # Author: Juan R. Pozo - http://html.conclase.net/cp/scripts/ # Released on December 8, 2003 ############################################################################### # This software is released into the public domain. Use at your own risk. # The author holds no rights or responsibilities related to this software. ############################################################################### use strict; my $delete = (defined($ARGV[0]) && $ARGV[0] eq "--delete") ? 1 : 0; opendir(QUEUE, "/var/spool/exim/input/"); my @t_ids = grep { /-D$/ } readdir(QUEUE); closedir(QUEUE); my @ids = (); foreach my $id (@t_ids) { if (`grep "potentially executable attachment" /var/spool/exim/input/$id`) { push @ids, $id; } } foreach (@ids) { if (!$delete) { s/-D$//; print $_."\n"; } elsif (/(\w{6}-\w{6}-\w{2})-D/) { print `exim -Mrm $1`; } } print "Done\n"; exit;