Low level keyboard hook

谁说我不能喝 提交于 2020-01-03 16:55:22

问题


I just bought a new keyboard, and I'm interested in tracking exactly how many keypresses/strokes I make during the entire life of the keyboard. (I would want to just record keyUp, as I don't care about repeats)

I've been googling around for the best way to do this, but I don't even know what approach to take, so I'm having trouble searching intelligently. Also, the only language I've really worked with is C#. Haven't done anything with C/C++ or WinAPI

Is it difficult to modify the Win 7 drivers directly? I do want to be able to record keystrokes from the moment the computer boots, but this may not be easily done. I would prefer to use an existing driver or hook, as I really don't care to get into learning device drivers right now.

I've looked briefly at Ctrl2Cap, but I don't know how to modify something like that to suit my case.

Other questions I looked at,

  • Writing a keyboard device driver
  • Low level keyboard Hook not at UI thread

This one indicates writing a USB Filter driver may work, but I have no clue where to start on that. Disabling the keyboard in windows c++?


回答1:


It is not necessary to go the driver route, which is not for the faint of heart. You can use use a low level keyboard hook which will work fine from .NET.

I did a quick bing and found the following on codeplex http://globalmousekeyhook.codeplex.com/

It should get you going




回答2:


If you want to do that you need to use Kernel Level Keylogger. It's grabs the keystrokes before the operating system takes effects and this one 99% invisible for detection techniques. Then you can grab the Windows Log On screen typed things like password/username etc.

@ChrisTaylor's key logger not work for WinLog-on Screen I reckon. If you can install the keyboard driver filter before the system keyboard device driver take a action you can handle windows user login screen also. But In order to install this driver level key hook you need to have administrator privileges.

I found Unix and Windows Keyloggers from Github. Free to play with this https://www.adlice.com/kernelmode-rootkits-part-3-kernel-filters/ and have fun!




回答3:


That, what you want is dangerous! With the same code everyone can create keylogger* But if you not a virus creator then I recommend you to search "hotkeying in C/C++" or something like that and hook keyboard with hotkeys! I have written HotKey Maker in VB6 which can make hotkey from every button of keyboard. But I really not interested in viruses :) Good Luck !

*Virus which hooks your keyboard and send all what you wrote in keyboard to Virus owner



来源:https://stackoverflow.com/questions/11570513/low-level-keyboard-hook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!