Thread View: news.software.nntp
3 messages
3 total messages
Started by Dougal Campbell
Tue, 24 Mar 1998 00:00
NoCeM generation?
Author: Dougal Campbell
Date: Tue, 24 Mar 1998 00:00
Date: Tue, 24 Mar 1998 00:00
22 lines
1642 bytes
1642 bytes
I asked this a couple of months ago (in several places: newsgroups,
mailing lists, private email to some current issuers....), but never
got any responses except for other people looking for the same info.
What the heck, let's try again....
Does anyone out there already have code they're willing to share which
will automatically generate NoCeM notices for spam? I've considered
hacking it into CleanFeed, but I've been horribly short on time, and
was hoping that I could mooch someone else's efforts :)
I want to start issuing notices on a couple of regional
hierarchies (hsv.* and alabama.*).
--
Dougal Campbell, Systems Manager, ADViCOM dougal@advicom.net
http://www.advicom.net/ http://advicom.net/~dougal/
See my homepage for anti-spam information!
QUOTE OF THE MOMENT:
Vitamin C deficiency is apauling
Re: NoCeM generation?
Author: Andrew Gierth
Date: Tue, 24 Mar 1998 00:00
Date: Tue, 24 Mar 1998 00:00
19 lines
1504 bytes
1504 bytes
>>>>> "Dougal" == Dougal Campbell <dougal@vespucci.advicom.net> writes: Dougal> Does anyone out there already have code they're willing to Dougal> share which will automatically generate NoCeM notices for Dougal> spam? Code to generate NoCeMs from a logfile was posted to nanau by Chris Lewis a while back; you can find it on DejaNews or I can forward you a copy. The harder part is the actual spam-detection. Modifying Cleanfeed to produce a log suitable for Chris's generator wouldn't be too hard. Brian Antoine posted his spam-detector (modified to do only local article removal) here a while back (again, Dejanews should have it). -- Andrew.
Re: NoCeM generation?
Author: Alan Schwartz
Date: Tue, 24 Mar 1998 00:00
Date: Tue, 24 Mar 1998 00:00
153 lines
4903 bytes
4903 bytes
Dougal Campbell <dougal@vespucci.advicom.net> writes:
>I asked this a couple of months ago (in several places: newsgroups,
>mailing lists, private email to some current issuers....), but never
>got any responses except for other people looking for the same info.
>What the heck, let's try again....
>
>Does anyone out there already have code they're willing to share which
>will automatically generate NoCeM notices for spam? I've considered
>hacking it into CleanFeed, but I've been horribly short on time, and
>was hoping that I could mooch someone else's efforts :)
>
>I want to start issuing notices on a couple of regional
>hierarchies (hsv.* and alabama.*).
How about this:
#!/usr/local/bin/perl -w
#
# mknocem - Given a news article or mbox file of news articles on stdin,
# issue a NoCeM notice for those articles
#
# Copyright (c) 1998 by Alan Schwartz
#
use strict 'subs';
use strict 'refs';
use English;
use Mail::Header;
require 'ctime.pl';
#######################################################################
# USER CONFIGURATION: VARIABLES YOU MUST SET
#######################################################################
# Your email address
$issuer = 'myname@myhost';
# Location of the pgp program:
$pgp = '/usr/local/bin/pgp';
# The id of the PGP key to sign messages with
$pgpid = 'myname@myhost';
# Put your PGP key pass phrase here if you don't want to be
# prompted for it.
$ENV{'PGPPASS'} = 'pgp pass phrase here';
# The tag to go at the end of the Subject: header:
# Use "@@NCM" if you're hiding spam/spew
# Use "@@<newsgroup name>" if you're hiding off-topic postings
$subjecttag = '@@NCM';
# The "type" of notice. Example: spam, spew, mmf
$type = "spam";
# You can put an explanation here of the purpose of these notices.
# The paragraph must end with the string EOP, on a line by itself.
$explanation = <<'EOP';
This is an automatically generated NoCeM ("no-see-um") notice. It is
purely advisory and does not cancel the message listed below. It's a
convenience for Usenet readers who may choose to mark these articles as
"already read".
EOP
#######################################################################
# END OF USER CONFIGURATION
#######################################################################
sub read_mbox_stdin;
my @messages = read_mbox_stdin();
die "No articles to process\n" unless @messages;
my @nocems;
my $id = "$issuer-$$-" . time;
unless ($subjecttag eq '@@NCM') {
$newsgroup = $subjecttag;
$newsgroup =~ s/\@\@//;
}
my $nltab = "\n\t";
foreach my $msgref (@messages) {
my $header = new Mail::Header $msgref, MailFrom => 'IGNORE';
my $messageid = $header->get("Message-ID");
chomp($messageid);
my $newsgroups = $header->get("Newsgroups");
chomp($newsgroups);
$newsgroups =~ s/,/$nltab/og;
push(@nocems,"$messageid\t$newsgroups\n");
}
my $headers = <<EOP;
Newsgroups: alt.nocem.misc,news.lists.filters
From: $issuer
Subject: NoCeM notice $id $subjecttag
EOP
my $tempfile = "/tmp/mknocem.$$";
open(OUT,">$tempfile") or die "Unable to open temporary file $tempfile: $!\n";
print OUT <<EOP;
$explanation
\@\@BEGIN NCM HEADERS
Version: 0.93
Issuer: $issuer
Type: $type
Action: hide
EOP
print OUT "Newsgroup: $newsgroup\n" if $newsgroup;
print OUT "Count: ", scalar(@nocems), "\n";
print OUT '@@BEGIN NCM BODY', "\n";
print OUT join("",@nocems);
print OUT '@@END NCM BODY', "\n";
close(OUT);
system("$pgp -s $tempfile -u $pgpid");
open(OUT,"$tempfile.asc") or
die "Unable to open pgp-signed temporary file $tempfile.asc: $!\n";
print $headers;
print <OUT>;
close(OUT);
unlink("$tempfile");
unlink("$tempfile.asc");
exit 0;
# Based on read_mbox in Graham Barr's MailTools module
# Returns an array of references to messages, where each
# message is an array of lines.
sub read_mbox_stdin {
my @mail = ();
my $mail = [];
my $blank = 1;
while(<STDIN>) {
if($blank && /\AFrom .*\d{4}/) {
push(@mail, $mail) if scalar(@{$mail});
$mail = [ $_ ];
$blank = 0;
} else {
$blank = m#\A\Z#o ? 1 : 0;
push(@{$mail}, $_);
}
}
push(@mail, $mail) if scalar(@{$mail});
return wantarray ? @mail : \@mail;
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads