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

 

 


Tema destacado: Estamos en la red social de Mastodon


+  Foro de elhacker.net
|-+  Seguridad Informática
| |-+  Análisis y Diseño de Malware (Moderador: fary)
| | |-+  Error intentando hookear FindNextFileA
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Error intentando hookear FindNextFileA  (Leído 2,864 veces)
fary
Moderador
***
Desconectado Desconectado

Mensajes: 1.062



Ver Perfil WWW
Error intentando hookear FindNextFileA
« en: 4 Agosto 2011, 13:03 pm »

pues eso, estoi intentando hookear la api FindNextFileA con una dll que estoi creando en FASM pero no hay manera, el programa me explota cuando arga la dll y intento usar la api, el problema creo que esta en que no vuelve a llamar correctamente al api que modifique y por eso explota :S

Este es el código:

Código
  1. format PE GUI 4.0 DLL
  2. entry DllEntryPoint
  3.  
  4. include 'd:\Fasm\INCLUDE\win32ax.inc'
  5.  
  6. section '.code' code readable executable
  7.  
  8. proc DllEntryPoint hinstDLL,fdwReason,lpvReserved
  9.        cmp [fdwReason],1
  10.        je mensage
  11.        jne salir
  12.  
  13.        mensage:
  14.  
  15.        invoke LoadLibrary,"Kernel32.dll"
  16.        invoke GetProcAddress,eax,"FindNextFileA"
  17.        mov ebx,eax ; Dirección de la api en ebx
  18.  
  19.        mov [PunteroOri],ebx
  20.  
  21.        lea edx,dword[ebp-4]
  22.        invoke VirtualProtectEx,-1,ebx,7,PAGE_EXECUTE_READWRITE,edx
  23.  
  24.  
  25.        mov ecx,ApiOriginal
  26.  
  27.        lea edx,dword[ebp-4]
  28.        invoke VirtualProtectEx,-1,ecx,7,PAGE_EXECUTE_READWRITE,edx
  29.  
  30.        mov al,byte[ebx] ; movemos el primer byte
  31.        mov byte[ecx],al
  32.  
  33.        mov byte[ebx],0x68  ; push
  34.        inc ebx
  35.        inc ecx
  36.  
  37.        mov eax,dword[ebx]   ; movemos 4 bytes
  38.        mov dword[ecx],eax
  39.  
  40.        mov dword[ebx],Funcion ; dreccion funcion
  41.        add ebx,4
  42.        add ecx,4
  43.  
  44.        mov al,byte[ebx] ; ultimo byte
  45.        mov byte[ecx],al
  46.  
  47.        mov byte[ebx],0xC3   ;ret
  48.        inc ebx
  49.  
  50.        salir:
  51.        ret
  52. endp
  53.  
  54. Funcion:
  55.  
  56.             ApiOriginal:
  57.             nop
  58.             nop
  59.             nop
  60.             nop
  61.             nop
  62.             nop
  63.  
  64.             mov eax,[PunteroOri]
  65.             add eax,6
  66.             jmp eax
  67.  
  68.             ret
  69.  
  70.  
  71. ; VOID ShowErrorMessage(HWND hWnd,DWORD dwError);
  72.  
  73. proc ShowErrorMessage hWnd,dwError
  74.  local lpBuffer:DWORD
  75.        lea     eax,[lpBuffer]
  76.        invoke  FormatMessage,FORMAT_MESSAGE_ALLOCATE_BUFFER+FORMAT_MESSAGE_FROM_SYSTEM,0,[dwError],LANG_NEUTRAL,eax,0,0
  77.        invoke  MessageBoxA,[hWnd],[lpBuffer],NULL,MB_ICONERROR+MB_OK
  78.        invoke  LocalFree,[lpBuffer]
  79.        ret
  80. endp
  81.  
  82. ; VOID ShowLastError(HWND hWnd);
  83.  
  84. proc ShowLastError hWnd
  85.        invoke  GetLastError
  86.        stdcall ShowErrorMessage,[hWnd],eax
  87.        ret
  88. endp
  89.  
  90.  
  91.  
  92. section '.data' data readable writeable
  93.        PunteroOri dd ?
  94.  
  95. section '.idata' import data readable writeable
  96.  
  97.  library kernel,'KERNEL32.DLL',\
  98.          user,'USER32.DLL'
  99.  
  100.  import kernel,\
  101.         GetLastError,'GetLastError',\
  102.         SetLastError,'SetLastError',\
  103.         FormatMessage,'FormatMessageA',\
  104.         LocalFree,'LocalFree',\
  105.         LoadLibrary,'LoadLibraryA',\
  106.         GetProcAddress,'GetProcAddress',\
  107.         VirtualProtectEx,'VirtualProtectEx',\
  108.         ExitProcess,'ExitProcess'
  109.  
  110.  import user,\
  111.         MessageBoxA,'MessageBoxA'
  112.  
  113. section '.edata' export data readable
  114.  
  115.  export 'ERRORMSG.DLL',\
  116.         ShowErrorMessage,'ShowErrorMessage',\
  117.         ShowLastError,'ShowLastError'
  118.  
  119. section '.reloc' fixups data discardable
  120.  


Tambien me gustaría que me explicasen como puedo debugear estas cosas ya que no lo tengo muy claro  :-\

saludos.
En línea

Un byte a la izquierda.
.:UND3R:.
Moderador Global
***
Desconectado Desconectado

Mensajes: 3.118


Ingeniería inversa / MASM


Ver Perfil WWW
Re: Error intentando hookear FindNextFileA
« Respuesta #1 en: 4 Agosto 2011, 18:33 pm »

Para debuggear necesitas usar ollydbg, así este te podría mostrar en que linea se genera el error, es decir si hay algún desbordamiento de la pila o se genera una excepción que no se pueda reparar, saludos
En línea


Solicitudes de crack, keygen, serial solo a través de mensajes privados (PM)
fary
Moderador
***
Desconectado Desconectado

Mensajes: 1.062



Ver Perfil WWW
Re: Error intentando hookear FindNextFileA
« Respuesta #2 en: 5 Agosto 2011, 13:13 pm »

Para debuggear necesitas usar ollydbg, así este te podría mostrar en que linea se genera el error, es decir si hay algún desbordamiento de la pila o se genera una excepción que no se pueda reparar, saludos

Asta ahí había llegado... yo preguntaba como cargar la dll y etc. Aora cargo mi DLL co LoadLibrary y listo :P

saludos.
En línea

Un byte a la izquierda.
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
hookear un browser en vb
Programación Visual Basic
achernar_ 5 2,951 Último mensaje 1 Octubre 2008, 17:04 pm
por achernar_
Sobre hookear teclado en c#
.NET (C#, VB.NET, ASP)
Foxzer 1 2,681 Último mensaje 15 Mayo 2010, 07:05 am
por BlackZeroX
Ayuda.Error. Intentando multiplicar dos matrices.
Programación C/C++
sofi1 2 3,014 Último mensaje 22 Agosto 2011, 04:11 am
por sofi1
[RESUELTO]No encuentro error, intentando borrar de un resultset « 1 2 »
Java
|Miguel| 12 9,186 Último mensaje 27 Febrero 2012, 13:59 pm
por |Miguel|
Compilador para hookear funciones
Programación C/C++
Halos 7 3,113 Último mensaje 4 Abril 2013, 02:43 am
por 85
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines