Walks

网络安全爱好者

Python3学习系列(四):编写属于自己的邮件伪造工具

《Python3学习系列(四):编写属于自己的邮件伪造工具》

前言:

相信有些人也看过一些渗透,邮件伪造然后钓鱼这个在渗透中也是经典技巧了,那么邮件伪造又是如何运作的呢?下面的文章将会为你揭示邮件伪造,看完这篇文章,你会发现,原来就是这样。


目录:

  • 0x01:邮件伪造原理

  • 0x02:处理流程

  • 0x03:代码实现

  • 0x04:逐行解析

 0x01 邮件伪造原理

利用的是SMTP协议,因为在SMTP协议里面,是不需要身份认证的,也就是邮件发送者和邮件显示的发送人不一定要一致,那为什么我们平时发送的邮件的邮件发送人和显示的发送人都是一致的呢?这是邮件服务商人为要求的,163,qq邮箱都是如此

 

 0x02 处理流程

  • 注册个邮箱,这里用网易163

 《Python3学习系列(四):编写属于自己的邮件伪造工具》 

  • 登陆邮箱

  • 进入设置

 《Python3学习系列(四):编写属于自己的邮件伪造工具》 

  • 打开SMTP服务

 《Python3学习系列(四):编写属于自己的邮件伪造工具》 

  • 设置授权码

这些只是代码之前的前奏,下面开始我们的工具编写   

0x03  代码编写 

# -*- coding: utf-8 -*-
'''
Program:邮件伪造
Function:伪造邮件发送工具

Version:Python3.6
Time:2017/10/13
Author:Walks
个人博客:http://www.bywalks.com
'''  
  
import smtplib  
import email.mime.multipart  
import email.mime.text  

#建立邮件对象  
msg = email.mime.multipart.MIMEMultipart()  
#添加数据,来自哪,去哪
msg['Subject'] = u'发送asd邮件时设置的标题asd'  
msg['From'] = '123asds@163.com'  
msg['To'] = 'xxx@qq.com'   
content = "你好啊今asdasda好日子,所以西乡说些阿萨德asdasd事情阿斯达所阿斯达所大所大大所大库拉索多拉还是打款哈手机打开哈金士顿哈见到过巴克斯降本增效变成你们准备下次找你没错吧红烧冬瓜 。" 
   
txt = email.mime.text.MIMEText(content,'text','utf-8')    
msg.attach(txt)  # 将多个子部分进行组合  

#防出错  
try:  
        smtp = smtplib.SMTP()
        # 连接到服务器
        smtp.connect('smtp.163.com', '25')
        # 用户名密码登录,密码为163邮箱的授权码
        smtp.login('bywalkss@163.com', 'XXX')
        # 发送邮件 
        smtp.sendmail('bywalkss@163.com', ['739327037@qq.com'], msg.as_string()) 
        smtp.quit()  
        print('邮件发送成功email has send out !')  
except Exception as e:  
    print(e)


0x04  逐行解析

# -*- coding: utf-8 -*-
'''
Program:邮件伪造
Function:伪造邮件发送工具

Version:Python3.6
Time:2017/10/13
Author:Walks
个人博客:http://www.bywalks.com
'''  

#导入两个库,用来发送邮件,multipart用来构造邮件,带附件的
import smtplib  
import email.mime.multipart  
import email.mime.text  

#建立邮件对象  
msg = email.mime.multipart.MIMEMultipart()  
#添加数据,来自哪,去哪
msg['Subject'] = u'发送asd邮件时设置的标题asd' 
#邮件显示的发送人 
msg['From'] = '123asds@163.com'  
#接受地
msg['To'] = 'XXX@qq.com' 
#发送的内容  
content = "你好啊今asdasda好日子,所以西乡说些阿萨德asdasd事情阿斯达所阿斯达所大所大大所大库拉索多拉还是打款哈手机打开哈金士顿哈见到过巴克斯降本增效变成你们准备下次找你没错吧红烧冬瓜 。" 
   
txt = email.mime.text.MIMEText(content,'text','utf-8')   
# 将多个子部分进行组合 
msg.attach(txt)    

#防出错  
try:  
        smtp = smtplib.SMTP()
        # 连接到服务器
        smtp.connect('smtp.163.com', '25')
        # 用户名密码登录,密码为163邮箱的授权码,自己设置的
        smtp.login('bywalkss@163.com', 'XXX')
        # 发送邮件(发送地,接受地,内容) 第二个参数必须为列表
        smtp.sendmail('bywalkss@163.com', ['XXX@qq.com'], msg.as_string()) 
        #退出
        smtp.quit()  
        print('邮件发送成功email has send out !')  
except Exception as e:
    #打印出错原因,可以查看出错代码  
    print(e)

两张成功图。这里为什么会显示代发,上面也说过了,邮件服务商要求,那么我们找一个小服务商是不是就行了?

