缓冲区溢出 - 为什么有些 ASCII 可以工作,而另一些则不行
如果这个问题很愚蠢或者已经被问过,我很抱歉,但我找不到它。
我有一个程序试图使用缓冲区溢出。这是一个简单的程序,使用 getchar() 检索用户的输入。缓冲区大小设置为 12。我可以通过键入 >12 x 或使用 >12 \x78 使程序崩溃,但如果我键入数百个 A 或 \x41,则不会出现分段错误。
任何帮助或指出正确的方向将不胜感激。
I'm sorry if this question is stupid or has been asked, but I couldn't find it.
I have a program that I was attempting to use a buffer over flow. It is a simple program that uses getchar() to retrieve the input from the user. The buffer is set to size 12. I can get the program to crash by typing >12 x's or using >12 \x78's, but it won't seg fault if I type in hundreds of A's or \x41's.
Any help or pointing in the right direction would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
0x41414141 可能是进程的文本页内的有效地址。详细信息请查看该流程的段图。
0x41414141 may be a valid address within a text page of the process. Look at the segment map of the process for details.
为了消除猜测,请查看汇编代码,然后查看程序的机器指令。在调试器中运行它并查看内存中发生了什么。您可以看到局部变量放置在堆栈上的哪些地址以及寄存器的哪些地址(尤其是指令指针)保存在函数调用中。
您是否看过维基百科上的堆栈溢出等示例?
To eliminate guessing, look at the assembly code and then at machine instructions of your program. Run it in a debugger and see what happens in the memory. You can see at what addresses on the stack local variables are placed and and what addresses registers and especially the instruction pointer are saved on a function call.
Have you look at examples like the stack overflow on Wikipedia?