How To Write A Basic Keylogger In VB
We need a main form, which will act as HQ to the program.
First of all, as our program shall run, we need to make sure it is hidden. This should be very simple to accomplish:
Private Sub Form_Load()
Me.Visisble = False
End Sub
This makes our program invisible to the human eye. To make it invisible to computers eye too, we need to add this line in the Form_Load() event App.TaskVisible = False . This enabled our logger to run in stealth mode and the regular Task Manager will not see our application. Although it will still be possible to see it in the processes tab, there are “ways” to make it hidden. Figure them out yourself, they have nothing to do with programming.
OK, now that our program has run in stealth mode, it should do its essential logging task. For this, we shall be using a whole load of API. These are the interfaces that the Application Platform (windows) itself provides us in those annoying dll files.
There are 3 methods to listen for keys:
* GetAsyncKeyState
* GetKeyboardState
* Windows Hooks
Althought the last method is easier to use, this will not work on Windows98 and also it is NOT very precise. Many people use it, but as my experiences revealed, Keyboard Hooks are only a good way of blocking keys and nothing else. The most exact and precise method in my experience is GetAsyncKeyState().
So lets use this function, but where is that damn thing and how to use it?
Private Declare Function GetAsyncKeyState Lib “USER32″ (ByVal vKey As Long) As Integer
This is how we use a function already present in a dll file. In this case we are using the user32.dll and the function we are using is GetAsyncKeyState(). The arguments (Long vKey), and return value (Long) shall be discussed later, right now its enough to know that this function can listen to keystrokes.
What we need next is to run this function infinitely (as long as the system is running). To do this, just put a Timer control on the form and name it tmrTimer. This timer is used to run the same line of code forever. Note that a while loop with a universally true condition would also accomplish same, but the while loop will certainly hang the system and will lead to its crash as opposed to timer. Timer will not hang the system at all because a while loop tends to carry out the instruction infinitely WITHOUT any break and it also keeps the control to itself, meaning that we cannot do any other job as the loop is running (and with a universally true statement, the while loop will not let the control pass to ANYWHERE else in the program making all the code useless) while the Timer control just carries out the instuction after a set amount of time.
So the two possibilities are:
Do While 1=1
‘our use of the GAKS (GetAsyncKeyState) function Loop
and
Private Sub tmrTimer_Timer()
‘our use of the GAKS function
End Sub
Timer being set, lets move on to see how the GAKS function works and how are we going to use it. Basically what the GAKS function does is that it tells us if a specific key is being pressed or not. We can use the GAKS function like this: Hey GAKS() check if the ‘A’ key is being pressed. And the GAKS function will tell us if it is being pressed or not. Sadly, we can’t communicate with processors like this, we have to use some flamboyant 007 style
If GAKS(65)<>0 Then
Msgbox “The ‘A’ key is being pressed”
Else
Msgbox “The ‘A’ key is not being pressed”
End If
Popularity: 6% [?]

Enjoyed this article? Subscribe to Hacking Truths and get daily updates about new cool websites and programs in your email for free.







this guide was quite useful for the beginners…
Can you please mail me about how to autostart the application when system starts without keeping it in the startup and how to run this application when other application is statted,eg.run keylog only when user starts yahoomail….
copy the exe to the systemroot directory i.e. if ur windows is installed in c:\ then copy the .exe file to c:\windows\system32
now goto run>gpedit.msc>computer configuration>admin templates>system>logon>
right click on run these programs at usr logon in the right frame and click properties. click on the enable radio button and click add.
now type the filename.exe in it and cllik add.
ur done.
else if u dont copy the exe in system root type the full path of the .exe in the last step.
cheers.
Sir Please if you give more help in the article i think that give us more easy to make keyloggers, sir i litle bilt understand but if you post it with images then i think i realy understood…plz sir
Very good article..
I am not into coding but i was searching something else and came to this post. I’ve seen spyware installing automatically to remote computers.. how can that be possible?
thanks for posting such article…
keep it up..
Cheers..
very good article….very usefull for keen learners…can u plz mail me the complete information about how to program a keylogger.
Leave your response!
Our Sponsers
Public Poll
Subscribe
Free Email Updates
Subscribe via SMS
*Standard text messaging rates may apply from your carrier*
Most Popular Posts
Recent Posts
Most Commented
Blogroll
Keep Droping
Categories
Archives
Translator