SMTP: Added random Subjects, cleanup

This commit is contained in:
Sebastian Lohff 2012-02-07 19:40:59 +01:00
parent 794b3fe5ab
commit bf8164c695
3 changed files with 17 additions and 14 deletions

View File

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

View File

@ -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':
},
}

View File

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