Article View: alt.privacy.anon-server
Article #238371Downloading a.a.m (and doing nothing else)
From: Non scrivetemi
Date: Thu, 06 May 2010 18:13
Date: Thu, 06 May 2010 18:13
183 lines
5782 bytes
5782 bytes
You have a computer with Python installed, some bandwidth to spare,
and do you want to help people who need a larger anonymity set for
their messages in a.a.m? Then I might have exactly what you need:
I wrote* a small script to download all messages from a.a.m. and do
nothing else. Its sole purpose is generating traffic reading a.a.m
in order to increase the crowd. CPU load is practically non-
existent, traffic is minimal (currently ~800-900 KB/day).
*) To be precise, I took some bits and pieces of aam2mail and
removed the rest.
Instructions: Save aam2crowd.py and config.py to two files, the
boundaries should be obvious. Check for erroneously wrapped lines
(no worries, Python can find any you miss), and edit the config to
your preferences. Preferrably, the script would be called
regularly, for example by a cron job.
As usual, comments are welcome.
#!/usr/bin/python
# aam2crowd.py
#------------------------------------------------------------
import nntplib
import socket
import string
import sys
import config
# Read file
try:
state_handle = open(config.aam_state_file, 'r')
state_lines = state_handle.readlines()
state_handle.close()
except IOError:
print 'Warning: error reading state file %s' %
(config.aam_state_file)
state_lines = []
# Fill state map
state_map = {}
for line in state_lines:
line = string.split(string.strip(line), ':', 2)
state_map[line[0]] = string.strip(line[1])
# Connect to server
try:
nntp_conn = nntplib.NNTP(config.nntp_server, config.nntp_port,
config.nntp_user, config.nntp_pass)
except nntplib.NNTPError, e:
print '\nError connecting to server:', e
sys.exit()
except socket.error, e:
print '\nError connecting to server:', e
sys.exit()
# Get group stats
try:
(group_resp,group_count,group_first,group_last,group_name) =
nntp_conn.group(config.nntp_group)
except nntplib.NNTPError, e:
print '\nError selecting group:', e
sys.exit()
group_first = int(group_first)
group_last = int(group_last)
# Read article watermark
if state_map.has_key(config.nntp_server):
watermark = int(state_map[config.nntp_server])
else:
watermark = -1
# Check watermark
if watermark == group_last:
print 'No new messages. (%d)' % (group_last)
nntp_conn.quit()
sys.exit()
# Get article range to load
load_first = max(group_first, watermark, group_last -
config.first_batch + 1)
load_last = group_last
# If too many articles, load only oldest
if watermark > 0 and load_last > load_first + config.max_batch - 1:
load_last = min(group_last, load_first + config.max_batch - 1)
# Info output
print '%s articles, %s-%s, load %d-%d (%d max)' % (group_count,
group_first,
group_last, load_first, load_last, load_last - load_first + 1)
# Get xover
(xover_resp, xover_items) = nntp_conn.xover(str(load_first),
str(load_last))
# Check message info
for item in xover_items:
# Get message info
(id, subject, poster, date, mid, references, size, lines) = item
subject = string.strip(subject)
size = int(size)
# Check message size
if size > config.max_size:
continue
if config.verbose:
print '* %s %5d %s' % (id, size, subject)
else:
print '%s' % (id),
# Get text
try:
(resp, id, mid, text) = nntp_conn.article(id)
except EOFError, e:
print '\nError downloading from server:', e
sys.exit()
# Output
if not config.verbose:
print '*'
# Close NNTP connection
nntp_conn.quit()
# Update watermark
state_map[config.nntp_server] = load_last
try:
state_handle = open(config.aam_state_file, 'w')
for key in state_map.keys():
state_handle.write(key + ':' + str(state_map[key]) + '\n')
state_handle.close()
except IOError:
print 'Warning: error writing state file %s' %
(config.aam_state_file)
state_lines = []
#------------------------------------------------------------
# aam2crowd.py
# end
#!/usr/bin/python
# config.py
#------------------------------------------------------------
# Base directory
basedir = '/tmp'
# News config
nntp_port = 119
nntp_server = 'news.alt.net'
nntp_user = False
nntp_pass = False
# State file
aam_state_file = basedir + "/aam2crowd.txt"
# NNTP group name
nntp_group = 'alt.anonymous.messages'
# Size of first batch
first_batch = 1000
# Maximum batch size after first
max_batch = 500
# Maximum message size in bytes
max_size = 32000
# Verbose output
verbose = True
#------------------------------------------------------------
# config.py
# end
Technical Details
Message-ID:
<c0602417d91f683dbfb9d08b60e852b4@pboxmix.winstonsmith.info>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!border1.nntp.ams.giganews.com!nntp.giganews.com!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!news.wiretrip.org!news.bananasplit.info!mail2newsShow Full Headers
Complete Article Headers
Message-ID: <c0602417d91f683dbfb9d08b60e852b4@pboxmix.winstonsmith.info> Subject: Downloading a.a.m (and doing nothing else) Date: Thu, 06 May 2010 18:13:12 +0000 From: "Non scrivetemi" <nonscrivetemi@pboxmix.winstonsmith.info> 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!border1.nntp.ams.giganews.com!nntp.giganews.com!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!news.wiretrip.org!news.bananasplit.info!mail2news Message: This is a Type II anonymous message, sent to you by the Winston Smith Project Pboxmix mixmaster server at pboxmix.winstonsmith.info. If you do not want to receive anonymous messages, please contact pbox-admin@winstonsmith.info. Newsgroups: alt.privacy.anon-server X-No-Archive: yes X-Abuse-Contact: abuse@bananasplit.info Organization: Bananasplit - Mail2News Injection-Info: mail2news.bananasplit.info Lines: 182