You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by Apache Wiki <wi...@apache.org> on 2007/02/14 11:41:08 UTC
[Spamassassin Wiki] Update of "RelayedByDialup" by CordBeermann
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Spamassassin Wiki" for change notification.
The following page has been changed by CordBeermann:
http://wiki.apache.org/spamassassin/RelayedByDialup
New page:
#language en
== How it works ==
This plugin checks if a mail has been delivered directly from a dialup-IP. It simply uses the last trusted received-line for the IP and the DNS-Names and tries to find out if the IP-Number is somehow coded into the DNS.
== Requirements ==
none.
== Installation ==
Save the two files below in your local configuration directory.
== Remarks ==
* Note that this is my first SA plugin, so any feedback is welcome
* This Plugin
== ToDo ==
* Words are hardcoded. Should be a configuration parameter instead.
* Instead of checking for specific words, it might be better to "check if the image contains a certain amount of text", since it is not very likely that people send legitimate mail with text in images.
-- Author: Maarten de Boer, mdeboer -at- iua -dot- upf -dot- edu
== Changelog ==
Version 2:
* Use {{{convert}}} instead of {{{giftopnm}}}, because I received some mails with .gif's that were actually .jpg's. {{{convert}}} handles that ok.
* Some words added
== Code ==
=== Ocr.cf ===
{{{
loadplugin Ocr Ocr.pm
body OCR eval:check_ocr()
describe OCR Check if text in attached images contains spam words
score OCR 3.0
}}}
=== Ocr.pm ===
{{{
# Ocr plugin, version 2
package Ocr;
use strict;
use Mail::SpamAssassin;
use Mail::SpamAssassin::Util;
use Mail::SpamAssassin::Plugin;
our @ISA = qw (Mail::SpamAssassin::Plugin);
# constructor: register the eval rule
sub new {
my ( $class, $mailsa ) = @_;
$class = ref($class) || $class;
my $self = $class->SUPER::new($mailsa);
bless( $self, $class );
$self->register_eval_rule("check_ocr");
return $self;
}
sub check_ocr {
my ( $self, $pms ) = @_;
my $cnt = 0;
foreach my $p ( $pms->{msg}->find_parts("image") ) {
my ( $ctype, $boundary, $charset, $name ) =
Mail::SpamAssassin::Util::parse_content_type(
$p->get_header('content-type') );
if ( $ctype eq "image/gif" ) {
open OCR, "|/usr/bin/convert -flatten - pnm:-|/usr/bin/gocr -i - > /tmp/spamassassin.ocr.$$";
foreach $p ( $p->decode() ) {
print OCR $p;
}
close OCR;
open OCR, "/tmp/spamassassin.ocr.$$";
my @words =
( 'company', 'money', 'stock', 'million', 'thousand', 'buy', 'price', 'don\'t' );
while (<OCR>) {
my $w;
foreach $w (@words) {
if (m/$w/i) {
$cnt++;
}
}
}
unlink "/tmp/spamassassin.ocr.$$";
}
}
return ( $cnt > 1 );
}
1;
}}}