[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

the hopping remailer is done



The hopping remailer is finished.  I wrote it this morning.

The change to make a hopping remailer is very easy.  Here's the new
perl script:

--------- cut here ---------
while (<>) {
	last if /^$/ ;
	$subject = $_ if /^Subject:/ ;
	if (/^Request-Remailing-To:/) {
		chop ;
		s/^.*:// ;
		$addressee = $_ ;
	}
}

#open( OUTPUT, ">foo" ) || die "Cannot open 'foo'." ;
open( OUTPUT, "| /usr/lib/sendmail " . $addressee ) ;
select( OUTPUT ) ;

print "To:" . $addressee . "\n" ;
print "From: nobody\n" ;
print $subject ;
print "Remailed-By: Eric Hughes <[email protected]>\n" ;

#
# check to see if there are header lines in the body to collapse 
#   into the full header.
#

if ( $_ = <> ) {
	if (/^##$/) {
		# do nothing if the pasting token appears
		# the rest of the body will be directly appended
		# this allows for extra header lines to be added
	} else {
		# normal line
		print "\n" ;
		print $_ ;
	}
} else {
	# empty body
	exit ;
}

while (<>) {
} continue {
	print ;
}
--------- cut here ---------

Short explanation.  The 'print "\n" ;' line was moved inside the new
if statement.  The if statement reads a line of the body and stops the
script if there is no body.  The line read is tested to see if it
contains the two characters "##" alone on the line.  "##" is the ANSI
C token pasting operator.  If there is no pasting, a blank line is
printed to mark the end of the header and the first line of the body
is printed.  If there is pasting, then the conditional does nothing,
which has the effect that the body is appended directly onto the end
of the header, allowing you to add more header lines after the header
is rewritten.


Here is a sample message that I sent myself after the new script was
installed:

--------- cut here ---------
To: hughes
Subject: multiple hops
Request-Remailing-To: hughes

##
X-Hop: 1
Request-Remailing-To: hughes

##
X-Hop: 2
Request-Remailing-To: hughes

##
X-Hop: 3

This is a test message of multiple hops.

Eric
--------- cut here ---------


I received four pieces of mail after sending this to myself.  The
first was the actual letter, which is still delivering normally and
not being filtered.  The next two were the first and second
remailings; they had X-Hop: 1 and 2.  The last message was the final
one, had X-Hop: 3 in its header and was delivered normally.

At each stage, the header got rewritten and a new
Request-Remailing-To: line inserted.  When that mail got delivered, it
was again rewritten, with a new remailing request.  This process is
extensible up to the 50K or so practical limitatation on mail size.

Note that this system is not at all secure by itself.  But if each
message body were encrypted first, and the message first decrypted
before the header re-write took place, the routing instructions as a
whole would be hidden from prying eyes.

That's the next project.

Eric