From 391099eadcda5e2a6b281315f45db0782a0bb6ed Mon Sep 17 00:00:00 2001 From: cora48 Date: Thu, 2 Apr 2015 13:56:03 +0300 Subject: [PATCH] debug output fix --- Connector.cpp | 5 ++- FileDownloader.cpp | 4 --- finder.cpp | 3 +- nesca_startModule.cpp | 71 ++++++++++++++++++++++++------------------- 4 files changed, 43 insertions(+), 40 deletions(-) diff --git a/Connector.cpp b/Connector.cpp index c21e38b..9046b79 100644 --- a/Connector.cpp +++ b/Connector.cpp @@ -151,7 +151,7 @@ int Connector::nConnect(const char* ip, const int port, std::string *buffer, } curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, gTimeOut); - curl_easy_setopt(curl, CURLOPT_TIMEOUT, gTimeOut + 5); + curl_easy_setopt(curl, CURLOPT_TIMEOUT, gTimeOut + 3); if(postData != NULL) { curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postData); @@ -255,8 +255,7 @@ int Connector::_ConnectToPort(char* ip, int port) if(size > 0) { ++Alive; - ++found; - stt->doEmitionChangeParsed(QString::number(saved) + "/" + QString::number(found)); + stt->doEmitionChangeParsed(QString::number(saved) + "/" + QString::number(++found)); Lexems lx; lx._filler(port, buffer.c_str(), ip, size, &lx); }; diff --git a/FileDownloader.cpp b/FileDownloader.cpp index 3659291..0225988 100644 --- a/FileDownloader.cpp +++ b/FileDownloader.cpp @@ -34,11 +34,7 @@ void checkWeb(const char *fileName, std::string *oldLM) { if(lm.compare(*oldLM) != 0) { *oldLM = lm; - //QString res(buffer.substr(buffer.find("\r\n\r\n") + 4).c_str()); std::string res(buffer.substr(buffer.find("\r\n\r\n") + 4).c_str()); - //res.replace("\r\n", "\n"); - //QTextCodec *codec = QTextCodec::codecForName("Windows-1251"); - //res = codec->toUnicode(res.toLocal8Bit().data()); std::ofstream out(fileName); out << std::string(res); out.close(); diff --git a/finder.cpp b/finder.cpp index da7e3e7..1782a8e 100644 --- a/finder.cpp +++ b/finder.cpp @@ -194,8 +194,7 @@ int globalSearchNeg(const char *buffcpy, const char *ip, int port) FileUpdater::cv.wait(FileUpdater::lk, []{return FileUpdater::ready;}); if(!globalScanFlag) return -1; - strcpy(negWord, GlobalNegatives[i]); - printf("%s", buffcpy); + strcpy(negWord, GlobalNegatives[i]); if(strstr(buffcpy, negWord) != NULL) { if(gNegDebugMode) diff --git a/nesca_startModule.cpp b/nesca_startModule.cpp index 200f445..affd362 100644 --- a/nesca_startModule.cpp +++ b/nesca_startModule.cpp @@ -758,37 +758,6 @@ unsigned long int numOfIps(int ipsstart[], int ipsend[]) { return gTargets; } -void _connect() { - - std::string ip = ""; - while (globalScanFlag) { - std::unique_lock lk(Threader::m); - Threader::cv.wait(lk, []{return Threader::ready; }); - - if (Threader::threadId > gThreads || !globalScanFlag) { - --Threader::threadId; - Threader::ready = false; - lk.unlock(); - return; - } - - if (!Threader::ipQueue.empty()) { - ip = Threader::ipQueue.front(); - Threader::ipQueue.pop(); - Threader::ready = false; - lk.unlock(); - - ConInc(); - for (int i = 0; i <= overallPorts; ++i) - { - if (!globalScanFlag) break; - if (Connector::_ConnectToPort((char*)ip.c_str(), portArr[i]) == -2) break; - }; - ConDec(); - } - } -} - void verboseProgress(unsigned long target) { stt->doEmitionIPRANGE(QString(currentIP)); @@ -1657,6 +1626,37 @@ int _getChunkCount(char *data) { return secondPos - firstPos + 1; } +void _connect() { + + std::string ip = ""; + while (globalScanFlag) { + std::unique_lock lk(Threader::m); + Threader::cv.wait(lk, []{return Threader::ready; }); + + if (Threader::threadId > gThreads || !globalScanFlag) { + --Threader::threadId; + Threader::ready = false; + lk.unlock(); + return; + } + + if (!Threader::ipQueue.empty()) { + ip = Threader::ipQueue.front(); + Threader::ipQueue.pop(); + Threader::ready = false; + lk.unlock(); + + ConInc(); + for (int i = 0; i <= overallPorts; ++i) + { + if (!globalScanFlag) break; + if (Connector::_ConnectToPort((char*)ip.c_str(), portArr[i]) == -2) break; + }; + ConDec(); + } + } +} + int _GetDNSFromMask(char *mask, char *saveMask, char *saveMaskEnder) { if(strstr(mask, "[") != NULL) @@ -1744,6 +1744,15 @@ void runAuxiliaryThreads() { saverThread.detach(); } + + + + + + + + + int startScan(char* args) { curl_global_init(CURL_GLOBAL_ALL);