首页 > 解决方案 > 如何远程利用 sprintf 代码漏洞

问题描述

#define PORT 7070
int exec_command(int sock, char *buf) {
    char command[300];
    // redirecting the stdout to the socket
    close(STDOUT_FILENO);
    dup2(sock, STDOUT_FILENO);
    // The following line is different for each linux command to be executed.
    sprintf(command, "/usr/bin/nslookup %s", buf);
    system(command);
    return 0;
}

所以假设我们有上面显示的代码片段,客户端输入一个 url 输入,让服务器对其进行 curl 搜索。我认为该漏洞与“sprintf”有关,问题是我尝试了多个输入来尝试提示服务器提供一些堆栈内存,但到目前为止都没有成功。有谁知道如何远程攻击这种类型的漏洞?

标签: securitybuffer-overflowformat-string

解决方案


推荐阅读