🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.privacy.anon-server
Article #214570

here is the famous trollwatch script, donated to the usenet populous!

#214570
From: Anonymous via Panta Rhei
Date: Fri, 23 Feb 2007 18:19
202 lines
7075 bytes
#!/usr/bin/perl
require 5;
$VERSION = '1.0';
use File::Slurp;
use warnings;
use Getopt::Std;
use List::Util ('shuffle');
use News::Article;
use strict 'refs';

my(%option, $inputFilename, $outputFilename, @addBody, $code);
my $ctr = 0;
my(@dropGroups) = ();
my(@followups) = ();

# generate troll alerts
# example:
# $ grep -r -l '^From: Some Idiot' /var/spool/news/alt/what/ever |xargs trollwatch

# By default this script adds Followup-To: alt.dev.null,
# X-No-Archive: Yes, and a X-Code header to keep it from replying
# to its own messages. It also copies the troll's From so that
# people who killfile him won't see these alerts.

# This script just generates messages, it's up to you how you get
# them onto usenet.  Warning, if you post a lot of these so you
# can be traced, you'll probably get TOSsed!

# -G alt.foo,alt.bar
#    drop some Newsgroups
# -N 
#    do not FU alt.dev.null
# -a 
#    do not set X-No-Archive: Yes
# -b FILE
#    use text from FILE instead of default data
# -c 
#    suppress X-Code: random header
# -d DIRECTORY
#    put output file here instead of pwd
# -f 'Some Name foo@bar'
#    use this From header instead of copying
#    from the original messages
# -u alt.foo,alt.bar
#    add FUs
# -L FILE
#    ignore files not newer than FILE

# This script is hereby donated to the PUBLIC DOMAIN.

getopts 'd:af:b:u:G:NcL:', \%option;

my $maxAge = $option{L} ? (-M $option{L}) : 0;
my $outputDirectory = $option{'d'} || '.';
if ($option{'G'}) {
    @dropGroups = split(/,/, $option{'G'}, 0);
}

push @followups, 'alt.dev.null' unless $option{'N'};
push @followups, split(/,/, $option{'u'}, 0) if $option{'u'};

if ($option{'b'}) {
    @addBody = read_file($option{'b'});
}
else {
    @addBody = <DATA>;
}

foreach $inputFilename (@ARGV) {
    if (($option{L}) && (-M $inputFilename >= $maxAge)) {
        print "$inputFilename  ignored (too old)\n";
    }
    else {
	my $input = 'News::Article'->new($inputFilename);
	if ($input->header('X-Code')) {
	    print "$inputFilename  ignored (X-Code)\n";
	}
	else {
	    my $output = 'News::Article'->new;
	    my $from = $option{'f'} || $input->header('From');
	    $output->set_headers('Subject', reSubject($input), 
				 'From', $from, 
				 'References', reRefs($input));
	    $output->set_headers('X-No-Archive', 'Yes') unless $option{'a'};
	    unless ($option{'c'}) {
		$code = `mcookie`;
		chomp $code;
		$output->set_headers('X-Code', $code);
	    }
	    $output->set_body(reBody($input));
	    my(@groupings) = reGroup($input);
	    my $groups;
	    while (@groupings) {
		$outputFilename = getFilename($outputDirectory, $inputFilename);
		$groups = shift @groupings;
		$output->set_headers('Newsgroups', $groups);
		$output->set_headers('Followup-To', fu($groups)) if @followups > 0;
		open OUTFILE, ">$outputFilename";
		$output->write(\*OUTFILE);
		close OUTFILE;
		print "$inputFilename  -->  $outputFilename\n";
	    }
	}
    }
}

sub reSubject {
    my $subject = $_[0]->header('Subject');
    $subject = 'Re: ' . $subject unless $subject =~ /\s*(\[.*\])?\s*Re:/i;
    return $subject;
}

sub reRefs {
    my(@refs) = $_[0]->header('Message-ID');
    my(@oldRefs) = split(/\s+/, $_[0]->header('References') || '', 0);
    unshift @refs, pop @oldRefs if @oldRefs;
    unshift @refs, shift @oldRefs if @oldRefs;
    return join(' ', @refs);
}

sub getFilename {
    my $orig = $_[1];
    $orig =~ s[^.*/][];
    my $fn;
    do {
        $fn = $_[0] . '/' . $orig . '-' . $$ . $ctr++ . '.output'
    } while -f $fn;
    return $fn;
}

sub reGroup {
    my(@groups) = shuffle(split(/,/, $_[0]->header('Newsgroups'), 0));
    if ($option{'G'}) {
        @groups = dropGroups(@groups);
    }
    my(@output) = ();
    while (@groups > 3) {
        push @output, join(',', @groups[0, 1, 2]);
        shift @groups;
        shift @groups;
        shift @groups;
    }
    push @output, join(',', @groups);
    return @output;
}

sub dropGroups {
    my(%groups) = map({$_, 1;} @_);
    foreach my $item (@dropGroups) {
        delete $groups{$item};
    }
    return keys %groups;
}

sub fu {
    my(@groups) = split(/,/, $_[0], 0);
    unshift @groups, @followups;
    if (@groups > 3) {
        @groups = @groups[0, 1, 2];
    }
    return join(',', shuffle(@groups));
}

sub reBody {
    my(@old) = $_[0]->body;
    my $from = $_[0]->header('From');
    my(@new) = map({"> $_";} grep({not $_ =~ /:\s*$/ if not $_ =~ /^\s*>/ and not $_ =~ /^\s*$/;} @old));
    while (@new > 4) {
        pop @new;
    }
    unshift @new, "$from wrote:", '';
    push @new, '', @addBody;
    return @new;
}

__DATA__
                    /|  /|      _____________________
                    ||__||     |                     |
                   /   O O\__  |    PLEASE DO NOT    |
                  /          \ |   FEED THE TROLLS   |
                 /      \     \|_____________________|
                /   _    \     \      ||
               /    |\____\     \     ||
              /     | | | |\____/     ||
             /       \|_|_|/   |     _||
            /  /  \            |____| ||
           /   |   |           |      --|
           |   |   |           |____  --|
    * _    |  |_|_|_|          |     \-/
*-- _--\ _ \                  |      ||
   /  _     \\        |        /      `
*  /   \_ /- |       |       |
   *      ___ C_c_c_C/ \C_c_c_c____________ 
~~~~~~~~~~~~~~~~~~~~~
This message was posted via one or more anonymous remailing services.
The original sender is unknown.  Any address shown in the From header
is unverified. You need a valid hashcash token to post to groups other
than alt.test and alt.anonymous.messages. Visit www.panta-rhei.eu.org
for abuse and hashcash info.


Technical Details
Message-ID: <L8V479BP39136.8053125@anonymous.poster>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-alt.privacy.anon-server.20141023.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!news-in-01.newsfeed.easynews.com!easynews.com!easynews!newsfeed.news2me.com!newsfeed.icl.net!colt.net!feeder.news-service.com!news2.euro.net!213.132.189.2.MISMATCH!multikabel.net!feed20.multikabel.net!newsfeed.freenet.de!border2.nntp.ams.giganews.com!nntp.giganews.com!news.wiretrip.org!news.bananasplit.info!news.panta-rhei.eu.org!not-for-mail

Show Full Headers
Complete Article Headers
Message-ID: <L8V479BP39136.8053125@anonymous.poster>
Subject: here is the famous trollwatch script, donated to the usenet populous!
Date: Fri, 23 Feb 2007 18:19:39 +0000
From: Anonymous via Panta Rhei <anonymous@panta-rhei.eu.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-alt.privacy.anon-server.20141023.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!news-in-01.newsfeed.easynews.com!easynews.com!easynews!newsfeed.news2me.com!newsfeed.icl.net!colt.net!feeder.news-service.com!news2.euro.net!213.132.189.2.MISMATCH!multikabel.net!feed20.multikabel.net!newsfeed.freenet.de!border2.nntp.ams.giganews.com!nntp.giganews.com!news.wiretrip.org!news.bananasplit.info!news.panta-rhei.eu.org!not-for-mail
Newsgroups: alt.privacy.anon-server
Organization: remailer network
Comments: Remailed message. Visit www.panta-rhei.eu.org for abuse info.
X-Remailer-Contact: admin@panta-rhei.eu.org
NNTP-Posting-Host: 127.0.0.1
X-Trace: news.panta-rhei.eu.org 1172254779 127.0.0.1 (23 Feb 2007 19:19:39
 +0100)
Lines: 202