From 082bde227b6d313652f0ce99edc2e1b127bcae40 Mon Sep 17 00:00:00 2001 From: cora48 Date: Fri, 6 Mar 2015 17:32:36 +0300 Subject: [PATCH] -- --- CheckKey_Th.cpp | 243 +++++----------------------- Connector.cpp | 193 ++++++++++++++++++++-- Connector.h | 13 +- DrawerTh_ME2Scanner.cpp | 2 +- Utils.cpp | 18 ++- Utils.h | 11 +- WebformWorker.cpp | 2 + WebformWorker.h | 5 +- connector_old.cpp | 86 +--------- externData.h | 10 +- externFunctions.h | 3 +- finder.cpp | 348 +++++++++++++++------------------------- mainResources.h | 2 +- msgcheckerthread.cpp | 2 +- nesca.pro | 4 +- nesca.pro.user | 2 +- nesca_3.cpp | 273 +++++++++---------------------- nesca_3.h | 2 +- nesca_3.ui | 148 ++++++++++++++--- nesca_startModule.cpp | 26 ++- 20 files changed, 620 insertions(+), 773 deletions(-) diff --git a/CheckKey_Th.cpp b/CheckKey_Th.cpp index 0610462..9ac16bd 100644 --- a/CheckKey_Th.cpp +++ b/CheckKey_Th.cpp @@ -4,8 +4,10 @@ #include "STh.h" #include "externData.h" #include "externFunctions.h" +#include +#include -void getSubStrEx(char *src, char *startStr, char *endStr, char *dest, int szDest) +void getSubStrEx(const char *src, char *startStr, char *endStr, char *dest, int szDest) { ZeroMemory(dest, szDest); char *ptr1 = strstri((const char*)src, startStr); @@ -48,214 +50,47 @@ int KeyCheckerMain() 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)); + std::vector headerVector; + headerVector.push_back("X-Nescav3: True"); - 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"); + std::string buffer; + Connector::nConnect((std::string(trcSrv) + std::string(trcScr)).c_str(), std::stoi(trcSrvPortLine), &buffer, NULL, &headerVector); - HOSTENT *host; + int hostStringIndex = Utils::ci_find_substr(buffer, std::string("\r\n\r\n")); + if(hostStringIndex != -1) { + const char *ptr1 = buffer.c_str() + hostStringIndex + 4; + buffer.clear(); + Connector::nConnect((std::string(ptr1) + std::string("/api/checkaccount?key=") + std::string(trcPersKey)).c_str(), + std::stoi(trcSrvPortLine), &buffer, NULL, &headerVector); -#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)); - - 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 + 7), "/") != NULL) - { - t2 = strstr((char*)(t1 + 7), "/"); - int ln = t2 - t1 - 7; - if(ln > 64) - { - stt->doEmitionRedFoundData("[Key check] -Received server string is not valid!"); - CSSOCKET(sock); - - return -1; - } - else strncpy(ndbServer, (char*)(t1 + 7), 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) - { - stt->doEmitionGreenFoundData("[Key check] -OK. Key is valid!"); - 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) - { - 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") + "]"); - 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 - { - 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)); - CSSOCKET(sock); - return -1; - }; - - ZeroMemory(msg, sizeof(msg)); - CSSOCKET(sock); - } - else - { - stt->doEmitionRedFoundData("[Key check] -Balancer replied with invalid string."); - if(gDebugMode) stt->doEmitionDebugFoundData(QString(msg)); - CSSOCKET(sock); - return -1; - }; -}; + if(Utils::ci_find_substr(buffer, std::string("202 Accepted")) != -1) { + stt->doEmitionGreenFoundData("Key is valid."); + if(emitIfOK == 0) stt->doEmitionStartScanIP(); + else if(emitIfOK == 1) stt->doEmitionStartScanDNS(); + else if(emitIfOK == 2) stt->doEmitionStartScanImport(); + return 1; + } else if(Utils::ci_find_substr(buffer, std::string("400 Bad Request")) != -1) { + QString errorDef = GetNSErrorDefinition(buffer.c_str(), "notify"); + if(errorDef == "Invalid access key") stt->doEmitionYellowFoundData("[NS-Track] [Key is unauthorized] A valid key is required."); + else stt->doEmitionYellowFoundData("[Key checker] -FAIL! [400 Bad Request : " + GetNSErrorDefinition(buffer.c_str(), "notify") + "]"); + return -1; + } else if(Utils::ci_find_substr(buffer, std::string("503 Bad Gateway")) != -1) { + stt->doEmitionYellowFoundData("[Key checker] 503 Backend not responding!"); + return -1; + } else { + char header[64] = {0}; + getSubStrEx(buffer.c_str(), "http/1.1 ", "\r\n", header, 64); + stt->doEmitionRedFoundData("[Key checker] -FAIL! An error occured. (" + QString::number(WSAGetLastError()) + ") Header: " + QString::fromLocal8Bit(header) + ""); + if(gDebugMode) stt->doEmitionDebugFoundData(QString(buffer.c_str())); + return -1; + }; + } else { + stt->doEmitionRedFoundData("[Key checker] Cannot acquire host string."); + } +} void CheckKey_Th::run() { KeyCheckerMain(); -}; +} diff --git a/Connector.cpp b/Connector.cpp index 342820b..8721bfe 100644 --- a/Connector.cpp +++ b/Connector.cpp @@ -1,8 +1,93 @@ #include +#include + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) +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*1000); + 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."); + } -int Connector::_sshConnect(char *user, char *pass, char *host, int port) + 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; + }; +} +#else +int _pingMyTarget(char *ip) +{ + FILE *pipe = popen(("ping -w " + std::to_string(gPingTimeout) + " " + ip).c_str(), "r"); + if(!pipe) { + stt->doEmitionRedFoundData("Ping pipe failed: cannot open pipe."); + perror("pipe"); + return 0; + } + + char buffer[128] = {0}; + std::string result; + + while(!feof(pipe)) { + if(fgets(buffer, 128, pipe) != NULL){ + result += buffer; + } + } + pclose(pipe); + + if(strstr((char*)result.c_str(), "100% packet loss") != NULL) return 0; + return 1; +} +#endif + +int _sshConnect(char *user, char *pass, char *host, int port) { char hostStr[128] = {0}; ZeroMemory(hostStr, sizeof(hostStr)); @@ -50,7 +135,7 @@ int Connector::_sshConnect(char *user, char *pass, char *host, int port) return 0; } -char Connector::_get_ssh_banner(char *ip, int port) +char _get_ssh_banner(char *ip, int port) { char recvBuff[256] = {0}; std::string buffer; @@ -66,7 +151,7 @@ char Connector::_get_ssh_banner(char *ip, int port) return *recvBuff; } -int Connector::check_ssh_pass(char *user, char *pass, char *userPass, char *host, int port, std::string *buffer, const char *banner) +int check_ssh_pass(char *user, char *pass, char *userPass, char *host, int port, std::string *buffer, const char *banner) { int res = -1; if(BALogSwitched) stt->doEmitionBAData("Probing SSH: " + QString(user) + ":" + QString(pass) + "@" + QString(host) + ":" + QString::number(port)); @@ -84,7 +169,7 @@ int Connector::check_ssh_pass(char *user, char *pass, char *userPass, char *host return res; } -int Connector::_EstablishSSHConnection(char *host, int port, std::string *buffer, const char *banner) +int _EstablishSSHConnection(char *host, int port, std::string *buffer, const char *banner) { char login[32] = {0}; char pass[32] = {0}; @@ -138,19 +223,101 @@ int Connector::_SSHLobby(char *ip, int port, std::string *buffer) return -1; } + +struct data { + char trace_ascii; /* 1 or 0 */ +}; + +static +void dump(const char *text, + FILE *stream, unsigned char *ptr, size_t size, + char nohex) +{ + size_t i; + size_t c; + + unsigned int width=0x10; + + if(nohex) + /* without the hex output, we can fit more on screen */ + width = 0x40; + + fprintf(stream, "%s, %10.10ld bytes (0x%8.8lx)\n", + text, (long)size, (long)size); + + for(i=0; i=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.'); + /* check again for 0D0A, to avoid an extra \n if it's at width */ + if (nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) { + i+=(c+3-width); + break; + } + } + fputc('\n', stream); /* newline */ + } + fflush(stream); +} + +static +int my_trace(CURL *handle, curl_infotype type, + char *data, size_t size, + void *userp) +{ + struct data *config = (struct data *)userp; + const char *text; + (void)handle; /* prevent compiler warning */ + + switch (type) { + case CURLINFO_TEXT: + //fprintf(stderr, "== Info: %s", data); + default: /* in case a new one is introduced to shock us */ + return 0; + } + + if(MapWidgetOpened) stt->doEmitionAddOutData(QString("size"), QString(data)); + dump(text, stderr, (unsigned char *)data, size, config->trace_ascii); + return 0; +} + static size_t nWriteCallback(void *contents, size_t size, size_t nmemb, void *userp) { ((std::string*)userp)->append((char*)contents, size * nmemb); return size * nmemb; } -int Connector::nConnect(char *ip, int port, std::string *buffer, - const char *postData = NULL, - const std::vector *customHeaders = NULL){ + +int Connector::nConnect(const char *ip, const int port, std::string *buffer, + const char *postData, + const std::vector *customHeaders){ CURL *curl = curl_easy_init(); + struct data config; + + config.trace_ascii = 1; /* enable ascii tracing */ if (curl) { + curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace); + curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &config); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_URL, ip); curl_easy_setopt(curl, CURLOPT_PORT, port); curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0"); @@ -160,8 +327,11 @@ int Connector::nConnect(char *ip, int port, std::string *buffer, curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, nWriteCallback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, buffer); - curl_easy_setopt(curl, CURLOPT_PROXY, "--"); - curl_easy_setopt(curl, CURLOPT_PROXYPORT, 3128); + int proxyPort = std::atoi(gProxyPort); + if(strlen(gProxyIP) != 0 && (proxyPort > 0 && proxyPort < 65535)) { + curl_easy_setopt(curl, CURLOPT_PROXY, gProxyIP); + curl_easy_setopt(curl, CURLOPT_PROXYPORT, proxyPort); + } curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, gTimeOut); curl_easy_setopt(curl, CURLOPT_TIMEOUT, gTimeOut); @@ -175,15 +345,16 @@ int Connector::nConnect(char *ip, int port, std::string *buffer, struct curl_slist *chunk = NULL; - for(auto &ch : customHeaders) { + for(auto &ch : *customHeaders) { - chunk = curl_slist_append(chunk, *ch); + chunk = curl_slist_append(chunk, ch.c_str()); } curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk); } curl_easy_perform(curl); + if(MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString(buffer->c_str())); curl_easy_cleanup(curl); } else { stt->doEmitionRedFoundData("Curl error."); diff --git a/Connector.h b/Connector.h index 24cf8da..86fc85e 100644 --- a/Connector.h +++ b/Connector.h @@ -1,17 +1,14 @@ #ifndef CONNECTOR_H #define CONNECTOR_H +#include +#include +#include + class Connector { -private: - int _sshConnect(char *user, char *pass, char *host, int port); - int _get_ssh_banner(char *ip, int port); - int check_ssh_pass(char *user, char *pass, char *userPass, - char *host, int port, std::string *buffer, const char *banner); - int _EstablishSSHConnection(char *host, int port, std::string *buffer, const char *banner); - public: - static int nConnect(char *ip, int port, std::string *buffer, + static int nConnect(const char *ip, const int port, std::string *buffer, const char *postData = NULL, const std::vector *customHeaders = NULL); static int _ConnectToPort(char *ip, int port, char *hl); diff --git a/DrawerTh_ME2Scanner.cpp b/DrawerTh_ME2Scanner.cpp index 3f6dae4..cdda4a0 100644 --- a/DrawerTh_ME2Scanner.cpp +++ b/DrawerTh_ME2Scanner.cpp @@ -147,6 +147,6 @@ void DrawerTh_ME2Scanner::run() Alive = 0; Susp = 0; }; - msleep(120); + msleep(90); }; } diff --git a/Utils.cpp b/Utils.cpp index 20c299c..a8f376a 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -1,11 +1,15 @@ #include -template int Utils::ci_find_substr(const T& str1, - const T& str2, - const std::locale& locale) { +char *getSystemProxy() { - auto it = std::search(str1.begin, str1.end, str2.begin, str2.end, - my_equal(locale)); - if(it != str1.end()) return it - str1.begin(); - else return -1; +} + +int Utils::getProxyPort() { +} + +char * Utils::getProxy() { + #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) +#else + getSystemProxy(); +#endif } diff --git a/Utils.h b/Utils.h index 213faf9..d5201b1 100644 --- a/Utils.h +++ b/Utils.h @@ -19,7 +19,16 @@ public: // find substring (case insensitive) template static int ci_find_substr(const T& str1, const T& str2, - const std::locale& loc = std::locale()); + const std::locale& loc = std::locale()) { + + auto it = std::search(str1.begin(), str1.end(), str2.begin(), str2.end(), + my_equal(loc)); + if(it != str1.end()) return it - str1.begin(); + else return -1; + } + + char * getProxy(); + int getProxyPort(); }; #endif // UTILS_H diff --git a/WebformWorker.cpp b/WebformWorker.cpp index 556f3c6..3460f89 100644 --- a/WebformWorker.cpp +++ b/WebformWorker.cpp @@ -1,5 +1,7 @@ #include +bool WFClass::active = false; + lopaStr WFClass::parseResponse(const char *ip, const int port, const std::string *buffer, diff --git a/WebformWorker.h b/WebformWorker.h index 659259b..33efaef 100644 --- a/WebformWorker.h +++ b/WebformWorker.h @@ -6,6 +6,7 @@ #include #include #include "STh.h" +#include "Connector.h" class WFClass { @@ -25,12 +26,12 @@ public: ++WF; BConInc(); - active = true; + this->active = true; passCounter = 1; } ~WFClass(){ - active = false; + this->active = false; BConDec(); } diff --git a/connector_old.cpp b/connector_old.cpp index e2c8eb5..f64cc0c 100644 --- a/connector_old.cpp +++ b/connector_old.cpp @@ -900,7 +900,7 @@ lopaStr _BABrute(char *cookie, char *ip, int port, char *pathT, char *method) return lps; } -lopaStr _BALobby(char *cookie, char *ip, int port, char *path, char *method, char *data = NULL) +lopaStr _BALobby(char *cookie, char *ip, int port, char *path, char *method) { while(BrutingThrds >= gMaxBrutingThreads) Sleep(700); @@ -1752,91 +1752,7 @@ lopaStr _IPCameraBLobby(char *ip, int port, char *SPEC) } -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) -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*1000); - 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; - }; -} -#else -int _pingMyTarget(char *ip) -{ - FILE *pipe = popen(("ping -w " + std::to_string(gPingTimeout) + " " + ip).c_str(), "r"); - if(!pipe) { - stt->doEmitionRedFoundData("Ping pipe failed: cannot open pipe."); - perror("pipe"); - return 0; - } - - char buffer[128] = {0}; - std::string result; - - while(!feof(pipe)) { - if(fgets(buffer, 128, pipe) != NULL){ - result += buffer; - } - } - pclose(pipe); - - if(strstr((char*)result.c_str(), "100% packet loss") != NULL) return 0; - return 1; -} -#endif diff --git a/externData.h b/externData.h index 5bd11a2..23945fd 100644 --- a/externData.h +++ b/externData.h @@ -23,20 +23,22 @@ 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; + gDebugMode, horLineFlag, gPingNScan, gShuffle, +BALogSwitched; 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; + 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]; + gVER[16], + gProxyIP[64], gProxyPort[8]; struct pl{ int loginCounter; diff --git a/externFunctions.h b/externFunctions.h index d0bb5ba..2cb8cf9 100644 --- a/externFunctions.h +++ b/externFunctions.h @@ -6,7 +6,7 @@ extern void GetNicks(); extern int startScan(char* argv); extern void BConInc(); extern void BConDec(); -extern QString GetNSErrorDefinition(char *str, char *defin); +extern QString GetNSErrorDefinition(const char *str, const char *defin); extern void _SaveBackupToFile(); extern char* strstri(const char *_Str, const char *_SubStr); extern char* _getAttribute(char *str, char *attrib); @@ -15,4 +15,5 @@ extern void nCleanup(); extern void getSubStr(char *src, char *startStr, char *endStr, char *dest, int szDest); extern void getSubStrEx(char *src, char *startStr, char *endStr, char *dest, int szDest); extern std::string xcode(LPCSTR src, UINT srcCodePage, UINT dstCodePage); +extern void _SaveBackupToFile(); //extern int nConnect(char *ip, int port, std::string *buffer); diff --git a/finder.cpp b/finder.cpp index 6e510e5..6e20675 100644 --- a/finder.cpp +++ b/finder.cpp @@ -5,6 +5,7 @@ #include "externData.h" #include "WebformWorker.h" #include "Connector.h" +#include char* strstri(const char *_Str, const char *_SubStr) { @@ -1322,7 +1323,7 @@ void _specWEBIPCAMBrute(char *ip, int port, char *hl, char *finalstr, int flag, }; } -void _specBrute(char *cookie, char *ip, int port, char *hl, char *finalstr, int flag, char *path, char *comment, char *cp, int recd, char *data) +void _specBrute(char *cookie, char *ip, int port, char *hl, char *finalstr, int flag, char *path, char *comment, char *cp, int recd) { isActive = 1; lopaStr lps; @@ -1333,8 +1334,8 @@ void _specBrute(char *cookie, char *ip, int port, char *hl, char *finalstr, int char tport[32] = {0}; sprintf(tport, ":%d", port); - if(strcmp(comment, "[DIGEST]") == 0) lps = _BALobby(cookie, ip, port, path, "[DIGEST]", data); - else lps = _BALobby(cookie, ip, port, path, "[NORMAL]", ""); + if(strcmp(comment, "[DIGEST]") == 0) lps = _BALobby(cookie, ip, port, path, "[DIGEST]"); + else lps = _BALobby(cookie, ip, port, path, "[NORMAL]"); if(strstr(lps.login, "UNKNOWN") == NULL && strlen(lps.other) == 0) { @@ -1725,47 +1726,47 @@ int Lexems::_filler(int p, char* buffcpy, char* ip, int recd, Lexems *lx, char * } else if(flag == 21) //Eyeon { - _specBrute(ps.cookie, ip, p, hl, "Eyeon Camera", flag, "/user/index.htm", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "Eyeon Camera", flag, "/user/index.htm", "Basic Authorization", cp, recd); } else if(flag == 22) //IP Camera control { - _specBrute(ps.cookie, ip, p, hl, "IP camera Control webpage", flag, "/main/cs_motion.asp", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "IP camera Control webpage", flag, "/main/cs_motion.asp", "Basic Authorization", cp, recd); } else if(flag == 23) //Network Camera BB-SC384 { - _specBrute(ps.cookie, ip, p, hl, "Network Camera BB-SC384", flag, "/live/index2.html", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "Network Camera BB-SC384", flag, "/live/index2.html", "Basic Authorization", cp, recd); } else if(flag == 24) //Network Camera VB-M40 { - _specBrute(ps.cookie, ip, p, hl, "Network Camera VB-M40", flag, "/-wvhttp-01-/open.cgi?", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "Network Camera VB-M40", flag, "/-wvhttp-01-/open.cgi?", "Basic Authorization", cp, recd); } else if(flag == 25) //Panasonic WTFISTHISAreaOMGIDONTEVEN-camera { - _specBrute(ps.cookie, ip, 60002, hl, "Panasonic WTFISTHISAreaOMGIDONTEVEN-camera", flag, "/SnapshotJPEG", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, 60002, hl, "Panasonic WTFISTHISAreaOMGIDONTEVEN-camera", flag, "/SnapshotJPEG", "Basic Authorization", cp, recd); } else if(flag == 26) //Sony Network Camera { - _specBrute(ps.cookie, ip, p, hl, "Sony Network Camera", flag, "/oneshotimage?", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "Sony Network Camera", flag, "/oneshotimage?", "Basic Authorization", cp, recd); } else if(flag == 27) //UA Network Camera { - _specBrute(ps.cookie, ip, p, hl, "UA Network Camera", flag, "/webs.cgi?", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "UA Network Camera", flag, "/webs.cgi?", "Basic Authorization", cp, recd); } else if(flag == 28) //Network Camera VB-M40 { - _specBrute(ps.cookie, ip, p, hl, "Network Camera VB-??", flag, "/-wvhttp-01-/open.cgi?", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "Network Camera VB-??", flag, "/-wvhttp-01-/open.cgi?", "Basic Authorization", cp, recd); } else if(flag == 29) //LG Smart IP Device { - _specBrute(ps.cookie, ip, p, hl, "LG Smart IP Device Camera", flag, "/digest.php", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "LG Smart IP Device Camera", flag, "/digest.php", "Basic Authorization", cp, recd); } else if(flag == 30) //NAS { - _specBrute(ps.cookie, ip, p, hl, "NAS", flag, "/cgi-bin/data/viostor-220/viostor/viostor.cgi", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "NAS", flag, "/cgi-bin/data/viostor-220/viostor/viostor.cgi", "Basic Authorization", cp, recd); } else if(flag == 31) //ip cam { - _specBrute(ps.cookie, ip, p, hl, "IP Camera", flag, "/check_user.cgi", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "IP Camera", flag, "/check_user.cgi", "Basic Authorization", cp, recd); } else if(flag == 32) //IPC WEB ip cam { @@ -1777,7 +1778,7 @@ int Lexems::_filler(int p, char* buffcpy, char* ip, int recd, Lexems *lx, char * } else if(flag == 34) //Hikvision ip cam { - _specBrute(ps.cookie, ip, p, hl, "[Hikvision] IP Camera", flag, "/PSIA/Custom/SelfExt/userCheck", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "[Hikvision] IP Camera", flag, "/PSIA/Custom/SelfExt/userCheck", "Basic Authorization", cp, recd); } else if(flag == 35) //EasyCam { @@ -1785,11 +1786,11 @@ int Lexems::_filler(int p, char* buffcpy, char* ip, int recd, Lexems *lx, char * } else if(flag == 36) //Panasonic Cam { - _specBrute(ps.cookie, ip, p, hl, "[Panasonic] IP Camera", flag, "/config/index.cgi", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "[Panasonic] IP Camera", flag, "/config/index.cgi", "Basic Authorization", cp, recd); } else if(flag == 37) //Panasonic Cam { - _specBrute(ps.cookie, ip, p, hl, "[Panasonic] IP Camera", flag, "/view/getuid.cgi", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "[Panasonic] IP Camera", flag, "/view/getuid.cgi", "Basic Authorization", cp, recd); } else if(flag == 38) //Foscam { @@ -1797,11 +1798,11 @@ int Lexems::_filler(int p, char* buffcpy, char* ip, int recd, Lexems *lx, char * } else if(flag == 39) //EagleEye { - _specBrute(ps.cookie, ip, p, hl, "[EagleEye] IP Camera", flag, "/cgi-bin/guest/Video.cgi?", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "[EagleEye] IP Camera", flag, "/cgi-bin/guest/Video.cgi?", "Basic Authorization", cp, recd); } else if(flag == 40) //Network Camera VB-C?? { - _specBrute(ps.cookie, ip, p, hl, "[Network Camera VB-C??] IP Camera", flag, "/admin/index.shtml?", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "[Network Camera VB-C??] IP Camera", flag, "/admin/index.shtml?", "Basic Authorization", cp, recd); } else if(flag == 41) //AVIOSYS-camera { @@ -1809,19 +1810,19 @@ int Lexems::_filler(int p, char* buffcpy, char* ip, int recd, Lexems *lx, char * } else if(flag == 42) //NW_camera { - _specBrute(ps.cookie, ip, p, hl, "[NW_camera] IP Camera", flag, "/cgi-bin/getuid?FILE=indexnw.html", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "[NW_camera] IP Camera", flag, "/cgi-bin/getuid?FILE=indexnw.html", "Basic Authorization", cp, recd); } else if(flag == 43) //NW_camera { - _specBrute(ps.cookie, ip, p, hl, "[Micros] IP Camera", flag, "/gui/rem_display.shtml", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "[Micros] IP Camera", flag, "/gui/rem_display.shtml", "Basic Authorization", cp, recd); } else if(flag == 44) //Hikvision ip cam 2 { - _specBrute(ps.cookie, ip, p, hl, "[Hikvision] IP Camera 2", flag, "/ISAPI/Security/userCheck", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "[Hikvision] IP Camera 2", flag, "/ISAPI/Security/userCheck", "Basic Authorization", cp, recd); } else if(flag == 45) //Panasonic ip cam { - _specBrute(ps.cookie, ip, p, hl, "[Panasonic] IP Camera", flag, "/config/index.cgi", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "[Panasonic] IP Camera", flag, "/config/index.cgi", "Basic Authorization", cp, recd); } else if(flag == 46) //Buffalo disk { @@ -1841,39 +1842,39 @@ int Lexems::_filler(int p, char* buffcpy, char* ip, int recd, Lexems *lx, char * } else if (flag == 50) //IP Camera { - _specBrute(ps.cookie, ip, p, hl, "IP Camera", flag, "/app/multi/single.asp", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "IP Camera", flag, "/app/multi/single.asp", "Basic Authorization", cp, recd); } else if(flag == 20) //AXIS Camera { - _specBrute(ps.cookie, ip, p, hl, "AXIS Camera", flag, "/axis-cgi/com/ptz.cgi?", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "AXIS Camera", flag, "/axis-cgi/com/ptz.cgi?", "Basic Authorization", cp, recd); } else if(flag == 19) //reecam cameras { - _specBrute(ps.cookie, ip, p, hl, "Reecam (network camera)", flag, "/videostream.cgi", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "Reecam (network camera)", flag, "/videostream.cgi", "Basic Authorization", cp, recd); } else if(flag == 18) //linksys camera { - _specBrute(ps.cookie, ip, p, hl, "Linksys camera", flag, "/img/main.cgi", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "Linksys camera", flag, "/img/main.cgi", "Basic Authorization", cp, recd); } else if(flag == 17) //Real-time IP Camera Monitoring System { - _specBrute(ps.cookie, ip, p, hl, "Real-time IP Camera Monitoring System", flag, "/live.htm", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "Real-time IP Camera Monitoring System", flag, "/live.htm", "Basic Authorization", cp, recd); } else if(flag == 11) { - _specBrute(ps.cookie, ip, p, hl, "Netwave IP Camera", flag, "/videostream.cgi", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "Netwave IP Camera", flag, "/videostream.cgi", "Basic Authorization", cp, recd); } else if(flag == 12) { - _specBrute(ps.cookie, ip, p, hl, "IP Camera", flag, "/view/view.shtml?videos=", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "IP Camera", flag, "/view/view.shtml?videos=", "Basic Authorization", cp, recd); } else if(flag == 13) { - _specBrute(ps.cookie, ip, p, hl, "IP Camera", flag, "/eng/view/indexjava.html", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "IP Camera", flag, "/eng/view/indexjava.html", "Basic Authorization", cp, recd); } else if(flag == 14) { - _specBrute(ps.cookie, ip, p, hl, "IP Camera", flag, "/rdr.cgi", "Basic Authorization", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, "IP Camera", flag, "/rdr.cgi", "Basic Authorization", cp, recd); } else if(flag == 15) //For HFS { @@ -1882,7 +1883,7 @@ int Lexems::_filler(int p, char* buffcpy, char* ip, int recd, Lexems *lx, char * isActive = 1; ++AnomC1; - lps = _BALobby(ps.cookie, ip, p, "/~login", "[NORMAL]", ""); + lps = _BALobby(ps.cookie, ip, p, "/~login", "[NORMAL]"); sprintf(log, "[HFS]:%s :: %s:%s T: %s Pass: %s:%s", hl, ip, port, ip, port, finalstr, lps.login, lps.pass); @@ -1910,11 +1911,11 @@ int Lexems::_filler(int p, char* buffcpy, char* ip, int recd, Lexems *lx, char * } else if(flag == 1) { - _specBrute(ps.cookie, ip, p, hl, finalstr, flag, pps, "[NORMAL]", cp, recd, ""); + _specBrute(ps.cookie, ip, p, hl, finalstr, flag, pps, "[NORMAL]", cp, recd); } else if(flag == 101) { - _specBrute(ps.cookie, ip, p, hl, finalstr, flag, pps, "[DIGEST]", cp, recd, buffcpy); + _specBrute(ps.cookie, ip, p, hl, finalstr, flag, pps, "[DIGEST]", cp, recd); } else if(flag == 10) { @@ -1929,11 +1930,6 @@ int Lexems::_filler(int p, char* buffcpy, char* ip, int recd, Lexems *lx, char * return flag; } -const char *rbuff1 = "GET "; -const char *rbuff2 = " HTTP/1.1\r\nHost: "; -const char *rbuff3 = "\r\nCookie:"; -const char *rbuff4 = "\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 redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, PathStr *ps, std::vector *redirStrLst, char *buff) { if(ls->iterationCount++ == 5) @@ -1949,8 +1945,7 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P char tempIP[MAX_ADDR_LEN] = {0}; strcpy(tempIP, ip); int tempPort = port; - char tempPath[1024] = {0}; - char mes[2048]= {0}; + char tempPath[1024] = {0}; if(strstri(str, "https://") != NULL) { @@ -2002,32 +1997,16 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P strcpy(tempPath, "/"); }; - strcpy(mes, rbuff1); - if(tempPath[0] != '/') strcat(mes, "/"); - strcat(mes, tempPath); - strcat(mes, rbuff2); - strcat(mes, tempIP); - if(tempPort != 80){ - strcat(mes, ":"); - char tbuff[16] = {0}; - sprintf(tbuff, "%d", tempPort); - strcat(mes, tbuff); - } - if(strlen(cookie) != 0) - { - strcat(mes, rbuff3); - strcat(mes, cookie); - }; - strcat(mes, rbuff4); - + std::unique_ptr nip(new char[strlen(tempIP) + strlen(tempPath) + 1]); + sprintf(nip.get(), "%s%s", tempIP, tempPath); std::string buffer; - int cSz = Connector::nConnect(tempIP, tempPort, buffer); + int cSz = Connector::nConnect(nip.get(), tempPort, &buffer); if(cSz > -1) { strncpy(buff, buffer.c_str(), (cSz < 65535 ? cSz : 65535)); strcpy(ps->codepage, GetCodePage(buff)); - ls->flag = ContentFilter(cstr.lowerBuff, tempPort, tempIP, ps->codepage); + ls->flag = ContentFilter(buff, tempPort, tempIP, ps->codepage); ps->flag = ls->flag; if(ls->flag == -1) @@ -2058,7 +2037,7 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P strcat(ps->headr, " -> "); strcat(ps->headr, GetTitle(buff)); - if (ls->_header(tempIP, tempPort, cstr.lowerBuff, ls, ps, redirStrLst, buff) == -1) + if (ls->_header(tempIP, tempPort, buff, ls, ps, redirStrLst, buff) == -1) { ps->flag = -1; strcpy(ps->headr, "[IGNR_ADDR]"); @@ -2068,16 +2047,16 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P }; ps->port = tempPort; - if(strlen(buff) < 1) - { - ps->flag = 3; - ls->flag = 3; - } - else if(cstr.overflow == true) - { - ls->flag = 0; - ps->flag = 0; - }; +// if(strlen(buff) < 1) +// { +// ps->flag = 3; +// ls->flag = 3; +// } +// else if(cstr.overflow == true) +// { +// ls->flag = 0; +// ps->flag = 0; +// }; } else { @@ -2113,6 +2092,7 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P strcpy(tempPath, "/"); sz = ptr2 - ptr1 - 7; }; + char tPort[8] = {0}; strncpy(tPort, ptr2 + 1, sz < 8 ? sz : 5); tempPort = atoi(tPort); @@ -2138,32 +2118,16 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P strcpy(tempPath, "/"); }; - strcpy(mes, rbuff1); - if(tempPath[0] != '/') strcat(mes, "/"); - strcat(mes, tempPath); - strcat(mes, rbuff2); - strcat(mes, tempIP); - if(tempPort != 80){ - strcat(mes, ":"); - char tbuff[16] = {0}; - sprintf(tbuff, "%d", tempPort); - strcat(mes, tbuff); - } - if(strlen(cookie) != 0) - { - strcat(mes, rbuff3); - strcat(mes, cookie); - }; - strcat(mes, rbuff4); - + std::unique_ptr nip(new char[strlen(tempIP) + strlen(tempPath) + 1]); + sprintf(nip.get(), "%s%s", tempIP, tempPath); std::string buffer; - int cSz = Connector::nConnect(tempIP, tempPort, buffer); + int cSz = Connector::nConnect(nip.get(), tempPort, &buffer); if(cSz > -1) { - strncpy(buff, cstr.lowerBuff, (cSz< 65535 ? cSz : 65535)); - strcpy(ps->codepage, GetCodePage(cstr.lowerBuff)); + strncpy(buff, buffer.c_str(), (cSz < 65535 ? cSz : 65535)); + strcpy(ps->codepage, GetCodePage(buff)); - ls->flag = ContentFilter(cstr.lowerBuff, tempPort, tempIP, ps->codepage); + ls->flag = ContentFilter(buff, tempPort, tempIP, ps->codepage); ps->flag = ls->flag; if(ls->flag == -1) @@ -2177,7 +2141,7 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P if(ls->flag >= 17 || ls->flag == 11 || ls->flag == 12 || ls->flag == 13 || ls->flag == 14 || ls->flag == 1 || ls->flag == 10) { - strcat(ps->headr, GetTitle(cstr.lowerBuff)); + strcat(ps->headr, GetTitle(buff)); ps->flag = ls->flag; strcpy(ps->path, tempPath); ps->port = tempPort; @@ -2191,9 +2155,11 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P ps->port = tempPort; return -2; }; + strcat(ps->headr, " -> "); - strcat(ps->headr, GetTitle(cstr.lowerBuff)); - if (ls->_header(tempIP, tempPort, cstr.lowerBuff, ls, ps, redirStrLst, buff) == -1) + strcat(ps->headr, GetTitle(buff)); + + if (ls->_header(tempIP, tempPort, buff, ls, ps, redirStrLst, buff) == -1) { ps->flag = -1; strcpy(ps->headr, "[IGNR_ADDR]"); @@ -2203,16 +2169,16 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P }; ps->port = tempPort; - if(strlen(buff) < 1) - { - ps->flag = 3; - ls->flag = 3; - } - else if(cstr.overflow == true) - { - ls->flag = 0; - ps->flag = 0; - }; +// if(strlen(buff) < 1) +// { +// ps->flag = 3; +// ls->flag = 3; +// } +// else if(cstr.overflow == true) +// { +// ls->flag = 0; +// ps->flag = 0; +// }; } else { @@ -2220,6 +2186,7 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P ls->flag = -1; if(gNegDebugMode) stt->doEmitionDebugFoundData("[" + QString(ip) + ":" + QString::number(port) + "" + "] Rejecting in _header::redirect [Dead host]."); }; + return -2; } else if(str[0] == '/' || (str[0] == '.' && str[1] == '/') || (str[0] == '.' && str[1] == '.' && str[2] == '/')) @@ -2228,61 +2195,33 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P else if(str[0] == '.') strcpy(tempPath, str + 1); else strcpy(tempPath, str); - strcpy(mes, rbuff1); - if(tempPath[0] != '/') strcat(mes, "/"); - strcat(mes, tempPath); - strcat(mes, rbuff2); - strcat(mes, ip); - if(tempPort != 80){ - strcat(mes, ":"); - char tbuff[16] = {0}; - sprintf(tbuff, "%d", tempPort); - strcat(mes, tbuff); - } - if(strlen(cookie) != 0) + std::unique_ptr nip(new char[strlen(tempIP) + strlen(tempPath) + 1]); + sprintf(nip.get(), "%s%s", tempIP, tempPath); + std::string buffer; + int cSz = Connector::nConnect(nip.get(), tempPort, &buffer); + if(cSz > -1) { - strcat(mes, rbuff3); - strcat(mes, cookie); - }; - strcat(mes, rbuff4); + strncpy(buff, buffer.c_str(), (cSz < 65535 ? cSz : 65535)); + strcpy(ps->codepage, GetCodePage(buff)); - conSTR cstr; - cstr.size = 0; - cstr.lowerBuff = NULL; - int cRes = 0; - if(port == 443) cRes = con._EstablishSSLConnection(ip, 443, mes, &cstr); - else cRes = con._EstablishConnection(ip, port, mes, &cstr); - if(cstr.size < 65535) - { - strncpy(buff, cstr.lowerBuff, cstr.size); - } - else - { - strncpy(buff, cstr.lowerBuff, 65535); - }; - if(cRes > -1) - { - strcpy(ps->codepage, GetCodePage(cstr.lowerBuff)); - - ls->flag = ContentFilter(cstr.lowerBuff, port, ip, ps->codepage); + ls->flag = ContentFilter(buff, port, ip, ps->codepage); ps->flag = ls->flag; if(ls->flag == -1) { ps->flag = -1; strcpy(ps->headr, "[IGNR_ADDR]"); - strcpy(ps->path, tempPath); - delete []cstr.lowerBuff; + strcpy(ps->path, tempPath); return -2; }; + if(ls->flag >= 17 || ls->flag == 11 || ls->flag == 12 || ls->flag == 13 || ls->flag == 14 || ls->flag == 1 || ls->flag == 10) { - strcat(ps->headr, GetTitle(cstr.lowerBuff)); + strcat(ps->headr, GetTitle(buff)); ps->flag = ls->flag; - strcpy(ps->path, tempPath); - delete []cstr.lowerBuff; + strcpy(ps->path, tempPath); ps->port = port; strcpy(ps->ip, ip); @@ -2294,30 +2233,30 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P ps->port = tempPort; return -2; }; + strcat(ps->headr, "->"); - strcat(ps->headr, GetTitle(cstr.lowerBuff)); - if (ls->_header(tempIP, tempPort, cstr.lowerBuff, ls, ps, redirStrLst, buff) == -1) + strcat(ps->headr, GetTitle(buff)); + + if (ls->_header(tempIP, tempPort, buff, ls, ps, redirStrLst, buff) == -1) { ps->flag = -1; strcpy(ps->headr, "[IGNR_ADDR]"); - strcpy(ps->path, tempPath); - delete[]cstr.lowerBuff; + strcpy(ps->path, tempPath); return -1; }; ps->port = tempPort; - if(strlen(cstr.lowerBuff) < 1) - { - ps->flag = 3; - ls->flag = 3; - } - else if(cstr.overflow == true) - { - ls->flag = 0; - ps->flag = 0; - }; +// if(strlen(buff) < 1) +// { +// ps->flag = 3; +// ls->flag = 3; +// } +// else if(cstr.overflow == true) +// { +// ls->flag = 0; +// ps->flag = 0; +// }; - delete []cstr.lowerBuff; } else { @@ -2328,42 +2267,23 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P return -2; } else if(strlen(str) > 2) - { - strcpy(tempPath, str); - strcpy(mes, rbuff1); - if(tempPath[0] != '/') strcat(mes, "/"); - strcat(mes, tempPath); - strcat(mes, rbuff2); - strcat(mes, ip); - if(tempPort != 80){ - strcat(mes, ":"); - char tbuff[16] = {0}; - sprintf(tbuff, "%d", tempPort); - strcat(mes, tbuff); - } - if(strlen(cookie) != 0) + { + std::unique_ptr nip(new char[strlen(ip) + strlen(str) + 1]); + sprintf(nip.get(), "%s%s", ip, str); + std::string buffer; + int cSz = Connector::nConnect(nip.get(), port, &buffer); + if(cSz > -1) { - strcat(mes, rbuff3); - strcat(mes, cookie); - }; - strcat(mes, rbuff4); - - conSTR cstr; - cstr.size = 0; - cstr.lowerBuff = NULL; - if(con._EstablishConnection(ip, port, mes, &cstr) != -1) - { - strncpy(buff, cstr.lowerBuff, (cstr.size < 65535 ? cstr.size : 65535)); - strcpy(ps->codepage, GetCodePage(cstr.lowerBuff)); + strncpy(buff, buffer.c_str(), (cSz < 65535 ? cSz : 65535)); + strcpy(ps->codepage, GetCodePage(buff)); - ls->flag = ContentFilter(cstr.lowerBuff, port, ip, ps->codepage); + ls->flag = ContentFilter(buff, port, ip, ps->codepage); ps->flag = ls->flag; if(ls->flag == -1) { ps->flag = -1; strcpy(ps->headr, "[IGNR_ADDR]"); - strcpy(ps->path, tempPath); - delete []cstr.lowerBuff; + strcpy(ps->path, tempPath); return -1; }; @@ -2371,39 +2291,37 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P if(ls->flag >= 17 || ls->flag == 11 || ls->flag == 12 || ls->flag == 13 || ls->flag == 14 || ls->flag == 1 || ls->flag == 10) { - strcat(ps->headr, GetTitle(cstr.lowerBuff)); + strcat(ps->headr, GetTitle(buff)); ps->flag = ls->flag; - strcpy(ps->path, tempPath); - delete []cstr.lowerBuff; + strcpy(ps->path, tempPath); ps->port = port; strcpy(ps->ip, ip); return -2; }; - if(ls->flag == 6) - { - ps->flag = ls->flag; - ps->port = tempPort; - return -2; - }; + if(ls->flag == 6) + { + ps->flag = ls->flag; + ps->port = tempPort; + return -2; + }; + strcat(ps->headr, " -> "); - strcat(ps->headr, GetTitle(cstr.lowerBuff)); - ls->_header(ip, port, cstr.lowerBuff, ls, ps, redirStrLst, buff); + strcat(ps->headr, GetTitle(buff)); + ls->_header(ip, port, buff, ls, ps, redirStrLst, buff); ps->port = tempPort; - if(strlen(cstr.lowerBuff) < 1) - { - ps->flag = 3; - ls->flag = 3; - } - else if(cstr.overflow == true) - { - ls->flag = 0; - ps->flag = 0; - }; - - delete []cstr.lowerBuff; +// if(strlen(buff) < 1) +// { +// ps->flag = 3; +// ls->flag = 3; +// } +// else if(cstr.overflow == true) +// { +// ls->flag = 0; +// ps->flag = 0; +// }; } else { diff --git a/mainResources.h b/mainResources.h index ce13e7f..e92283d 100644 --- a/mainResources.h +++ b/mainResources.h @@ -158,5 +158,5 @@ class Connector_old extern lopaStr _IPCameraBLobby(char *ip, int port, char *SPEC); -extern lopaStr _BALobby(char *cookie, char *ip, int port, char *path, char *method, char *data = NULL); +extern lopaStr _BALobby(char *cookie, char *ip, int port, char *path, char *method); extern lopaStr _FTPLobby(char *ip, int port, PathStr *ps); diff --git a/msgcheckerthread.cpp b/msgcheckerthread.cpp index eb4c9da..9f71f8c 100644 --- a/msgcheckerthread.cpp +++ b/msgcheckerthread.cpp @@ -7,7 +7,7 @@ void MSGCheckerThread::doEmitionShowNewMsg(QString str) { emit mct->showNewMsg(str); -}; +} void _getNewMsg() { diff --git a/nesca.pro b/nesca.pro index fa5a8ed..b773f97 100644 --- a/nesca.pro +++ b/nesca.pro @@ -35,10 +35,10 @@ SOURCES +=\ STh.cpp \ vercheckerthread.cpp \ finder.cpp \ - Utils.cpp \ WebformWorker.cpp \ Connector.cpp \ - connector_old.cpp + connector_old.cpp \ + Utils.cpp HEADERS += ActivityDrawerTh_HorNet.h \ diff --git a/nesca.pro.user b/nesca.pro.user index 3139876..8b5234f 100644 --- a/nesca.pro.user +++ b/nesca.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/nesca_3.cpp b/nesca_3.cpp index a261655..ce941c6 100644 --- a/nesca_3.cpp +++ b/nesca_3.cpp @@ -35,6 +35,8 @@ int ver = 100*(100*(date.year()%100) + date.month()) + date.day(); #define WIDGET_WIDTH 500 //#define IRC_CHAN "iskopasi_lab01" + + bool utfIRCFlag = true; bool HTMLDebugMode = false; bool code160 = false; @@ -74,6 +76,8 @@ char trcProxy[128] = {0}; char trcSrv[256] = {0}; char trcScr[256] = {0}; char trcPersKey[32] = {0}; +char gProxyIP[64] = {0}; +char gProxyPort[8] = {0}; SOCKET lSock; @@ -738,37 +742,39 @@ void nesca_3::slotAddLine(int x1, int y1, int x2, int y2) void nesca_3::slotAddPolyLine() { + sceneGraph->setItemIndexMethod(QGraphicsScene::NoIndex); if(ME2ScanFlag) - { - double uu = 0.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); - int vSz = sceneGraph->items().size(); - for(int i = 0; i < vSz; ++i) + { + QPainterPath path; + if(vect.size() > 0) { - sceneGraph->items()[i]->setY(u+i + 1); - sceneGraph->items()[i]->setOpacity(1 - uu); - uu+=0.027; - u+=1; + path.moveTo(vect[0]); + for(int i = 1; i < vect.size(); ++i) + { + path.lineTo(vect[i]); + }; }; + + QGraphicsPathItem* itm = new QGraphicsPathItem(path); + itm->setPen(pen2i); sceneGraph->addItem(itm); - if(vSz == 50) + double uu = 0.0; + int vSz = sceneGraph->items().count(); + for(int i = 0; i < vSz; ++i) { - sceneGraph->items().pop_back(); - }; - if(u > 10) u = 1; + sceneGraph->items()[i]->setY(u + i + 1); + sceneGraph->items()[i]->setOpacity(0 + uu); + uu += 0.027; + u += 1; + }; + + while(sceneGraph->items().count() > 38) + { + sceneGraph->removeItem(sceneGraph->items().first()); + }; + + if(u > 10) u = 1; }; } @@ -2977,6 +2983,21 @@ void nesca_3::ConnectEvrthng() connect ( irc_nmb, SIGNAL(sBlinkMessage()), this, SLOT(slotBlinkMessage()) ); } +QString loadNescaSetup(char *resStr, char *option) { + + char *lex = NULL; + if(strstr(resStr, option) != NULL) + { + lex = strstr(resStr, option) + strlen(option); + + if(strlen(lex) > 1) + { + lex[strlen(lex) - 1] = '\0'; + return QString(lex); + } return ""; + } + return ""; +} void RestoreSession() { FILE *resFile = fopen("restore", "r"); @@ -2985,7 +3006,6 @@ void RestoreSession() if(resFile != NULL) { - stt->doEmitionYellowFoundData("Previous session file found! Restoring..."); while(fgets(resStr, 128, resFile) != NULL) @@ -3087,176 +3107,32 @@ void RestoreSession() }; }; - 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 )); - }; - }; + if(strstr(resStr, "[NDBSERVER]:") != NULL) ui->lineTrackerSrv->setText(loadNescaSetup(resStr, "[NDBSERVER]:").simplified()); + if(strstr(resStr, "[NDBSCRIPT]:") != NULL) ui->lineTrackerScr->setText(loadNescaSetup(resStr, "[NDBSCRIPT]:").simplified()); + if(strstr(resStr, "[NDBPORT]:") != NULL) ui->trcSrvPortLine->setText(loadNescaSetup(resStr, "[NDBPORT]:").simplified()); + if(strstr(resStr, "[PING]:") != NULL) ui->pingingOnOff->setText(loadNescaSetup(resStr, "[PING]:").simplified()); + if(strstr(resStr, "[PING_TO]:") != NULL) ui->PingTO->setText(loadNescaSetup(resStr, "[PING_TO]:").simplified()); + if(strstr(resStr, "[THREAD_DELAY]:") != NULL) ui->threadDelayBox->setText(loadNescaSetup(resStr, "[THREAD_DELAY]:").simplified()); + if(strstr(resStr, "[TIMEOUT]:") != NULL) { + ui->iptoLine_value->setText(loadNescaSetup(resStr, "[TIMEOUT]:")); + ui->iptoLine_value_2->setText(loadNescaSetup(resStr, "[TIMEOUT]:")); + ui->iptoLine_value_3->setText(loadNescaSetup(resStr, "[TIMEOUT]:")); + } + if(strstr(resStr, "[MAXBTHR]:") != NULL) ui->maxBrutingThrBox->setText(loadNescaSetup(resStr, "[MAXBTHR]:").simplified()); + if(strstr(resStr, "[PERSKEY]:") != NULL) ui->linePersKey->setText(loadNescaSetup(resStr, "[PERSKEY]:").simplified()); + if(strstr(resStr, "[IRCSERVER]:") != NULL) ui->ircServerBox->setText(loadNescaSetup(resStr, "[IRCSERVER]:").simplified()); + if(strstr(resStr, "[IRCPORT]:") != NULL) ui->serverPortBox->setText(loadNescaSetup(resStr, "[IRCPORT]:").simplified()); + if(strstr(resStr, "[IRCPROXY]:") != NULL) ui->ircProxy->setText(loadNescaSetup(resStr, "[IRCPROXY]:").simplified()); + if(strstr(resStr, "[IRCPROXYPORT]:") != NULL) ui->ircProxyPort->setText(loadNescaSetup(resStr, "[IRCPROXYPORT]:").simplified()); + if(strstr(resStr, "[SYSTEMPROXYIP]:") != NULL) ui->systemProxyIP->setText(loadNescaSetup(resStr, "[SYSTEMPROXYIP]:").simplified()); + if(strstr(resStr, "[SYSTEMPROXYPORT]:") != NULL) ui->systemProxyPort->setText(loadNescaSetup(resStr, "[SYSTEMPROXYPORT]:").simplified()); + if(strstr(resStr, "[IRCNICK]:") != NULL) ui->ircNickBox->setText(loadNescaSetup(resStr, "[IRCNICK]:").simplified()); + ZeroMemory(resStr, sizeof(resStr)); }; + fclose(resFile); - stt->doEmitionGreenFoundData("Previous session restored."); - }; } @@ -3336,13 +3212,6 @@ void _startMsgCheck() mct->start(); } - -static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp) -{ - ((std::string*)userp)->append((char*)contents, size * nmemb); - return size * nmemb; -} - nesca_3::nesca_3(QWidget *parent) : QMainWindow(parent) { setWindowFlags ( Qt::FramelessWindowHint ); @@ -3500,8 +3369,6 @@ void nesca_3::saveOptions() { int ci = ui->tabMainWidget->currentIndex(); - - if(ci == 0) { ZeroMemory(saveStartIP, sizeof(saveStartIP)); @@ -3570,6 +3437,10 @@ void nesca_3::saveOptions() strcpy(ircProxy, ui->ircProxy->text().toLocal8Bit().data()); strcpy(ircProxyPort, ui->ircProxyPort->text().toLocal8Bit().data()); strcpy(ircNick, ui->ircNickBox->text().toLocal8Bit().data()); + strncpy(gProxyIP, ui->systemProxyIP->text().toLocal8Bit().data(), 64); + strncpy(gProxyPort, ui->systemProxyPort->text().toLocal8Bit().data(), 8); + + _SaveBackupToFile(); } void nesca_3::STTTerminate() diff --git a/nesca_3.h b/nesca_3.h index 3a4a9f9..4a12fd7 100644 --- a/nesca_3.h +++ b/nesca_3.h @@ -22,7 +22,7 @@ #include extern Ui::nesca_3Class *ui; -extern bool widgetIsHidden, IRCLogToggled, BALogSwitched, blinkFlag, disableBlink, debugFileOK, QOSWait, +extern bool widgetIsHidden, IRCLogToggled, 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; diff --git a/nesca_3.ui b/nesca_3.ui index 86349b1..720c9df 100644 --- a/nesca_3.ui +++ b/nesca_3.ui @@ -78,6 +78,7 @@ Eurostile + 10 @@ -90,7 +91,7 @@ QTabWidget::Rounded - 0 + 3 Qt::ElideMiddle @@ -144,6 +145,7 @@ Eurostile + 9 @@ -174,6 +176,7 @@ Eurostile + 9 @@ -201,6 +204,7 @@ Eurostile + 9 @@ -335,6 +339,7 @@ Eurostile + 9 @@ -365,6 +370,7 @@ Eurostile + 8 @@ -397,6 +403,7 @@ Eurostile + 9 @@ -448,6 +455,7 @@ Eurostile + 9 @@ -478,6 +486,7 @@ Eurostile + 9 @@ -505,6 +514,7 @@ Eurostile + 9 @@ -639,6 +649,7 @@ Eurostile + 9 @@ -669,6 +680,7 @@ Eurostile + 8 @@ -701,6 +713,7 @@ Eurostile + 8 @@ -749,6 +762,7 @@ color: rgb(214, 214, 0); Eurostile + 9 @@ -779,6 +793,7 @@ color: rgb(214, 214, 0); Eurostile + 9 @@ -881,6 +896,7 @@ color: rgb(214, 214, 0); Eurostile + 9 @@ -911,6 +927,7 @@ color: rgb(214, 214, 0); Eurostile + 8 @@ -957,7 +974,7 @@ border-radius: 3px; 30 100 - 208 + 241 17 @@ -983,14 +1000,15 @@ border-radius: 3px; 250 - 10 + 2 121 - 20 + 16 Eurostile + 8 @@ -1013,14 +1031,15 @@ border-radius: 3px; 30 - 10 + 2 211 - 20 + 16 Eurostile + 8 @@ -1043,14 +1062,15 @@ border-radius: 3px; 30 - 35 + 22 341 - 20 + 12 Eurostile + 8 @@ -1073,14 +1093,15 @@ border-radius: 3px; 379 - 10 + 2 62 - 20 + 16 Eurostile + 8 @@ -1102,15 +1123,16 @@ border-radius: 3px; - 380 - 35 + 379 + 18 61 - 23 + 16 Eurostile + 8 @@ -1132,6 +1154,7 @@ border-radius: 3px; Eurostile + 8 @@ -1159,6 +1182,7 @@ border-radius: 3px; Eurostile + 8 @@ -1215,7 +1239,7 @@ border-radius: 3px; 163 85 - 17 + 31 16 @@ -1276,6 +1300,7 @@ border-radius: 3px; Eurostile + 8 @@ -1346,7 +1371,7 @@ border-radius: 3px; 30 68 - 100 + 161 17 @@ -1371,6 +1396,71 @@ border-radius: 3px; true + + + + 30 + 38 + 341 + 12 + + + + + Eurostile + 8 + + + + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56); border:none; + + + + + + 32 + + + Qt::AlignCenter + + + Proxy here + + + + + + 379 + 38 + 62 + 12 + + + + + Eurostile + 8 + + + + color: rgb(216, 216, 216);background-color: rgb(56, 56, 56);border:none; + + + 3128 + + + 5 + + + Qt::AlignCenter + + + Balancer port here + + @@ -1518,6 +1608,7 @@ border-radius: 3px; Eurostile + 8 @@ -1545,6 +1636,7 @@ border-radius: 3px; Eurostile + 8 @@ -1569,6 +1661,7 @@ border-radius: 3px; Eurostile + 8 @@ -1590,6 +1683,7 @@ border-radius: 3px; Eurostile + 8 @@ -1611,6 +1705,7 @@ border-radius: 3px; Eurostile + 8 @@ -1632,6 +1727,7 @@ border-radius: 3px; Eurostile + 8 @@ -1678,7 +1774,7 @@ border-radius: 3px; <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Consolas'; font-size:8.25pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'Consolas'; font-size:11pt; font-weight:400; font-style:normal;"> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></body></html> @@ -1718,6 +1814,7 @@ p, li { white-space: pre-wrap; } Eurostile + 8 @@ -1745,6 +1842,7 @@ p, li { white-space: pre-wrap; } Eurostile + 8 @@ -1778,6 +1876,7 @@ p, li { white-space: pre-wrap; } Eurostile + 8 @@ -1805,6 +1904,7 @@ p, li { white-space: pre-wrap; } Eurostile + 8 @@ -1826,6 +1926,7 @@ p, li { white-space: pre-wrap; } Eurostile + 8 @@ -1847,6 +1948,7 @@ p, li { white-space: pre-wrap; } Eurostile + 8 @@ -2361,6 +2463,7 @@ p, li { white-space: pre-wrap; } Eurostile + 8 @@ -2388,6 +2491,7 @@ p, li { white-space: pre-wrap; } Eurostile + 8 @@ -2433,7 +2537,7 @@ p, li { white-space: pre-wrap; } <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Eurostile'; font-size:8.25pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'Eurostile'; font-size:11pt; font-weight:400; font-style:normal;"> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></body></html> @@ -2494,6 +2598,7 @@ background-color: #000000; Eurostile + 8 @@ -2809,6 +2914,7 @@ background-color: #000000; Eurostile + 8 @@ -3415,7 +3521,7 @@ background-color: #000000; <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Eurostile'; font-size:8.25pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'Eurostile'; font-size:11pt; font-weight:400; font-style:normal;"> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></body></html> @@ -3551,7 +3657,7 @@ p, li { white-space: pre-wrap; } <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Eurostile'; font-size:8.25pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'Eurostile'; font-size:11pt; font-weight:400; font-style:normal;"> <p style="-qt-paragraph-type:empty; margin-top:2px; margin-bottom:2px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></body></html> @@ -3885,6 +3991,7 @@ color: rgb(71, 71, 71); Eurostile + 8 @@ -3912,6 +4019,7 @@ color: rgb(71, 71, 71); Eurostile + 8 @@ -3939,6 +4047,7 @@ color: rgb(71, 71, 71); Eurostile + 8 @@ -3969,6 +4078,7 @@ color: rgb(71, 71, 71); Eurostile + 8 diff --git a/nesca_startModule.cpp b/nesca_startModule.cpp index e66936f..501cb9c 100644 --- a/nesca_startModule.cpp +++ b/nesca_startModule.cpp @@ -121,15 +121,15 @@ void SaveErrorLog(char *sender, char *MesSent, char *ReplRecv) }; } -QString GetNSErrorDefinition(char *str, char *elem) +QString GetNSErrorDefinition(const char *str, const char *elem) { - char *temp = strstr(str, elem); + const char *temp = strstr(str, elem); if(temp != NULL) { char definition[128] = {0}; - char *firstComma = strstr(temp + strlen(elem) + 1, "\""); - char *lastComma = strstr(firstComma + 1, "\""); + const char *firstComma = strstr(temp + strlen(elem) + 1, "\""); + const char *lastComma = strstr(firstComma + 1, "\""); int sz = lastComma - firstComma - 1; @@ -351,8 +351,16 @@ void _SaveBackupToFile() ZeroMemory(saveStr, sizeof(saveStr)); sprintf(saveStr, "[MAXBTHR]: %d\n", gMaxBrutingThreads); - strcat(saveBuffer, saveStr); - ZeroMemory(saveStr, sizeof(saveStr)); + strcat(saveBuffer, saveStr); + ZeroMemory(saveStr, sizeof(saveStr)); + + sprintf(saveStr, "[SYSTEMPROXYIP]: %s\n", gProxyIP); + strcat(saveBuffer, saveStr); + ZeroMemory(saveStr, sizeof(saveStr)); + + sprintf(saveStr, "[SYSTEMPROXYPORT]: %s\n", gProxyPort); + strcat(saveBuffer, saveStr); + ZeroMemory(saveStr, sizeof(saveStr)); strcpy(saveStr, "[PERSKEY]:"); strcat(saveStr, trcPersKey); @@ -1127,7 +1135,9 @@ void _passLoginFapper() stt->doEmitionKillSttThread(); }; - 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())); + 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())); } void ReadUTF8(FILE* nFile, char *cp) @@ -2271,7 +2281,7 @@ int _GetDNSFromMask(char *mask, char *saveMask, char *saveMaskEnder) } 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 */