nesca/BasicAuth.cpp

55 lines
1.3 KiB
C++
Raw Normal View History

2015-03-13 14:27:21 +00:00
#include <BasicAuth.h>
2015-03-16 14:29:34 +00:00
bool BA::checkOutput(const string *buffer) {
if(Utils::ci_find_substr(*buffer, "200 ok") != -1 ||
Utils::ci_find_substr(*buffer, "http/1.0 200") != -1 ||
Utils::ci_find_substr(*buffer, "http/1.1 200") != -1
) {
return true;
}
return false;
}
lopaStr BA::_BABrute(const char *ip, const int port) {
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");
for(int i = 0; i < MaxLogin; ++i) {
for (int j = 0; j < MaxPass; ++j) {
if (!globalScanFlag) return lps;
lpString = string(loginLst[i]) + ":" + string(passLst[j]);
Connector::nConnect(ip, port, &buffer, NULL, NULL, &lpString);
2015-03-17 14:30:53 +00:00
if(checkOutput(&buffer)) {
2015-03-16 14:29:34 +00:00
strcpy(lps.login, loginLst[i]);
strcpy(lps.pass, passLst[j]);
return lps;
};
Sleep(70);
}
}
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-17 14:30:53 +00:00
lopaStr BA::_BALobby(const char *ip, const int port) {
while(BrutingThrds >= gMaxBrutingThreads) Sleep(1000);
2015-03-13 14:27:21 +00:00
BruteUtils::BConInc();
2015-03-17 14:30:53 +00:00
const lopaStr &lps = _BABrute(ip, port);
2015-03-13 14:27:21 +00:00
BruteUtils::BConDec();
2015-03-17 14:30:53 +00:00
return lps;
2015-03-13 14:27:21 +00:00
}