《Python3学习系列(四):编写属于自己的邮件伪造工具》 《Python3学习系列(四):编写属于自己的邮件伪造工具》

转载请注明来自:www.bywalks.com

点赞
  1. CrowdforApps说道:

    I could not resist commenting. Perfectly written.

  2. CrowdforThink说道:

    I could not resist commenting. Very well written.

  3. Loree Servello说道:

    It happens to be the best occasion to create some goals for the forthcoming future. I've go through this blog posting and if I have the ability to, I desire to propose you handful of worthwhile advice.

  4. Antione Newsom说道:

    I’m impressed, I must say. Rarely do I come across a blog that’s both educative and interesting, and without a doubt, you've hit the nail on the head. The issue is something which not enough folks are speaking intelligently about. Now i'm very happy that I stumbled across this in my hunt for something regarding this.

  5. Tracy Hirst说道:

    You have made some really good points there. I checked on the internet for more information about the issue and found most individuals will go along with your views on this website.

  6. Awsome post and to the purpose. I not extremely apprehend if this is often really the most effective place to raise however do you guys have any thoughts on where to employ several professional writers? Thank you!

  7. MetroClick specializes in building completely interactive products like Photo Booth for rental or sale, Touch Screen Kiosks, Large Touch Screen Displays , Monitors, Digital Signages and experiences. With our own hardware production facility and in-house software development teams, we are able to achieve the highest level of customization and versatility for Photo Booths, Touch Screen Kiosks, Touch Screen Monitors and Digital Signage. Visit MetroClick in NYC at http://www.metroclick.com/ or , 121 Varick St, New York, NY 10013, +1 646-843-0888

  8. viagra说道:

    Excellent post! We will be linking to this particularly great content on our website. Keep up the good writing.

  9. NYC Sapid Agency说道:

    Sapid Agency is a Search Engine Optimization company in New York City that provides SEO Services. Their proprietary SEO strategies help struggling websites and aspiring business owners to rank their websites higher in multiple search engines like Google , Yahoo and Bing. They provide local and gmb map ranking for businesses in NYC and many other local areas. Find more at https://www.sapidagency.com/ @ 145 E 57TH NEW YORK, NY 10022, USA, +1 971 341 5608 USA

  10. why not try here说道:

    I simply want to mention I am just newbie to weblog and actually savored this page. Most likely I’m likely to bookmark your website . You really have great well written articles. With thanks for revealing your website.

  11. viagra说道:

    I used to be able to find good information from your blog posts.

  12. Dixie Bookbinder说道:

    Hi there! This blog post couldn’t be written much better! Looking at this post reminds me of my previous roommate! He always kept talking about this. I will forward this article to him. Fairly certain he's going to have a good read. Thanks for sharing!

  13. Having read this I thought it was very enlightening. I appreciate you spending some time and energy to put this article together. I once again find myself personally spending a lot of time both reading and commenting. But so what, it was still worthwhile!

  14. VSLprint.com说道:

    This is most suitable time to prepare some desires for the extended term. I've read this blog post and if I may, I wish to recommend you number of useful advice.

  15. Way cool! Some extremely valid points! I appreciate you writing this post and also the rest of the site is also really good.

  16. Eugenio Ponds说道:

    Good day there, just turned mindful of your blog site through Bing, and found that it's seriously beneficial. I’ll be grateful for in the event you maintain this informative article.

  17. Corrina Maddron说道:

    It is usually perfect day to get some schemes for the possible future. I have study this posting and if I may, I desire to propose you very few appealing proposal.

  18. Elle Blonde说道:

    Everything is very open with a really clear description of the issues. It was truly informative. Your site is extremely helpful. Many thanks for sharing.

  19. Love Irrigation说道:

    I could not refrain from commenting. Well written.

  20. Gary Kumar说道:

    Heya here, just started to be familiar with your blogging site through The Big G, and have found that it's really good. I’ll be grateful if you continue this informative article.

  21. We List Products说道:

    Aw, this was an exceptionally nice post. Spending some time and actual effort to produce a great article… but what can I say… I hesitate a lot and never manage to get anything done.

  22. Arron Kneisley说道:

    Your style is unique in comparison to other people I've read stuff from. Many thanks for posting when you've got the opportunity, Guess I'll just bookmark this page.

  23. Ferne Cicarella说道:

    This is convenient opportunity to produce some preparations for the long run. I've browsed this blog post and if I can possibly, I want to suggest to you you couple of fascinating tips and advice.

  24. Aconda说道:

    Way cool! Some extremely valid points! I appreciate you penning this article plus the rest of the site is really good.

  25. texas escorts说道:

    I could not resist commenting. Very well written.

  26. shop wise说道:

    I'm more than happy to discover this site. I want to to thank you for ones time for this particularly fantastic read!! I definitely loved every bit of it and I have you book marked to check out new things on your site.

发表评论

电子邮件地址不会被公开。 必填项已用*标注

3 + 5 =