From 40d69a654a019f5522592b736e29f99daf134b6c Mon Sep 17 00:00:00 2001 From: cora48 Date: Wed, 25 Mar 2015 17:29:08 +0300 Subject: [PATCH] mutex testing --- BasicAuth.cpp | 17 +- FTPAuth.cpp | 2 - FileUpdater.cpp | 622 ++++++++++++++++++++---------------------- FileUpdater.h | 12 +- SSHAuth.cpp | 1 - Threader.cpp | 1 - WebformWorker.cpp | 9 +- WebformWorker.h | 8 +- externFunctions.h | 2 +- nesca_startModule.cpp | 4 +- 10 files changed, 313 insertions(+), 365 deletions(-) diff --git a/BasicAuth.cpp b/BasicAuth.cpp index 35fbeb7..324db34 100644 --- a/BasicAuth.cpp +++ b/BasicAuth.cpp @@ -1,4 +1,5 @@ #include "BasicAuth.h" +#include "FileUpdater.h" bool BA::checkOutput(const string *buffer, const char *ip, const int port) { if((Utils::ci_find_substr(*buffer, "200 ok") != -1 || @@ -40,29 +41,23 @@ lopaStr BA::BABrute(const char *ip, const int port) { strcpy(lps.login, "UNKNOWN"); - char login[128] = {0}; - char pass[32] = {0}; - for(int i = 0; i < MaxLogin; ++i) { - if(!lUpdated) Sleep(100); - strcpy(login, loginLst[i]); for (int j = 0; j < MaxPass; ++j) { + FileUpdater::cv.wait(FileUpdater::lk, []{return FileUpdater::ready;}); if (!globalScanFlag) return lps; - if(!pUpdated) Sleep(100); - strcpy(pass, passLst[j]); - lpString = string(login) + ":" + string(pass); + lpString = string(loginLst[i]) + ":" + string(passLst[j]); if (Connector::nConnect(ip, port, &buffer, NULL, NULL, &lpString) == -2) return lps; if(checkOutput(&buffer, ip, port)) { - strcpy(lps.login, login); - strcpy(lps.pass, pass); + strcpy(lps.login, loginLst[i]); + strcpy(lps.pass, passLst[j]); return lps; }; if (BALogSwitched) stt->doEmitionBAData("BA: " + QString(ip) + ":" + QString::number(port) + - "; l/p: " + QString(login) + ":" + QString(pass) + "; - Progress: (" + + "; l/p: " + QString(loginLst[i]) + ":" + QString(passLst[j]) + "; - Progress: (" + QString::number((++passCounter / (double)(MaxPass*MaxLogin)) * 100).mid(0, 4) + "%)"); Sleep(100); diff --git a/FTPAuth.cpp b/FTPAuth.cpp index d810344..3ba1817 100644 --- a/FTPAuth.cpp +++ b/FTPAuth.cpp @@ -27,7 +27,6 @@ lopaStr FTPA::FTPBrute(const char *ip, const int port, PathStr *ps) { for(int i = 0; i < MaxLogin; ++i) { if(!globalScanFlag) return lps; - if(!lUpdated) Sleep(100); if(strlen(loginLst[i]) <= 1) continue; strcpy(login, loginLst[i]); @@ -35,7 +34,6 @@ lopaStr FTPA::FTPBrute(const char *ip, const int port, PathStr *ps) { for(int j = 0; j < MaxPass; ++j) { if(!globalScanFlag) return lps; - if(!pUpdated) Sleep(100); if(strlen(passLst[j]) <= 1) continue; strcpy(pass, passLst[j]); diff --git a/FileUpdater.cpp b/FileUpdater.cpp index c8eb4cd..32b3f18 100644 --- a/FileUpdater.cpp +++ b/FileUpdater.cpp @@ -1,4 +1,6 @@ #include "FileUpdater.h" +#include "STh.h" +#include "mainResources.h" long FileUpdater::oldNegLstSize = 0; long FileUpdater::oldLoginLstSize = 0; @@ -6,329 +8,10 @@ long FileUpdater::oldPassLstSize = 0; long FileUpdater::oldSSHLstSize = 0; long FileUpdater::oldWFLoginLstSize = 0; long FileUpdater::oldWFPassLstSize = 0; -bool FileUpdater::negUpdated = false; -bool FileUpdater::lUpdated = false; -bool FileUpdater::pUpdated = false; -bool FileUpdater::wflUpdated = false; -bool FileUpdater::wfpUpdated = false; -bool FileUpdater::sshlpUpdated = false; - -void updateNegatives() { - if(GlobalNegatives != NULL) - { - for(int i = 0; i < GlobalNegativeSize; ++i) delete []GlobalNegatives[i]; - delete []GlobalNegatives; - GlobalNegatives = NULL; - }; - - negativeLoader(); -} -void updateLogin() { - - if(loginLst != NULL) - { - for(int i = 0; i < MaxLogin; ++i) delete []loginLst[i]; - delete []loginLst; - loginLst = NULL; - }; - - MaxLogin = 0; - - char buffFG[32] = {0}; - - FILE *loginList = fopen("login.txt", "r"); - - if(loginList != NULL) - { - while(fgets(buffFG, 32, loginList) != NULL) - { - MaxLogin++; - ZeroMemory(buffFG, sizeof(buffFG)); - }; - - rewind(loginList); - - loginLst = new char*[MaxLogin]; - - for(int j = 0; j < MaxLogin; j++) - { - loginLst[j] = new char[32]; - }; - - int i = 0; - while(fgets(buffFG, 32, loginList) != NULL) - { - memset(loginLst[i], 0, strlen(buffFG) + 1); - - if(strstr(buffFG, "\n") != NULL) strncat(loginLst[i++], buffFG, strlen(buffFG) - 1); - else strncat(loginLst[i++], buffFG, strlen(buffFG)); - ZeroMemory(buffFG, sizeof(buffFG)); - }; - - stt->doEmitionGreenFoundData("Login list loaded (" + QString::number(MaxLogin) + " entries)"); - - fclose(loginList); - } - else - { - stt->doEmitionRedFoundData("No login list found"); - stt->doEmitionKillSttThread(); - }; -} -void updatePass() { - - if(passLst != NULL) - { - for(int i = 0; i < MaxPass; ++i) delete []passLst[i]; - delete []passLst; - passLst = NULL; - }; - - MaxPass = 0; - - char buffFG[32] = {0}; - - FILE *passList = fopen("pass.txt", "r"); - - if(passList != NULL) - { - while(fgets(buffFG, 32, passList) != NULL) - { - MaxPass++; - ZeroMemory(buffFG, sizeof(buffFG)); - }; - - rewind(passList); - - passLst = new char*[MaxPass]; - - for(int j = 0; j < MaxPass; j++) - { - passLst[j] = new char[32]; - }; - - int i = 0; - while(fgets(buffFG, 32, passList) != NULL) - { - memset(passLst[i], 0, strlen(buffFG) + 1); - - if(strstr(buffFG, "\n") != NULL) strncat(passLst[i++], buffFG, strlen(buffFG) - 1); - else strncat(passLst[i++], buffFG, strlen(buffFG)); - ZeroMemory(buffFG, sizeof(buffFG)); - }; - - stt->doEmitionGreenFoundData("Password list loaded (" + QString::number(MaxPass) + " entries)"); - - fclose(passList); - } - else - { - stt->doEmitionRedFoundData("No password list found"); - stt->doEmitionKillSttThread(); - }; -} -void updateSSH() { - - if(sshlpLst != NULL) - { - for(int i = 0; i < MaxSSHPass; ++i) delete []sshlpLst[i]; - delete []sshlpLst; - sshlpLst = NULL; - }; - - MaxSSHPass = 0; - - FILE *sshlpList; - ZeroMemory(buffFG, sizeof(buffFG)); - - sshlpList = fopen("sshpass.txt", "r"); - - if(sshlpList != NULL) - { - while(fgets(buffFG, 32, sshlpList) != NULL) - { - ++MaxSSHPass; - ZeroMemory(buffFG, sizeof(buffFG)); - }; - - rewind(sshlpList); - - sshlpLst = new char*[MaxSSHPass]; - - for(int j = 0; j < MaxSSHPass; j++) - { - sshlpLst[j] = new char[32]; - }; - - int i = 0; - while(fgets(buffFG, 32, sshlpList) != NULL) - { - memset(sshlpLst[i], 0, strlen(buffFG) + 1); - - if(strstr(buffFG, "\n") != NULL) strncat(sshlpLst[i++], buffFG, strlen(buffFG) - 1); - else strncat(sshlpLst[i++], buffFG, strlen(buffFG)); - ZeroMemory(buffFG, sizeof(buffFG)); - }; - - stt->doEmitionGreenFoundData("SSH Password list loaded (" + QString::number(MaxSSHPass) + " entries)"); - - fclose(sshlpList); - } - else - { - stt->doEmitionRedFoundData("No password/login list found"); - stt->doEmitionKillSttThread(); - }; -} -void updateWFLogin() { - - if(wfLoginLst != NULL) - { - for(int i = 0; i < MaxWFLogin; ++i) delete []wfLoginLst[i]; - delete []wfLoginLst; - wfLoginLst = NULL; - }; - - MaxWFLogin = 0; - - FILE *wfLoginList; - - ZeroMemory(buffFG, sizeof(buffFG)); - - wfLoginList = fopen("wflogin.txt", "r"); - - if(wfLoginList != NULL) - { - while(fgets(buffFG, 32, wfLoginList) != NULL) - { - MaxWFLogin++; - ZeroMemory(buffFG, sizeof(buffFG)); - }; - - rewind(wfLoginList); - - wfLoginLst = new char*[MaxWFLogin]; - - for(int j = 0; j < MaxWFLogin; j++) - { - wfLoginLst[j] = new char[32]; - }; - - int i = 0; - while(fgets(buffFG, 32, wfLoginList) != NULL) - { - memset(wfLoginLst[i], 0, strlen(buffFG) + 1); - - if(strstr(buffFG, "\n") != NULL) strncat(wfLoginLst[i++], buffFG, strlen(buffFG) - 1); - else strncat(wfLoginLst[i++], buffFG, strlen(buffFG)); - ZeroMemory(buffFG, sizeof(buffFG)); - }; - - stt->doEmitionGreenFoundData("WFLogin list loaded (" + QString::number(MaxWFLogin) + " entries)"); - fclose(wfLoginList); - } -} -void updateWFPass() { - - if(wfPassLst != NULL) - { - for(int i = 0; i < MaxWFPass; ++i) delete []wfPassLst[i]; - delete []wfPassLst; - wfPassLst = NULL; - }; - - MaxWFPass = 0; - - FILE *wfPassList; - - ZeroMemory(buffFG, sizeof(buffFG)); - - wfPassList = fopen("wfpass.txt", "r"); - - if(wfPassList != NULL) - { - while(fgets(buffFG, 32, wfPassList) != NULL) - { - MaxWFPass++; - ZeroMemory(buffFG, sizeof(buffFG)); - }; - - rewind(wfPassList); - - wfPassLst = new char*[MaxWFPass]; - - for(int j = 0; j < MaxWFPass; j++) - { - wfPassLst[j] = new char[32]; - }; - - int i = 0; - while(fgets(buffFG, 32, wfPassList) != NULL) - { - memset(wfPassLst[i], 0, strlen(buffFG) + 1); - - if(strstr(buffFG, "\n") != NULL) strncat(wfPassLst[i++], buffFG, strlen(buffFG) - 1); - else strncat(wfPassLst[i++], buffFG, strlen(buffFG)); - ZeroMemory(buffFG, sizeof(buffFG)); - }; - - stt->doEmitionGreenFoundData("WFPassword list loaded (" + QString::number(MaxWFPass) + " entries)"); - fclose(wfPassList); - } -} - -long getFileSize(const char *fileName) { - std::ifstream in(fileName, std::ifstream::ate | std::ifstream::binary); - return in.tellg(); -} - -bool updateList(const char *fileName) { - long sz = getFileSize(fileName); - - if(strstr(fileName, "negatives") != NULL) { - if(sz != oldNegLstSize) { - negUpdated = false; - oldNegLstSize = sz; - updateNegatives(); - negUpdated = true; - } - } else if(strstr(fileName, "login") != NULL) { - if(sz != oldLoginLstSize) { - lUpdated = false; - oldLoginLstSize = sz; - updateLogin(); - lUpdated = true; - } - } else if(strstr(fileName, "pass") != NULL) { - if(sz != oldPassLstSize) { - pUpdated = false; - oldPassLstSize = sz; - updatePass(); - pUpdated = true; - } - } else if(strstr(fileName, "sshpass") != NULL) { - if(sz != oldSSHLstSize) { - sshlpUpdated = false; - oldSSHLstSize = sz; - updateSSH(); - sshlpUpdated = true; - } - } else if(strstr(fileName, "wflogin") != NULL) { - if(sz != oldWFLoginLstSize) { - wflUpdated = false; - oldWFLoginLstSize = sz; - updateWFLogin(); - wflUpdated = true; - } - } else if(strstr(fileName, "wfpass") != NULL) { - if(sz != oldWFPassLstSize) { - wfpUpdated = false; - oldWFPassLstSize = sz; - updateWFPass(); - wfpUpdated = true; - } - } -} +std::mutex FileUpdater::filesUpdatingMutex; +std::condition_variable FileUpdater::cv; +bool FileUpdater::ready = false; +std::unique_lock FileUpdater::lk; void ReadUTF8(FILE* nFile, char *cp) { char buffFG[256] = {0}; @@ -461,14 +144,295 @@ void negativeLoader() { } } +void *updateNegatives() { + if(GlobalNegatives != NULL) + { + for(int i = 0; i < GlobalNegativeSize; ++i) delete []GlobalNegatives[i]; + delete []GlobalNegatives; + GlobalNegatives = NULL; + }; + + negativeLoader(); +} +void *updateLogin() { + + if(loginLst != NULL) + { + for(int i = 0; i < MaxLogin; ++i) delete []loginLst[i]; + delete []loginLst; + loginLst = NULL; + }; + + MaxLogin = 0; + + char buffFG[32] = {0}; + + FILE *loginList = fopen("login.txt", "r"); + + if(loginList != NULL) + { + while(fgets(buffFG, 32, loginList) != NULL) + { + MaxLogin++; + ZeroMemory(buffFG, sizeof(buffFG)); + }; + + rewind(loginList); + + loginLst = new char*[MaxLogin]; + + for(int j = 0; j < MaxLogin; j++) + { + loginLst[j] = new char[32]; + }; + + int i = 0; + while(fgets(buffFG, 32, loginList) != NULL) + { + memset(loginLst[i], 0, strlen(buffFG) + 1); + + if(strstr(buffFG, "\n") != NULL) strncat(loginLst[i++], buffFG, strlen(buffFG) - 1); + else strncat(loginLst[i++], buffFG, strlen(buffFG)); + ZeroMemory(buffFG, sizeof(buffFG)); + }; + + stt->doEmitionGreenFoundData("Login list loaded (" + QString::number(MaxLogin) + " entries)"); + + fclose(loginList); + } + else + { + stt->doEmitionRedFoundData("No login list found"); + stt->doEmitionKillSttThread(); + }; +} +void *updatePass() { + + if(passLst != NULL) + { + for(int i = 0; i < MaxPass; ++i) delete []passLst[i]; + delete []passLst; + passLst = NULL; + }; + + MaxPass = 0; + + char buffFG[32] = {0}; + + FILE *passList = fopen("pass.txt", "r"); + + if(passList != NULL) + { + while(fgets(buffFG, 32, passList) != NULL) + { + MaxPass++; + ZeroMemory(buffFG, sizeof(buffFG)); + }; + + rewind(passList); + + passLst = new char*[MaxPass]; + + for(int j = 0; j < MaxPass; j++) + { + passLst[j] = new char[32]; + }; + + int i = 0; + while(fgets(buffFG, 32, passList) != NULL) + { + memset(passLst[i], 0, strlen(buffFG) + 1); + + if(strstr(buffFG, "\n") != NULL) strncat(passLst[i++], buffFG, strlen(buffFG) - 1); + else strncat(passLst[i++], buffFG, strlen(buffFG)); + ZeroMemory(buffFG, sizeof(buffFG)); + }; + + stt->doEmitionGreenFoundData("Password list loaded (" + QString::number(MaxPass) + " entries)"); + + fclose(passList); + } + else + { + stt->doEmitionRedFoundData("No password list found"); + stt->doEmitionKillSttThread(); + }; +} +void *updateSSH() { + + if(sshlpLst != NULL) + { + for(int i = 0; i < MaxSSHPass; ++i) delete []sshlpLst[i]; + delete []sshlpLst; + sshlpLst = NULL; + }; + + MaxSSHPass = 0; + + char buffFG[32] = {0}; + ZeroMemory(buffFG, sizeof(buffFG)); + + FILE *sshlpList = fopen("sshpass.txt", "r"); + + if(sshlpList != NULL) + { + while(fgets(buffFG, 32, sshlpList) != NULL) + { + ++MaxSSHPass; + ZeroMemory(buffFG, sizeof(buffFG)); + }; + + rewind(sshlpList); + + sshlpLst = new char*[MaxSSHPass]; + + for(int j = 0; j < MaxSSHPass; j++) + { + sshlpLst[j] = new char[32]; + }; + + int i = 0; + while(fgets(buffFG, 32, sshlpList) != NULL) + { + memset(sshlpLst[i], 0, strlen(buffFG) + 1); + + if(strstr(buffFG, "\n") != NULL) strncat(sshlpLst[i++], buffFG, strlen(buffFG) - 1); + else strncat(sshlpLst[i++], buffFG, strlen(buffFG)); + ZeroMemory(buffFG, sizeof(buffFG)); + }; + + stt->doEmitionGreenFoundData("SSH Password list loaded (" + QString::number(MaxSSHPass) + " entries)"); + + fclose(sshlpList); + } + else + { + stt->doEmitionRedFoundData("No password/login list found"); + stt->doEmitionKillSttThread(); + }; +} +void *updateWFLogin() { + + if(wfLoginLst != NULL) + { + for(int i = 0; i < MaxWFLogin; ++i) delete []wfLoginLst[i]; + delete []wfLoginLst; + wfLoginLst = NULL; + }; + + MaxWFLogin = 0; + + char buffFG[32] = {0}; + ZeroMemory(buffFG, sizeof(buffFG)); + + FILE *wfLoginList = fopen("wflogin.txt", "r"); + + if(wfLoginList != NULL) + { + while(fgets(buffFG, 32, wfLoginList) != NULL) + { + MaxWFLogin++; + ZeroMemory(buffFG, sizeof(buffFG)); + }; + + rewind(wfLoginList); + + wfLoginLst = new char*[MaxWFLogin]; + + for(int j = 0; j < MaxWFLogin; j++) + { + wfLoginLst[j] = new char[32]; + }; + + int i = 0; + while(fgets(buffFG, 32, wfLoginList) != NULL) + { + memset(wfLoginLst[i], 0, strlen(buffFG) + 1); + + if(strstr(buffFG, "\n") != NULL) strncat(wfLoginLst[i++], buffFG, strlen(buffFG) - 1); + else strncat(wfLoginLst[i++], buffFG, strlen(buffFG)); + ZeroMemory(buffFG, sizeof(buffFG)); + }; + + stt->doEmitionGreenFoundData("WFLogin list loaded (" + QString::number(MaxWFLogin) + " entries)"); + fclose(wfLoginList); + } +} +void *updateWFPass() { + + if(wfPassLst != NULL) + { + for(int i = 0; i < MaxWFPass; ++i) delete []wfPassLst[i]; + delete []wfPassLst; + wfPassLst = NULL; + }; + + MaxWFPass = 0; + + char buffFG[32] = {0}; + ZeroMemory(buffFG, sizeof(buffFG)); + + FILE *wfPassList = fopen("wfpass.txt", "r"); + + if(wfPassList != NULL) + { + while(fgets(buffFG, 32, wfPassList) != NULL) + { + MaxWFPass++; + ZeroMemory(buffFG, sizeof(buffFG)); + }; + + rewind(wfPassList); + + wfPassLst = new char*[MaxWFPass]; + + for(int j = 0; j < MaxWFPass; j++) + { + wfPassLst[j] = new char[32]; + }; + + int i = 0; + while(fgets(buffFG, 32, wfPassList) != NULL) + { + memset(wfPassLst[i], 0, strlen(buffFG) + 1); + + if(strstr(buffFG, "\n") != NULL) strncat(wfPassLst[i++], buffFG, strlen(buffFG) - 1); + else strncat(wfPassLst[i++], buffFG, strlen(buffFG)); + ZeroMemory(buffFG, sizeof(buffFG)); + }; + + stt->doEmitionGreenFoundData("WFPassword list loaded (" + QString::number(MaxWFPass) + " entries)"); + fclose(wfPassList); + } +} + +long getFileSize(const char *fileName) { + std::ifstream in(fileName, std::ifstream::ate | std::ifstream::binary); + return in.tellg(); +} + +void updateList(const char *fileName, long *szPtr, void *funcPtr(void)) { + long sz = getFileSize(fileName); + + if(sz != *szPtr) { + + FileUpdater::lk = std::unique_lock (FileUpdater::filesUpdatingMutex); + *szPtr = sz; + funcPtr(); + FileUpdater::lk.unlock(); + FileUpdater::ready = true; + FileUpdater::cv.notify_one(); + } +} + int FileUpdater::updateLists() { while(globalScanFlag) { - bool res = updateList("negatives.txt"); - res = updateList("login.txt"); - res = updateList("pass.txt"); - res = updateList("sshpass.txt"); - res = updateList("wflogin.txt"); - res = updateList("wfpass.txt"); + updateList("negatives.txt", &oldNegLstSize, updateNegatives); + updateList("login.txt", &oldLoginLstSize, updateLogin); + updateList("pass.txt", &oldPassLstSize, updatePass); + updateList("sshpass.txt", &oldSSHLstSize, updateSSH); + updateList("wflogin.txt", &oldWFLoginLstSize, updateWFLogin); + updateList("wfpass.txt", &oldWFPassLstSize, updateWFPass); Sleep(60000); } diff --git a/FileUpdater.h b/FileUpdater.h index 2c75840..4d5d58a 100644 --- a/FileUpdater.h +++ b/FileUpdater.h @@ -6,6 +6,8 @@ #endif #include +#include +#include #include "externData.h" #include "externFunctions.h" @@ -17,12 +19,10 @@ public: static long oldSSHLstSize; static long oldWFLoginLstSize; static long oldWFPassLstSize; - static bool negUpdated; - static bool lUpdated; - static bool pUpdated; - static bool wflUpdated; - static bool wfpUpdated; - static bool sshlpUpdated; + static bool ready; + static std::condition_variable cv; + static std::mutex filesUpdatingMutex; + static std::unique_lock lk; public: static int updateLists(); diff --git a/SSHAuth.cpp b/SSHAuth.cpp index 75885de..3398382 100644 --- a/SSHAuth.cpp +++ b/SSHAuth.cpp @@ -92,7 +92,6 @@ int SSHBrute(const char* host, int port, std::string *buffer, const char *banner for(int i = 0; i < MaxSSHPass; ++i) { if(!globalScanFlag) break; - if(!sshlpUpdated) Sleep(100); strcpy(temp, sshlpLst[i]); ptr1 = strstr(temp, ":"); if (ptr1 == NULL) { diff --git a/Threader.cpp b/Threader.cpp index 7817892..da8fca3 100644 --- a/Threader.cpp +++ b/Threader.cpp @@ -8,7 +8,6 @@ std::queue Threader::ipQueue; void Threader::fireThread(std::string ip, void *func(void)) { - std::unique_lock lk(m); ipQueue.push(ip); if(threadId < gThreads) { diff --git a/WebformWorker.cpp b/WebformWorker.cpp index 500c289..d556521 100644 --- a/WebformWorker.cpp +++ b/WebformWorker.cpp @@ -1,6 +1,5 @@ #include "WebformWorker.h" - -bool WFClass::active = false; +#include "FileUpdater.h" lopaStr WFClass::parseResponse(const char *ip, const int port, @@ -29,8 +28,6 @@ lopaStr WFClass::parseResponse(const char *ip, && Utils::ci_find_substr(*buffer, std::string("forbidden")) == -1 ) { - if(*iIndex == 0) return result; - stt->doEmition_BAGreenData("[+] " + QString(ip) + ":" + QString::number(port) + " - WF pass: " + QString(login) + ":" + QString(pass)); strcpy(result.login, login); @@ -66,13 +63,11 @@ lopaStr WFClass::doGetCheck(const char *ip, for(int i = 0; i < MaxWFLogin; ++i) { if(!globalScanFlag) break; - if(!wflUpdated) Sleep(100); strcpy(login, wfLoginLst[i]); for(int j = firstCycle; j < MaxWFPass; ++j) { if(!globalScanFlag) break; - if(!wfpUpdated) Sleep(100); strcpy(pass, wfPassLst[j]); int rSize = strlen(ip) + strlen(actionVal) + strlen(userVal) + strlen(login) + strlen(passVal) + strlen(pass) + 4; @@ -119,13 +114,11 @@ lopaStr WFClass::doPostCheck(const char *ip, for(int i = 0; i < MaxWFLogin; ++i) { if(!globalScanFlag) break; - if(!wflUpdated) Sleep(100); strcpy(login, wfLoginLst[i]); for(int j = firstCycle; j < MaxWFPass; ++j) { if(!globalScanFlag) break; - if(!wfpUpdated) Sleep(100); strcpy(pass, wfPassLst[j]); int rSize = strlen(ip) + strlen(actionVal) + strlen(userVal) + strlen(login) + strlen(passVal) + strlen(pass) + 4; diff --git a/WebformWorker.h b/WebformWorker.h index a44f271..3b7157f 100644 --- a/WebformWorker.h +++ b/WebformWorker.h @@ -10,13 +10,13 @@ class WFClass : BruteUtils { -private: static bool active; +private: int passCounter = 1; lopaStr doGetCheck(const char *ip, int port, char *actionVal, char *userVal, char *passVal, char *formVal); lopaStr doPostCheck(const char *ip, int port, char *actionVal, char *userVal, char *passVal, char *formVal); lopaStr parseResponse(const char *ip, const int port, const std::string *buffer, const char* formVal, - const int *iIndex, - const int *jIndex); + const char *login, + const char *pass); public: @@ -26,12 +26,10 @@ public: ++WF; BConInc(); - this->active = true; passCounter = 1; } ~WFClass(){ - this->active = false; BConDec(); } diff --git a/externFunctions.h b/externFunctions.h index 50b3df6..788a2e6 100644 --- a/externFunctions.h +++ b/externFunctions.h @@ -15,7 +15,7 @@ extern char* strstri(const char *_Str, const char *_SubStr); extern void nCleanup(); extern void getSubStr(char *src, char *startStr, char *endStr, char *dest, int szDest); extern void getSubStrEx(char *src, char *startStr, char *endStr, char *dest, int szDest); -extern std::string xcode(LPCSTR src, UINT srcCodePage, UINT dstCodePage); +//extern std::string xcode(LPCSTR src, UINT srcCodePage, UINT dstCodePage); extern void _SaveBackupToFile(); extern char *_findFirst(const char *str, char *delim); //extern int nConnect(char *ip, int port, std::string *buffer); diff --git a/nesca_startModule.cpp b/nesca_startModule.cpp index c1c45a0..039c126 100644 --- a/nesca_startModule.cpp +++ b/nesca_startModule.cpp @@ -762,7 +762,8 @@ void _connect() { while (globalScanFlag) { std::unique_lock lk(Threader::m); Threader::cv.wait(lk, []{return Threader::ready; }); - if (Threader::threadId > gThreads || !globalScanFlag) { + + if (Threader::threadId > gThreads || !globalScanFlag) { --Threader::threadId; Threader::ready = false; lk.unlock(); @@ -1326,6 +1327,7 @@ char *GetCIDRRangeStr(char *str) { return result; } + int fInit(int InitMode, char *gR) { strcpy(metaRange, gR); if (InitMode == 0)