summaryrefslogtreecommitdiff
path: root/tools/blacklist-update
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-07-16 22:16:43 (GMT)
committerJohn Denker <jsd@av8n.com>2012-07-16 23:04:51 (GMT)
commit14b7add3c77a79fd46ad55a43a4051a10ebfc0b4 (patch)
tree201ac3911ae85a19975926b5df48c2a4cdb35d69 /tools/blacklist-update
parent5636774abde98bcddffdec88b297c7ff322aab43 (diff)
minor upgrades
Diffstat (limited to 'tools/blacklist-update')
-rwxr-xr-xtools/blacklist-update52
1 files changed, 44 insertions, 8 deletions
diff --git a/tools/blacklist-update b/tools/blacklist-update
index 99fe4cc..4621ef2 100755
--- a/tools/blacklist-update
+++ b/tools/blacklist-update
@@ -1,9 +1,33 @@
#! /usr/bin/perl -w
+#########################
+# BEWARE:
+#
+# The most dangerous criminals routinely forge email from-addresses.
+# Therefore blacklisting addresses only works for senders
+# who have bad manners but are otherwise quasi-legitimate.
+#
+# Overuse of blacklisting will punish innocent parties
+# whose domain-names look nice to forgers.
+
+## hint: mail-scan +from * | iconv -c \...
+## | sed 's/.*@//;s/>$//' | sort | uniq -c | sort -nr > some-junk.from-count
+
use strict;
use Symbol;
main: {
+ my $baremode = 0;
+ my @argv = @ARGV;
+ @ARGV = ();
+ while (@argv){
+ my $arg = shift @argv;
+ if ($arg eq '-bare') {
+ $baremode++;
+ } else {
+ die "Unrecognized verbiage '$arg'\n";
+ }
+ }
my $file = '/etc/mail/spamassassin/local.cf';
my $inch = Symbol::gensym;
my $mainpart = '';
@@ -15,6 +39,7 @@ main: {
chomp $line;
my @stuff = split(' ', $line, 2);
if (0+@stuff == 2 && $stuff[0] eq $verb) {
+ my $key = lc($stuff[1]);
$blacklist{$stuff[1]} ++;
} else {
$mainpart .= $line . "\n";
@@ -23,23 +48,34 @@ main: {
close $inch;
my $unchanged = 0;
my $new = 0;
- while (my $line=<>){
+ liner: while (my $line=<>){
chomp $line;
- if ($line =~ m'<.*@(.*)>$') {
- my $key = "*@" . $1;
+ my $domain = '';
+ if ($baremode) {
+ my @stuff = split(' ', $line);
+ $domain = $stuff[$#stuff];
+ } else {
+ if ($line =~ m'<.*@(.*)>$') {
+ $domain = $1;
+ } else {
+ print STDERR "no '<user\@domain>'; ignoring line ...\n";
+ print STDERR "... '$line'\n";
+ next liner;
+ }
+ }
+ if ($domain ne '') {
+ my $key = "*@" . lc($domain);
if (exists $blacklist{$key}) {
$unchanged++;
} else {
$new++;
}
- $blacklist{$key} ++;
- } else {
- print STDERR "no '<user\@domain>'; ignoring line ...\n";
- print STDERR "... '$line'\n";
+ $blacklist{$key} ++;
}
+
}
- my $ouch = Symbol::gensym;
+ my $ouch = Symbol::gensym;
open($ouch, '>', $file)
|| die "Could not open output file '$file'\n";
print $ouch $mainpart;