Click here to Skip to main content
Licence 
First Posted 22 Jun 2005
Views 103,666
Bookmarked 50 times

Pedrams Elite Keylogger

By | 22 Jun 2005 | Article
Logs any Keys and/or Blocks Keys/key combinations

Download Source Code
Download Demo Project
Sample Image - P-E-K.jpg

Note: I intend to make another version, and beside removing bugs and making current code more reliable, I also want to add new features. What features would you like to see in a Keylogger or how could this program be extended? (Please email me at one of the email addresses at the end of the article)

Introduction

This program is capable of capturing any keys at any time. This program can also be customised to preferences. I have created a user interface where you can change options and settings. I have also included a function, where you can block any keys/key combinations pressed.

Using the code

All the keyboard logging/blocking related code is in a module called Keyboard.vb. When you first start the program you might be given an error which says that "Block.txt" is in use or it cannot find "Settings.Set", ignore them and the next time you start the program it should be fixed. In order to see the user interface, you will need to press F12 to exit stealth mode then double-click on the notify icon that appears in the Notification Area (System Tray).

Functions

Below is a list of impotant functions and how they are used

IsHooked - Blocking Keys

(- Public Function IsHooked(ByRef Hookstruct As KBDLLHOOKSTRUCT) As Boolean -)

This function is used to block the key/key combination that has been pressed, to block a key all you have to do is put in 'Return True' :

Public Function IsHooked(ByRef Hookstruct As KBDLLHOOKSTRUCT) As Boolean 
Return True
End Sub

However, this would block any key that is pressed so in order to just block the specified keys you should use Hookstruct.vkcode and the GetAsyncKeyState() function:

Public Function IsHooked(ByRef Hookstruct As KBDLLHOOKSTRUCT) As Boolean 
If Hookstruct.vkcode = 13 Then
Return True
End If
Return False
End Sub

This would block the 'Enter' Key as the keycode for the enter key is 13. Instead of 13, Keys.Enter or VK_ENTER could also be used: Hookstruct.vkcode = 13 > Hookstruct.vkcode = Keys.Enter OR Hookstruct.vkcode = VK_ENTER

To block key combinations the GetAsyncKeyState() function should be used:

Public Function IsHooked(ByRef Hookstruct As KBDLLHOOKSTRUCT) As Boolean 
If GetAsyncKeyState(VK_MENU) and Hookstruct.vkcode = VK_TAB Then
Return True
End If
Return False
End Sub

This would block the key combination ALT + TAB. It first checks too see if the ALT key is down, then it checks too see if the TAB has been pressed. This also means that the Keys ALT and TAB can still be used, but not together.

HookKeyboard & KeyboardCallback - Logging Keys

(- Public Sub HookKeyboard() -)
(- Public Function KeyboardCallback(ByVal Code As Integer, _
      ByVal wParam As Integer, _
      ByRef lParam As KBDLLHOOKSTRUCT) As Integer -)

These two functions are used in logging every key pressed, first HookKeyboard is called from the load event in the main form (Form1.vb) and through a timer, this then 'Hooks' the keyboard and enables the program to log every key pressed. It does this by first retrieving every key pressed before the system does. HookKeyboard then calls KeyboardCallback which determines which key has been pressed. The variable wParam is used to check if any key has been pressed at all:

If wParam = WM_KEYDOWN Then

Once we know that a key has been pressed we have to determine which key it was. This part is easy:

keycode = lParam.vkCode

lParam.vkCode contains the keycode for the key that has been pressed.

In my program, I have used these functions to gather all the keys pressed then write it to a Log File when the user has switched programs:

GetForegroundWindow, GetWindowTextLength, GetWindowText - Logging Keys

(- Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Integer, ByVal lpString As String, ByVal cch As Integer) As Integer -)
(- Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Integer) As Integer -)
(- Private Declare Function GetForegroundWindow Lib "user32" () As Integer -)

In Timer1 I have used these functions to get the program titles that the user has active. The timer builds up a list of Keys (KeysList) that has been pressed, and when the user switches to another program it writes the program title and the keys into the Log file.

If title <> last And last <> "" Then
    writekeys()
End If

It records the windows titles into a variable and checks it agaisnt the new window title, if they are the same the user has still got the same program activated, if they are different the user has switched windows and the keys are written into the Log File.

CreateDefaultSI - Settings

(- Public Function CreateDefaultSI() -)

This is a more simple function which is called if the settings file cannot be found and is corrupt. It deletes the old settings file (if any) then replaces it with a new one with the default settings.

Most functions have not been reviewed in this article and I have just covered the main ones, if you have any questions or need help concerning the code email me at one of the emails listed at the end of this article.

This program was created by Pedram Emrouznejad (p3pedram@hotmail.com, pthree2004@aol.com, pedramscomputer3@aol.com)
Please read the Read Me file (Read Me!!!.txt) (It Explains a lot of stuff)This program is not intended for malicious activities. Use this program at your own risk!
Please retain all credits and give a reference to me and my email when using this code.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Pedram Emrouznejad



United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 1 PinmemberNebojsa Janjic23:42 9 Feb '12  
Questionthis code contains torjan virus Pinmemberpulkit2819:58 29 Dec '11  
GeneralI prefer LightLogger. Pinmemberminregol5:56 10 Nov '10  
GeneralMy vote of 2 PinmemberMARK02410:09 8 Mar '10  
GeneralSourceCode Pinmembersdrolson11:11 6 Dec '07  
General[Message Deleted] PinmemberDomo929:31 18 Sep '07  
GeneralRe: how to remove it? PinmemberiSeeGhosts14:50 20 Oct '07  
GeneralUgly code Pinmemberhorvardson-gly14:59 11 Sep '07  
General5 Based on Merit Pinmembermntc15:17 25 Aug '07  
GeneralFlamers Pinmemberrobert_smith766:13 19 Jul '07  
GeneralRe: Flamers PinmemberPedram Emrouznejad6:19 19 Jul '07  
GeneralRe: Flamers Pinmemberrobert_smith766:57 19 Jul '07  
GeneralWOW is Right PinmemberTellyB5:38 10 Oct '06  
Generalwow! Pinmemberkachie12:17 12 May '06  
GeneralRe: wow! PinmemberPedram Emrouznejad11:52 14 May '06  
QuestionHow dumb can a single person be Pinmembermav.northwind20:22 22 Jun '05  
AnswerRe: How dumb can a single person be Pinmembertom_dx6:31 23 Jun '05  
GeneralRe: How dumb can a single person be Pinmembermav.northwind7:34 23 Jun '05  
AnswerRe: How dumb can a single person be PinmemberPedram Emrouznejad7:32 24 Jun '05  
GeneralRe: How dumb can a single person be Pinmembermav.northwind19:23 24 Jun '05  
GeneralRe: How dumb can a single person be PinmemberPedram Emrouznejad22:55 24 Jun '05  
GeneralRe: How dumb can a single person be Pinmembermav.northwind2:00 25 Jun '05  
GeneralRe: How dumb can a single person be PinPopularmemberPedram Emrouznejad8:23 25 Jun '05  
GeneralRe: How dumb can a single person be Pinmembertom_dx12:15 26 Jun '05  
GeneralRe: How dumb can a single person be - THE FINAL ANSWER PinmemberConXioN15:26 20 Aug '05  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 22 Jun 2005
Article Copyright 2005 by Pedram Emrouznejad
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid