最近學緩衝區溢出,同時又在學習Python,foxmail5有個溢出漏洞,書上給出的利用程序是用C語言寫的,代碼很長很複雜,決定用python改寫下,沒什麼技術含量,代碼還沒完全寫好,下面的只是發送郵件的功能。
- #code by 趙小布
- import smtplib
- import email
- from email.message import Message
- from email.mime.multipart import MIMEMultipart
- from email.mime.text import MIMEText
- from email.mime.p_w_picpath import MIMEImage
- #用了QQ的郵箱
- smtpserver='smtp.qq.com'
- smtpuser='******@qq.com'
- smtppass='******'
- smtpport='25'
- def login():
- #登陸郵件服務器
- server=smtplib.SMTP(smtpserver,smtpport)
- server.ehlo()
- server.login(smtpuser,smtppass)
- return server
- def sendTextEmail(DestAdd,subject,content):
- result = False
- server = login()
- msg = Message()
- msg['Mime-Version']='1.0'
- msg['From'] = 'aaaaaaa' #Foxmail5有溢出漏洞的地方
- msg['To'] = '[email protected]'
- msg['Subject'] = 'test '
- msg['Date'] = email.Utils.formatdate()
- msg.set_payload(content)
- try:
- server.sendmail(smtpuser,toAdd,str(msg))
- result = True
- except Exception ,ex:
- print Exception,ex
- print 'Error - send failed'
- return result
- if __name__ == '__main__':
- print sendTextEmail('DestAddr', 'subject, 'content')
沒什麼技術含量,呵呵,接下去打算補全。