🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
13 messages
13 total messages Started by Jesse Mon, 03 Jun 2013 20:05
X-Trace Header Hashing?
#85526
Author: Jesse
Date: Mon, 03 Jun 2013 20:05
9 lines
1325 bytes
I've tried to find recent/useable documentation on hashing the X-Trace 
header in INN but am not finding anything that I (a Usenet admin 
newbee) can follow and make work.

Any tips or links to working documentation?

Cheers,
Jesse
Re: X-Trace Header Hashing?
#85531
Author: Tony
Date: Mon, 03 Jun 2013 22:24
42 lines
2502 bytes
In news.software.nntp, Jesse <jesse.rehmer@blueworldhosting.com> wrote:

>I've tried to find recent/useable documentation on hashing the X-Trace 
>header in INN but am not finding anything that I (a Usenet admin 
>newbee) can follow and make work.
>
>Any tips or links to working documentation?

In $pathetc/filter, change filter_nnrpd.pl.

This is what I'm doing (my perl sucks, btw, but this does work for me),

Near the top,

use Digest::SHA qw(sha256_base64);

then inside 'sub filter_post {'

    if (hdr->{'X-Trace'} =~ m/^(\S+)\s+(.*)/)
    {
      $info .= $1; #
      $newhdr = $1 . ' ' . sha256_base64('some secret key'.$2);
      while (length($newhdr) % 4) {
           $newhdr .= '=';
      }
      $hdr{'X-Trace'}=$newhdr;
    }

    $modify_headers = 1;


The while loop is required to pad the hashed entry to the right length (for
base64).

200 perl experts can now step in and condense it to one line, but I tend to
build things incrementally.
-- 
Tony Evans
Saving trees and wasting electrons since 1993
blog  -> http://perceptionistruth.com/
books -> http://www.bookthing.co.uk/
[ anything below this line wasn't written by me ]
Re: X-Trace Header Hashing?
#85530
Author: Steve Crook
Date: Tue, 04 Jun 2013 09:26
37 lines
2118 bytes
On Mon, 03 Jun 2013 23:24:50 +0100, Tony wrote in
Message-Id: <koj52n$i2d$1@matrix.darkstorm.co.uk>:

> use Digest::SHA qw(sha256_base64);
>
> then inside 'sub filter_post {'
>
>     if (hdr->{'X-Trace'} =~ m/^(\S+)\s+(.*)/)
>     {
>       $info .= $1; #
>       $newhdr = $1 . ' ' . sha256_base64('some secret key'.$2);
>       while (length($newhdr) % 4) {
>            $newhdr .= '=';
>       }
>       $hdr{'X-Trace'}=$newhdr;
>     }
>
>     $modify_headers = 1;

Your example looks fine to me.

> The while loop is required to pad the hashed entry to the right length (for
> base64).
True, if you ever wanted to convert it back from base64 but normally it's
just used to provide a unique identifer.

> 200 perl experts can now step in and condense it to one line, but I tend to
> build things incrementally.

I'm no Perl expert but there are a couple of examples on the Cleanfeed
FAQ page:-
http://mixmin.net/cleanfeed/faq.html#hashhost

-- 
What shall we use 
To fill the empty spaces 
Where we used to talk?
Re: X-Trace Header Hashing?
#85529
Author: Tony
Date: Tue, 04 Jun 2013 16:15
18 lines
1955 bytes
In news.software.nntp, Steve Crook <steve@mixmin.net> wrote:

>I'm no Perl expert but there are a couple of examples on the Cleanfeed
>FAQ page:-
>http://mixmin.net/cleanfeed/faq.html#hashhost

Yup I scanned those when I was putting something together.  I also cobbled
bits from the code used by Albasani.

http://svn.schnuerpel.eu/viewvc.cgi/trunk/?root=schnuerpel

All of my perl code is like Frankenstein's monster.
-- 
Tony Evans
Saving trees and wasting electrons since 1993
blog  -> http://perceptionistruth.com/
books -> http://www.bookthing.co.uk/
[ anything below this line wasn't written by me ]
Re: X-Trace Header Hashing?
#85532
Author: Jesse
Date: Tue, 04 Jun 2013 18:19
14 lines
1686 bytes
On 2013-06-04 09:26:23 +0000, Steve Crook said:

> I'm no Perl expert but there are a couple of examples on the Cleanfeed
> FAQ page:-
> http://mixmin.net/cleanfeed/faq.html#hashhost

One of the examples is for servers generating the Injection-Info 
header… but I didn't think that INN did that yet (thought it was a 
feature added in 2.6.0).  Are you using INN 2.6.0 or how do your 
servers add the Injection-Info header?

Cheers,
Jesse
Re: X-Trace Header Hashing?
#85535
Author: Steve Crook
Date: Tue, 04 Jun 2013 19:38
35 lines
2364 bytes
On Tue, 4 Jun 2013 13:19:25 -0500, Jesse wrote in
Message-Id: <kolb36$kj7$1@nnrp.blueworldhosting.com>:

> On 2013-06-04 09:26:23 +0000, Steve Crook said:
>
>> I'm no Perl expert but there are a couple of examples on the Cleanfeed
>> FAQ page:-
>> http://mixmin.net/cleanfeed/faq.html#hashhost
>
> One of the examples is for servers generating the Injection-Info 
> header… but I didn't think that INN did that yet (thought it was a 
> feature added in 2.6.0).  Are you using INN 2.6.0 or how do your 
> servers add the Injection-Info header?

