I am trying to exploit a small program. The program looks somewhat like this:
int func(void) {
char text[100];
scanf("%s", text);
return 0;
}
int foo(unsigned short rand) {
char RandomBuffer[rand];
return func();
}
int main(int argc, char* args[]) {
srand(time(NULL));
return foo(rand() % 1000);
}
I used ROPgadget to build a ROP chain. The tool finds a gadet which is needed for the attack:
Gadget found: 0x8058fcc pop edx ; ret
My ROP chain starts like this:
p = ‘rnd padding’
p += pack('<I', 0x08058fcc) # pop edx ; ret
However when executing my exploit I get:
Stopped reason: SIGILL
0x08058fcc in _int_memalign ()
The EIP points to the address computed by ROPgadget but somehow it is not the correct command.
EIP: 0x8058fcc (<_int_memalign+108>: lock mov eax,esi)
What am I missing?
Cheers