返回地址我用C写的程序(只用于调试):找不到在gdb
void return_input(void)
{
char array[10];
gets(array);
printf("%s\n", array);
}
main()
{
return_input();
return 0;
}
我一直在尝试堆栈溢出,因为我有工作64位机我
gcc -m32 -mpreferred-stack-boundary=2 -ggdb overflow.c -o overflow
然后我gdb调试使用程序编译它,拆开return_input功能,我得到:
0x0804841b <+0>: push %ebp
0x0804841c <+1>: mov %esp,%ebp
0x0804841e <+3>: sub $0xc,%esp
0x08048421 <+6>: lea -0xa(%ebp),%eax
0x08048424 <+9>: push %eax
0x08048425 <+10>: call 0x80482e0 <[email protected]>
0x0804842a <+15>: add $0x4,%esp
0x0804842d <+18>: lea -0xa(%ebp),%eax
0x08048430 <+21>: push %eax
0x08048431 <+22>: call 0x80482f0 <[email protected]>
0x08048436 <+27>: add $0x4,%esp
0x08048439 <+30>: nop
0x0804843a <+31>: leave
0x0804843b <+32>: ret
这标志着返回地址应0x0804843b(或不是吗?)但是,检查ESP时(记住这是一个64位机器上编译程序的32位)与x/20x $esp
(在设置断点后获取函数和ret),我无法找到返回地址:
0xffffd400: 0xffffd406 0x080481ec 0x08048459 0x00000000
0xffffd410: 0xffffd418 0x08048444 0x00000000 0xf7e195f7
0xffffd420: 0x00000001 0xffffd4b4 0xffffd4bc 0x00000000
0xffffd430: 0x00000000 0x00000000 0xf7fb0000 0xf7ffdc04
0xffffd440: 0xf7ffd000 0x00000000 0xf7fb0000 0xf7fb0000
为什么我看不到返回地址?对于长期的问题抱歉。在此先感谢
你有多少''获取'字符串?覆盖返回地址正是如何使用缓冲区溢出来运行恶意代码... – StoryTeller
@StoryTeller,因为我已经在问题中提到过。我在gets处设置了一个中断,因此并没有输入任何内容。问题是我没有看到返回地址 –
@StoryTeller我从来没有听说过堆栈正在向下发展。你能详细说明这一点吗? –