我试图利用c编写(不是我本人)的Web服务器中的缓冲区溢出漏洞。为此,我必须从命令行向Web服务器发送HTML请求,这会导致缓冲区溢出并使服务器崩溃。我知道如何使用curl向Web服务器发出HTML请求,但是到目前为止,我能够成功完成的工作只是请求index.html文件。为此,我使用命令
curl http://<host-name>:<port>/index.html
我不知道该怎么做,除了检索上面的页面外,还使用此命令执行其他操作。
我知道我需要发出一个包含比缓冲区能够容纳的更多字节的请求,但是我不知道如何使用HTTP请求来做到这一点。
这是我在缓冲区缓冲区漏洞位于218行附近的位置附近评论的Web服务器的代码。(该文件很长,但我认为遗漏任何内容可能会使问题难以回答,请粘贴整个内容https://pastebin.com/yQwn97xY)
这是我认为缓冲区溢出漏洞所在的部分:
char *status(int statcode) {
if (statcode == 200) return "200 OK";
else if (statcode == 304) return "304 Not Modified";
else if (statcode == 400) return "400 Bad Request";
else if (statcode == 403) return "403 Forbidden";
else if (statcode == 404) return "404 Not Found";
else if (statcode == 500) return "500 Internal Server Error";
else if (statcode == 501) return "501 Not Implemented";
else return "";
}
int send_response(int sockfd, httpreq_t *req, int statcode) {
//BUFFER OVERFLOW VULNERABILITY BELOW
//
int urifd;
const int BUFSIZE = 1024;
char sendmessage[BUFSIZE];
char *path = req->uri;
if (req->uri == NULL || req->method == NULL ||
req->headers == NULL || req->version == NULL) {
return 0;
}
要在端口8081上启动服务器,我只需键入:
./webserver 8081
下一步,我想从另一个终端发送一个HTTP请求,该请求滥用了缓冲区溢出漏洞,导致服务器崩溃。
编辑: 在看到另一个可能的漏洞(第79行附近)之后,我尝试尝试的其他操作是在标头中添加一些内容,使其长度超过1024个字节。使用命令:
curl -v -H "Other:<about 2000 characters>" <hostname>:<port>/index.html
这仍然没有使服务器崩溃,因此我认为漏洞利用没有在79行附近,但这可能是正确的,但这并不是利用它的正确方法。