#!/usr/bin/env python # -*- coding: utf-8 -*- # ShootMail anonymous email sender by Multiversum import smtplib from email.MIMEText import MIMEText from optparse import OptionParser defaultmx = "aspmx.l.google.com" def shootMail(fro, to, subj, text, server=defaultmx): """ The function that actually gets all the job done. Supply source address, destination address, message subject, message text and (optionally) vulnerable mail exchanger address. """ mail = MIMEText(text) mail['From'], mail['Subject'], mail['To'] = fro, subj, to smtp = smtplib.SMTP(server) smtp.sendmail(fro, [to], mail.as_string()) smtp.close() if __name__ == "__main__": parser = OptionParser() parser.add_option("-f", dest="fromaddr", help="sender email", metavar="from@example.com") parser.add_option("-t", dest="destaddr", help="receiver email", metavar="to@example.com") parser.add_option("-s", dest="subj", help="message subject", metavar="subject") parser.add_option("-m", dest="msg", help="message text", metavar="text") parser.add_option("-x", dest="smtp", help="mail exchanger address (default: Google's primary MX)", metavar="mx.example.com") (options, args) = parser.parse_args() if not options.fromaddr: options.fromaddr = raw_input('From: ') if not options.destaddr: options.destaddr = raw_input('To: ') if not options.subj: options.subj = raw_input('Subject: ') if not options.smtp: options.smtp = defaultmx if not options.msg: print "Enter your message, end with two newlines:" options.msg = '' while True: mline = raw_input('> ') if mline: options.msg = options.msg+mline+"\n" else: break print "Sending message..." shootMail(options.fromaddr, options.destaddr, options.subj, options.msg, options.smtp) print "Message sent"