From cc1e51e2a87080b8f44724cf453252bfc7f4858b Mon Sep 17 00:00:00 2001 From: cora32 Date: Sat, 4 Apr 2015 10:24:31 +0300 Subject: [PATCH] Multiple fixes. --- BasicAuth.cpp | 17 +++++++++------ Connector.cpp | 9 +++----- FTPAuth.cpp | 10 ++++----- IPCAuth.cpp | 50 +++++++++++++++++++++---------------------- WebformWorker.cpp | 14 ++++++------ finder.cpp | 30 ++++++++++++++++++++++---- negatives.txt | 2 +- nesca_3.cpp | 14 +++++++----- nesca_startModule.cpp | 5 ++++- version | 2 +- 10 files changed, 90 insertions(+), 63 deletions(-) diff --git a/BasicAuth.cpp b/BasicAuth.cpp index 73859b5..6f16ce3 100644 --- a/BasicAuth.cpp +++ b/BasicAuth.cpp @@ -38,6 +38,7 @@ lopaStr BA::BABrute(const char *ip, const int port) { ZeroMemory(lps.pass, sizeof(lps.pass)); ZeroMemory(lps.other, sizeof(lps.other)); int passCounter = 0; + int res = 0; for(int i = 0; i < MaxLogin; ++i) { for (int j = 0; j < MaxPass; ++j) { @@ -46,13 +47,15 @@ lopaStr BA::BABrute(const char *ip, const int port) { 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, loginLst[i]); - strcpy(lps.pass, passLst[j]); - return lps; - }; + 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; + }; + } if (BALogSwitched) stt->doEmitionBAData("BA: " + QString(ip) + ":" + QString::number(port) + "; l/p: " + QString(loginLst[i]) + ":" + QString(passLst[j]) + "; - Progress: (" + diff --git a/Connector.cpp b/Connector.cpp index 6c2fee2..6b7291a 100644 --- a/Connector.cpp +++ b/Connector.cpp @@ -185,8 +185,8 @@ int Connector::nConnect(const char* ip, const int port, std::string *buffer, Activity += buffer->size(); return buffer->size(); } else { - if (res != 28 && - res != 6 && + if (res == 6) return -2; + else if (res != 28 && res != 7 && res != 67 && res != 52 && @@ -218,14 +218,11 @@ int Connector::nConnect(const char* ip, const int port, std::string *buffer, else stt->doEmitionRedFoundData("CURL error: (" + QString::number(res) + ") " + QString(ip) + ":" + QString::number(port)); } - else if (gMode == 1 && res == 6) return -2; if(res == 23 && buffer->size() > 0) { if (MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString("[OVERFLOW]")); return buffer->size(); - } else { - return -1; - } + } else return -1; } } else { stt->doEmitionRedFoundData("Curl error."); diff --git a/FTPAuth.cpp b/FTPAuth.cpp index 65f8aca..27597a1 100644 --- a/FTPAuth.cpp +++ b/FTPAuth.cpp @@ -13,10 +13,7 @@ bool FTPA::checkOutput(const string *buffer) { lopaStr FTPA::FTPBrute(const char *ip, const int port, PathStr *ps) { string buffer; string lpString; - lopaStr lps{"UNKNOWN", "", ""};; - ZeroMemory(lps.login, sizeof(lps.login)); - ZeroMemory(lps.pass, sizeof(lps.pass)); - ZeroMemory(lps.other, sizeof(lps.other)); + lopaStr lps{"UNKNOWN", "", ""}; strcpy(lps.login, "UNKNOWN"); int res = 0; @@ -24,6 +21,7 @@ lopaStr FTPA::FTPBrute(const char *ip, const int port, PathStr *ps) { char login[128] = {0}; char pass[32] = {0}; + char nip[128] = { 0 }; for(int i = 0; i < MaxLogin; ++i) { @@ -43,7 +41,9 @@ lopaStr FTPA::FTPBrute(const char *ip, const int port, PathStr *ps) { lpString = string(login) + ":" + string(pass); - res = Connector::nConnect((string("ftp://") + string(ip)).c_str(), port, &buffer, NULL, NULL, &lpString); + ZeroMemory(nip, 128); + sprintf(nip, "ftp://%s", ip); + res = Connector::nConnect(nip, port, &buffer, NULL, NULL, &lpString); if (res == -2) return lps; else if (res != -1) { if (!globalScanFlag) return lps; diff --git a/IPCAuth.cpp b/IPCAuth.cpp index e381807..ab67e8d 100644 --- a/IPCAuth.cpp +++ b/IPCAuth.cpp @@ -7,9 +7,6 @@ lopaStr IPC::IPCBrute(const char *ip, int port, char *SPEC) { lopaStr lps{"UNKNOWN", "", ""}; bool result = true; - ZeroMemory(lps.login, sizeof(lps.login)); - ZeroMemory(lps.pass, sizeof(lps.pass)); - ZeroMemory(lps.other, sizeof(lps.other)); char login[128] = {0}; char pass[128] = {0}; char request[1024] = {0}; @@ -69,18 +66,18 @@ lopaStr IPC::IPCBrute(const char *ip, int port, char *SPEC) { stt->doEmitionRedFoundData("[_IPCameraBrute] No \"SPEC\" specified!"); - strcpy(lps.login, "UNKNOWN"); return lps; }; - for(int i = 0; i < MaxLogin; i++) + int res = 0; + for(int i = 0; i < MaxLogin; ++i) { if(!globalScanFlag) break; if(strcmp(loginLst[i], " ") == 0) continue; ZeroMemory(login, sizeof(login)); strcpy(login, loginLst[i]); - for(int j = 0; j < MaxPass; j++) + for(int j = 0; j < MaxPass; ++j) { FileUpdater::cv.wait(FileUpdater::lk, []{return FileUpdater::ready;}); if(!globalScanFlag) break; @@ -141,32 +138,33 @@ lopaStr IPC::IPCBrute(const char *ip, int port, char *SPEC) std::string buffer; if(doPost) { - if (Connector::nConnect(request, port, &buffer, postData) == -2) return lps; + res = Connector::nConnect(request, port, &buffer, postData); } else { - if (Connector::nConnect(request, port, &buffer) == -2) return lps; + res = Connector::nConnect(request, port, &buffer); } - for(int i = 0; i < negVector.size(); ++i) - { - if(Utils::ci_find_substr(buffer, negVector[i]) != -1) - { - result = false; - break; - }; - }; - - if(result) - { - strcpy(lps.login, loginLst[i]); - strcpy(lps.pass, passLst[j]); - return lps; - }; - - ++passCounter; + if (res == -2) return lps; + else if (res != -1) { + for (int i = 0; i < negVector.size(); ++i) + { + if (Utils::ci_find_substr(buffer, negVector[i]) != -1) + { + result = false; + break; + }; + }; + if (result) + { + strcpy(lps.login, loginLst[i]); + strcpy(lps.pass, passLst[j]); + return lps; + }; + } + if (BALogSwitched) stt->doEmitionBAData("IPC: " + QString(ip) + ":" + QString::number(port) + "; l/p: " + QString(login) + ":" + QString(pass) + "; - Progress: (" + - QString::number((++passCounter / (double)(MaxPass*MaxLogin)) * 100).mid(0, 4) + "%)"); + QString::number((passCounter++ / (double)(MaxPass*MaxLogin)) * 100).mid(0, 4) + "%)"); Sleep(100); }; diff --git a/WebformWorker.cpp b/WebformWorker.cpp index 81f4eec..93fe75e 100644 --- a/WebformWorker.cpp +++ b/WebformWorker.cpp @@ -8,7 +8,7 @@ lopaStr WFClass::parseResponse(const char *ip, const char *login, const char *pass) { - lopaStr result = {"UNKNOWN", "UNKNOWN", "UNKNOWN"}; + lopaStr result = {"UNKNOWN", "", ""}; if(buffer->size() != 0) { @@ -53,7 +53,7 @@ lopaStr WFClass::doGetCheck(const char *ip, char *passVal, char *formVal) { - lopaStr result = {"UNKNOWN", "UNKNOWN", "UNKNOWN"}; + lopaStr result = {"UNKNOWN", "", ""}; int passCounter = 0; int firstCycle = 0; @@ -81,12 +81,12 @@ lopaStr WFClass::doGetCheck(const char *ip, sprintf(nip, "%s%s?%s=%s&%s=%s", ip, actionVal, userVal, login, passVal, pass); std::string buffer; - Connector::nConnect(nip, port, &buffer); + if(Connector::nConnect(nip, port, &buffer) <= 0) return result; if(BALogSwitched) stt->doEmitionBAData("Checked WF: " + QString(ip) + ":" + QString::number(port) + "; login/pass: "+ QString(login) + ":" + QString(pass) + - "; - Progress: (" + QString::number((passCounter/(double)(MaxWFPass*MaxWFLogin)) * 100).mid(0, 4) + "%)"); - ++passCounter; + "; - Progress: (" + + QString::number((passCounter++/(double)(MaxWFPass*MaxWFLogin)) * 100).mid(0, 4) + "%)"); result = parseResponse(ip, port, &buffer, formVal, login, pass); if(i == 0) ++i; @@ -104,7 +104,7 @@ lopaStr WFClass::doPostCheck(const char *ip, char *passVal, char *formVal) { - lopaStr result = {"UNKNOWN", "UNKNOWN", "UNKNOWN"}; + lopaStr result = {"UNKNOWN", "", ""}; int passCounter = 0; int firstCycle = 0; @@ -134,7 +134,7 @@ lopaStr WFClass::doPostCheck(const char *ip, sprintf(postData, "%s=%s&%s=%s", userVal, login, passVal, pass); std::string buffer; - Connector::nConnect(nip, port, &buffer, postData); + if(Connector::nConnect(nip, port, &buffer, postData) <= 0) return result; if(BALogSwitched) stt->doEmitionBAData("Checked WF: " + QString(ip) + ":" + QString::number(port) + "; login/pass: " + QString(login) + ":" + QString(pass) + "; - Progress: (" + diff --git a/finder.cpp b/finder.cpp index e643e19..c4ee6c2 100644 --- a/finder.cpp +++ b/finder.cpp @@ -368,19 +368,39 @@ int ContentFilter(const char *buff, int port, const char *ip, char *cp, int sz) { if(buff != NULL) { + QTextCodec *codec; + QString strf; + + if (strstri(cp, "shift_jis") != NULL) + { + codec = QTextCodec::codecForName("Shift-JIS"); + strf = codec->toUnicode(buff).toLower(); + } + else if (strstri(cp, "utf") != NULL) + { + codec = QTextCodec::codecForName("UTF-8"); + strf = codec->toUnicode(buff).toLower(); + } + else if (strstri(cp, "cp") != NULL || strstri(cp, "windows") != NULL) + { + codec = QTextCodec::codecForName("Windows-1251"); + strf = codec->toUnicode(buff).toLower(); + } + else strf = QString(buff); + int res = 0; if(sz <= 500) { - res = _mainFinderFirst(toLowerStr(buff).c_str(), 1, port, ip, sz); + res = _mainFinderFirst(strf.toLocal8Bit().data(), 1, port, ip, sz); } else if((sz > 500 && sz <= 3500) || sz > 180000) { - res = _mainFinderFirst(toLowerStr(buff).c_str(), 0, port, ip, sz); + res = _mainFinderFirst(strf.toLocal8Bit().data(), 0, port, ip, sz); } else if(sz > 3500 && sz <= 180000) { - res = _mainFinderSecond(toLowerStr(buff).c_str(), port, ip); + res = _mainFinderSecond(strf.toLocal8Bit().data(), port, ip); }; return res; @@ -2053,6 +2073,7 @@ void _getPopupTitle(PathStr *ps, char *str) void _getLinkFromJSLocation(char *dataBuff, char *str, char *tag, char *ip, int port) { + if (strstri(str, ".title") != NULL) return; char *ptr1 = strstr(str, tag); if(ptr1 != NULL) { @@ -2135,7 +2156,8 @@ void _getLinkFromJSLocation(char *dataBuff, char *str, char *tag, char *ip, int } else { - stt->doEmitionRedFoundData("[JSLocator] _findFirst failed [" + QString(ip) + ":" + QString::number(port) + "]"); + stt->doEmitionRedFoundData("[JSLocator] Location extraction failed [" + QString(ip) + ":" + QString::number(port) + "]"); }; }; } diff --git a/negatives.txt b/negatives.txt index 80e6a2b..557fafc 100644 --- a/negatives.txt +++ b/negatives.txt @@ -1,3 +1,4 @@ +купить г‚Ёгѓ©гѓј pagerror Error report @@ -892,5 +893,4 @@ UNKNOWN HOST офис юридич страница не найдена -купить прода \ No newline at end of file diff --git a/nesca_3.cpp b/nesca_3.cpp index 60158b3..dd6fcb3 100644 --- a/nesca_3.cpp +++ b/nesca_3.cpp @@ -1498,7 +1498,9 @@ void nesca_3::slotSaveImage(QAction *qwe) { if(ME2ScanFlag || VoiceScanFlag) { - QString fn = QString::number(QT.msec()) + "_" + (ME2ScanFlag ? QString("ME2") : QString("Voice")) + "_" + (ci == 0 ? ui->ipLine->text() : ui->lineEditStartIPDNS->text()) + ".png"; + QString fn = QString::number(QT.msec()) + "_" + + (ME2ScanFlag ? QString("ME2") : QString("Voice")) + "_" + + (ci == 0 ? ui->ipLine->text() : ui->lineEditStartIPDNS->text()) + ".png"; int ax = 27; int ay = 2; int w = ui->graphicLog->width() + 30; @@ -1539,7 +1541,9 @@ void nesca_3::slotSaveImage(QAction *qwe) } else { - QString fn = QString::number(QT.msec()) + "_" + (PieStatFlag ? "PieStat" : "QoS") + "_" + (ci == 0 ? ui->ipLine->text() : ui->lineEditStartIPDNS->text()) + ".png"; + QString fn = QString::number(QT.msec()) + "_" + + (PieStatFlag ? "PieStat" : "QoS") + "_" + + (ci == 0 ? ui->ipLine->text() : ui->lineEditStartIPDNS->text()) + ".png"; QPixmap pixmap(ui->graphicLog->width(), ui->graphicLog->height()); QPainter painter(&pixmap); @@ -2046,7 +2050,6 @@ void nesca_3::IPScanSeq() { if(ui->portLine->text() != "") { - _LoadPersInfoToLocalVars(savedTabIndex); stopFirst = false; ui->tabMainWidget->setTabEnabled(1, false); ui->tabMainWidget->setTabEnabled(2, false); @@ -2068,6 +2071,7 @@ void nesca_3::IPScanSeq() }; }; + saveOptions(); strcpy(inputStr, ("DUMMY|0|" + rangeData + "|" + ui->threadLine->text() + "|-p" + ui->portLine->text().replace(" ", "")).toLocal8Bit().data()); stt->start(); @@ -2142,7 +2146,7 @@ void nesca_3::DNSScanSeq() ui->lineILVL->setText(topLevelDomainStr); }; - _LoadPersInfoToLocalVars(savedTabIndex); + saveOptions(); stopFirst = false; ui->tabMainWidget->setTabEnabled(0, false); @@ -2186,10 +2190,10 @@ void nesca_3::ImportScanSeq() if(fileName != "") { - _LoadPersInfoToLocalVars(savedTabIndex); ui->tabMainWidget->setTabEnabled(0, false); ui->tabMainWidget->setTabEnabled(1, false); + saveOptions(); strcpy(inputStr, ("DUMMY|-f|" + fileName + "|" + ui->importThreads->text() + "|-p" + ui->importPorts->text().replace(" ", "")).toLocal8Bit().data()); globalScanFlag = true; diff --git a/nesca_startModule.cpp b/nesca_startModule.cpp index 5467492..0a9aeb2 100644 --- a/nesca_startModule.cpp +++ b/nesca_startModule.cpp @@ -181,7 +181,10 @@ void _SaveBackupToFile() { if (gMode == 1) { - strcpy(endStr, currentMask); + if (strlen(currentMask) == 0) { + sprintf(endStr, "%s", currentIP); + } + else strcpy(endStr, currentMask); } else { diff --git a/version b/version index 8a70cf6..2a432c9 100644 --- a/version +++ b/version @@ -1 +1 @@ -24B84-386 \ No newline at end of file +24B84-3FA \ No newline at end of file