Hi all,
I'm thinking of using bogofilter as an additional spam filter,
combined with Spamassassin as already supported in the qmail-scanner
package. Bogofilter is very simple to use, it returns a 0 when spam
is likely, and a 1 if it's not.
As I'm just building a mailserver from scratch I have a chance to
play with it a little right now.
Since I'd like to use it as a site-wide scanner I use it with an
option to set the location of the word
lists database it uses. This negates some of the effectiveness, no
doubt, since it's harder to tune
for 150 people than for 1but it's worth a try to see how effective it
is in the end.
I've played a little with the spamassassin routine as an example and
managed something like the
below. Since I'm not much of a perl programmer (read not at all :-) )
I wonder if someone could take a
look at it and give me a few hints on if it would work at all, and on
how to integrate it into the whole
of qmail-scanner.
Locations of files etc:
# when using source rpm and rebuilding:
Bogofilter: /usr/bin/bogofilter
#when compiling from source it defaults to
Bogofilter: /usr/local/bin/bogofilter
#bogofilter options
# -v is verbose, needed to get the actual score string: X-Bogosity:
Yes, tests=bogofilter, spamicity=1.000000, version=0.8.0
# plain and simple check
/usr/bin/bogofilter -v -d /etc/bogofilter/list
#when auto-adding to word lists as bad/good, reinforcing the words db
/usr/bin/bogofilter -v -u -d /etc/bogofilter/list
#when adding to word lists as bad and adding to words db
/usr/bin/bogofilter -v -s -d /etc/bogofilter/list
#when adding to word lists as good and adding to words db
/usr/bin/bogofilter -v -n -d /etc/bogofilter/list
# defined by myself
word lists: /etc/bogofilter/list
#changes to qmail-scanner-queue.template
my $bogo_binary='BOGO_BINARY';
my $bogo_options='BOGO_OPTIONS';
my $bogo_subject='BOGO_SUBJECT';
I assume you'd need to add some tests to the configure script to see
if the binary is present etc. and to
see if the scanner is actually working OK. If you do not have the OK
words list filled, you'll be getting a
SPAM score of 1 on pretty much anything. This would be good to test
for with a direct check, with some
innocent bit of text. There's probably a bunch of other things I
haven't even thought of yet I'm sure you'll
point me to :-)
Anyways, time to go home,
thanks,
Marc
#### code I have hacked up but haven't yet used yet.
sub bogofilter {
#Only run BF if mail is from a "remote" SMTP client, or
QS_SPAMASSASSIN
#is defined via tcpserver...
# dunno..what to do with this QS spamassassin thing ? I suppose it
should just use a diff ENV var
return if (defined($ENV{'RELAYCLIENT'}) &&
!defined($ENV{'QS_SPAMASSASSIN'}));
#bogofilter scanner, returns 0 if spam, 1 if not, or using -v it
will return the X-Bogosity line shown below
my ($bogofilter_found,$bogofilter_status);
my ($start_bogofilter_time)=[gettimeofday];
my ($DD,$bogofilter_status,$stop_bogofilter_time,$bogofilter_time);
my ($bf_status)=0;
my ($bf_score)=0;
&debug("BF: run $bogo_binary $bogo_options <
$scandir/$wmaildir/new/$file_id");
open(BF,"$bogo_binary $bogo_options <
$scandir/$wmaildir/new/$file_id|")||&tempfail("cannot run
$bogo_binary < $scandir/$wmaildir/new/$file_id - $!");
open(SOUT,">$scandir/$wmaildir/new/$file_id.bogo")||&tempfail("cannot
open for write $scandir/$wmaildir/new/$file_id.bogo - $!");
while (<BF>) {
#X-Bogosity: Yes, tests=bogofilter, spamicity=1.000000,
version=0.8.0
if (/^X-Bogosity: (Yes|No), tests=bogofilter, spamicity=(.*),
version=(.*)/) {
$bf_status=1 if ($1 eq "Yes");
$bf_score=$2;$bf_version=$3;
}
print SOUT;
}
close(BF);
close(SOUT);
$bf_score='0' if (!$bf_score);
unlink("$scandir/$wmaildir/new/$file_id.bogo");
if ($bf_status == 0) {
$tag_score .= "BF:0($bf_score):";
$sa_comment = "No, $bf_score too low" if ($bogo_options =~ /\-
v/);
$debug("BF: nope, I don't think this is SPAM");
} else {
$tag_score .= "BF:1($bf_score):";
$bf_comment = "Yes, $bf_score over 0.54" if ($bogo_options =~ /\-
v/);
&debug("BF: yup, this smells like SPAM");
}
$stop_bogofilter_time=[gettimeofday];
$bogofilter_time = tv_interval ($start_bogofilter_time,
$stop_bogofilter_time);
&debug("bogofilter: finished scan of dir \"$scandir/$file_id\" in
$bogofilter_time secs");
}
-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing
your web site with SSL, click here to get a FREE TRIAL of a Thawte
Server Certificate: http://www.gothawte.com/rd524.html
_______________________________________________
Qmail-scanner-general mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/qmail-scanner-general