A cross-platform (Windows/Linux) keylogger written in Python, which detects keystrokes (including correct capitalization) and sends the logs to a Telegram bot periodically.
Warning
This project is for educational purposes only. Malicious use of this code is illegal Use it at your own risk and only on systems that you control or have permission to monitor.
- Real-time keystroke logging.
- Shift and Caps Lock case detection.
- Automatic sending of logs via Telegram.
- Compatible with Windows and Linux.
- Clean, structured and extensible code.
Follow these exact steps to create your Telegram bot and connect it with the keylogger.
- Open the Telegram app.
- Search for @BotFather and start a chat.
- Send the command:
/newbot
- BotFather will ask you for:
- A name -> any name you want (e.g. KeyLog Bot)
- A username -> must end in bot (e.g. logger_bot)
- After successfyl creation, you'll get your token like:
123456789:AbCdEFGhiJklmNoPQRstuvWXyZ
- In Telegram, search for your newly created bot (@logger_bot).
- Click start or type any message like Hello World!.
This is necessary so Telegram can register your chat for updates.
- OpeN your favorite browser and go to:
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates
It's important to replace <YOUR_BOT_TOKEN> with the actual token from BotFather. Alternatively, you can use the terminal
curl -Ss "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates" | jq
- In the response, find a block like:
"chat": {
"id": 123456789,
"first_name": "Çԋ4Яµm",
"username": "Çԋ4Яµm",
"type": "private"
}
- Copy the number inside id -> this is your
CHAT_ID
Open your main.py file and edit the following lines with your actual bot credentials:
BOT_TOKEN = "Your_Telegram_Bot_Token"
CHAT_ID = "Your_Chat_Id"
-
Replace "Your_Telegram_Bot_Token" with the token you received from BotFather.
-
Replace "Your_Chat_Id" with the chat ID you obtained using the getUpdates method.
To run this code, you need to install some dependencies in your Python environment. To do this, you can use pip
or pacman
(on Arch Linux).
- Python 3.7+
- Dependencies:
pynput
requests
python-xlib
(Linux only)
Note
python-xlib
is required only on Linux systems for pynput
to function properly. Do not install it on Windows.
- Clone the repository and install the dependencies.
git clone https://github.com/ch4rum/Keylogger.git
cd Keylogger/Python
- Then install dependencies:
# In windows & some linux
pip install pynput requests python-xlib
# I nArch & some derivate
sudo pacman -S --noconfirm python-pynput python-requests python-xlib
Feel free to fork this repository and propose improvements or additional features though pull requests.