elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: AIO elhacker.NET 2021 Compilación herramientas análisis y desinfección malware


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  Detectar tipo de teclado
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Detectar tipo de teclado  (Leído 4,363 veces)
.:Weeds:.

Desconectado Desconectado

Mensajes: 122



Ver Perfil
Detectar tipo de teclado
« en: 10 Agosto 2013, 02:28 am »

Bueno estoy trabajando en un keylogger y funciona todo a la perfección, pero investigando el tema me he dado cuenta que no todos los teclados son iguales.
Código:
http://es.wikipedia.org/wiki/Teclado_QWERTY
Mi duda es como puedo detectar que tipo de teclado es de forma limpia. Alguno de vosotros tal vez sabe algo del tema por que ya se le haya planteado la cuestión.

Código
  1. Keys.OemOpenBrackets

Esto en el teclado ingles da este valor [, pero en el teclado español da este '. Para que me entendais mejor.

Saludos y gracias.


En línea


raul338


Desconectado Desconectado

Mensajes: 2.633


La sonrisa es la mejor forma de afrontar las cosas


Ver Perfil WWW
Re: Detectar tipo de teclado
« Respuesta #1 en: 10 Agosto 2013, 02:50 am »

Que metodo utilizas para obtener las entradas? Quizás se pueda partir de ahí


En línea

.:Weeds:.

Desconectado Desconectado

Mensajes: 122



Ver Perfil
Re: Detectar tipo de teclado
« Respuesta #2 en: 10 Agosto 2013, 03:27 am »

DLL
Código
  1.        Private Declare Function CallNextHookEx Lib "user32" _
  2.        (ByVal hHook As Integer, _
  3.        ByVal nCode As Integer, _
  4.        ByVal wParam As Integer, _
  5.        ByVal lParam As KBDLLHOOKSTRUCT) As Integer

Funcion
Código
  1.        Private Shared Function KeyboardProc(ByVal nCode As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer
  2.            If (nCode = HC_ACTION) Then
  3.                Select Case wParam
  4.                    Case WM_KEYDOWN, WM_SYSKEYDOWN
  5.                        RaiseEvent KeyDown(CType(lParam.vkCode, Keys))
  6.                    Case WM_KEYUP, WM_SYSKEYUP
  7.                        RaiseEvent KeyUp(CType(lParam.vkCode, Keys))
  8.                End Select
  9.            End If
  10.            Return CallNextHookEx(KeyHook, nCode, wParam, lParam)
  11.        End Function

Lo tipico vamos.. xD

Saludos.
En línea


Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.813



Ver Perfil
Re: Detectar tipo de teclado
« Respuesta #3 en: 10 Agosto 2013, 09:54 am »

Siento decirte que según mis informaciones es símplemente imposible hacerlo en VBNET (al menos usando un hook de bajo nivel como haces),
es más, si quisieras hacerlo en otro lenguaje necesitarías pasar a un siguiente nivel muy superior de experiencia para escribir el hook, inyectarlo, hacerlo compatible con 64 bits, y bypassear UAC.

Intenté solucionar el mismo problema, pero mis capacidades para esto son igual de limitadas e inexpertas, te cito la respuesta a mi problema por parte de un Dios de la programación, para que lo entiendas mejor:

Cita de: Hans Passant
You can never write a correct low-level keyboard hook that translates virtual keys to typing keys. The keyboard state and the active keyboard layout are properties of the process that owns the foreground window. Never of the process that implements the hook.

In particular the keyboard state will be wrong, you don't know if the logical state of the keyboard for the process has the shift, alt, control and Windows key active. That state is recorded when the program receives a keyboard event. Particular to a keyboard layout for languages that use diacritics are the state of the dead keys, the ones you type to get the next typed letter to have an accent. This keyboard state is a per-process state and cannot be retrieved from another process. It is only discoverable within the process itself, GetKeyboardState() function. Much the same for the active keyboard layout, GetKeyboardLayout() function. The language bar allows processes to use different layouts.

It can only ever work 100% correctly when you use a WH_KEYBOARD hook. It requires a DLL that can be injected into other processes. The 3rd argument of SetWindowsHookEx(). Which ensures that GetKeyboardState and GetKeyboardLayout return accurate information. You cannot write such a DLL in VB.NET, the process you inject won't have the CLR loaded to execute managed code. A language like C, C++ or Delphi is required, languages that have very modest runtime support requirements. This is usually where the project peters out. Not just because of the runtime injection problem, debugging such code and dealing with the bitness of a process on a 64-bit operating system as well as UAC are major headaches.

You can limp along somewhat by using GetAsyncKeyState() to get the state of the modifier keys. There is no solution for dead keys other than an injected DLL. This is not a helpful answer, it merely explains why you can never make it work completely reliably in vb.net.

The mapping of Keys.Oemtilde to a typing key is the job of the keyboard layout. Different keyboards produce different letters for that key. The underlying winapi function is ToUnicodeEx(). Note how it requires the keyboard state and layout as I described.

Si quieres leer el resto: http://stackoverflow.com/questions/16893190/issue-with-the-keys-enumeration-and-a-low-level-keyboard-hook#comment24389665_16900034

EDITO: y esto por otra parte para aclarártelo aún más:

Citar
A global WH_KEYBOARD hook however executes in teh context of the app. that is recieving the keyboard message so your code has to be injected into every running process. This is NOT a good idea IMHO.

Saludos
« Última modificación: 10 Agosto 2013, 10:12 am por EleKtro H@cker » En línea

.:Weeds:.

Desconectado Desconectado

Mensajes: 122



Ver Perfil
Re: Detectar tipo de teclado
« Respuesta #4 en: 10 Agosto 2013, 10:57 am »

Gracias electro, me temia algo asi. En la programación siempre pasa algo asi  :xD, pero bueno mi próximo lenguaje es delphi y ahi ya intentare hacer cosas mas serias en cuanto a virus se refiera.

De todas formas para el uso que le voi a dar me sobra, normalmente casi todos los teclados tienen distribución QWERTY (por lo menos en españa), y simplemente quiero que funcione en américa latina y españa. Mi duda es donde se almacena en windows el idioma del teclado, así yo en función de cual sea le doi un valor a la tecla, total es para sacar cuentas de un jueguecillo. También me asalta la duda de que pasaria si hubiera dos teclados conectados jaja.

Posdata: Este es mi mensaje 100 jaja, llevo aqui desde el 2007 (tenia 14 años), y soñaba con hacer troyanos y 'super virus destructivos', que tiempos, ahora que ya lo veo mas factible paso del tema jajajaj, como cambian las cosas.

Saludos!
En línea


Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Convertir de teclado portatil a teclado xa pc
Electrónica
qtpirex 1 3,274 Último mensaje 13 Marzo 2007, 18:09 pm
por loredo
Detectar atajos de teclado « 1 2 »
Programación Visual Basic
50l3r 15 9,372 Último mensaje 1 Febrero 2010, 23:22 pm
por raul338
Redes inhambricas tipo OPN - tipo abierto sin contraseña
Hacking Wireless
a3lf 7 18,494 Último mensaje 29 Septiembre 2010, 00:11 am
por a3lf
Problemas con el teclado en portatil y teclado inalambrico
Hardware
any_t 2 4,098 Último mensaje 2 Septiembre 2012, 16:08 pm
por simorg
detectar parrafo de registro mysql tipo text
PHP
basickdagger 3 2,058 Último mensaje 20 Enero 2015, 19:18 pm
por MinusFour
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines