mirror of
https://github.com/trustedsec/social-engineer-toolkit
synced 2024-12-13 22:42:37 +00:00
utf-8 fix
This commit is contained in:
parent
c2e35f4118
commit
6ccb8bf26c
1 changed files with 15 additions and 5 deletions
|
@ -10,11 +10,17 @@ import glob
|
|||
import random
|
||||
import time
|
||||
import base64
|
||||
from cStringIO import StringIO
|
||||
from email.MIMEMultipart import MIMEMultipart
|
||||
from email.MIMEBase import MIMEBase
|
||||
from email.MIMEText import MIMEText
|
||||
from email.header import Header
|
||||
from email.generator import Generator
|
||||
from email import Charset
|
||||
from email import Encoders
|
||||
|
||||
Charset.add_charset('utf-8', Charset.BASE64, Charset.BASE64, 'utf-8')
|
||||
|
||||
# default the email messages to plain text
|
||||
# unless otherwise specified
|
||||
message_flag="plain"
|
||||
|
@ -241,17 +247,21 @@ if option1 != "99":
|
|||
def mail(to, subject, prioflag1, prioflag2, text):
|
||||
|
||||
msg = MIMEMultipart()
|
||||
msg['From'] = from_displayname
|
||||
msg['From'] = str(Header(from_displayname, 'UTF-8').encode() + ' <' + from_address + '> ')
|
||||
msg['To'] = to
|
||||
msg['X-Priority'] = prioflag1
|
||||
msg['X-MSMail-Priority'] = prioflag2
|
||||
msg['Subject'] = subject
|
||||
msg['Subject'] = Header(subject, 'UTF-8').encode()
|
||||
|
||||
body_type=MIMEText(text, "%s" % (message_flag))
|
||||
body_type=MIMEText(text, "%s" % (message_flag), 'UTF-8')
|
||||
msg.attach(body_type)
|
||||
|
||||
mailServer = smtplib.SMTP(smtp, port)
|
||||
|
||||
io = StringIO()
|
||||
msggen = Generator(io, False)
|
||||
msggen.flatten(msg)
|
||||
|
||||
if sendmail == 0:
|
||||
|
||||
if email_provider == "gmail":
|
||||
|
@ -266,7 +276,7 @@ def mail(to, subject, prioflag1, prioflag2, text):
|
|||
try:
|
||||
if provideruser != "" or pwd != "":
|
||||
mailServer.login(provideruser, pwd)
|
||||
mailServer.sendmail(from_address, to, msg.as_string())
|
||||
mailServer.sendmail(from_address, to, io.getvalue())
|
||||
|
||||
except:
|
||||
# try logging in with base64 encoding here
|
||||
|
@ -281,7 +291,7 @@ def mail(to, subject, prioflag1, prioflag2, text):
|
|||
return_continue()
|
||||
|
||||
if sendmail == 1:
|
||||
mailServer.sendmail(from_address, to, msg.as_string())
|
||||
mailServer.sendmail(from_address, to, io.getvalue())
|
||||
|
||||
# if we specified a single address
|
||||
if option1 == '1':
|
||||
|
|
Loading…
Reference in a new issue