Spamcopped

Oleg Broytmann phd at phd.russ.ru
Mon Feb 26 05:10:44 EST 2001


Hello!

On Thu, 22 Feb 2001, Chris Withers wrote:
> >    If SpamCop does the same, whay it's better? (I really interesting...)
>
> SpamCop is also very well respected. In fact, I've read the some ISPs value
> SpamCop reports a lot more than hand written emails to their abuse addresses.

   Thank you very much! The SpamCop.NET service proved to be very good!!!
I took their perl script and rewrote it to Python. Julian gladly accepted
the script on http://spamcop.net/fom-serve/cache/166.html.
   I'm attaching the script here too, for archiving purpose.

Oleg.
----
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.
-------------- next part --------------
#! /usr/local/bin/python -O
"""Spamcop reporter. This program is a translation of a perl script
published on http://spamcop.net/fom-serve/cache/166.html to Python.
Author: Oleg BroytMann <phd2 at mail.com>"""


# The programs expects UCE with full headers to be fed into its stdin.
# After it forwards the message to SpamCop, it opens additional filehandle
# to read from /dev/tty and waits for Enter. This is to report that the spam
# was successfully forwarded.


### IMPORTANT! IMPORTANT! IMPORTANT!
### Put you *real* address or forwarder here
### Because some "abuse departments" may collect such addresses to
### flood you with additional spam (UCE) you may register additional
### addres specially for this. There are many free e-mail providers to
### help you.

my_real_address = "user at host.domain"


# open a pipe to sendmail
import os
sendmail = os.popen("/usr/lib/sendmail -oi -t", 'w')

# write headers and simulate MIME attachments in the body of the message
sendmail.write("""From: %s
To: spamcop at spamcop.net
Subject: reply anyway
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="DeathToSpamDeathToSpamDeathToSpam"

This is a multi-part message in MIME format.
--DeathToSpamDeathToSpamDeathToSpam
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


--DeathToSpamDeathToSpamDeathToSpam
Content-Type: message/rfc822
Content-Disposition: attachment

""" % my_real_address)


# copy stdin to the pipe
import sys
while 1:
   line = sys.stdin.readline()
   if not line: break

   sendmail.write(line)


# finish MIME part
sendmail.write("""

--DeathToSpamDeathToSpamDeathToSpam--
""")


# report success
print
print "Message forwarded"
print "Press Enter to continue"

# open /dev/tty for reading and wait for Enter key; this is needed because
# stdin is not available (there was UCE fed into stdin, do you remember?)
tty = open("/dev/tty", 'r')
line = tty.readline()
tty.close()


More information about the Python-list mailing list