diff --git a/ActivityDrawerTh_HorNet.cpp b/ActivityDrawerTh_HorNet.cpp index cd7b11e..db19e28 100644 --- a/ActivityDrawerTh_HorNet.cpp +++ b/ActivityDrawerTh_HorNet.cpp @@ -4,11 +4,12 @@ void ActivityDrawerTh_HorNet::doEmitDrawActivityLine(QString data) { emit adtHN->sDrawActivityLine(data); -}; +} + void ActivityDrawerTh_HorNet::doEmitDrawGrid() { emit adtHN->sDrawGrid(); -}; +} void makeActLine(int val) { @@ -18,7 +19,8 @@ void makeActLine(int val) actLst.pop_front(); actLst.push_back(val); }; -}; +} + void ActivityDrawerTh_HorNet::run() { adtHN->doEmitDrawGrid(); @@ -34,4 +36,4 @@ void ActivityDrawerTh_HorNet::run() Activity = 0; msleep(130); }; -}; \ No newline at end of file +} diff --git a/CheckKey_Th.cpp b/CheckKey_Th.cpp index 9ac16bd..6cfd09b 100644 --- a/CheckKey_Th.cpp +++ b/CheckKey_Th.cpp @@ -1,4 +1,3 @@ -#pragma once #include "CheckKey_Th.h" #include "CheckProxy_Th.h" #include "STh.h" @@ -36,6 +35,7 @@ void getSubStr(char *src, char *startStr, char *endStr, char *dest, int szDest) }; }; } + int emitIfOK = -1; int KeyCheckerMain() { @@ -57,11 +57,13 @@ int KeyCheckerMain() std::string buffer; Connector::nConnect((std::string(trcSrv) + std::string(trcScr)).c_str(), std::stoi(trcSrvPortLine), &buffer, NULL, &headerVector); - int hostStringIndex = Utils::ci_find_substr(buffer, std::string("\r\n\r\n")); + int hostStringIndex = buffer.find("\r\n\r\n"); if(hostStringIndex != -1) { - const char *ptr1 = buffer.c_str() + hostStringIndex + 4; - buffer.clear(); - Connector::nConnect((std::string(ptr1) + std::string("/api/checkaccount?key=") + std::string(trcPersKey)).c_str(), + + int s = buffer.find("http://", hostStringIndex); + int e = buffer.find('/', s + 8); + std::string url = buffer.substr(s, e - s); + Connector::nConnect((url + std::string("/api/checkaccount?key=") + std::string(trcPersKey)).c_str(), std::stoi(trcSrvPortLine), &buffer, NULL, &headerVector); if(Utils::ci_find_substr(buffer, std::string("202 Accepted")) != -1) { @@ -72,22 +74,20 @@ int KeyCheckerMain() return 1; } else if(Utils::ci_find_substr(buffer, std::string("400 Bad Request")) != -1) { QString errorDef = GetNSErrorDefinition(buffer.c_str(), "notify"); - if(errorDef == "Invalid access key") stt->doEmitionYellowFoundData("[NS-Track] [Key is unauthorized] A valid key is required."); - else stt->doEmitionYellowFoundData("[Key checker] -FAIL! [400 Bad Request : " + GetNSErrorDefinition(buffer.c_str(), "notify") + "]"); - return -1; + if(errorDef == "Invalid access key") stt->doEmitionYellowFoundData("[NS-Track] Key is unauthorized. A valid key is required."); + else stt->doEmitionYellowFoundData("[Key check] -FAIL! [400 Bad Request : " + GetNSErrorDefinition(buffer.c_str(), "notify") + "]"); } else if(Utils::ci_find_substr(buffer, std::string("503 Bad Gateway")) != -1) { - stt->doEmitionYellowFoundData("[Key checker] 503 Backend not responding!"); - return -1; + stt->doEmitionYellowFoundData("[Key check] 503 Backend not responding!"); } else { char header[64] = {0}; getSubStrEx(buffer.c_str(), "http/1.1 ", "\r\n", header, 64); - stt->doEmitionRedFoundData("[Key checker] -FAIL! An error occured. (" + QString::number(WSAGetLastError()) + ") Header: " + QString::fromLocal8Bit(header) + ""); + stt->doEmitionRedFoundData("[Key check] -FAIL! An error occured. (" + QString::number(WSAGetLastError()) + ") Header: " + QString::fromLocal8Bit(header) + ""); if(gDebugMode) stt->doEmitionDebugFoundData(QString(buffer.c_str())); - return -1; }; } else { - stt->doEmitionRedFoundData("[Key checker] Cannot acquire host string."); + stt->doEmitionRedFoundData("[Key check] Cannot acquire host string."); } + return -1; } void CheckKey_Th::run() diff --git a/CheckProxy_Th.cpp b/CheckProxy_Th.cpp index 403075a..02f10b2 100644 --- a/CheckProxy_Th.cpp +++ b/CheckProxy_Th.cpp @@ -80,14 +80,12 @@ void CheckProxyLogic() ) { - chPTh->doEmitChangeRawIRCDataOut(QString::fromLocal8Bit("GET / HTTP/1.1\r\nHost: 2ip.ru\r\n\r\n")); send(pSock, "GET / HTTP/1.1\r\nHost: 2ip.ru\r\n\r\n", strlen("GET / HTTP/1.1\r\nHost: 2ip.ru\r\n\r\n"), 0); ZeroMemory(precvBuff, sizeof(precvBuff)); while(recv(pSock, precvBuff, sizeof(precvBuff), 0) > 0) { - chPTh->doEmitChangeRawIRCDataInc(QString::fromLocal8Bit(precvBuff)); @@ -103,8 +101,6 @@ void CheckProxyLogic() && strstr(precvBuff, "gateway timeout") == NULL ) { - - chPTh->doEmitChangeGreenIRCData("[OK] Success! Now using " + QString(ircProxy) + ":" + QString(ircProxyPort) + "."); proxyEnabledFlag = 1; diff --git a/Connector.cpp b/Connector.cpp index b75438e..dcaf0b8 100644 --- a/Connector.cpp +++ b/Connector.cpp @@ -226,55 +226,6 @@ struct data { char trace_ascii; /* 1 or 0 */ }; -static -void dump(const char *text, - FILE *stream, unsigned char *ptr, size_t size, - char nohex) -{ - size_t i; - size_t c; - - unsigned int width=0x10; - - if(nohex) - /* without the hex output, we can fit more on screen */ - width = 0x40; - - fprintf(stream, "%s, %10.10ld bytes (0x%8.8lx)\n", - text, (long)size, (long)size); - - for(i=0; i=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.'); - /* check again for 0D0A, to avoid an extra \n if it's at width */ - if (nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) { - i+=(c+3-width); - break; - } - } - fputc('\n', stream); /* newline */ - } - fflush(stream); -} - static int my_trace(CURL *handle, curl_infotype type, char *data, size_t size, @@ -285,14 +236,14 @@ int my_trace(CURL *handle, curl_infotype type, (void)handle; /* prevent compiler warning */ switch (type) { - case CURLINFO_TEXT: + case CURLINFO_HEADER_OUT: + if(MapWidgetOpened) stt->doEmitionAddOutData(QString("size"), QString(data)); + cout<<"Data: "<doEmitionAddOutData(QString("size"), QString(data)); - dump(text, stderr, (unsigned char *)data, size, config->trace_ascii); return 0; } diff --git a/DrawerTh_ME2Scanner.h b/DrawerTh_ME2Scanner.h index 397d2f8..a2c3c1f 100644 --- a/DrawerTh_ME2Scanner.h +++ b/DrawerTh_ME2Scanner.h @@ -10,7 +10,7 @@ class DrawerTh_ME2Scanner : public QThread Q_OBJECT public: - static QList itmList; + static QList itmList; static QVector polyVect; static void doEmitionAddPolyLine(); diff --git a/DrawerTh_QoSScanner.cpp b/DrawerTh_QoSScanner.cpp index a67efc4..dfc695c 100644 --- a/DrawerTh_QoSScanner.cpp +++ b/DrawerTh_QoSScanner.cpp @@ -1,16 +1,11 @@ -#pragma once #include "DrawerTh_QoSScanner.h" #include "STh.h" #include "externData.h" -int tMax; - void DrawerTh_QoSScanner::run() { while(QoSScanFlag) - { - tMax = 0; - + { if(stt->isRunning() == true && widgetIsHidden == false && tray->isVisible() == false && QOSWait == false) { lstOfLabels.clear(); @@ -19,15 +14,13 @@ void DrawerTh_QoSScanner::run() lstOfLabels.append(WF); lstOfLabels.append(Susp); lstOfLabels.append(Lowl); - lstOfLabels.append((int)BA); + lstOfLabels.append(BA); lstOfLabels.append(Overl); lstOfLabels.append(ssh); QList lstOfLabelsCopy = lstOfLabels; - qSort(lstOfLabelsCopy.begin(), lstOfLabelsCopy.end(), qGreater()); - int curVal = lstOfLabelsCopy[0]; - if(curVal > MaxDataVal) MaxDataVal = curVal; - if(curVal > tMax) tMax = curVal; + qSort(lstOfLabelsCopy.begin(), lstOfLabelsCopy.end(), qGreater()); + if(lstOfLabelsCopy[0] > MaxDataVal) MaxDataVal = lstOfLabelsCopy[0]; dtQoS->doEmitionAddLine(); } @@ -56,9 +49,9 @@ void DrawerTh_QoSScanner::run() ssh = 0; msleep(2000); }; -}; +} void DrawerTh_QoSScanner::doEmitionAddLine() { emit dtQoS->sAddLine(); -}; \ No newline at end of file +} diff --git a/IRCPinger_Th.cpp b/IRCPinger_Th.cpp index aaec3e0..29fde02 100644 --- a/IRCPinger_Th.cpp +++ b/IRCPinger_Th.cpp @@ -1,4 +1,3 @@ -#pragma once #include "IRCPinger_Th.h" #include "externData.h" @@ -28,4 +27,4 @@ void IRCPinger_Th::run() ++globalPinger; msleep(1000); }; -}; \ No newline at end of file +}; diff --git a/Utils.h b/Utils.h index 647bde6..a0e7297 100644 --- a/Utils.h +++ b/Utils.h @@ -11,9 +11,9 @@ struct my_equal { my_equal( const locale loc ) : loc_(loc) {} bool operator()(charT ch1, charT ch2) { #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) - return toupper(ch1) == toupper(ch2); + return tolower(ch1) == tolower(ch2); #else - return toupper(ch1, loc_) == toupper(ch2, loc_); + return tolower(ch1, loc_) == tolower(ch2, loc_); #endif } private: @@ -33,6 +33,17 @@ public: else return -1; } + template static int ci_find_substr(const T& str1, + const char* str2c, + const locale& loc = locale()) { + + std::string str2 = std::string(str2c); + auto it = std::search(str1.begin(), str1.end(), str2.begin(), str2.end(), + my_equal(loc)); + if(it != str1.end()) return it - str1.begin(); + else return -1; + } + char * getProxy(); int getProxyPort(); }; diff --git a/connector_old.cpp b/connector_old.cpp index 5b403b6..787591a 100644 --- a/connector_old.cpp +++ b/connector_old.cpp @@ -224,7 +224,7 @@ void _baSSLWorker(char *ip, char *request, char *rvBuff) int x = 1; int xx = 0; - ZeroMemory(rvBuff, sizeof(rvBuff)); + ZeroMemory(rvBuff, sizeof(*rvBuff)); while(xx < 512) { x = SSL_read(ssl, tempBuff, sizeof(tempBuff)); diff --git a/externData.h b/externData.h index 23945fd..a696a3f 100644 --- a/externData.h +++ b/externData.h @@ -17,9 +17,9 @@ extern QJsonArray *jsonArr; -extern unsigned long long gTargetsOverall, Activity; +extern unsigned long long gTargetsOverall; extern char top_level_domain[128]; -extern volatile int BA, cons, BrutingThrds, gThreads; +extern volatile int cons, BrutingThrds, gThreads; extern char **loginLst, **passLst, **wfLoginLst, **wfPassLst, **sshlpLst, **GlobalNegatives; extern bool trackerOK, __savingBackUpFile, globalScanFlag, MapWidgetOpened, widgetIsHidden, OnlineMsgSentFlag, utfIRCFlag, HTMLDebugMode, gNegDebugMode, @@ -32,8 +32,10 @@ extern int found, indexIP, gMode, gThreadDelay, AnomC1, Filt, Overl, Lowl, Alive, saved, Susp, WF, + BA, offlines, ssh, globalPinger, gPingTimeout, nickFlag, offlineFlag; -extern char trcSrv[256], trcScr[256], trcProxy[128], trcPersKey[32], +extern unsigned int Activity; +extern char trcSrv[256], trcScr[256], trcProxy[128], trcPersKey[64], ircServer[32], ircPort[32], ircProxy[64], ircProxyPort[8], ircNick[32], trcPort[32], trcSrvPortLine[32], saveStartIP[128], saveEndIP[128], gRange[128], gFirstDom[128], gPorts[65536], endIP2[128], diff --git a/finder.cpp b/finder.cpp index 9e1f868..e5e0fbf 100644 --- a/finder.cpp +++ b/finder.cpp @@ -1,5 +1,4 @@ -#pragma once -#include "STh.h" +#include "STh.h" #include "mainResources.h" #include "externFunctions.h" #include "externData.h" @@ -183,13 +182,13 @@ char *GetCodePage(const char *str) }; } -int Lexems::globalSearchNeg(const char *buffcpy, char *ip, int port) +int globalSearchNeg(const char *buffcpy, char *ip, int port) { char negWord[256] = {0}; - for(int i = 0; i < GlobalNegativeSize; i++) + for(int i = 0; i < GlobalNegativeSize; ++i) { - if(globalScanFlag) - { + if(!globalScanFlag) break; + strcpy(negWord, GlobalNegatives[i]); if(strstr(buffcpy, negWord) != NULL) { @@ -209,16 +208,18 @@ int Lexems::globalSearchNeg(const char *buffcpy, char *ip, int port) stt->doEmitionDebugFoundData("Space hit!"); }; }; + ++Filt; return -1; }; - }; + + ZeroMemory(negWord, 256); }; - return 0; + return -1; } -int globalSearchPrnt(char *buffcpy) +int globalSearchPrnt(const char *buffcpy) { if(strstr(buffcpy, "en/_top.htm") != NULL || strstr(buffcpy, "cannon http server") != NULL || strstr(buffcpy, "konica minolta") != NULL || strstr(buffcpy, "/eng/home_frm.htm") != NULL @@ -237,198 +238,125 @@ int globalSearchPrnt(char *buffcpy) { stt->doEmitionDebugFoundData("Printer detected."); }; + return -1; }; + + return 0; +} + +int sharedDetector(char * ip, int port, const char *buffcpy) { + + if(strstr(buffcpy, "401 authorization") != NULL || strstr(buffcpy, "401 unauthorized") != NULL + || (strstr(buffcpy, "www-authenticate") != NULL && strstr(buffcpy, "401 ") != NULL ) + || strstr(buffcpy, "401 unauthorized access denied") != NULL + || strstr(buffcpy, "401 unauthorised") != NULL || (strstr(buffcpy, "www-authenticate") != NULL + && strstr(buffcpy, " 401\r\n") != NULL) + ) { + if(strstr(buffcpy, "digest realm") != NULL && strstr(buffcpy, "basic realm") == NULL) { + return 101; + } else return 1; + }; + if(strstr(buffcpy, "netwave ip camera")) return 11; + if(strstr(buffcpy, "live view / - axis")) return 12; + if(strstr(buffcpy, "vilar ipcamera")) return 13; + if(strstr(buffcpy, "window.location = \"rdr.cgi\"")) return 14; + if(strstr(buffcpy, "httpfileserver")) return 15; + if(strstr(buffcpy, "real-time ip camera monitoring system") != NULL + || strstr(buffcpy, "server push mode") != NULL + ) return 17; //Real-time IP Camera Monitoring System + if(strstr(buffcpy, "linksys.com") != NULL && strstr(buffcpy, "tm05") != NULL) return 18; //linksys.com cameras + if(strstr(buffcpy, "reecam ip camera") != NULL) return 19; //reecam cameras + if(strstr(buffcpy, "/view/viewer_index.shtml") != NULL) return 20; //axis cameras + if(strstr(buffcpy, "bridge eyeon") != NULL) return 21; //Bridge Eyeon + if(strstr(buffcpy, "ip camera control webpage") != NULL && strstr(buffcpy, "/main/cs_motion.asp") != NULL) return 22; //ip camera control + if(strstr(buffcpy, "network camera") != NULL && strstr(buffcpy, "/live/index2.html") != NULL) return 23; //network camera BB-SC384 + if(strstr(buffcpy, "network camera") != NULL && strstr(buffcpy, "/viewer/live/en/live.html") != NULL) return 24; //Network Camera VB-M40 + if(strstr(buffcpy, "panasonic ") != NULL && strstr(buffcpy, ":60002/snapshotjpeg") != NULL) return 25; //Panasonic wtfidonteven-camera + if(strstr(buffcpy, "sony network camera") != NULL && strstr(buffcpy, "/command/inquiry.cgi?") != NULL) return 26; //Sony Network Camera + if(strstr(buffcpy, "network camera") != NULL && strstr(buffcpy, "src=\"webs.cgi?") != NULL) return 27; //UA Network Camera + if(strstr(buffcpy, "network camera") != NULL && strstr(buffcpy, "/viewer/live/index.html") != NULL) return 28; //Network Camera VB-M40 + if(strstr(buffcpy, "lg smart ip device") != NULL) return 29; //LG Smart IP Device Camera + if(strstr(buffcpy, "/view/viewer_index.shtml") != NULL) return 20; //axis cameras + if(strstr(buffcpy, "nas") != NULL && strstr(buffcpy, "/cgi-bin/data/viostor-220/viostor/viostor.cgi") != NULL) return 30; //NAX + if(strstr(buffcpy, "ip camera") != NULL && strstr(buffcpy, "check_user.cgi") != NULL) return 31; //axis cameras + if(strstr(buffcpy, "ws(\"user\");") != NULL && strstr(buffcpy, "src=\"/tool.js") != NULL + && strstr(buffcpy, "") != NULL) return 32; //web ip cam + if(strstr(buffcpy, "geovision") != NULL + && (strstr(buffcpy, "ip camera") != NULL + || strstr(buffcpy, "ssi.cgi/login.htm") != NULL)) return 33; //GEO web ip cam + + if(strstr(buffcpy, "hikvision-webs") != NULL + || (strstr(buffcpy, "hikvision digital") != NULL && strstr(buffcpy, "dvrdvs-webs") != NULL) + || (strstr(buffcpy, "lapassword") != NULL && strstr(buffcpy, "lausername") != NULL && strstr(buffcpy, "dologin()") != NULL)) return 34; //hikvision cam + if((strstr(buffcpy, "easy cam") != NULL && strstr(buffcpy, "easy life") != NULL) + || (strstr(buffcpy, "ipcamera") != NULL && strstr(buffcpy, "/tool.js") != NULL)) return 35; //EasyCam + if(strstr(buffcpy, "/config/cam_portal.cgi") != NULL || strstr(buffcpy, "/config/easy_index.cgi") != NULL) return 36; //Panasonic Cam + if(strstr(buffcpy, "panasonic") != NULL && strstr(buffcpy, "/view/getuid.cgi") != NULL) return 37; //Panasonic Cam WJ-HD180 + if(strstr(buffcpy, "ipcam client") != NULL && strstr(buffcpy, "plugins.xpi") != NULL && strstr(buffcpy, "js/upfile.js") != NULL) return 38; //Foscam + if(strstr(buffcpy, "ip surveillance") != NULL && strstr(buffcpy, "customer login") != NULL) return 39; //EagleEye + if(strstr(buffcpy, "network camera") != NULL && strstr(buffcpy, "/admin/index.shtml?") != NULL) return 40; //Network Camera VB-C300 + if(strstr(buffcpy, "sq-webcam") != NULL && strstr(buffcpy, "liveview.html") != NULL) return 41; //AVIOSYS-camera + if(strstr(buffcpy, "nw_camera") != NULL && strstr(buffcpy, "/cgi-bin/getuid") != NULL) return 42; //NW_camera + if(strstr(buffcpy, "micros") != NULL && strstr(buffcpy, "/gui/gui_outer_frame.shtml") != NULL) return 43; //NW_camera + if(strstr(buffcpy, "lapassword") != NULL + && strstr(buffcpy, "lausername") != NULL + && strstr(buffcpy, "g_ologin.dologin()") != NULL + ) return 44; //hikvision cam 2 + if(strstr(buffcpy, "panasonic") != NULL && strstr(buffcpy, "/config/index.cgi") != NULL) return 45; //Panasonic Cam BB-HG??? + if(strstr(buffcpy, "/ui/") != NULL && strstr(buffcpy, "sencha-touch") != NULL) return 46; //BUFFALO disk + if(strstr(buffcpy, "digital video server") != NULL && strstr(buffcpy, "gui.css") != NULL) return 47; //Digital Video Server + if(strstr(buffcpy, "/ipcamerasetup.zip") != NULL && strstr(buffcpy, "download player") != NULL + && strstr(buffcpy, "ipcam") != NULL) return 48; //ipCam + if(strstr(buffcpy, "dvr") != NULL && strstr(buffcpy, "ieorforefox") != NULL + && strstr(buffcpy, "sofari") != NULL) return 49; //IEORFOREFOX + if (strstr(buffcpy, "seyeon") != NULL && (strstr(buffcpy, "/app/multi/single.asp") != NULL + || strstr(buffcpy, "/app/live/sim/single.asp") != NULL)) return 50; //Network Video System + + if(((strstr(buffcpy, "220") != NULL) && (port == 21)) || + (strstr(buffcpy, "220 diskStation ftp server ready") != NULL) || + (strstr(buffcpy, "220 ftp server ready") != NULL) + || strstr(buffcpy, "500 'get': command not understood") != NULL + ) return 16; // 16 - FTP + + if((strstr(buffcpy, "camera web server") != NULL || strstr(buffcpy, "webcamxp 5") != NULL + || strstr(buffcpy, "ip box camera") != NULL || strstr(buffcpy, "snaff") != NULL + || strstr(buffcpy, "hfs /") != NULL || strstr(buffcpy, "httpfileserver") != NULL + || strstr(buffcpy, "network camera") != NULL + || strstr(buffcpy, "$lock extended") != NULL || strstr(buffcpy, "ip camera") != NULL + || strstr(buffcpy, "/viewer/video.jpg") != NULL || strstr(buffcpy, "smart ip device") != NULL + || strstr(buffcpy, "sanpshot_icon") != NULL || strstr(buffcpy, "snapshot_icon") != NULL + || strstr(buffcpy, "ipcam") != NULL) + && strstr(buffcpy, "customer") == NULL + && strstr(buffcpy, "purchase") == NULL + && strstr(buffcpy, "contac") == NULL + && strstr(buffcpy, "company") == NULL + ) return 0; + + if(globalSearchNeg(buffcpy, ip, port) == -1) return -1; + if(globalSearchPrnt(buffcpy) == -1) return -1; + if(strstr(buffcpy, "
") != NULL) return 32; //IPC web ip cam - if(strstr(buffcpy, "geovision") != NULL && (strstr(buffcpy, "ip camera") != NULL - || strstr(buffcpy, "ssi.cgi/login.htm") != NULL)) return 33; //GEO web ip cam - if(strstr(buffcpy, "hikvision-webs") != NULL || (strstr(buffcpy, "hikvision digital") != NULL - && strstr(buffcpy, "dvrdvs-webs") != NULL) - || (strstr(buffcpy, "lapassword") != NULL && strstr(buffcpy, "lausername") != NULL - && strstr(buffcpy, "dologin()") != NULL)) return 34; //hikvision cam - if((strstr(buffcpy, "easy cam") != NULL && strstr(buffcpy, "easy life") != NULL) - || (strstr(buffcpy, "ipcamera") != NULL && strstr(buffcpy, "/tool.js") != NULL)) return 35; //EasyCam - if(strstr(buffcpy, "/config/cam_portal.cgi") != NULL || strstr(buffcpy, "/config/easy_index.cgi") != NULL) return 36; //Panasonic Cam - if(strstr(buffcpy, "panasonic") != NULL && strstr(buffcpy, "/view/getuid.cgi") != NULL) return 37; //Panasonic Cam WJ-HD180 - if(strstr(buffcpy, "ipcam client") != NULL && strstr(buffcpy, "plugins.xpi") != NULL - && strstr(buffcpy, "js/upfile.js") != NULL) return 38; //Foscam - if(strstr(buffcpy, "ip surveillance") != NULL && strstr(buffcpy, "customer login") != NULL) return 39; //EagleEye - if(strstr(buffcpy, "network camera") != NULL && strstr(buffcpy, "/admin/index.shtml?") != NULL) return 40; //Network Camera VB-C300 - if(strstr(buffcpy, "sq-webcam") != NULL && strstr(buffcpy, "liveview.html") != NULL) return 41; //AVIOSYS-camera - if(strstr(buffcpy, "nw_camera") != NULL && strstr(buffcpy, "/cgi-bin/getuid") != NULL) return 42; //NW_camera - if(strstr(buffcpy, "micros") != NULL && strstr(buffcpy, "/gui/gui_outer_frame.shtml") != NULL) return 43; //NW_camera - if(strstr(buffcpy, "lapassword") != NULL - && strstr(buffcpy, "lausername") != NULL - && strstr(buffcpy, "g_ologin.dologin()") != NULL - ) return 44; //hikvision cam 2 - if(strstr(buffcpy, "panasonic") != NULL && strstr(buffcpy, "/config/index.cgi") != NULL) return 45; //Panasonic Cam BB-HG??? - if(strstr(buffcpy, "/ui/") != NULL && strstr(buffcpy, "sencha-touch") != NULL) return 46; //BUFFALO disk - if(strstr(buffcpy, "digital video server") != NULL && strstr(buffcpy, "gui.css") != NULL) return 47; //Digital Video Server - if(strstr(buffcpy, "/ipcamerasetup.zip") != NULL && strstr(buffcpy, "download player") != NULL - && strstr(buffcpy, "ipcam") != NULL) return 48; //ipCam - if(strstr(buffcpy, "dvr") != NULL && strstr(buffcpy, "ieorforefox") != NULL - && strstr(buffcpy, "sofari") != NULL) return 49; //IEORFOREFOX - if (strstr(buffcpy, "seyeon") != NULL && (strstr(buffcpy, "/app/multi/single.asp") != NULL - || strstr(buffcpy, "/app/live/sim/single.asp") != NULL)) return 50; //Network Video System - - if((strstr(buffcpy, "camera web server") != NULL || strstr(buffcpy, "webcamxp 5") != NULL - || strstr(buffcpy, "ip box camera") != NULL || strstr(buffcpy, "snaff") != NULL - || strstr(buffcpy, "hfs /") != NULL || strstr(buffcpy, "httpfileserver") != NULL - || strstr(buffcpy, "network camera") != NULL - || strstr(buffcpy, "$lock extended") != NULL || strstr(buffcpy, "ip camera") != NULL - || strstr(buffcpy, "/viewer/video.jpg") != NULL || strstr(buffcpy, "smart ip device") != NULL - || strstr(buffcpy, "sanpshot_icon") != NULL || strstr(buffcpy, "snapshot_icon") != NULL - || strstr(buffcpy, "ipcam") != NULL) - && strstr(buffcpy, "customer") == NULL - && strstr(buffcpy, "purchase") == NULL - && strstr(buffcpy, "contac") == NULL - && strstr(buffcpy, "company") == NULL - ) return 0; +int _mainFinderFirst(const char *buffcpy, int f, int port, char *ip) +{ + int flag = sharedDetector(ip, port, buffcpy); + if(flag != -2) return flag; - if(lxf.globalSearchNeg(buffcpy, ip, port) == -1) return -1; - if(globalSearchPrnt(buffcpy) == -1) return -1; - if(strstr(buffcpy, " 1600 -int _mainFinderSecond(char *buffcpy, int port, char *ip) +int _mainFinderSecond(const char *buffcpy, int port, char *ip) { - if((strstr(buffcpy, "401 authorization") != NULL || strstr(buffcpy, "401 unauthorized") != NULL - || (strstr(buffcpy, "www-authenticate") != NULL && strstr(buffcpy, "401 ") != NULL ) - || strstr(buffcpy, "401 unauthorized access denied") != NULL - || strstr(buffcpy, "401 unauthorised") != NULL || (strstr(buffcpy, "www-authenticate") != NULL - && strstr(buffcpy, " 401\r\n") != NULL) - ) - && strstr(buffcpy, "digest realm") != NULL && strstr(buffcpy, "basic realm") == NULL - ) return 101; - if(strstr(buffcpy, "401 authorization") != NULL || strstr(buffcpy, "401 unauthorized") != NULL - || (strstr(buffcpy, "www-authenticate") != NULL && strstr(buffcpy, "401 ") != NULL ) - || strstr(buffcpy, "401 unauthorized access denied") != NULL - || strstr(buffcpy, "401 unauthorised") != NULL || (strstr(buffcpy, "www-authenticate") != NULL - && strstr(buffcpy, " 401\r\n") != NULL) - ) return 1; - if(strstr(buffcpy, "netwave ip camera")) return 11; - if(strstr(buffcpy, "live view / - axis")) return 12; - if(strstr(buffcpy, "vilar ipcamera")) return 13; - if(strstr(buffcpy, "window.location = \"rdr.cgi\"")) return 14; - if(strstr(buffcpy, "httpfileserver")) return 15; - if(strstr(buffcpy, "real-time ip camera monitoring system") != NULL || - strstr(buffcpy, "server push mode") != NULL - ) return 17; //Real-time IP Camera Monitoring System - if(strstr(buffcpy, "linksys.com") != NULL && strstr(buffcpy, "tm05") != NULL) return 18; //linksys.com cameras - if(strstr(buffcpy, "reecam ip camera") != NULL) return 19; //reecam cameras - if(strstr(buffcpy, "/view/viewer_index.shtml") != NULL) return 20; //axis cameras - if(strstr(buffcpy, "bridge eyeon") != NULL) return 21; //Bridge Eyeon - if(strstr(buffcpy, "ip camera control webpage") != NULL && strstr(buffcpy, "/main/cs_motion.asp") != NULL) return 22; //ip camera control - if(strstr(buffcpy, "network camera") != NULL && strstr(buffcpy, "/live/index2.html") != NULL) return 23; //network camera BB-SC384 - if(strstr(buffcpy, "network camera") != NULL && strstr(buffcpy, "/viewer/live/en/live.html") != NULL) return 24; //Network Camera VB-M40 - if(strstr(buffcpy, "panasonic ") != NULL && strstr(buffcpy, ":60002/snapshotjpeg") != NULL) return 25; //Panasonic wtfidonteven-camera - if(strstr(buffcpy, "sony network camera") != NULL && strstr(buffcpy, "/command/inquiry.cgi?") != NULL) return 26; //Sony Network Camera - if(strstr(buffcpy, "network camera") != NULL && strstr(buffcpy, "src=\"webs.cgi?") != NULL) return 27; //UA Network Camera - if(strstr(buffcpy, "network camera") != NULL && strstr(buffcpy, "/viewer/live/index.html") != NULL) return 28; //Network Camera VB-M40 - if(strstr(buffcpy, "lg smart ip device") != NULL) return 29; //LG Smart IP Device Camera - if(strstr(buffcpy, "/view/viewer_index.shtml") != NULL) return 20; //axis cameras - if(strstr(buffcpy, "nas") != NULL && strstr(buffcpy, "/cgi-bin/data/viostor-220/viostor/viostor.cgi") != NULL) return 30; //NAX - if(strstr(buffcpy, "ip camera") != NULL && strstr(buffcpy, "check_user.cgi") != NULL) return 31; //axis cameras - if(strstr(buffcpy, "ws(\"user\");") != NULL && strstr(buffcpy, "src=\"/tool.js") != NULL && strstr(buffcpy, "") != NULL) return 32; //web ip cam - if(strstr(buffcpy, "geovision") != NULL && (strstr(buffcpy, "ip camera") != NULL || strstr(buffcpy, "ssi.cgi/login.htm") != NULL)) return 33; //GEO web ip cam + int flag = sharedDetector(ip, port, buffcpy); + if(flag != -2) return flag; - if(strstr(buffcpy, "hikvision-webs") != NULL || (strstr(buffcpy, "hikvision digital") != NULL && strstr(buffcpy, "dvrdvs-webs") != NULL) - || (strstr(buffcpy, "lapassword") != NULL && strstr(buffcpy, "lausername") != NULL && strstr(buffcpy, "dologin()") != NULL)) return 34; //hikvision cam - if((strstr(buffcpy, "easy cam") != NULL && strstr(buffcpy, "easy life") != NULL) - || (strstr(buffcpy, "ipcamera") != NULL && strstr(buffcpy, "/tool.js") != NULL)) return 35; //EasyCam - if(strstr(buffcpy, "/config/cam_portal.cgi") != NULL || strstr(buffcpy, "/config/easy_index.cgi") != NULL) return 36; //Panasonic Cam - if(strstr(buffcpy, "panasonic") != NULL && strstr(buffcpy, "/view/getuid.cgi") != NULL) return 37; //Panasonic Cam WJ-HD180 - if(strstr(buffcpy, "ipcam client") != NULL && strstr(buffcpy, "plugins.xpi") != NULL && strstr(buffcpy, "js/upfile.js") != NULL) return 38; //Foscam - if(strstr(buffcpy, "ip surveillance") != NULL && strstr(buffcpy, "customer login") != NULL) return 39; //EagleEye - if(strstr(buffcpy, "network camera") != NULL && strstr(buffcpy, "/admin/index.shtml?") != NULL) return 40; //Network Camera VB-C300 - if(strstr(buffcpy, "sq-webcam") != NULL && strstr(buffcpy, "liveview.html") != NULL) return 41; //AVIOSYS-camera - if(strstr(buffcpy, "nw_camera") != NULL && strstr(buffcpy, "/cgi-bin/getuid") != NULL) return 42; //NW_camera - if(strstr(buffcpy, "micros") != NULL && strstr(buffcpy, "/gui/gui_outer_frame.shtml") != NULL) return 43; //NW_camera - if(strstr(buffcpy, "lapassword") != NULL - && strstr(buffcpy, "lausername") != NULL - && strstr(buffcpy, "g_ologin.dologin()") != NULL - ) return 44; //hikvision cam 2 - if(strstr(buffcpy, "panasonic") != NULL && strstr(buffcpy, "/config/index.cgi") != NULL) return 45; //Panasonic Cam BB-HG??? - if(strstr(buffcpy, "/ui/") != NULL && strstr(buffcpy, "sencha-touch") != NULL) return 46; //BUFFALO disk - if(strstr(buffcpy, "digital video server") != NULL && strstr(buffcpy, "gui.css") != NULL) return 47; //Digital Video Server - if(strstr(buffcpy, "/ipcamerasetup.zip") != NULL && strstr(buffcpy, "download player") != NULL - && strstr(buffcpy, "ipcam") != NULL) return 48; //ipCam - if(strstr(buffcpy, "dvr") != NULL && strstr(buffcpy, "ieorforefox") != NULL - && strstr(buffcpy, "sofari") != NULL) return 49; //IEORFOREFOX - if (strstr(buffcpy, "seyeon") != NULL && (strstr(buffcpy, "/app/multi/single.asp") != NULL - || strstr(buffcpy, "/app/live/sim/single.asp") != NULL)) return 50; //Network Video System - - if(((strstr(buffcpy, "220") != NULL) && (port == 21)) || - (strstr(buffcpy, "220 diskStation ftp server ready") != NULL) || - (strstr(buffcpy, "220 ftp server ready") != NULL) - || strstr(buffcpy, "500 'get': command not understood") != NULL - ) return 16; // 16 - FTP - - if((strstr(buffcpy, "camera web server") != NULL || strstr(buffcpy, "webcamxp 5") != NULL - || strstr(buffcpy, "ip box camera") != NULL || strstr(buffcpy, "snaff") != NULL - || strstr(buffcpy, "hfs /") != NULL || strstr(buffcpy, "httpfileserver") != NULL - || strstr(buffcpy, "network camera") != NULL - || strstr(buffcpy, "$lock extended") != NULL || strstr(buffcpy, "ip camera") != NULL - || strstr(buffcpy, "/viewer/video.jpg") != NULL || strstr(buffcpy, "smart ip device") != NULL - || strstr(buffcpy, "sanpshot_icon") != NULL || strstr(buffcpy, "snapshot_icon") != NULL - || strstr(buffcpy, "ipcam") != NULL) - && strstr(buffcpy, "customer") == NULL - && strstr(buffcpy, "purchase") == NULL - && strstr(buffcpy, "contac") == NULL - && strstr(buffcpy, "company") == NULL - ) return 0; - - if(lxf.globalSearchNeg(buffcpy, ip, port) == -1) return -1; - if(globalSearchPrnt(buffcpy) == -1) return -1; - if(strstr(buffcpy, " 500 && sz <= 3500) || sz > 180000) { - res = _mainFinderFirst(lBuff, 0, port, ip); + res = _mainFinderFirst(lBuff, 0, port, ip); } else if(sz > 3500 && sz <= 180000) { - res = _mainFinderSecond(lBuff, port, ip); + res = _mainFinderSecond(lBuff, port, ip); }; + delete []lBuff; return res; } @@ -559,7 +488,6 @@ void fputsf(char *text, int flag, char *msg) { FILE *file = NULL; -#pragma region FileExistenceCheck if(flag == 0 || flag == 15 || flag == -10) { if(ftsAnom) ftsAnom = __checkFileExistence(flag); @@ -649,7 +577,6 @@ void fputsf(char *text, int flag, char *msg) strcat (string, ""); }; -#pragma region styleFiller if(flag == 0 && ftsAnom) { char tmsg[1024] = {0}; @@ -908,26 +835,8 @@ void _specFillerWF(char *hl, char *ip, char *port, char *finalstr, char *login, ++PieWF; - sprintf(log, "[WF]:%s:%d T: %s Pass: %s:%s\n" - , ip, port, ip, port, finalstr, login, pass); - - strcpy(log, "[WF]:"); - strcat(log, ""); - strcat(log, ip); - strcat(log, ":"); - strcat(log, port); - strcat(log, " T: "); - strcat(log, finalstr); - strcat(log, " Pass: "); - strcat(log, login); - strcat(log, ":"); - strcat(log, pass); - strcat(log, ""); - strcat(log, "\n"); + sprintf(log, "[WF]:%s:%s T: %s Pass: %s:%s\n", + ip, port, ip, port, finalstr, login, pass); stt->doEmitionFoundData(QString::fromLocal8Bit(log)); diff --git a/mainResources.h b/mainResources.h index 6aa3ab2..ec78631 100644 --- a/mainResources.h +++ b/mainResources.h @@ -31,7 +31,7 @@ #include #define ZeroMemory(Destination,Length) memset((Destination),0,(Length)) -#define Sleep(secs) usleep((secs)*1000) +#define Sleep(msecs) usleep((msecs)*1000) #define WSAGetLastError() errno #define closesocket(sock) ::close((sock)) @@ -133,8 +133,13 @@ class Lexems PathStr *ps, std::vector *lst, char *rBuff); - int _filler(int p, const char *buffcpy, char* ipi, int recd, Lexems *lx, char *hl); - int globalSearchNeg(const char *buffcpy, char *ip, int port); + + int _filler(int p, + const char *buffcpy, + char* ipi, + int recd, + Lexems *lx, + char *hl); }; @@ -143,16 +148,39 @@ class Connector_old public: int _Updater(); - lopaStr _FTPLobby(char *ip, int port, PathStr *ps); - lopaStr _BALobby(char *cookie, char *ip, int port, char *path, char *method, char *data); - lopaStr _WFLobby(char *cookie, char *ip, int port, char *methodVal, char *actionVal, char *userVal, char *passVal, char *formVal); - lopaStr _IPCameraBLobby(char *ip, int port, char *SPEC); - int _SSHLobby(char *ip, int port, std::string *buffer); + lopaStr _FTPLobby(char *ip, + int port, + PathStr *ps); + + lopaStr _BALobby(char *cookie, + char *ip, + int port, + char *path, + char *method, + char *data); + + lopaStr _WFLobby(char *cookie, + char *ip, + int port, + char *methodVal, + char *actionVal, + char *userVal, + char *passVal, + char *formVal); + + lopaStr _IPCameraBLobby(char *ip, + int port, + char *SPEC); + + int _SSHLobby(char *ip, + int port, + std::string *buffer); - //int _EstablishConnection(char *ip, int port, char *request, conSTR *cstr, int force = 0); - //int _EstablishSSLConnection(char *ip, int port, char *request, conSTR *cstr); void _Connect(void *s); - int _ConnectToPort(char *ip, int port, char *hl); + + int _ConnectToPort(char *ip, + int port, + char *hl); }; diff --git a/nesca.pro b/nesca.pro index b773f97..a493743 100644 --- a/nesca.pro +++ b/nesca.pro @@ -9,6 +9,8 @@ QT += core gui multimedia greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 +QMAKE_CFLAGS += -Wno-write-strings +QMAKE_CXXFLAGS += -Wno-write-strings TARGET = nesca TEMPLATE = app diff --git a/nesca_3.cpp b/nesca_3.cpp index a2900e2..bbf5241 100644 --- a/nesca_3.cpp +++ b/nesca_3.cpp @@ -1,6 +1,4 @@ -#pragma region Decls -#pragma once -#include +#include #include #include "nesca_3.h" #include "CheckKey_Th.h" @@ -73,7 +71,7 @@ char trcSrvPortLine[32] = {0}; char trcProxy[128] = {0}; char trcSrv[256] = {0}; char trcScr[256] = {0}; -char trcPersKey[32] = {0}; +char trcPersKey[64] = {0}; char gProxyIP[64] = {0}; char gProxyPort[8] = {0}; @@ -704,7 +702,7 @@ void nesca_3::slotQoSAddLine() fnt.setFamily("Eurostile"); fnt.setPixelSize(10); - QGraphicsTextItem *item = sceneUpper->addText("Max = " + QString(std::to_string(MaxDataVal).c_str()), fnt); + QGraphicsTextItem *item = sceneUpper->addText("Max = " + QString::number(MaxDataVal), fnt); item->setX(215); item->setDefaultTextColor(Qt::white); QOSWait = false; @@ -747,38 +745,39 @@ void nesca_3::slotAddPolyLine() if(ME2ScanFlag) { QPainterPath path; - if (DrawerTh_ME2Scanner::polyVect.size() > 0) + if (DrawerTh_ME2Scanner::polyVect.count() > 0) { - path.moveTo(DrawerTh_ME2Scanner::polyVect[0]); + path.moveTo(DrawerTh_ME2Scanner::polyVect[0]); for (int i = 1; i < DrawerTh_ME2Scanner::polyVect.count(); ++i) { - path.lineTo(DrawerTh_ME2Scanner::polyVect[i]); + path.lineTo(DrawerTh_ME2Scanner::polyVect[i]); }; }; QGraphicsPathItem* itm = new QGraphicsPathItem(path); itm->setPen(pen2i); - DrawerTh_ME2Scanner::itmList.push_front(itm); + sceneGraph->addItem(itm); + DrawerTh_ME2Scanner::itmList.push_front(itm); int u = 0; double uu = 1.0; for (int i = 0; i < DrawerTh_ME2Scanner::itmList.count(); ++i) { - itm = DrawerTh_ME2Scanner::itmList[i]; int y = u - i - 1; - itm->setY(y); - itm->setOpacity(uu); - sceneGraph->addItem(itm); + itm = DrawerTh_ME2Scanner::itmList[i]; + itm->setY(y); + itm->setOpacity(uu); uu -= 0.027; u -= 1; }; - while (DrawerTh_ME2Scanner::itmList.count() > 38) + while (DrawerTh_ME2Scanner::itmList.count() > 38) { - sceneGraph->removeItem(DrawerTh_ME2Scanner::itmList[38]); - delete DrawerTh_ME2Scanner::itmList[38]; - DrawerTh_ME2Scanner::itmList.pop_back(); + sceneGraph->removeItem(DrawerTh_ME2Scanner::itmList[38]); + delete DrawerTh_ME2Scanner::itmList[38]; + DrawerTh_ME2Scanner::itmList.pop_back(); }; + }; } @@ -1292,6 +1291,10 @@ void nesca_3::slotBlinkMessage() }; } +void nesca_3::slotTabChanged(int index){ + if(index < 2) savedTabIndex = index; +} + void nesca_3::ChangeDispalyMode() { if(widgetIsHidden == false && tray->isVisible() == false) @@ -1341,8 +1344,8 @@ void nesca_3::switchToJobMode() void nesca_3::CheckProxy() { - saveOptions(); - _SaveBackupToFile(); + saveOptions(); + QStringList qsl; if(ui->ircProxy->text().contains(":")) { @@ -1371,8 +1374,6 @@ void nesca_3::slotIRCOfflined() void nesca_3::ConnectToIRCServer() { - saveOptions(); - _SaveBackupToFile(); QStringList qsl; if(ui->ircServerBox->text().contains(":")) { @@ -1381,14 +1382,15 @@ void nesca_3::ConnectToIRCServer() ui->ircServerBox->setText(qsl[0]); ui->serverPortBox->setText(qsl[1]); }; + if(ui->ircProxy->text().contains(":")) { qsl = ui->ircProxy->text().split(":"); ui->ircProxy->setText(qsl[0]); ui->ircProxyPort->setText(qsl[1]); - }; - saveOptions(); + }; + if(ui->ircServerBox->text() != "") { if(ui->serverPortBox->text() != "") @@ -1445,6 +1447,8 @@ void nesca_3::ConnectToIRCServer() ui->ircText->append("No IRC server specified!"); }; + + saveOptions(); } void nesca_3::ChangeIRCRawLog() @@ -1475,8 +1479,8 @@ void nesca_3::ChangeNick() void nesca_3::CheckPersKey() { emitIfOK = -1; - saveOptions(); - _SaveBackupToFile(); + saveOptions(); + if(!chKTh->isRunning()) { stt->doEmitionYellowFoundData("[Key check] Starting checker-thread..."); @@ -1491,8 +1495,8 @@ void nesca_3::CheckPersKey() void nesca_3::CheckPersKey(int val = -1) { emitIfOK = val; - saveOptions(); - _SaveBackupToFile(); + saveOptions(); + if(!chKTh->isRunning()) { stt->doEmitionYellowFoundData("[Key check] Starting checker-thread..."); @@ -1595,6 +1599,17 @@ bool nesca_3::eventFilter(QObject* obj, QEvent *event) }; return false; } + else if (obj == qwm) + { + ///TODO: raise parent window with qwm +// if(event->type() == QEvent::MouseButtonPress) +// { +// Qt::WindowFlags eFlags = windowFlags (); +// eFlags |= Qt::WindowStaysOnTopHint; +// setWindowFlags(eFlags); +// return true; +// }; + } else { if (event->type() == QEvent::KeyPress) @@ -1864,7 +1879,7 @@ void nesca_3::slotIRCGetTopic(QString str) int c = 1; -void nesca_3::slotSaveImage(QAction *qwe) +void nesca_3::slotSaveImage() { QObject *smB = this->sender(); int ci = ui->tabMainWidget->currentIndex(); @@ -1916,7 +1931,7 @@ 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); @@ -1949,7 +1964,7 @@ void PieStatView::contextMenuEvent(QContextMenuEvent *event) menuPS->addAction("Save image."); menuPS->popup(event->globalPos()); - connect(menuPS, SIGNAL(triggered(QAction *)), gthis, SLOT(slotSaveImage(QAction *))); + connect(menuPS, SIGNAL(triggered()), gthis, SLOT(slotSaveImage())); } QLabel *msgLbl; @@ -2043,7 +2058,8 @@ void nesca_3::slotShowDataflow() MapWidgetOpened = true; ui->DataflowModeBut->setStyleSheet("background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(0, 214, 0, 40);color: rgb(0, 214, 0);"); qwm = new QWidget(); - qwm->setWindowFlags(Qt::FramelessWindowHint|Qt::SubWindow); + qwm->setWindowFlags(Qt::FramelessWindowHint|Qt::SubWindow); + qwm->installEventFilter(this); qwm->setStyleSheet( "background-color:qlineargradient(spread:pad, x1:0.541, y1:0.500364, x2:0.54, y2:0, stop:0 rgba(16, 16, 16, 255), stop:1 rgba(0, 0, 0, 255));" "border: 1px solid #616161;"); @@ -2186,22 +2202,26 @@ void nesca_3::slotOutData(QString ip, QString str) { _rOutPath.indexIn(str); QString prot = _rOutPath.cap(0); - if(prot.size() > 0) str.replace(prot, " " + prot + " "); + if(prot.size() > 0) str.replace(prot, "" + prot + ""); _rOutHost.indexIn(str); prot = _rOutHost.cap(1); - if(prot.size() > 0) str.replace(prot, " " + prot + " "); + if(prot.size() > 0) str.replace(prot, "" + prot + ""); + str.replace("HTTP ", "HTTP "); str.replace("GET ", "GET "); str.replace("POST ", "POST "); str.replace("Host: ", "Host: "); - str.replace("Cookie: ", "Cookie: "); - str.replace("Accept:", "Accept:"); + str.replace("Cookie: ", "Cookie: "); str.replace("Accept-Language:", "Accept-Language:"); str.replace("Accept-Charset:", "Accept-Charset:"); str.replace("Accept-Encoding:", "Accept-Encoding:"); - str.replace("User-Agent:", "User-Agent:"); + str.replace("Accept:", "Accept:"); + str.replace("User-Agent:", "User-Agent:"); + str.replace("Proxy-Connection:", "Proxy-Connection:"); str.replace("Connection:", "Connection:"); str.replace("Content-Length:", "Content-Length:"); - str.replace("Authorization:", "Authorization:"); + str.replace("Authorization:", "Authorization:"); + str.replace("X-Nescav3:", "X-Nescav3:"); + _rOutProt.indexIn(str); prot = _rOutProt.cap(0); if(prot.size() > 0) str.replace(prot, "" + prot + ""); @@ -2251,14 +2271,12 @@ void nesca_3::slotIncData(QString ip, QString str) str.replace(tagRes, "" + tagRes + ""); }; tStr.replace(tagRes, ""); - }; - str.replace("HTTP/1.1", "HTTP/1.1"); + }; + str.replace("HTTP/1.0", "HTTP/1.0"); + str.replace("HTTP/1.1", "HTTP/1.1"); str.replace("\r\n", "
"); RecvData->append("[" + ip + "]
[HEAD]
" + str + "

"); - - - _rIncTags1.setMinimal(true); _rIncInnerTags.setMinimal(true); @@ -2930,6 +2948,72 @@ void nesca_3::ConnectEvrthng() connect ( vsTh, SIGNAL(sDrawTextPlacers()), this, SLOT(slotDrawTextPlacers())); connect ( psTh, SIGNAL(sUpdatePie()), this, SLOT(slotUpdatePie()) ); connect ( irc_nmb, SIGNAL(sBlinkMessage()), this, SLOT(slotBlinkMessage()) ); + connect ( ui->tabMainWidget, SIGNAL(currentChanged(int)), this, SLOT(slotTabChanged(int)) ); +} + +void nesca_3::saveOptions() +{ + ZeroMemory(saveStartIP, sizeof(saveStartIP)); + ZeroMemory(endIP2, sizeof(endIP2)); + ZeroMemory(top_level_domain, sizeof(top_level_domain)); + ZeroMemory(gPorts, sizeof(gPorts)); + + if(savedTabIndex == 0) + { + gMode = 0; + gThreads = ui->threadLine->text().toInt(); + int indexof = ui->ipLine->text().indexOf("-"); + + if(indexof > 0) + { + strncpy(saveStartIP, ui->ipLine->text().toLocal8Bit().data(), indexof); + if(ui->ipLine->text().indexOf("/") < 0) strcpy(endIP2, ui->ipLine->text().toLocal8Bit().data()); + } + else + { + if(ui->ipLine->text().indexOf("/") < 0) + { + strcpy(endIP2, ui->ipLine->text().toLocal8Bit().data()); + strcat(endIP2, "-"); + strcat(endIP2, ui->ipLine->text().toLocal8Bit().data()); + } + else + { + strncpy(saveStartIP, ui->ipLine->text().toLocal8Bit().data(), ui->ipLine->text().indexOf("/")); + }; + }; + + strncpy(gPorts, ("-p" + ui->portLine->text()).toLocal8Bit().data(), 65536); + gPorts[ui->lineEditPort->text().size()] = '\0'; + } + else if(savedTabIndex == 1) + { + gMode = 1; + gThreads = ui->lineEditThread->text().toInt(); + + strcpy(saveStartIP, ui->lineEditStartIPDNS->text().toLocal8Bit().data()); + strcpy(endIP2, ui->lineEditStartIPDNS->text().toLocal8Bit().data()); + strcpy(top_level_domain, ui->lineILVL->text().toLocal8Bit().data()); + strncpy(gPorts, ("-p" + ui->lineEditPort->text()).toLocal8Bit().data(), 65536); + gPorts[ui->lineEditPort->text().size()] = '\0'; + }; + + strcpy(trcSrv, ui->lineTrackerSrv->text().toLocal8Bit().data()); + strcpy(trcScr, ui->lineTrackerScr->text().toLocal8Bit().data()); + strncpy(trcPersKey, ui->linePersKey->text().toLocal8Bit().data(), 32); + memset(trcPersKey + 32, '\0', 1); + strcpy(trcSrvPortLine, ui->trcSrvPortLine->text().toLocal8Bit().data()); + strcpy(ircServer, ui->ircServerBox->text().toLocal8Bit().data()); + strcpy(ircPort, ui->serverPortBox->text().toLocal8Bit().data()); + strcpy(ircProxy, ui->ircProxy->text().toLocal8Bit().data()); + strcpy(ircProxyPort, ui->ircProxyPort->text().toLocal8Bit().data()); + strcpy(ircNick, ui->ircNickBox->text().toLocal8Bit().data()); + strncpy(gProxyIP, ui->systemProxyIP->text().toLocal8Bit().data(), 64); + gProxyIP[ui->systemProxyIP->text().size()] = '\0'; + strncpy(gProxyPort, ui->systemProxyPort->text().toLocal8Bit().data(), 8); + gProxyPort[ui->systemProxyPort->text().size()] = '\0'; + + _SaveBackupToFile(); } QString loadNescaSetup(char *resStr, char *option) { @@ -3001,12 +3085,17 @@ void RestoreSession() } else if(gMode == 1) { - ui->lineEditStartIPDNS->setText(QString(lex)); + QString qLex(lex); + qLex.replace("[az]", "\\l"); + qLex.replace("[0z]", "\\w"); + qLex.replace("[09]", "\\d"); + ui->lineEditStartIPDNS->setText(qLex); lex = strtok(NULL, " "); strcpy(gFirstDom, lex); lex = strtok(NULL, " "); - gThreads = atoi(lex); + gThreads = atoi(lex); + ui->lineEditThread->setText(QString(lex)); ui->lineILVL->setText(QString(gFirstDom)); ui->tabMainWidget->setCurrentIndex(1); @@ -3072,9 +3161,11 @@ void RestoreSession() else if (strstr(resStr, "[THREAD_DELAY]:") != NULL) ui->threadDelayBox->setText(loadNescaSetup(resStr, "[THREAD_DELAY]:").simplified()); else if (strstr(resStr, "[TIMEOUT]:") != NULL) { const QString &tempLex = loadNescaSetup(resStr, "[TIMEOUT]:"); - ui->iptoLine_value->setText(tempLex); - ui->iptoLine_value_2->setText(tempLex); - ui->iptoLine_value_3->setText(tempLex); + if(tempLex.toInt() > 0) { + ui->iptoLine_value->setText(tempLex); + ui->iptoLine_value_2->setText(tempLex); + ui->iptoLine_value_3->setText(tempLex); + } } else if (strstr(resStr, "[MAXBTHR]:") != NULL) ui->maxBrutingThrBox->setText(loadNescaSetup(resStr, "[MAXBTHR]:").simplified()); else if (strstr(resStr, "[PERSKEY]:") != NULL) ui->linePersKey->setText(loadNescaSetup(resStr, "[PERSKEY]:").simplified()); @@ -3090,7 +3181,7 @@ void RestoreSession() fclose(resFile); - stt->doEmitionGreenFoundData("Previous session restored."); + stt->doEmitionGreenFoundData("Previous session loaded."); }; } @@ -3176,8 +3267,8 @@ void _startMsgCheck() this->hide(); gthis = this; - ui->setupUi(this); - ui->widgetIRC->installEventFilter(this); + ui->setupUi(this); + ui->widgetIRC->installEventFilter(this); ui->shoutBox->installEventFilter(this); setSomeStyleArea(); ui->IRCModeChangerBut->setVisible(false); @@ -3208,8 +3299,7 @@ void _startMsgCheck() CreateVerFile(); - RestoreSession(); - saveOptions(); + RestoreSession(); PhraseLog.push_back(""); CreateMsgPopupWidget(); @@ -3317,84 +3407,6 @@ void nesca_3::ChangeDebugFileState(bool val) debugFileOK = val; } -void nesca_3::saveOptions() -{ - int ci = ui->tabMainWidget->currentIndex(); - - if(ci == 0) - { - ZeroMemory(saveStartIP, sizeof(saveStartIP)); - ZeroMemory(endIP2, sizeof(endIP2)); - ZeroMemory(top_level_domain, sizeof(top_level_domain)); - ZeroMemory(gPorts, sizeof(gPorts)); - gMode = 0; - gThreads = ui->threadLine->text().toInt(); - int indexof = ui->ipLine->text().indexOf("-"); - if(indexof > 0) - { - strncpy(saveStartIP, ui->ipLine->text().toLocal8Bit().data(), indexof); - if(ui->ipLine->text().indexOf("/") < 0) strcpy(endIP2, ui->ipLine->text().toLocal8Bit().data()); - } - else - { - if(ui->ipLine->text().indexOf("/") < 0) - { - strcpy(saveStartIP, ui->ipLine->text().toLocal8Bit().data()); - strcpy(endIP2, ui->ipLine->text().toLocal8Bit().data()); - strcat(endIP2, "-"); - strcat(endIP2, ui->ipLine->text().toLocal8Bit().data()); - } - else - { - strncpy(saveStartIP, ui->ipLine->text().toLocal8Bit().data(), ui->ipLine->text().indexOf("/")); - }; - }; - - strncpy(gPorts, ("-p" + ui->portLine->text()).toLocal8Bit().data(), 65536); - } - else if(ci == 1) - { - ZeroMemory(saveStartIP, sizeof(saveStartIP)); - ZeroMemory(endIP2, sizeof(endIP2)); - ZeroMemory(top_level_domain, sizeof(top_level_domain)); - ZeroMemory(gPorts, sizeof(gPorts)); - gMode = 1; - gThreads = ui->lineEditThread->text().toInt(); - int indexof = ui->lineEditStartIPDNS->text().indexOf("/"); - if(indexof > 0) - { - strncpy(saveStartIP, ui->lineEditStartIPDNS->text().toLocal8Bit().data(), indexof); - strcpy(endIP2, ui->lineEditStartIPDNS->text().toLocal8Bit().data()); - } - else - { - strcpy(saveStartIP, ui->lineEditStartIPDNS->text().toLocal8Bit().data()); - strcpy(endIP2, ui->lineEditStartIPDNS->text().toLocal8Bit().data()); - strcat(endIP2, "/"); - strcat(endIP2, ui->lineEditStartIPDNS->text().toLocal8Bit().data()); - }; - - strcpy(top_level_domain, ui->lineILVL->text().toLocal8Bit().data()); - - strncpy(gPorts, ("-p" + ui->lineEditPort->text()).toLocal8Bit().data(), 65536); - }; - - strcpy(trcSrv, ui->lineTrackerSrv->text().toLocal8Bit().data()); - strcpy(trcScr, ui->lineTrackerScr->text().toLocal8Bit().data()); - strncpy(trcPersKey, ui->linePersKey->text().toLocal8Bit().data(), 32); - strcpy(trcSrvPortLine, ui->trcSrvPortLine->text().toLocal8Bit().data()); - - strcpy(ircServer, ui->ircServerBox->text().toLocal8Bit().data()); - strcpy(ircPort, ui->serverPortBox->text().toLocal8Bit().data()); - strcpy(ircProxy, ui->ircProxy->text().toLocal8Bit().data()); - strcpy(ircProxyPort, ui->ircProxyPort->text().toLocal8Bit().data()); - strcpy(ircNick, ui->ircNickBox->text().toLocal8Bit().data()); - strncpy(gProxyIP, ui->systemProxyIP->text().toLocal8Bit().data(), 64); - strncpy(gProxyPort, ui->systemProxyPort->text().toLocal8Bit().data(), 8); - - _SaveBackupToFile(); -} - void nesca_3::STTTerminate() { importFileName = ""; @@ -3571,7 +3583,8 @@ void nesca_3::logoLabelClicked() void nesca_3::ChangeLabelTO_ValueChanged(QString str) { - gTimeOut = str.toInt(); + int gto = str.toInt(); + gTimeOut = gto > 0 ? gto : 1; } void nesca_3::ChangeLabelThreads_ValueChanged(QString str) @@ -3722,8 +3735,7 @@ void nesca_3::appendDefaultIRCTextOut(QString str) void nesca_3::appendDefaultIRCText(bool pm, bool hlflag, QString str, QString senderNick) { bool thisIsUrl = false; - -#pragma region Color-handler + int pos = 0; QString colRes; while ((pos = colr.indexIn(str, pos)) != -1) @@ -3735,8 +3747,6 @@ void nesca_3::appendDefaultIRCText(bool pm, bool hlflag, QString str, QString se thisIsUrl = true; }; - -#pragma region Bold-handler int posBold = 0; QString boldRes; boldr.setMinimal(true); @@ -3750,8 +3760,6 @@ void nesca_3::appendDefaultIRCText(bool pm, bool hlflag, QString str, QString se thisIsUrl = true; }; - -#pragma region underline-handler int posUnder = 0; QString underRes; under.setMinimal(true); @@ -3765,8 +3773,6 @@ void nesca_3::appendDefaultIRCText(bool pm, bool hlflag, QString str, QString se thisIsUrl = true; }; - -#pragma region link-handler r.indexIn(str); QString link = r.cap(0); if(link.size() != 0) diff --git a/nesca_3.h b/nesca_3.h index ddc922d..829b650 100644 --- a/nesca_3.h +++ b/nesca_3.h @@ -52,7 +52,7 @@ public: void newListItem(QString str); static int perc; private: - + int savedTabIndex; protected: bool eventFilter(QObject* obj, QEvent *event); void run(); @@ -79,6 +79,7 @@ protected: void slotAppendIRCNick(QString str); void slotShowNicks(); void slotBlinkMessage(); + void slotTabChanged(int index); void IPScanSeq(); void DNSScanSeq(); void ImportScanSeq(); @@ -87,7 +88,7 @@ protected: void slotOutData(QString ip, QString str); void slotIncData(QString ip, QString str); void slotShowServerMsg(QString str); - void slotSaveImage(QAction *qwe); + void slotSaveImage(); void slotUpdatePie(); void slotClearLogs(); void slotRestartIRC(); diff --git a/nesca_3.ui b/nesca_3.ui index c09152b..4765a44 100644 --- a/nesca_3.ui +++ b/nesca_3.ui @@ -1748,8 +1748,8 @@ border-radius: 3px; - Consolas - PreferDefault + Eurostile + 9 @@ -1774,7 +1774,7 @@ border-radius: 3px; <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Consolas'; font-size:8.25pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'Eurostile'; font-size:9pt; font-weight:400; font-style:normal;"> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></body></html> @@ -2537,7 +2537,7 @@ p, li { white-space: pre-wrap; } <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Eurostile'; font-size:8.25pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'Eurostile'; font-size:11pt; font-weight:400; font-style:normal;"> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></body></html> @@ -3521,7 +3521,7 @@ background-color: #000000; <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Eurostile'; font-size:8.25pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'Eurostile'; font-size:11pt; font-weight:400; font-style:normal;"> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></body></html> @@ -3657,7 +3657,7 @@ p, li { white-space: pre-wrap; } <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Eurostile'; font-size:8.25pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'Eurostile'; font-size:11pt; font-weight:400; font-style:normal;"> <p style="-qt-paragraph-type:empty; margin-top:2px; margin-bottom:2px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></body></html> diff --git a/nesca_startModule.cpp b/nesca_startModule.cpp index a15d1dc..5e889ee 100644 --- a/nesca_startModule.cpp +++ b/nesca_startModule.cpp @@ -1,5 +1,4 @@ -#pragma once -#include "STh.h" +#include "STh.h" #include "mainResources.h" #include "externData.h" #include "externFunctions.h" @@ -31,8 +30,11 @@ int isActive = 0; int MaxPass = 0, MaxLogin = 0, MaxTags = 0, MaxWFLogin = 0, MaxWFPass = 0, MaxSSHPass = 0; int ipsstart[4], ipsend[4], overallPorts, flCounter, octet[4]; -unsigned char **ipsstartfl = NULL, **ipsendfl = NULL, **starterIP = NULL; +int BA = 0; int gPingTimeout = 1; +unsigned int Activity = 0; + +unsigned char **ipsstartfl = NULL, **ipsendfl = NULL, **starterIP = NULL; double ips = 0; char top_level_domain[128] = {0}; char endIP2[128] = {0}; @@ -54,10 +56,9 @@ char metaETA[256] = {0}; char metaOffline[256] = {0}; bool ErrLogFirstTime = true; bool gPingNScan = false; -unsigned long long gTargets = 0, gTargetsOverall = 1, targets, Activity = 0; +long long unsigned int gTargets = 0, gTargetsOverall = 1, targets; volatile int gThreads; volatile int cons = 0; -volatile int BA = 0; volatile int BrutingThrds = 0; volatile int threads = 20; @@ -148,11 +149,10 @@ __asm lock inc cons; }; #else - asm("lock incl cons"); + asm("lock; incl cons"); #endif - - stt->doEmitionThreads(QString::number(cons) + "/" + QString::number(gThreads)); - + + stt->doEmitionThreads(QString::number(cons) + "/" + QString::number(gThreads)); } void ConDec() @@ -165,19 +165,18 @@ void ConDec() lock dec cons; }; #else - asm("lock decl cons"); + asm("lock; decl cons"); #endif }; stt->doEmitionThreads(QString::number(cons) + "/" + QString::number(gThreads)); - } void _SaveBackupToFile() { char saveStr[512] = {0}; - char saveBuffer[65536] = {0}; + char saveBuffer[4096] = {0}; char endStr[128] = {0}; if(gMode == 0 || gMode == 1) @@ -189,24 +188,24 @@ void _SaveBackupToFile() else { if(strstr(endIP2, "-") != NULL) strcpy(endStr, strstr(endIP2, "-")); - else if(strstr(endIP2, "/") != NULL) strcpy(endStr, strstr(endIP2, "/")); + else if(strstr(endIP2, "/") != NULL) strcpy(endStr, strstr(endIP2, "/")); else { - char temp[512] = {0}; - strncpy(temp, endIP2, 512); - strcat(endIP2, "-"); - strcat(endIP2, temp); - strcpy(endStr, strstr(endIP2, "-")); + char temp[512] = {0}; + strncpy(temp, endIP2, 512); + strcat(endIP2, "-"); + strcat(endIP2, temp); + strcpy(endStr, strstr(endIP2, "-")); }; }; - if(strlen(endIP2) > 0) + if(strlen(endStr) > 0) { strcpy(saveStr, "[SESSION]:"); strcat(saveStr, std::to_string(gMode).c_str()); strcat(saveStr, " "); if(gMode == 0) strcat(saveStr, saveStartIP); - strcat(saveStr, endStr); + strcat(saveStr, endStr); if(gMode == 1) { strcat(saveStr, " "); @@ -363,7 +362,7 @@ void _SaveBackupToFile() ZeroMemory(saveStr, sizeof(saveStr)); strcpy(saveStr, "[PERSKEY]:"); - strcat(saveStr, trcPersKey); + strncat(saveStr, trcPersKey, 32); strcat(saveStr, "\n"); strcat(saveBuffer, saveStr); ZeroMemory(saveStr, sizeof(saveStr)); @@ -379,7 +378,8 @@ void _SaveBackupToFile() ZeroMemory(saveStr, strlen(saveStr)); ZeroMemory(saveBuffer, strlen(saveBuffer)); -}; +} + void _saver() { while(globalScanFlag) @@ -447,7 +447,7 @@ void *_tracker() if(globalScanFlag == false && jsonArr->size() == 0) break; char rBuffT[250000] = {0}; char *msg = new char[4096]; - ZeroMemory(msg, sizeof(msg)); + ZeroMemory(msg, sizeof(*msg)); char ndbServer[64] = {0}; char ndbScriptT[64] = {0}; char ndbScript[64] = {0}; @@ -646,15 +646,15 @@ void *_tracker() delete []msg; msg = 0; }; + msg = new char[r.size() + 1024]; - ZeroMemory(msg, sizeof(msg)); + ZeroMemory(msg, sizeof(*msg)); strcpy(msg, "POST /"); strcat(msg, ndbScript); strcat(msg, " HTTP/1.1\r\nHost: "); strcat(msg, ndbServer); strcat(msg, "\r\nContent-Type: application/json\r\nAccept-Encoding: application/json\r\nContent-Length: "); - strcat(msg, std::to_string(r.size()).c_str()); strcat(msg, "\r\nConnection: close\r\n\r\n"); @@ -775,11 +775,12 @@ void *_tracker() ZeroMemory(msgR, sizeof(msgR)); ZeroMemory(rBuffT, sizeof(rBuffT)); - ZeroMemory(msg, sizeof(msg)); + ZeroMemory(msg, sizeof(*msg)); + if(msg != NULL) { - delete []msg; - msg = 0; + delete msg; + msg = NULL; }; CSSOCKET(sock); @@ -788,9 +789,7 @@ void *_tracker() }; } else - { - CSSOCKET(sock); - + { stt->doEmitionRedFoundData("[NS-Track] -Balancer replied with invalid string."); SaveErrorLog("NS-Track", msg, rBuffT); }; @@ -887,7 +886,6 @@ unsigned long int numOfIps(int ipsstart[], int ipsend[]) // return res; //} -//Connector con; #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) void _connect(void* ss) #else @@ -899,7 +897,9 @@ void *_connect(void* ss) strcpy(ip, ((ST*)ss)->argv); //char hostLog[256] = {0}; //strcpy(hostLog, GetHost(ip)); - delete []ss; + delete (ST*)ss; + + ConInc(); for(int i = 0; i <= overallPorts; ++i) { @@ -910,7 +910,7 @@ void *_connect(void* ss) ConDec(); } -void targetAndIPWriter(unsigned long int target, char *buff) +void targetAndIPWriter(long long unsigned int target, char *buff) { char curIPBuff[256] = {0}, targetNPers[32] = {0}, dbuffer[32] = {0}; strcpy(metaIPDNS, buff); @@ -1211,7 +1211,7 @@ void ReadUTF8(FILE* nFile, char *cp) #endif int sz = res.size(); GlobalNegatives[i] = new char[sz + 1]; - ZeroMemory(GlobalNegatives[i], sizeof(GlobalNegatives[i])); + ZeroMemory(GlobalNegatives[i], sizeof(*GlobalNegatives[i])); memcpy(GlobalNegatives[i], toLowerStr(res.c_str()).c_str(), sz - 1); memset(GlobalNegatives[i] + sz - 1, '\0', 1); ++i; @@ -1226,7 +1226,7 @@ void ReadUTF8(FILE* nFile, char *cp) #endif int sz = res.size(); GlobalNegatives[i] = new char[sz + 1]; - ZeroMemory(GlobalNegatives[i], sizeof(GlobalNegatives[i])); + ZeroMemory(GlobalNegatives[i], sizeof(*GlobalNegatives[i])); memcpy(GlobalNegatives[i], toLowerStr(res.c_str()).c_str(), sz); memset(GlobalNegatives[i] + sz, '\0', 1); ++i; @@ -2075,7 +2075,7 @@ int ParseArgs(int argc, char *argv[]) }; char *argString = new char [s + 1]; - ZeroMemory(argString, sizeof(argString)); + ZeroMemory(argString, sizeof(*argString)); for(int i = 1; i <= argc - 1; i++) { @@ -2162,7 +2162,7 @@ int ParseArgs(int argc, char *argv[]) strcpy(gPorts, "--DEFAULT"); }; - ZeroMemory(argString, sizeof(argString)); + ZeroMemory(argString, sizeof(*argString)); delete[] argString; @@ -2187,7 +2187,8 @@ int _getChunkCount(char *data) int firstPos = _getPos(data[1]); int secondPos = _getPos(data[2]); return secondPos - firstPos + 1; -}; +} + int _GetDNSFromMask(char *mask, char *saveMask, char *saveMaskEnder) { if(strstr(mask, "[") != NULL) @@ -2226,12 +2227,14 @@ int _GetDNSFromMask(char *mask, char *saveMask, char *saveMaskEnder) { ZeroMemory(maskEnd, sizeof(maskEnd)); }; + char maskSaver[128] = {0}; if(firstPos != -1 && secondPos != -1) { for(int i = firstPos; i <= secondPos; ++i) { if(globalScanFlag == false) break; + strcpy(maskSaver, saveMask); strcat(maskSaver, maskEntry); chunk[1] = charAll[i]; @@ -2241,20 +2244,23 @@ int _GetDNSFromMask(char *mask, char *saveMask, char *saveMaskEnder) strcat(maskRes, maskEnd); if(_GetDNSFromMask(maskRes, maskSaver, maskEnd) == -1) return -1; + ZeroMemory(maskSaver, sizeof(maskSaver)); ZeroMemory(maskRes, sizeof(maskRes)); }; }; } else - { -#pragma region DNS-SCAN + { if(globalScanFlag == false) return 0; + strcpy(endIP2, saveMask); st = new ST(); ZeroMemory(st->argv, sizeof(st->argv)); ZeroMemory(iip, sizeof(iip)); - while(cons >= gThreads) Sleep(300); + + while(cons >= gThreads && globalScanFlag) Sleep(300); + strcpy(iip, mask); strcpy(saveStartIP, iip); strcat(iip, top_level_domain); @@ -2265,7 +2271,6 @@ int _GetDNSFromMask(char *mask, char *saveMask, char *saveMaskEnder) targetAndIPWriter(--gTargets, st->argv); - ConInc(); #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) if(globalScanFlag) _beginthread( (void(*)(void*))_connect, 0, st ); #else @@ -2375,7 +2380,10 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads)); tAddr.s_addr = i; #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) - ipVec.push_back(std::to_string(tAddr.S_un.S_un_b.s_b4) + "." + std::to_string(tAddr.S_un.S_un_b.s_b3) + "." + std::to_string(tAddr.S_un.S_un_b.s_b2) + "." + std::to_string(tAddr.S_un.S_un_b.s_b1)); + ipVec.push_back(std::to_string(tAddr.S_un.S_un_b.s_b4) + + "." + std::to_string(tAddr.S_un.S_un_b.s_b3) + + "." + std::to_string(tAddr.S_un.S_un_b.s_b2) + + "." + std::to_string(tAddr.S_un.S_un_b.s_b1)); #else tAddr.s_addr = ntohl(tAddr.s_addr); const char *ipStr = inet_ntoa(tAddr); @@ -2390,14 +2398,14 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads)); st = new ST(); ZeroMemory(st->argv, sizeof(st->argv)); - while (cons >= gThreads) Sleep(500); + while (cons >= gThreads && globalScanFlag) Sleep(500); ++indexIP; strcpy(st->argv, ipVec[0].c_str()); strcpy(saveStartIP, ipVec[0].c_str()); ipVec.erase(ipVec.begin()); - targetAndIPWriter(gTargets--, st->argv); - ConInc(); + targetAndIPWriter(gTargets--, st->argv); + #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) _beginthread((void(*)(void*))_connect, 0, st); #else @@ -2419,20 +2427,23 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads)); st = new ST(); ZeroMemory(st->argv, sizeof(st->argv)); ZeroMemory(res, sizeof(res)); - while (cons >= gThreads) Sleep(500); + while (cons >= gThreads && globalScanFlag) Sleep(500); ++indexIP; tAddr.s_addr = i; #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) - strcpy(res, (std::to_string(tAddr.S_un.S_un_b.s_b4) + "." + std::to_string(tAddr.S_un.S_un_b.s_b3) + "." + std::to_string(tAddr.S_un.S_un_b.s_b2) + "." + std::to_string(tAddr.S_un.S_un_b.s_b1)).c_str()); + strcpy(res, (std::to_string(tAddr.S_un.S_un_b.s_b4) + + "." + std::to_string(tAddr.S_un.S_un_b.s_b3) + + "." + std::to_string(tAddr.S_un.S_un_b.s_b2) + + "." + std::to_string(tAddr.S_un.S_un_b.s_b1)).c_str()); #else strcpy(res, inet_ntoa(tAddr)); #endif strcpy(st->argv, res); strcpy(saveStartIP, res); - targetAndIPWriter(gTargets--, st->argv); - ConInc(); + targetAndIPWriter(gTargets--, st->argv); + #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) _beginthread((void(*)(void*))_connect, 0, st); #else @@ -2442,75 +2453,8 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads)); Sleep(gThreadDelay); } break; + } } - } - - /*int eor0 = 0, eor1 = 0, eor2 = 0, eor3 = 0; - stt->doEmitionChangeStatus("Scanning..."); - sockstruct *st = NULL; - while ((eor0 == 0 || eor1 == 0 || eor2 == 0 || eor3 == 0 ) && globalScanFlag) - { - if(globalScanFlag == false) break; - while(ipsstart[0] < 256 && eor0 == 0) - { - if(ipsstart[0] == ipsend[0]) eor0 = 1; - if(globalScanFlag == false) break; - while(ipsstart[1] < 256 && eor1 == 0) - { - if(ipsstart[1] == ipsend[1] && eor0 == 1) eor1 = 1; - if(globalScanFlag == false) break; - while(ipsstart[2] < 256 && eor2 == 0) - { - if(ipsstart[2] == ipsend[2] && eor1 == 1) eor2 = 1; - if(globalScanFlag == false) break; - while(ipsstart[3] < 256 && eor3 == 0) - { - if(globalScanFlag == false) break; - st = new sockstruct(); - ZeroMemory(st->argv, sizeof(st->argv)); - ZeroMemory(res, sizeof(res)); - while(cons >= gThreads) Sleep(300); - if(ipsstart[3] == ipsend[3] && eor2 == 1) eor3 = 1; - ++indexIP; - - strcat(res, std::to_string(ipsstart[0]).c_str()); - strcat(res, "."); - strcat(res, std::to_string(ipsstart[1]).c_str()); - strcat(res, "."); - strcat(res, std::to_string(ipsstart[2]).c_str()); - strcat(res, "."); - strcat(res, std::to_string(ipsstart[3]).c_str()); - - strcpy(st->argv, res); - strcpy(saveStartIP, res); - - targetAndIPWriter(gTargets--, st->argv); - ConInc(); -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) - _beginthread( (void(*)(void*))_connect, 0, st ); -#else - pthread_t thrc; - pthread_create(&thrc, NULL, (void *(*)(void*))&_connect, st); -#endif - Sleep(gThreadDelay); - ++ipsstart[3]; - }; - ipsstart[3] = 0; - ++ipsstart[2]; - }; - ipsstart[3] = 0; - ipsstart[2] = 0; - ++ipsstart[1]; - }; - ipsstart[3] = 0; - ipsstart[2] = 0; - ipsstart[1] = 0; - ++ipsstart[0]; - }; - ipsstart[3] = 0; - ipsstart[2] = 0; - ipsstart[1] = 0; - };*/ } else if(gMode == 1 ) { @@ -2641,13 +2585,15 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads)); { dnsCounter *= _getChunkCount(dnsPtr1); dnsPtr1 = strstr(dnsPtr1 + 1, "["); - }; + }; + gTargets = dnsCounter; gTargetsOverall = gTargets; stt->doEmitionYellowFoundData("Starting DNS-scan..."); stt->doEmitionChangeStatus("Scanning..."); - if(_GetDNSFromMask(dataEntry, "", dataEntry) == -1) + int y = _GetDNSFromMask(dataEntry, "", dataEntry); + if(y == -1) { stt->doEmitionRedFoundData("DNS-Mode error"); }; @@ -2734,14 +2680,14 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads)); st = new ST(); ZeroMemory(st->argv, sizeof(st->argv)); - while (cons >= gThreads) Sleep(500); + while (cons >= gThreads && globalScanFlag) Sleep(500); ++indexIP; strcpy(st->argv, ipVec[0].c_str()); strcpy(saveStartIP, ipVec[0].c_str()); ipVec.erase(ipVec.begin()); - targetAndIPWriter(gTargets--, st->argv); - ConInc(); + targetAndIPWriter(gTargets--, st->argv); + #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) _beginthread((void(*)(void*))_connect, 0, st); #else @@ -2762,7 +2708,7 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads)); st = new ST(); ZeroMemory(st->argv, sizeof(st->argv)); ZeroMemory(res, sizeof(res)); - while (cons >= gThreads) Sleep(500); + while (cons >= gThreads && globalScanFlag) Sleep(500); ++indexIP; tAddr.s_addr = i; @@ -2775,7 +2721,7 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads)); strcpy(saveStartIP, res); targetAndIPWriter(gTargets--, st->argv); - ConInc(); + #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) _beginthread((void(*)(void*))_connect, 0, st); #else @@ -2785,88 +2731,14 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads)); Sleep(gThreadDelay); } - break; - /*int eor0 = 0, eor1 = 0, eor2 = 0, eor3 = 0; - while ((eor0 == 0 || eor1 == 0 || eor2 == 0 || eor3 == 0) && globalScanFlag) - { - if (globalScanFlag == false) break; - while (ipsstartfl[gC][0] < 256 && eor0 == 0) - { - if (globalScanFlag == false) break; - if (ipsstartfl[gC][0] == ipsendfl[gC][0]) eor0 = 1; - while (ipsstartfl[gC][1] < 256 && eor1 == 0) - { - if (globalScanFlag == false) break; - if (ipsstartfl[gC][1] == ipsendfl[gC][1] && eor0 == 1) eor1 = 1; - while (ipsstartfl[gC][2] < 256 && eor2 == 0) - { - if (globalScanFlag == false) break; - if (ipsstartfl[gC][2] == ipsendfl[gC][2] && eor1 == 1) eor2 = 1; - while (ipsstartfl[gC][3] < 256 && eor3 == 0) - { - if (globalScanFlag == false) break; - st = new sockstruct(); - ZeroMemory(st->argv, sizeof(st->argv)); - ZeroMemory(res, sizeof(res)); - - while (cons >= gThreads) Sleep(300); - - if (ipsstartfl[gC][3] == ipsendfl[gC][3] && eor2 == 1) eor3 = 1; - - ++indexIP; - - strcat(res, std::to_string(ipsstartfl[gC][0]).c_str()); - strcat(res, "."); - strcat(res, std::to_string(ipsstartfl[gC][1]).c_str()); - strcat(res, "."); - strcat(res, std::to_string(ipsstartfl[gC][2]).c_str()); - strcat(res, "."); - strcat(res, std::to_string(ipsstartfl[gC][3]).c_str()); - - strcpy(st->argv, res); - strcpy(saveStartIP, res); - - targetAndIPWriter(gTargets--, st->argv); - - ConInc(); -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) - _beginthread((void(*)(void*))_connect, 0, st); -#else - pthread_t thrc; - pthread_create(&thrc, NULL, (void *(*)(void*))&_connect, st); -#endif - Sleep(gThreadDelay); - if (ipsstartfl[gC][3] == 255) break; - if (ipsstartfl[gC][3] <= ipsendfl[gC][3]) ++ipsstartfl[gC][3]; - }; - ipsstartfl[gC][3] = 0; - if (ipsstartfl[gC][2] == 255) break; - if (ipsstartfl[gC][2] <= ipsendfl[gC][2]) ++ipsstartfl[gC][2]; - }; - ipsstartfl[gC][3] = 0; - ipsstartfl[gC][2] = 0; - if (ipsstartfl[gC][1] == 255) break; - if (ipsstartfl[gC][1] <= ipsendfl[gC][1]) ++ipsstartfl[gC][1]; - }; - ipsstartfl[gC][3] = 0; - ipsstartfl[gC][2] = 0; - ipsstartfl[gC][1] = 0; - if (ipsstartfl[gC][0] == 255) break; - if (ipsstartfl[gC][0] <= ipsendfl[gC][0]) ++ipsstartfl[gC][0]; - }; - ipsstartfl[gC][3] = 0; - ipsstartfl[gC][2] = 0; - ipsstartfl[gC][1] = 0; - };*/ - }; + break; + }; } } } else { - stt->doEmitionRedFoundData("Wrong parameters."); - }; Sleep(gTimeOut + 1); @@ -2875,15 +2747,16 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads)); stt->doEmitionChangeStatus("Stopping..."); - while(cons > 0 || isActive == 1 || jsonArr->size() > 0) Sleep(2000); + while(cons > 0 || isActive == 1 || jsonArr->size() > 0) { + Sleep(2000); + }; nCleanup(); stt->doEmitionGreenFoundData("Done. Saved: " + QString::number(saved) + "; Alive: " + QString::number(found) + "."); stt->doEmitionChangeParsed(QString::number(saved) + "/" + QString::number(found)); stt->doEmitionChangeStatus("Idle"); - stt->doEmitionKillSttThread(); - + stt->doEmitionKillSttThread(); } void nCleanup(){ diff --git a/oIRC_Th.cpp b/oIRC_Th.cpp index 1db931a..562a178 100644 --- a/oIRC_Th.cpp +++ b/oIRC_Th.cpp @@ -77,7 +77,6 @@ QString GetNickColor(char *sn) QString nickBGColorStr = hexNick.mid(hexNick.size() - 6, hexNick.size()); int nickColor = nickColorStr.toUInt(NULL, 16); - int dim = QString::number(nickColor).length(); nickColor += (7*origLen + nickColor*6 + 123456 - hln*hln*hln*hln + (int)(str[0].toLatin1())*123); nickColorStr.setNum(nickColor, 16); @@ -187,6 +186,7 @@ char *GetServerName(char *buff) char *temp1 = NULL; int sz = 0; char name[128] = {0}; + if(strstr(buff, " ") != NULL) { temp1 = strstr(buff, " ");