From bf8164c695882e17eb94e8962f27806bb5dc2680 Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Tue, 7 Feb 2012 19:40:59 +0100 Subject: [PATCH] SMTP: Added random Subjects, cleanup --- tunnel/spam/README | 2 +- tunnel/spam/conf.sample.py | 11 ----------- tunnel/spam/spam.py | 18 ++++++++++++++++-- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/tunnel/spam/README b/tunnel/spam/README index 3d0dc48..a0eb97b 100644 --- a/tunnel/spam/README +++ b/tunnel/spam/README @@ -43,10 +43,10 @@ As said in the section below: This needs to be implemented. ;) What could be done ================== + * add support to send mails directly via smtp, not via a specific smtp server * allow the spam tunnel to run as an IP tunnel, configurable via config * implement support for multiple clients * support exchange of encoding dictionary prior to sending/receiving data - * add support to send mails directly via smtp, not via a specific smtp server Licensing diff --git a/tunnel/spam/conf.sample.py b/tunnel/spam/conf.sample.py index 6855f7e..ca81689 100755 --- a/tunnel/spam/conf.sample.py +++ b/tunnel/spam/conf.sample.py @@ -75,17 +75,6 @@ Conf = { # list of all allowed recipients, None for everyone # e.g. ["foo@somedomain.de", "bar@someserver.de"] 'allowTo': None, - - # accept traffic (set to False, if only used as ARP-Server) - # Note: Nevertheless a tapdevice will be created and configured - 'acceptTraffic': False, - }, - - # arp server, returns mac and mail addresses to arp-requests - 'arpserv': - { - # timeout in seconds, when to throw old arps away - 'timeout': }, } diff --git a/tunnel/spam/spam.py b/tunnel/spam/spam.py index a3896a9..af3b5e5 100755 --- a/tunnel/spam/spam.py +++ b/tunnel/spam/spam.py @@ -8,12 +8,13 @@ import asyncore import email from email.mime.text import MIMEText import imaplib +import random import select import smtpd import smtplib +import sys import time import threading -import sys sys.path.append("../../../") from ether2any import Ether2Any @@ -75,12 +76,14 @@ class SimpleSMTPServer(smtpd.SMTPServer): smtpd.SMTPServer.__init__(self, *args, **kwargs) self._handler = handler def process_message(self, peer, mailfrom, mailto, data): + print "[SMTPD] Incoming mail" # give mail to handler self._handler.receiveMail(mailfrom, mailto, data) class SMTPServerThread(threading.Thread): def __init__(self, listen, handler): threading.Thread.__init__(self) + self.daemon = True self.server = SimpleSMTPServer(handler, listen, None) def run(self): @@ -89,6 +92,7 @@ class SMTPServerThread(threading.Thread): class SimpleIMAPClient(threading.Thread): def __init__(self, imapConf, mailTo, handler): threading.Thread.__init__(self) + self.daemon = True self.imapConf = imapConf self.imap = None self.quit = False @@ -227,9 +231,19 @@ class MailTunnel(Ether2Any): self.smtp.sendmail(fromAddr, toAddrs, e.as_string()) print "Mail+reconnect took %fs" % (time.time()-t) + def getRandomSubject(self): + return random.choice([ + "Get laid TODAY!", "This is your chance", "Hello", + "Business proposal", "Your ad on 2 million websites", + "Make Money Online", "Assistance needed", "You WON!", + "Stop wasting time - buy viagra!", "She is waiting for you...", + "He is waiting for you...", "Your IP addres was logged!", + "Never be short again!", "Have your own traffic generator!", + "Credit report FRAUD ALERT", "It's time for you"]) + def sendToNet(self, packet): data = self.generator.encode(packet) - self.sendMail(self.mailFrom, [self.mailTo], "Ohai!", data) + self.sendMail(self.mailFrom, [self.mailTo], self.getRandomSubject(), data) def sendToDev(self, socket): pass