add klez filter plugin
git-svn-id: https://svn.perl.org/qpsmtpd/branches/v010@52 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
parent
a1d52491bf
commit
ed958c64f6
38
plugins/klez_filter
Normal file
38
plugins/klez_filter
Normal file
@ -0,0 +1,38 @@
|
||||
sub register {
|
||||
my ($self, $qp) = @_;
|
||||
$self->register_hook("data_post", "check_klez");
|
||||
}
|
||||
|
||||
sub check_klez {
|
||||
my ($self, $transaction) = @_;
|
||||
|
||||
# klez files are always around 140K, no?
|
||||
return (DECLINED)
|
||||
if $transaction->body_size < 60_000
|
||||
or $transaction->body_size > 220_000;
|
||||
|
||||
# maybe it would be worthwhile to add a check for
|
||||
# Content-Type: multipart/alternative; here?
|
||||
|
||||
# make sure we read from the beginning;
|
||||
$transaction->body_resetpos;
|
||||
|
||||
my $line_number = 0;
|
||||
my $seen_klez_signature = 0;
|
||||
|
||||
while ($_ = $transaction->body_getline) {
|
||||
$line_number++;
|
||||
warn "$_";
|
||||
m/^Content-type:.*(?:audio|application)/i
|
||||
and ++$seen_klez_signature and next;
|
||||
|
||||
return (DENY, "Klez Virus Detected")
|
||||
if $seen_klez_signature
|
||||
and m!^TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQA!;
|
||||
|
||||
last if $line_number > 40;
|
||||
}
|
||||
|
||||
warn "DECLINED is ", DECLINED;
|
||||
return (DECLINED);
|
||||
}
|
Loading…
Reference in New Issue
Block a user