You may be wondering: What is a Keylogger? And how can I use it to spy on my friends? Here's all you need to know: The Keylogger is a program that runs in the background without interrupting your work, and monitors your keyboard, recording each key stroke (that is, every time you press a key) in a logfile. By accessing this Logfile, you would hit the Jackpot.
With this program running on someone's laptop/computer, you can get hold of usernames and passwords that they enter, with the user unaware that the information is being recorded.
Beware! Data Theft is a serious offence. We will not take responsibility for any mishap that can be caused by this program. This program is shared solely for the purpose of entertainment.
So what are we waiting for? Let's jump right in! And don't forget to get the source code from the download link given at the end!
Required Libraries
We will require pynput library, which you can install using pip. We will be working specifically with the Listener method of the pynput.keyboard module, which will detect all interactions with the keyboard. We need the logging library to log the keys in the file. Apart from these, we also require os to get the directory for storing logfile, and datetime for logging the time at which a key is pressed.
The Code
As always, importing our libraries before we get on with the actual coding:
Getting the directory and setting the configuration (directory, mode, format) for the logfile:
We then define our own function key_handler(key) with key as the parameter. Here, key is the pressed key which will be detected by Listener. This function then records the information along with the time from datetime to the logfile:
We now initiate the Listener module, with its parameter on_press calling our defined function key_handler(key), and finally joining this entire instance (of recording a single key) to the main thread, as follows:
With this, our Keylogger program is ready to enter service! As you can see, the entire program is just a couple of lines, but it serves the purpose full and square.
The Working
On running the program, you may minimize the IDLE window, and type anything anywhere, like for example, on chrome.
After you type to your heart's wish, go to the same directory, where this python program is stored, and you will see the text document mylog (the name is set using the logging.basicConfig(), discussed in the previous section.
This is how the logfile looks:
Additionally, we can also make a program to simplify the information by grouping the information to form sentences across different time intervals. That's up to you!
And there you have it! All you have to do now is to start this program in the system you want to spy on. You could do that manually or by sending the executable program via email as .exe file (which is highly unlikely to work, as windows and anti-viruses usually block these).
Here's the promised download link for the source code: Download Python File
Credits to Mihir Trivedi for Source code of this project.
Comments
Post a Comment