2015-03-22 00:43:15 +00:00
|
|
|
|
#include "BasicAuth.h"
|
2015-03-25 14:29:08 +00:00
|
|
|
|
#include "FileUpdater.h"
|
2015-03-13 14:27:21 +00:00
|
|
|
|
|
2015-03-22 00:43:15 +00:00
|
|
|
|
bool BA::checkOutput(const string *buffer, const char *ip, const int port) {
|
2015-04-16 11:51:51 +00:00
|
|
|
|
if((Utils::ustrstr(*buffer, "200 ok") != -1 ||
|
|
|
|
|
Utils::ustrstr(*buffer, "http/1.0 200") != -1 ||
|
|
|
|
|
Utils::ustrstr(*buffer, "http/1.1 200") != -1)
|
|
|
|
|
&& Utils::ustrstr(*buffer, "http/1.1 401 ") == -1
|
|
|
|
|
&& Utils::ustrstr(*buffer, "http/1.0 401 ") == -1
|
|
|
|
|
&& Utils::ustrstr(*buffer, "<statusValue>401</statusValue>") == -1
|
|
|
|
|
&& Utils::ustrstr(*buffer, "<statusString>Unauthorized</statusString>") == -1
|
|
|
|
|
&& Utils::ustrstr(*buffer, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>") == -1
|
|
|
|
|
&& Utils::ustrstr(*buffer, "Неправильны") == -1
|
2015-03-16 14:29:34 +00:00
|
|
|
|
) {
|
|
|
|
|
return true;
|
2015-03-22 00:43:15 +00:00
|
|
|
|
}
|
2015-04-16 11:51:51 +00:00
|
|
|
|
else if (Utils::ustrstr(*buffer, "503 service unavailable") != -1
|
|
|
|
|
|| Utils::ustrstr(*buffer, "http/1.1 503") != -1
|
|
|
|
|
|| Utils::ustrstr(*buffer, "http/1.0 503") != -1
|
|
|
|
|
|| Utils::ustrstr(*buffer, "400 BAD_REQUEST") != -1
|
|
|
|
|
|| Utils::ustrstr(*buffer, "400 bad request") != -1
|
|
|
|
|
|| Utils::ustrstr(*buffer, "403 Forbidden") != -1
|
2015-03-22 00:43:15 +00:00
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
stt->doEmition_BARedData("[.] 503/400/403 - Waiting 30sec (" + QString(ip) + ":" + QString::number(port) + ")");
|
|
|
|
|
|
|
|
|
|
Sleep(30000);
|
|
|
|
|
}
|
2015-03-16 14:29:34 +00:00
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-23 13:54:40 +00:00
|
|
|
|
lopaStr BA::BABrute(const char *ip, const int port) {
|
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-24 14:29:27 +00:00
|
|
|
|
int passCounter = 0;
|
2015-04-04 07:24:31 +00:00
|
|
|
|
int res = 0;
|
2015-03-16 14:29:34 +00:00
|
|
|
|
|
|
|
|
|
for(int i = 0; i < MaxLogin; ++i) {
|
|
|
|
|
for (int j = 0; j < MaxPass; ++j) {
|
2015-03-25 14:29:08 +00:00
|
|
|
|
FileUpdater::cv.wait(FileUpdater::lk, []{return FileUpdater::ready;});
|
2015-03-16 14:29:34 +00:00
|
|
|
|
if (!globalScanFlag) return lps;
|
|
|
|
|
|
2015-03-25 14:29:08 +00:00
|
|
|
|
lpString = string(loginLst[i]) + ":" + string(passLst[j]);
|
2015-03-16 14:29:34 +00:00
|
|
|
|
|
2015-04-04 07:24:31 +00:00
|
|
|
|
res = Connector::nConnect(ip, port, &buffer, NULL, NULL, &lpString);
|
|
|
|
|
if (res == -2) return lps;
|
|
|
|
|
else if (res != -1) {
|
|
|
|
|
if (checkOutput(&buffer, ip, port)) {
|
|
|
|
|
strcpy(lps.login, loginLst[i]);
|
|
|
|
|
strcpy(lps.pass, passLst[j]);
|
|
|
|
|
return lps;
|
|
|
|
|
};
|
|
|
|
|
}
|
2015-03-16 14:29:34 +00:00
|
|
|
|
|
2015-03-23 17:47:48 +00:00
|
|
|
|
if (BALogSwitched) stt->doEmitionBAData("BA: " + QString(ip) + ":" + QString::number(port) +
|
2015-03-25 14:29:08 +00:00
|
|
|
|
"; l/p: " + QString(loginLst[i]) + ":" + QString(passLst[j]) + "; - Progress: (" +
|
2015-03-22 10:13:17 +00:00
|
|
|
|
QString::number((++passCounter / (double)(MaxPass*MaxLogin)) * 100).mid(0, 4) + "%)");
|
|
|
|
|
|
2015-03-22 00:43:15 +00:00
|
|
|
|
Sleep(100);
|
2015-03-16 14:29:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-03-13 14:27:21 +00:00
|
|
|
|
|
2015-03-16 14:29:34 +00:00
|
|
|
|
return lps;
|
2015-03-13 14:27:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-23 13:54:40 +00:00
|
|
|
|
lopaStr BA::BALobby(const char *ip, const int port) {
|
2015-04-02 12:33:49 +00:00
|
|
|
|
if(gMaxBrutingThreads > 0) {
|
2015-03-13 14:27:21 +00:00
|
|
|
|
|
2015-04-02 12:33:49 +00:00
|
|
|
|
while(BrutingThrds >= gMaxBrutingThreads) Sleep(1000);
|
2015-03-13 14:27:21 +00:00
|
|
|
|
|
2015-04-04 12:43:22 +00:00
|
|
|
|
++baCount;
|
|
|
|
|
++BrutingThrds;
|
|
|
|
|
//BruteUtils::BConInc();
|
2015-04-02 12:33:49 +00:00
|
|
|
|
const lopaStr &lps = BABrute(ip, port);
|
2015-04-04 12:43:22 +00:00
|
|
|
|
//BruteUtils::BConDec();
|
|
|
|
|
--BrutingThrds;
|
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-13 14:27:21 +00:00
|
|
|
|
}
|