【发布时间】:2017-04-01 00:10:42
【问题描述】:
我正在尝试制作一个简单的缓冲区溢出教程,通过 xinetd 在端口 8000 上将下面的程序作为服务运行。代码是使用
编译的gcc -o bof bof.c -fno-stack-protector
ubuntu 也关闭了堆栈保护。
利用本地即
python -c ---snippet--- | ./bof
成功并执行了隐藏功能,显示文本文件内容。
但是,将其作为服务运行并执行
python -c ---snippet--- | nc localhost 8000
利用时不返回任何内容。我在这里遗漏了什么吗?
#include <stdio.h>
void secret()
{
int c;
FILE *file;
file = fopen("congratulations.txt", "r");
if (file) {
while ((c= getc(file)) !=EOF)
putchar(c);
fclose(file);
}
void textdisplay()
{
char buffer[56];
scanf("%s", buffer);
printf("You entered: %s\n", buffer);
}
int main()
{
textdisplay();
return 0;
}
【问题讨论】:
-
在 stackoverflow.com 寻求帮助之前,您缺少一些可以自己进行的分析。例如,使用 strace 来验证 xinetd 确实按预期分叉并执行您的服务器进程,并且您的服务器进程成功地读取()了漏洞。
标签: c buffer-overflow