对于缓冲区溢出,使用 pthread 时堆栈地址是多少?
我正在上一门计算机安全课程,有一个额外的学分分配是将可执行代码插入到缓冲区溢出中。我有我正在尝试操作的目标程序的 c 源代码,并且我已经达到了可以成功覆盖当前函数堆栈帧的 eip 的程度。但是,我总是遇到分段错误,因为我提供的地址总是错误的。问题是当前函数位于 pthread 内部,因此,堆栈的地址似乎总是在程序的不同运行之间发生变化。是否有任何方法可以查找 pthread 中的堆栈地址(或估计 pthread 中的堆栈地址)? (注意:pthread_create 的第二个参数为 null,因此我们不会手动分配堆栈地址)
I'm taking a class in computer security and there is an extra credit assignment to insert executable code into a buffer overflow. I have the c source code for the target program I'm trying to manipulate, and I've gotten to the point where I can successfully overwrite the eip for the current function stack frame. However, I always get a Segmentation fault, because the address I supply is always wrong. The problem is that the current function is inside a pthread, and therefore, the address of the stack seems to always change between different runs of the program. Is there any method for finding the stack address within a pthread (or for estimating the stack address within a pthread)? (note: pthread_create's 2nd argument is null, so we're not manually assigning a stack address)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我建议阅读关于利用缓冲区溢出漏洞的优秀(如果有点过时)文章/教程粉碎堆栈为了乐趣和利润。
以下是简短摘录:
您可以通过一些内联汇编来检索堆栈指针的当前值。 为了乐趣和利润而粉碎堆栈中的所有示例都会溢出缓冲区在
main
中,但是您可以轻松地使用相同的技术来溢出从 pthread 调用的函数中的缓冲区。下面的代码基于文章 (overflow1.c) 中的示例构建,以表明相同的技术可以使用 pthreads 工作。您将使用的实际技术取决于您尝试利用的目标程序。I suggest reading the excellent (if a bit dated) article/tutorial on exploiting buffer overflow vulnerabilities Smashing The Stack For Fun And Profit.
Here's a brief excerpt:
You can retrieve the current value of the stack pointer with a bit of inline assembly. All the examples in Smashing The Stack For Fun And Profit overflow a buffer in
main
, but you can just as easily use the same techniques to overflow a buffer in a function called from a pthread. The code below is built on an example from the article (overflow1.c) to show that the same techniques will work using pthreads. The actual technique you will use will depend on the target program you are trying to exploit.除了我之前的回答之外,您可能还想阅读以下内容:
写入缓冲区溢出漏洞利用 - 初学者教程
A逐步解决缓冲区溢出漏洞
以下文章更多地关注堆溢出:
In addition to my previous answer, you may also want to read the following:
Writing buffer overflow exploits - a tutorial for beginners
A step-by-step on the buffer overflow vulnerablity
The following article focuses more on heap overflows:
如果不了解有关应用程序的更多信息,就很难知道,但首先想到的是堆喷射。
Without knowing more about the application it's a little hard to know, but the first thing that comes to mind is heap spraying.