VB .Net Keyboard Hook

Share This:

vb-headerThere are many ways of making a key logger in Visual Basic .Net. Just like there are many legitimate reasons to making a key logger. However many of the hookless key logging methods I’ve tried in VB .Net have many limitations. Some wont log speacial characters like the Period or the @ and # characters. This causes problems with reliable key logging. The only and best way I have found to be able to log keystrokes in a way that it should log them is by hooking the keyboard.

After spending some time on the MSDN site, studying keyboard mapping. As well as spending time on the PinVoke site looking at examples of using the user32.dll file on Windows systems. I was able to come up with a nice little class that can be added to a VB .Net project to log keystrokes by using a low level keyboard hook to hook the keyboard.




This is done by injecting our custom VB .Net code into the user32.dll, since the user32.dll is not a supported .Net Library it becomes a bit more difficult to import it into our project. Which is why injecting the DLL is necessary.

After writing the class and adding it the VB .Net project it becomes simple to apply the achieve the needed goals. Because this involves injecting code into DLLs and certain legal concerns, I wont be posting any code since it people can apply the methods used for injecting dlls for malicious purposes.




Resources