zoukankan      html  css  js  c++  java
  • 使用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 = '952693358@qq.com'
    
    # receiver QQ
    receiver = '952693358@qq.com'
    
    # 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
    '
    reply: '250-smtp.qq.com
    '
    reply: '250-PIPELINING
    '
    reply: '250-SIZE 73400320
    '
    reply: '250-AUTH LOGIN PLAIN
    '
    reply: '250-AUTH=LOGIN
    '
    reply: '250-MAILCOMPRESS
    '
    reply: '250 8BITMIME
    '
    reply: retcode (250); Msg: smtp.qq.com
    PIPELINING
    SIZE 73400320
    AUTH LOGIN PLAIN
    AUTH=LOGIN
    MAILCOMPRESS
    8BITMIME
    send: 'AUTH PLAIN ADk1MjY5MzM1OABxcmFzdGl1cmNicXViY2ln
    '
    reply: '235 Authentication successful
    '
    reply: retcode (235); Msg: Authentication successful
    send: 'mail FROM:<952693358@qq.com> size=203
    '
    reply: '250 Ok
    '
    reply: retcode (250); Msg: Ok
    send: 'rcpt TO:<952693358@qq.com>
    '
    reply: '250 Ok
    '
    reply: retcode (250); Msg: Ok
    send: 'data
    '
    reply: '354 End data with <CR><LF>.<CR><LF>
    '
    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"
    MIME-Version: 1.0
    Content-Transfer-Encoding: base64
    Subject: =?utf-8?q?Hello?=
    From: 952693358@qq.com
    To: 952693358@qq.com
    
    SGksIHlvdSBhcmUgYmVpbmcgYXR0YWNrZWQh
    .
    '
    reply: '250 Ok: queued as 
    '
    reply: retcode (250); Msg: Ok: queued as
    data: (250, 'Ok: queued as')
    send: 'quit
    '
    reply: '221 Bye
    '
    reply: retcode (221); Msg: Bye
    

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

    2017.3.12

  • 相关阅读:
    乘法逆元
    17-11-01模拟赛
    17/10-17/11做题记录
    17-10-18模拟赛
    17-10-15模拟赛
    13-2.模板复习priority_queue
    bzoj1042[HAOI2008]硬币购物
    bzoj1057[ZJOI2007]棋盘制作
    bzoj1029[JSOI2007]建筑抢修
    bzoj1068[SCOI2007]压缩
  • 原文地址:https://www.cnblogs.com/qq952693358/p/6540220.html
Copyright © 2011-2022 走看看