elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.
 
Inicio Ayuda Buscar Ingresar Registrarse
23 Mayo 2012, 05:56  


Tema destacado: Recuerda que debes registrarte en el foro para poder participar (preguntar y responder)

+  Foro de elhacker.net
|-+  Seguridad Informática
| |-+  Análisis y Diseño de Malware (Moderadores: Karcrack, [Zero])
| | |-+  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 739 veces)
mDrinky

Desconectado Desconectado

Mensajes: 277


Miauuuuuuuuuuuuu dice el gato XD


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

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
format PE GUI 4.0 DLL
entry DllEntryPoint
 
include 'd:\Fasm\INCLUDE\win32ax.inc'
 
section '.code' code readable executable
 
proc DllEntryPoint hinstDLL,fdwReason,lpvReserved
       cmp [fdwReason],1
       je mensage
       jne salir
 
       mensage:
 
       invoke LoadLibrary,"Kernel32.dll"
       invoke GetProcAddress,eax,"FindNextFileA"
       mov ebx,eax ; Dirección de la api en ebx
 
       mov [PunteroOri],ebx
 
       lea edx,dword[ebp-4]
       invoke VirtualProtectEx,-1,ebx,7,PAGE_EXECUTE_READWRITE,edx
 
 
       mov ecx,ApiOriginal
 
       lea edx,dword[ebp-4]
       invoke VirtualProtectEx,-1,ecx,7,PAGE_EXECUTE_READWRITE,edx
 
       mov al,byte[ebx] ; movemos el primer byte
       mov byte[ecx],al
 
       mov byte[ebx],0x68  ; push
       inc ebx
       inc ecx
 
       mov eax,dword[ebx]   ; movemos 4 bytes
       mov dword[ecx],eax
 
       mov dword[ebx],Funcion ; dreccion funcion
       add ebx,4
       add ecx,4
 
       mov al,byte[ebx] ; ultimo byte
       mov byte[ecx],al
 
       mov byte[ebx],0xC3   ;ret
       inc ebx
 
       salir:
       ret
endp
 
Funcion:
 
            ApiOriginal:
            nop
            nop
            nop
            nop
            nop
            nop
 
            mov eax,[PunteroOri]
            add eax,6
            jmp eax
 
            ret
 
 
; VOID ShowErrorMessage(HWND hWnd,DWORD dwError);
 
proc ShowErrorMessage hWnd,dwError
 local lpBuffer:DWORD
       lea     eax,[lpBuffer]
       invoke  FormatMessage,FORMAT_MESSAGE_ALLOCATE_BUFFER+FORMAT_MESSAGE_FROM_SYSTEM,0,[dwError],LANG_NEUTRAL,eax,0,0
       invoke  MessageBoxA,[hWnd],[lpBuffer],NULL,MB_ICONERROR+MB_OK
       invoke  LocalFree,[lpBuffer]
       ret
endp
 
; VOID ShowLastError(HWND hWnd);
 
proc ShowLastError hWnd
       invoke  GetLastError
       stdcall ShowErrorMessage,[hWnd],eax
       ret
endp
 
 
 
section '.data' data readable writeable
       PunteroOri dd ?
 
section '.idata' import data readable writeable
 
 library kernel,'KERNEL32.DLL',\
         user,'USER32.DLL'
 
 import kernel,\
        GetLastError,'GetLastError',\
        SetLastError,'SetLastError',\
        FormatMessage,'FormatMessageA',\
        LocalFree,'LocalFree',\
        LoadLibrary,'LoadLibraryA',\
        GetProcAddress,'GetProcAddress',\
        VirtualProtectEx,'VirtualProtectEx',\
        ExitProcess,'ExitProcess'
 
 import user,\
        MessageBoxA,'MessageBoxA'
 
section '.edata' export data readable
 
 export 'ERRORMSG.DLL',\
        ShowErrorMessage,'ShowErrorMessage',\
        ShowLastError,'ShowLastError'
 
section '.reloc' fixups data discardable
 


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

saludos.
En línea
.:UND3R:.


Desconectado Desconectado

Mensajes: 1.957


Ingeniería inversa


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

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

mDrinky

Desconectado Desconectado

Mensajes: 277


Miauuuuuuuuuuuuu dice el gato XD


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

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
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Powered by SMF 1.1.16 | SMF © 2006-2008, Simple Machines