I'm running 2.6.0.  You could use filter_nnrpd.pl to replace
NNTP-Posting-Host with Injection-Info on older versions.  I haven't
tested it but I think this would work.

use strict;
our (%hdr, $modify_headers);

sub filter_post {
    my $posthost = $hdr{'NNTP-Posting-Host'};
    undef $hdr{'NNTP-Posting-Host'};
    $hdr{'Injection-Info'} = "news.mixmin.net; posting-host=\"$posthost\"; ".
                             'mail-complaints-to="abuse@mixmin.net"';

    $modify_headers = 1;
    return '';
};

-- 
What shall we use 
To fill the empty spaces 
Where we used to talk?
Re: X-Trace Header Hashing?
#85536
Author: Jesse
Date: Wed, 05 Jun 2013 20:03
7 lines
1546 bytes
Next question… As SHA is a one-way hash, how do you decode it later, if 
necessary?  I get that if you have a list of potential values you could 
hash those and compare the hashes, but what if you don't have the list 
of potential values, or your source for generating that list no longer 
exists?

Re: X-Trace Header Hashing?
#85538
Author: Tony
Date: Wed, 05 Jun 2013 20:57
40 lines
2678 bytes
In news.software.nntp, Jesse <jesse.rehmer@blueworldhosting.com> wrote:

>Next question… As SHA is a one-way hash, how do you decode it later, if 
>necessary?  I get that if you have a list of potential values you could 
>hash those and compare the hashes, but what if you don't have the list 
>of potential values, or your source for generating that list no longer 
>exists?

You can't decode hashes.  If you want two way you need to use one of the
encryption libraries instead.  Be warned, the strings you end up with will
be longer.

http://search.cpan.org/~lds/Crypt-CBC-2.22/CBC.pm

You'll need to install the Perl Blowfish libraries too.

Untested,

  use Crypt::CBC;
  use MIME::Base64;

  $cipher = Crypt::CBC->new( -key    => 'my secret key',
                             -cipher => 'Blowfish'
                            );

    if (hdr->{'X-Trace'} =~ m/^(\S+)\s+(.*)/)
    {
      $info .= $1; #
      $cyphertext = $cipher->encrypt($hdr{'X-Trace'});
      $cyphertext = encode_base64($cyphertext);
      $hdr{'X-Trace'}=$1 . ' ' . $cyphertext;
    }

    $modify_headers = 1;
-- 
Tony Evans
Saving trees and wasting electrons since 1993
blog  -> http://perceptionistruth.com/
books -> http://www.bookthing.co.uk/
[ anything below this line wasn't written by me ]
Re: X-Trace Header Hashing?
#85539
Author: Jesse
Date: Wed, 05 Jun 2013 21:12
13 lines
1877 bytes
On 2013-06-05 20:57:33 +0000, Tony said:

> You can't decode hashes.  If you want two way you need to use one of the
> encryption libraries instead.  Be warned, the strings you end up with will
> be longer.

Thanks for the example, I will give this a shot.  All of the examples 
I've found online use a one-way hash as well, but I figured most admins 
would want a way to be able to see the original content in case of 
abuse/DMCA violations.  I couldn't think of a possible way to do that 
with all of the examples I have seen, but assumed admins had some way 
of doing so in order to trace it back if needed.
Re: X-Trace Header Hashing?
#85540
Author: Tony
Date: Wed, 05 Jun 2013 22:14
68 lines
3720 bytes
In news.software.nntp, Jesse <jesse.rehmer@blueworldhosting.com> wrote:

>On 2013-06-05 20:57:33 +0000, Tony said:
>
>> You can't decode hashes.  If you want two way you need to use one of the
>> encryption libraries instead.  Be warned, the strings you end up with will
>> be longer.
>
>Thanks for the example, I will give this a shot.  All of the examples 
>I've found online use a one-way hash as well, but I figured most admins 
>would want a way to be able to see the original content in case of 
>abuse/DMCA violations.  I couldn't think of a possible way to do that 
>with all of the examples I have seen, but assumed admins had some way 
>of doing so in order to trace it back if needed.

The Albasani stuff,

http://svn.schnuerpel.eu/viewvc.cgi/trunk/?root=schnuerpel

uses encryption rather than hashing.

This is the filter_nnrpd.pl file,

http://svn.schnuerpel.eu/viewvc.cgi/trunk/etc/filter/filter_nnrpd.pl?view=markup&root=schnuerpel

Which calls encrypt_headers, which is here,

http://svn.schnuerpel.eu/viewvc.cgi/trunk/lib/Schnuerpel/INN/Filter.pm?view=markup&root=schnuerpel

You want sub encrypt_headers_1036 for INN 2.5.x,

It basically calls encode, which is here,

http://svn.schnuerpel.eu/viewvc.cgi/trunk/lib/Schnuerpel/Crypt.pm?view=markup&root=schnuerpel

use Crypt::Rijndael();
use MIME::Base64();

sub encode($;$)
######################################################################
{
  my $line = shift || confess;
  my $time = shift;

  # add one for line feed
  my $l = 1 + length($line);
  my $keysize = KEYSIZE;

  # round up to next multiple of KEYSIZE, which must be a power of two
  # MIN_PADDING is some integer greater 0
  my $padding = (($l + MIN_PADDING + $keysize) & ~($keysize - 1)) - $l;

  my $p = chars($padding, $padding);
  return MIME::Base64::encode_base64(
    getCipher($time)->encrypt($p . "\n" . $line),
    ''
  );
}

You can basically use the whole Albasani library as-is to do most of the
work if you want, although it's quite heavy for just encrypting a few
headers.
-- 
Tony Evans
Saving trees and wasting electrons since 1993
blog  -> http://perceptionistruth.com/
books -> http://www.bookthing.co.uk/
[ anything below this line wasn't written by me ]
Re: X-Trace Header Hashing?
#85541
Author: Steve Crook
Date: Thu, 06 Jun 2013 08:17
30 lines
2509 bytes
On Wed, 5 Jun 2013 16:12:22 -0500, Jesse wrote in
Message-Id: <koo9jm$cf6$1@nnrp.blueworldhosting.com>:

> On 2013-06-05 20:57:33 +0000, Tony said:
>
>> You can't decode hashes.  If you want two way you need to use one of the
>> encryption libraries instead.  Be warned, the strings you end up with will
>> be longer.
>
> Thanks for the example, I will give this a shot.  All of the examples 
> I've found online use a one-way hash as well, but I figured most admins 
> would want a way to be able to see the original content in case of 
> abuse/DMCA violations.  I couldn't think of a possible way to do that 
> with all of the examples I have seen, but assumed admins had some way 
> of doing so in order to trace it back if needed.

Admins at the injecting server can see the original source because it's
logged (with the Message-ID) in news.notice.  The purpose of the hash is
to supply other users/servers with a consistent user signature without
compromising the originators privacy.

If a group has a regular disruptive poster, other members of the group
can filter out the disruption using the hash.
Unless the posters source address changes, the hash will remain
consistent.

-- 
What shall we use 
To fill the empty spaces 
Where we used to talk?
Re: X-Trace Header Hashing?
#85542
Author: Graham Drabble
Date: Thu, 06 Jun 2013 08:37
23 lines
2504 bytes
On 05 Jun 2013 Jesse <jesse.rehmer@blueworldhosting.com> wrote in
news:koo9jm$cf6$1@nnrp.blueworldhosting.com: 

> On 2013-06-05 20:57:33 +0000, Tony said:
> 
>> You can't decode hashes.  If you want two way you need to use one
>> of the encryption libraries instead.  Be warned, the strings you
>> end up with will be longer.
> 
> Thanks for the example, I will give this a shot.  All of the
> examples I've found online use a one-way hash as well, but I
> figured most admins would want a way to be able to see the
> original content in case of abuse/DMCA violations.  I couldn't
> think of a possible way to do that with all of the examples I have
> seen, but assumed admins had some way of doing so in order to
> trace it back if needed. 

One option would be to store the raw data along with the hash in a 
database and then just put the hash out on the wire.

Gives you a shorter hash, avoids them problem of people trying to 
decrypt your encryption, probably less computationally expensive and 
still lets you get back to the original data if you need it.
Re: X-Trace Header Hashing?
#85543
Author: Jesse
Date: Thu, 06 Jun 2013 13:49
10 lines
1726 bytes
On 2013-06-06 08:17:54 +0000, Steve Crook said:

> Admins at the injecting server can see the original source because it's
> logged (with the Message-ID) in news.notice.

Ah, yes, I was overlooking that simple bit.  I was overthinking this a 
bit yesterday.  Thanks for all the pointers guys!

-Jesse
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