-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspam-filter
85 lines (66 loc) · 2.61 KB
/
spam-filter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
Janos Farkas writes:
> My point is not total elimination of all spam-suspicious mail (I'll have
> other tools for that, as you can see from my address -- yes, it's still
> not finished, should anyone ask :),
Inspired by Janos's idea, I've written two anti-spam email address
manipulators. One expires addresses, and the other matches the
address against the sender, so that only certain senders work. The
code is disgustingly short, so I'm including it here.
Expiring addresses
------------------
This one lets you advertise an email address that only works for a
period of time. It uses an encrypted TAI date. If someone sends
mail after that date, their mail bounces and they're given a new
expiring address. If you post to Usenet with "$USER-dated", then
that mail will immediately bounce back a new dated address to them.
No, I don't have a good system for inserting a dated address into your
mail or posts, although I'd entertain suggestions.
echo '|bin/dated-mail' >.qmail-dated-default
echo './Mailbox-preferred'>>.qmail-dated-default
#!/usr/bin/perl
# -*- Perl -*-
use Crypt::IDEA;
my $timeout = 5*24*60*60; # five days
my $ext2 = $ENV{'EXT2'};
my $user = $ENV{'USER'};
my $key = pack("H*", "55941241c04759c741112d05c23bcd1d");
my $cipher = new IDEA $key;
my $in;
if (length($ext2) == 16 && length($in = pack("H*", $ext2)) == 8) {
$date = unpack("H*",$cipher->decrypt($in));
} else {
$date = 0;
}
exit 0 if $date > time;
$in = sprintf("%16d",time+$timeout);
print "That email address has expired. Use $user-dated-".unpack("H*",$cipher->encrypt(pack("H*", $in)))." instead\n";
exit 100;
Matching Sender
---------------
This one gives you an address that only a certain sender can use. To
get the proper address, subscribe to a list (to get the envelope
sender they'll be using). Examine the log file output to get the
address that will pass the filter, and resubscribe to the list using
that address. Or, if it's a person who's sending you mail, once he
sends you mail, tell him the address that will get into your preferred
mailbox.
echo '|bin/sender-mail 1' >>.qmail
echo '|bin/sender-mail' >.qmail-l-default
echo './Mailbox-preferred'>>.qmail-l-default
#!/usr/bin/perl
# -*- Perl -*-
use MD5;
my $md5 = new MD5;
my $really = shift;
my $user = $ENV{'USER'};
my $sender;
$sender = $ENV{'SENDER'};
$sender =~ s/-return-\d*-.*\@//; # eliminate serial numbers from ezmlm lists.
$sender =~ s/nelson.*=crynwr\.com//; # eliminate VERP
$md5->add("Insert your hash seed here");
$md5->add($sender);
$hash = $md5->hexdigest;
exit 0 if $hash eq $ENV{'EXT2'};
print "The address $user-l-$hash will pass\n";
exit 99 if $really;
exit 0;