From 98e2f08885a4ae5749a7d8cdd26797b3a7202953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ask=20Bj=C3=B8rn=20Hansen?= Date: Mon, 19 Jan 2004 09:33:19 +0000 Subject: [PATCH] check for hi virus plugin from matt git-svn-id: https://svn.perl.org/qpsmtpd/trunk@200 958fd67b-6ff1-0310-b445-bb7760255be9 --- plugins/check_for_hi_virus | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 plugins/check_for_hi_virus diff --git a/plugins/check_for_hi_virus b/plugins/check_for_hi_virus new file mode 100644 index 0000000..bc9601f --- /dev/null +++ b/plugins/check_for_hi_virus @@ -0,0 +1,44 @@ +#!/usr/bin/perl -w + +sub register { + my $self = shift; + $self->register_hook('data_post', 'check_for_hi_virus'); +} + +sub check_for_hi_virus { + my ($self, $transaction) = @_; + + # make sure we read from the beginning; + $transaction->body_resetpos; + + my $line_number = 0; + my $seen_file = 0; + my $ct_filename = ''; + my $cd_filename = ''; + + while ($_ = $transaction->body_getline) { + last if $line_number++ > 40; + if (/^Content-Type: (.*)/) { + my $val = $1; + if ($val =~ /name="(.*)"/) { + $seen_file = 1; + $ct_filename = $1; + } + } + if (/^Content-Disposition: (.*)/) { + my $val = $1; + if ($val =~ /filename="(.*)"/) { + $seen_file = 1; + $cd_filename = $1; + } + } + } + + if ($seen_file and $ct_filename and $cd_filename) { + if ($ct_filename ne $cd_filename) { + return (DENY, "Probably the 'Hi' virus"); + } + } + + return DECLINED; +}