使用Python登陆QQ邮箱发送垃圾邮件 简单实现

使用Python登陆QQ邮箱发送垃圾邮件 简单实现,第1张

使用Python登陆QQ邮箱发送垃圾邮件 简单实现 参考:Python爱好者 知乎文章

需要做的是:

1.邮箱开启SMTP功能

2.获取授权码

上述两步百度都有。


源码

#!/usr/bin/env python

from email.mime.text import MIMEText
from email.header import Header
from smtplib import SMTP_SSL # QQ mail smtp server
host_server = 'smtp.qq.com' # sender QQ
sender_qq = '952693358' # pwd
pwd = '*****' # 授权码 # sender qqmail
sender_qq_mail = '[email protected]' # receiver QQ
receiver = '[email protected]' # content
mail_content = 'Hi, you are being attacked!' # title
mail_title = 'Hello' # SSL login
smtp = SMTP_SSL(host_server)
smtp.set_debuglevel(1) # debug
smtp.ehlo(host_server)
smtp.login(sender_qq, pwd) msg = MIMEText(mail_content, "plain", 'utf-8')
msg['Subject'] = Header(mail_title, 'utf-8')
msg['From'] = sender_qq_mail
msg['To'] = receiver smtp.sendmail(sender_qq_mail, receiver, msg.as_string())
smtp.quit()
sh-3.2# ./qqmailattack.py
send: 'ehlo smtp.qq.com\r\n'
reply: '250-smtp.qq.com\r\n'
reply: '250-PIPELINING\r\n'
reply: '250-SIZE 73400320\r\n'
reply: '250-AUTH LOGIN PLAIN\r\n'
reply: '250-AUTH=LOGIN\r\n'
reply: '250-MAILCOMPRESS\r\n'
reply: '250 8BITMIME\r\n'
reply: retcode (250); Msg: smtp.qq.com
PIPELINING
SIZE 73400320
AUTH LOGIN PLAIN
AUTH=LOGIN
MAILCOMPRESS
8BITMIME
send: 'AUTH PLAIN ADk1MjY5MzM1OABxcmFzdGl1cmNicXViY2ln\r\n'
reply: '235 Authentication successful\r\n'
reply: retcode (235); Msg: Authentication successful
send: 'mail FROM:<[email protected]> size=203\r\n'
reply: '250 Ok\r\n'
reply: retcode (250); Msg: Ok
send: 'rcpt TO:<[email protected]>\r\n'
reply: '250 Ok\r\n'
reply: retcode (250); Msg: Ok
send: 'data\r\n'
reply: '354 End data with <CR><LF>.<CR><LF>\r\n'
reply: retcode (354); Msg: End data with <CR><LF>.<CR><LF>
data: (354, 'End data with <CR><LF>.<CR><LF>')
send: 'Content-Type: text/plain; charset="utf-8"\r\nMIME-Version: 1.0\r\nContent-Transfer-Encoding: base64\r\nSubject: =?utf-8?q?Hello?=\r\nFrom: [email protected]\r\nTo: [email protected]\r\n\r\nSGksIHlvdSBhcmUgYmVpbmcgYXR0YWNrZWQh\r\n.\r\n'
reply: '250 Ok: queued as \r\n'
reply: retcode (250); Msg: Ok: queued as
data: (250, 'Ok: queued as')
send: 'quit\r\n'
reply: '221 Bye\r\n'
reply: retcode (221); Msg: Bye

Hint:MIMEText函数中的第二个参数为plain时,发送的是text文本,如果为html,则能发送网页格式文本。


2017.3.12

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/588150.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-12
下一篇 2022-04-12

发表评论

登录后才能评论

评论列表(0条)

保存