#!/usr/bin/perl
sub
extra_vote($$$);
my
@filters
=
@Mail::SpamFilter::FILTER_LIST
;
if
(
@ARGV
&& (
$ARGV
[0] eq
"-f"
)) {
shift
(
@ARGV
);
@filters
=
grep
{
$_
ne
"spamassassin"
}
@filters
;
}
@filters
=
grep
{
$_
ne
"dspam"
}
@filters
;
undef
$/;
my
$msg
= <>;
die
"$!\n"
unless
defined
(
$msg
);
if
(
length
(
$msg
) > 750000) {
print
$msg
;
exit
(0);
}
$msg
=~ s/\nX-Spam-Votes:.*//g;
my
(
$tags
,
$header
,
$body
) = filter_message(
$msg
,
@filters
);
my
(
$spam_votes
) = count_votes(
$tags
,
@filters
);
$spam_votes
++
if
$$tags
{
"*extra*"
} =~ /(^|\n)X-\w+-MailScanner-SpamScore: .
*sssss
/;
$spam_votes
++
if
extra_vote(
$tags
,
$header
,
$body
);
$spam_votes
++
if
$body
=~ /^\s*$/;
print
$header
;
print
$$tags
{
"*extra*"
};
foreach
my
$filter
(
sort
@filters
) {
print
$$tags
{
$filter
};
}
print
"X-Spam-Votes: $spam_votes\n"
;
print
$body
;
sub
extra_vote($$$) {
my
(
$tags
,
$header
,
$body
) =
@_
;
$body
=~ s/=([a-fA-F0-9]{2})/
pack
(
"H2"
,
"$1"
)/ge;
if
(
$body
=~ /<a\s+href=[^\"]*\"(.*?)\">\s*<img/is) {
my
$ref
= $1;
return
(1)
unless
$ref
=~ /amazon|ebay|paypal/i;
}
elsif
(
$body
=~ /<a\s+href\s*=\s*[^\"]*\"(.*?)\">.*<[^<>]
*img
.
*src
\s*=\s*\"cid:/is) {
my
$ref
= $1;
return
(1)
unless
$ref
=~ /amazon|ebay|paypal/i;
}
elsif
(
$body
=~ /<a\s+href\s*=\s*[^\"]*\"(.*?)\">.*\"font-size:\s*1px;\"/is) {
my
$ref
= $1;
return
(1)
unless
$ref
=~ /amazon|ebay|paypal/i;
}
return
(0);
}