Sorry for the delay in response, I had to think on this one a bit. I think that this may be possible, but won't be easy. Searching on this subject indicates you are not the only one interested in this, but isn't showing solutions. One positive to note is that they are rendered in HTML so you can avoid them with text view only. However, this doesn't stop them from being attached.
I think what you will need to do is put a custom content filter in place on your email server. How you do this will depend on what server your using. If you are using Postfix for example, you can create a path through the mail queue and create a set of SMTP ports, one for transmitting and one for listening, where mail is sent through out, filtered, and then re-introduced. The spam program Amavis does this. If you use such a content filter or virus checker it may be possible to call a script of your own from it which would be easier.
After you are able to call your own script, the next step is to use a pattern matching algorithm to identify the animated gif. This may be further complicated by the MIME encoding, which is something that you will need to look into. I am sure that there are some common algorithms for identifying the attachments as this is a common function of most mail filter programs. In this case, were taking it a step further.
After you decode the MIME, you will want to trigger on a set of comparisons that indicate the presence of an animated gif. You can then write your script to remove these lines, change the message and pass a bounce response, etc. This is the kind of thing that PERL will excel at. Wikipedia has a really good article on the .gif file format and shows the header patterns and things that you could pattern match against.
I admit that this will be a project, but off hand, I can't think of other ways to specifically target animated gifs. Other things you may try would be to limit attachment size, or block .gif attachments (assuming this also picks up the animated ones). If someone really wants to send a file, they can encode it with zip or something.
Lastly, it might be easiest to take a direct approach, asking the offenders to stop using animated gifs and if they fail to comply with the request, temporarily ban their email account so that they get the message that your serious.
|