So I try to understand stack based buffer-overflow but now I am stuck. This is the vulnerable function (32 bit ELF).
int test(char* input)
{
char buf[100];
printf("Buffer is at %p\n", &buf); // leak helper
strcpy(buf, input);
return 1;
}
I already calculated to number of bytes until the eip is overwritten (112 bytes). The exploit looks like this roughly like this shellcode + '\x55' * (116 - len(shellcode) - 4) + '\x??\x??\x??\x??'
The last 4 bytes are my return address and I get this value from the leak in the code (printf of buf address). The value of the address is something like 0x????ffff. Now when I fill the ?? with the little endian format the value from the leak \xff get's converted to 0xc3 0xbf when I look into the stack memory. What am I doing wrong ?
checksecoutput of the binary as well