Merge pull request #525 from s0i37/master

added anti-blocking inline images in "Mass Mailer Attack"
This commit is contained in:
trustedsec 2018-04-11 10:56:35 -04:00 committed by GitHub
commit dad1604875
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -212,6 +212,17 @@ if option1 != "99":
if not os.path.isfile(file_format):
file_format = ""
inline_files = []
while True:
yesno = raw_input("Do you want to attach an inline file - [y/n]: ")
if yesno.lower() == "y" or yesno.lower() == "yes":
inline_file = raw_input(
"Enter the path to the inline file you want to attach: ")
if os.path.isfile(inline_file):
inline_files.append( inline_file )
else:
break
subject = input(setprompt(["1"], "Email subject"))
try:
html_flag = input(
@ -315,9 +326,19 @@ def mail(to, subject, prioflag1, prioflag2, text):
fileMsg.set_payload(file(file_format).read())
email.encoders.encode_base64(fileMsg)
fileMsg.add_header(
'Content-Disposition', 'attachment;filename=%s' % (file_format))
'Content-Disposition', 'attachment; filename="%s"' % os.path.basename(file_format) )
msg.attach(fileMsg)
for inline_file in inline_files:
if inline_file != "":
fileMsg = email.mime.base.MIMEBase('application', '')
fileMsg.set_payload(file(inline_file).read())
email.encoders.encode_base64(fileMsg)
fileMsg.add_header(
'Content-Disposition', 'inline; filename="%s"' % os.path.basename(inline_file) )
fileMsg.add_header( "Content-ID", "<%s>" % os.path.basename(inline_file) )
msg.attach(fileMsg)
mailServer = smtplib.SMTP(smtp, port)
io = StringIO()