From 5c26625f853e1f9eee5b3a5c7b52f535caad31ee Mon Sep 17 00:00:00 2001 From: cora48 Date: Mon, 30 Mar 2015 17:31:06 +0300 Subject: [PATCH 1/2] File Downloader carcas --- FileDownloader.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++ FileDownloader.h | 9 ++++++++ nesca.pro | 6 +++-- nesca.pro.user | 2 +- nesca_startModule.cpp | 3 +++ 5 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 FileDownloader.cpp create mode 100644 FileDownloader.h diff --git a/FileDownloader.cpp b/FileDownloader.cpp new file mode 100644 index 0000000..fa1bdd0 --- /dev/null +++ b/FileDownloader.cpp @@ -0,0 +1,51 @@ +#include "FileDownloader.h" +#include "Connector.h" +#include "FileUpdater.h" +#include "istream" + +int getCL(std::string *buffer) { + + std::size_t pos1 = buffer->find("Content-Length:"); + if(pos1 == std::string::npos) { + stt->doEmitionFoundData("Cannot find Content-Length."); + return -1; + } + int pos2 = buffer->find("\r\n", pos1); + if(pos2 == std::string::npos) { + stt->doEmitionFoundData("Weird reply."); + return -1; + } + + std::string res = buffer->substr(pos1 + 15, pos2 - pos1 - 15); + return stoi(res); +} + +void checkWeb(const char *fileName, long *ptr, void *func(void)) { + std::string buffer; + Connector::nConnect(std::string("localhost/nesca/" + std::string(fileName)).c_str(), 8080, &buffer); + + std::cout<doEmitionFoundData("File " + QString(fileName) + " downloaded."); + } +} + +void loadNegatives(){ +} + +void FileDownloader::checkWebFiles() { + //checkWeb("negatives.txt", &FileUpdater::oldNegLstSize, (void*(*)(void))loadNegatives); + //checkWeb("login.txt", (void*(*)(void))loadLogins); + //checkWeb("pass.txt", (void*(*)(void))loadPass); + //checkWeb("sshpass.txt", (void*(*)(void))loadSSHPass); + //checkWeb("wflogin.txt", (void*(*)(void))loadWFLogins); + //checkWeb("wfpass.txt", (void*(*)(void))loadWFPass); +} + diff --git a/FileDownloader.h b/FileDownloader.h new file mode 100644 index 0000000..6bb6a7d --- /dev/null +++ b/FileDownloader.h @@ -0,0 +1,9 @@ +#ifndef FILEDOWNLOADER_H +#define FILEDOWNLOADER_H + +class FileDownloader { +public: + static void checkWebFiles(); +}; + +#endif // FILEDOWNLOADER_H diff --git a/nesca.pro b/nesca.pro index ec62f8d..f28d132 100644 --- a/nesca.pro +++ b/nesca.pro @@ -42,7 +42,8 @@ SOURCES +=\ FTPAuth.cpp \ Threader.cpp \ SSHAuth.cpp \ - FileUpdater.cpp + FileUpdater.cpp \ + FileDownloader.cpp HEADERS += ActivityDrawerTh_HorNet.h \ @@ -71,7 +72,8 @@ HEADERS += ActivityDrawerTh_HorNet.h \ FTPAuth.h \ Threader.h \ SSHAuth.h \ - FileUpdater.h + FileUpdater.h \ + FileDownloader.h FORMS += nesca_3.ui diff --git a/nesca.pro.user b/nesca.pro.user index 71414b8..9d0b304 100644 --- a/nesca.pro.user +++ b/nesca.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/nesca_startModule.cpp b/nesca_startModule.cpp index 0beeb5f..d9c0a95 100644 --- a/nesca_startModule.cpp +++ b/nesca_startModule.cpp @@ -5,6 +5,7 @@ #include "Connector.h" #include "Threader.h" #include "FileUpdater.h" +#include "FileDownloader.h" #include QJsonArray *jsonArr = new QJsonArray(); @@ -1764,6 +1765,8 @@ int _GetDNSFromMask(char *mask, char *saveMask, char *saveMaskEnder) { void runAuxiliaryThreads() { std::thread lpThread(FileUpdater::updateLists); lpThread.detach(); + std::thread fuThread(FileDownloader::checkWebFiles); + fuThread.detach(); std::thread saverThread(_saver); saverThread.detach(); std::thread trackerThread(_tracker); From c5fc4c16db869ad581f7c60ea341063077baa9ad Mon Sep 17 00:00:00 2001 From: cora48 Date: Wed, 1 Apr 2015 15:39:14 +0300 Subject: [PATCH 2/2] Added overflow detection --- Connector.cpp | 39 ++++++--- Connector.h | 2 +- Threader.cpp | 7 +- externData.h | 3 +- finder.cpp | 195 +++++++++++++++++++++--------------------- mainResources.h | 29 +++---- nesca.pro.user | 2 +- nesca_3.cpp | 31 +++++-- nesca_startModule.cpp | 141 +++++++++++------------------- 9 files changed, 218 insertions(+), 231 deletions(-) diff --git a/Connector.cpp b/Connector.cpp index 9547b65..f056d80 100644 --- a/Connector.cpp +++ b/Connector.cpp @@ -104,9 +104,14 @@ int my_trace(CURL *handle, curl_infotype type, return 0; } -static size_t nWriteCallback(void *contents, size_t size, size_t nmemb, void *userp) +size_t nWriteCallback(void *contents, size_t size, size_t nmemb, void *userp) { ((std::string*)userp)->append((char*)contents, size * nmemb); + Activity += nmemb; + int ssz = ((std::string*)userp)->size(); + if(ssz > 180000) { + return -1; + } return size * nmemb; } @@ -116,10 +121,10 @@ int Connector::nConnect(const char* ip, const int port, std::string *buffer, const std::string *lpString){ buffer->clear(); CURL *curl = curl_easy_init(); - curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 0L); if (curl) { + curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 0L); if (MapWidgetOpened) { struct data config; config.trace_ascii = 1; /* enable ascii tracing */ @@ -178,14 +183,15 @@ int Connector::nConnect(const char* ip, const int port, std::string *buffer, (port == 21 && buffer->size() > 0)) { if (MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString(buffer->c_str())); Activity += buffer->size(); - return buffer->size(); + return buffer->size(); } else { if (res != 28 && res != 7 && res != 67 && res != 52 && - res != 55 && - res != 56) { + res != 55 && + res != 56 && + res != 23) { if (res == 5) { stt->doEmitionRedFoundData("Couldn't resolve proxy. The given proxy host could not be resolved. "); return -2; @@ -215,24 +221,29 @@ int Connector::nConnect(const char* ip, const int port, std::string *buffer, else stt->doEmitionRedFoundData("CURL error: (" + QString::number(res) + ") " + QString(ip) + ":" + QString::number(port)); } - ++offlines; - return -1; + + if(res == 23 && buffer->size() > 0) { + if (MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString("[OVERFLOW]")); + return buffer->size(); + } else { + stt->doEmitionOffline(QString::number(++offlines)); + return -1; + } } } else { stt->doEmitionRedFoundData("Curl error."); return -1; }; - if (MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString(buffer->c_str())); - Activity += buffer->size(); + if (MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString(buffer->c_str())); return buffer->size(); } -int Connector::_ConnectToPort(std::string ip, int port, char *hl) +int Connector::_ConnectToPort(char* ip, int port) { if(gPingNScan) { - if(_pingMyTarget(ip.c_str()) == 0) + if(_pingMyTarget(ip) == 0) { return -2; }; @@ -241,8 +252,8 @@ int Connector::_ConnectToPort(std::string ip, int port, char *hl) std::string buffer; int size = 0; - if (port == 22) size = SSHAuth::SSHLobby(ip.c_str(), port, &buffer); - else size = nConnect(ip.c_str(), port, &buffer); + if (port == 22) size = SSHAuth::SSHLobby(ip, port, &buffer); + else size = nConnect(ip, port, &buffer); if(size > 0) { @@ -250,7 +261,7 @@ int Connector::_ConnectToPort(std::string ip, int port, char *hl) ++found; stt->doEmitionChangeParsed(QString::number(saved) + "/" + QString::number(found)); Lexems lx; - lx._filler(port, buffer.c_str(), (char*)ip.c_str(), size, &lx, hl); + lx._filler(port, buffer.c_str(), ip, size, &lx); }; return 0; diff --git a/Connector.h b/Connector.h index 2be5089..4e0affe 100644 --- a/Connector.h +++ b/Connector.h @@ -17,6 +17,6 @@ public: const char *postData = NULL, const std::vector *customHeaders = NULL, const std::string *lpString = NULL); - static int _ConnectToPort(std::string ip, int port, char *hl); + static int _ConnectToPort(char *ip, int port); }; #endif // CONNECTOR_H diff --git a/Threader.cpp b/Threader.cpp index 7a469b7..317f00b 100644 --- a/Threader.cpp +++ b/Threader.cpp @@ -8,8 +8,9 @@ std::queue Threader::ipQueue; void Threader::fireThread(std::string ip, void *func(void)) { - std::unique_lock lk(m); - ipQueue.push(ip); + std::unique_lock lk(m); + ipQueue.push(ip); + if(threadId < gThreads) { ++threadId; std::thread workerThread(func); @@ -26,6 +27,6 @@ void Threader::cleanUp() { lk.unlock(); lk.release(); threadId = 0; - std::queue empty = {}; + std::queue empty = {}; std::swap(ipQueue, empty); } diff --git a/externData.h b/externData.h index c9be601..5fe6ff3 100644 --- a/externData.h +++ b/externData.h @@ -21,7 +21,6 @@ extern QJsonArray *jsonArr; extern unsigned long long gTargetsOverall; -extern char top_level_domain[128]; extern volatile int cons, BrutingThrds, gThreads; extern char **loginLst, **passLst, **wfLoginLst, **wfPassLst, **sshlpLst, **GlobalNegatives; extern bool trackerOK, __savingBackUpFile, globalScanFlag, MapWidgetOpened, @@ -40,7 +39,7 @@ extern int found, indexIP, gMode, extern unsigned int Activity; extern char trcSrv[256], trcScr[256], trcProxy[128], trcPersKey[64], trcPort[32], trcSrvPortLine[32], saveEndIP[128], - gRange[128], gFirstDom[128], gPorts[65536], + gRange[128], gTLD[128], gPorts[65536], gProxyIP[64], gProxyPort[8], currentIP[MAX_ADDR_LEN], finalIP[32]; diff --git a/finder.cpp b/finder.cpp index 93efd2f..f88af39 100644 --- a/finder.cpp +++ b/finder.cpp @@ -346,12 +346,12 @@ int sharedDetector(const char * ip, int port, const char *buffcpy) { } // 500 < 1600 -int _mainFinderFirst(const char *buffcpy, int f, int port, const char *ip) +int _mainFinderFirst(const char *buffcpy, int f, int port, const char *ip, int sz) { int flag = sharedDetector(ip, port, buffcpy); if(flag != -2) return flag; - if(f) return 7; + if(sz > 180000) return 2; return 0; } @@ -365,7 +365,7 @@ int _mainFinderSecond(const char *buffcpy, int port, const char *ip) return 3; //Suspicious } -int ContentFilter(const char *buff, int port, const char *ip, char *cp) +int ContentFilter(const char *buff, int port, const char *ip, char *cp, int sz) { if(buff != NULL) { @@ -384,8 +384,7 @@ int ContentFilter(const char *buff, int port, const char *ip, char *cp) tempString = toLowerStr(buff); #endif }; - - int sz = tempString.size(); + char *lBuff = new char[sz + 1]; ZeroMemory(lBuff, sz + 1); strcpy(lBuff, tempString.c_str()); @@ -393,11 +392,11 @@ int ContentFilter(const char *buff, int port, const char *ip, char *cp) if(sz <= 500) { - res = _mainFinderFirst(lBuff, 1, port, ip); + res = _mainFinderFirst(lBuff, 1, port, ip, sz); } else if((sz > 500 && sz <= 3500) || sz > 180000) { - res = _mainFinderFirst(lBuff, 0, port, ip); + res = _mainFinderFirst(lBuff, 0, port, ip, sz); } else if(sz > 3500 && sz <= 180000) { @@ -410,7 +409,7 @@ int ContentFilter(const char *buff, int port, const char *ip, char *cp) else return -1; } -void fillGlobalLogData(const char *ip, char *hostname, char *port, const char *sz, char *title, +void fillGlobalLogData(const char *ip, char *port, const char *sz, char *title, const char *login, const char *pass, char *comment, char *cdpg, char *clss) { if(trackerOK == true) @@ -425,7 +424,7 @@ void fillGlobalLogData(const char *ip, char *hostname, char *port, const char *s if(strlen(ip) > 0) jsonData.insert("ip_addr", QJsonValue(QString(ip)) ); else jsonData.insert("ip_addr", QJsonValue(QString("")) ); - jsonData.insert("hostname", QJsonValue(QString(hostname)) ); + jsonData.insert("hostname", QJsonValue(QString("")) ); } else { @@ -680,7 +679,7 @@ void fputsf(char *text, int flag, char *msg) }; } -void putInFile(int flag, const char *ip, char *port, int recd, char *finalstr, char *hl, char *cp) +void putInFile(int flag, const char *ip, char *port, int size, char *finalstr, char *cp) { char log[4096] = {0}, msg[512] = {0}; @@ -719,34 +718,34 @@ void putInFile(int flag, const char *ip, char *port, int recd, char *finalstr, c stt->doEmitionFoundData(resMes); sprintf(log, "%s:%s; Received: %d", - ip, port, ip, port, recd); + ip, port, ip, port, size); if(flag == 666 || flag == 350) { - fillGlobalLogData(ip, hl, port, std::to_string(recd).c_str(), finalstr, "", "", "", cp, "Strange error"); + fillGlobalLogData(ip, port, std::to_string(size).c_str(), finalstr, "", "", "", cp, "Strange error"); ++PieAnomC1; ++AnomC1; } else if(flag == 0 || flag == 15 || flag == -10) { - fillGlobalLogData(ip, hl, port, std::to_string(recd).c_str(), finalstr, "", "", "", cp, "Anomaly"); + fillGlobalLogData(ip, port, std::to_string(size).c_str(), finalstr, "", "", "", cp, "Anomaly"); ++PieAnomC1; ++AnomC1; } else if(flag == 3) { - fillGlobalLogData(ip, hl, port, std::to_string(recd).c_str(), finalstr, "", "", "", cp, "Suspicious"); + fillGlobalLogData(ip, port, std::to_string(size).c_str(), finalstr, "", "", "", cp, "Suspicious"); ++PieSusp; ++Susp; } else if(flag == 7) { - fillGlobalLogData(ip, hl, port, std::to_string(recd).c_str(), finalstr, "", "", "", cp, "Low load"); + fillGlobalLogData(ip, port, std::to_string(size).c_str(), finalstr, "", "", "", cp, "Low load"); ++PieLowl; } else if(flag == 10) { - fillGlobalLogData(ip, hl, port, std::to_string(recd).c_str(), finalstr, "", "", "", cp, "Login form"); + fillGlobalLogData(ip, port, std::to_string(size).c_str(), finalstr, "", "", "", cp, "Login form"); ++PieWF; }; @@ -994,7 +993,7 @@ void _getInputVal(std::vector inputVec, char *buff, char *key) }; } -void _specWFBrute(const char *ip, int port, char *hl, const char *buff, int flag, char *path, char *comment, char *tclass, char *cp, int recd, char *title) +void _specWFBrute(const char *ip, int port, const char *buff, int flag, char *path, char *comment, char *tclass, char *cp, int size, char *title) { if(strstr(buff, "VER_CODE") != NULL || strstri(buff, "captcha") != NULL) { @@ -1075,15 +1074,15 @@ void _specWFBrute(const char *ip, int port, char *hl, const char *buff, int flag else { if(gNegDebugMode) stt->doEmitionFoundData("" + QString(ip) + ":" + QString::number(port) + " - [WF]: No text/password fields found."); - ///fillGlobalLogData(ip, hl, tport, std::to_string(recd).c_str(), title, "NULL", "NULL", comment, cp, tclass); - ///putInFile(flag, ip, tport, recd, title, hl, cp); + ///fillGlobalLogData(ip, tport, std::to_string(size).c_str(), title, "NULL", "NULL", comment, cp, tclass); + ///putInFile(flag, ip, tport, size, title, cp); }; } else { stt->doEmitionFoundData("" + QString(ip) + ":" + QString::number(port) + " - [WF]: Cannot find form block."); - fillGlobalLogData(ip, hl, tport, std::to_string(recd).c_str(), title, "NULL", "NULL", comment, cp, tclass); - putInFile(flag, ip, tport, recd, title, hl, cp); + fillGlobalLogData(ip, tport, std::to_string(size).c_str(), title, "NULL", "NULL", comment, cp, tclass); + putInFile(flag, ip, tport, size, title, cp); }; if(strlen(methodVal) == 0) @@ -1150,20 +1149,20 @@ void _specWFBrute(const char *ip, int port, char *hl, const char *buff, int flag { _specFillerWF(ip, tport, title, lps.login, lps.pass, flag); - fillGlobalLogData(ip, hl, tport, std::to_string(recd).c_str(), title, lps.login, lps.pass, comment, cp, tclass); - putInFile(flag, ip, tport, recd, title, hl, cp); + fillGlobalLogData(ip, tport, std::to_string(size).c_str(), title, lps.login, lps.pass, comment, cp, tclass); + putInFile(flag, ip, tport, size, title, cp); }; } else { if(gNegDebugMode) stt->doEmitionFoundData("" + QString(ip) + ":" + QString::number(port) + " - [WF]: Cannot find user/pass field."); - ///fillGlobalLogData(ip, hl, tport, std::to_string(recd).c_str(), title, "", "", "UnknownWebform", cp, tclass); - ///putInFile(flag, ip, tport, recd, title, hl, cp); + ///fillGlobalLogData(ip, tport, std::to_string(size).c_str(), title, "", "", "UnknownWebform", cp, tclass); + ///putInFile(flag, ip, tport, size, title, cp); }; }; } -void _specWEBIPCAMBrute(const char *ip, int port, char *hl, char *finalstr, int flag, char *comment, char *cp, int recd, char *SPEC) +void _specWEBIPCAMBrute(const char *ip, int port, char *finalstr, int flag, char *comment, char *cp, int size, char *SPEC) { lopaStr lps; ZeroMemory(lps.login, sizeof(lps.login)); @@ -1178,13 +1177,13 @@ void _specWEBIPCAMBrute(const char *ip, int port, char *hl, char *finalstr, int { _specFillerBA(ip, tport, finalstr, lps.login, lps.pass, flag); - fillGlobalLogData(ip, hl, tport, std::to_string(recd).c_str(), finalstr, lps.login, lps.pass, comment, cp, "Basic Authorization"); + fillGlobalLogData(ip, tport, std::to_string(size).c_str(), finalstr, lps.login, lps.pass, comment, cp, "Basic Authorization"); }; } void _specBrute(const char *ip, int port, - char *hl, char *finalstr, int flag, - char *path, char *comment, char *cp, int recd) + char *finalstr, int flag, + char *path, char *comment, char *cp, int size) { char temp[64] = {0}; char tport[32] = {0}; @@ -1196,7 +1195,7 @@ void _specBrute(const char *ip, int port, { _specFillerBA(ip, tport, finalstr, lps.login, lps.pass, flag); - fillGlobalLogData(ip, hl, tport, std::to_string(recd).c_str(), finalstr, lps.login, lps.pass, comment, cp, "Basic Authorization"); + fillGlobalLogData(ip, tport, std::to_string(size).c_str(), finalstr, lps.login, lps.pass, comment, cp, "Basic Authorization"); }; ZeroMemory(temp, sizeof(temp)); @@ -1318,7 +1317,7 @@ const char *GetTitle(const char* str) return finalstr; } -void _saveSSH(const char *ip, int port, int recd, const char *buffcpy) +void _saveSSH(const char *ip, int port, int size, const char *buffcpy) { if(buffcpy != NULL) { @@ -1349,7 +1348,7 @@ void _saveSSH(const char *ip, int port, int recd, const char *buffcpy) const char *ptrl2 = strstr(buffcpy, "@"); lpsz = ptrl2 - ptrl1; strncpy(passSSH, ptrl1 + 1, lpsz); - fillGlobalLogData(ip, "", portString, std::to_string(recd).c_str(), "[SSH service]", loginSSH, passSSH, "NULL", "UTF-8", "SSH"); + fillGlobalLogData(ip, portString, std::to_string(size).c_str(), "[SSH service]", loginSSH, passSSH, "NULL", "UTF-8", "SSH"); stt->doEmitionFoundData(QString::fromLocal8Bit(logEmit)); } else @@ -1363,20 +1362,20 @@ void _saveSSH(const char *ip, int port, int recd, const char *buffcpy) }; } -int Lexems::_filler(int p, const char* buffcpy, char* ip, int recd, Lexems *lx, char *hl) +int Lexems::_filler(int p, const char* buffcpy, char* ip, int size, Lexems *lx) { if( strstr(buffcpy, "SSH-2.0-OpenSSH") != NULL || strstr(buffcpy, "SSH-2.0-mod_sftp") != NULL) { std::string sshBuff; int res = SSHAuth::SSHLobby(ip, p, &sshBuff); - if(res != -1 && res != -2) _saveSSH(ip, p, recd, (char*)sshBuff.c_str()); + if(res != -1 && res != -2) _saveSSH(ip, p, size, (char*)sshBuff.c_str()); return -1; }; if(p == 22) { - _saveSSH(ip, p, recd, buffcpy); + _saveSSH(ip, p, size, buffcpy); return -1; }; @@ -1392,7 +1391,7 @@ int Lexems::_filler(int p, const char* buffcpy, char* ip, int recd, Lexems *lx, char cp[32] = {0}; strcpy(cp, GetCodePage(buffcpy)); - flag = ContentFilter(buffcpy, p, ip, cp); + flag = ContentFilter(buffcpy, p, ip, cp, size); if(flag == -1 ) return -1; strcpy(ps.headr, GetTitle(buffcpy)); @@ -1404,7 +1403,7 @@ int Lexems::_filler(int p, const char* buffcpy, char* ip, int recd, Lexems *lx, std::vector redirStrLst; if(flag == 0 || flag == 3 || flag == 7 ) { - int rh = _header(ip, p, buffcpy, lx, &ps, &redirStrLst); + int rh = _header(ip, p, buffcpy, lx, &ps, &redirStrLst, size); strcpy(cp, ps.codepage); if (rh == -1) { return -1; @@ -1440,13 +1439,13 @@ int Lexems::_filler(int p, const char* buffcpy, char* ip, int recd, Lexems *lx, ++PieBA; sprintf(log, "[FTP]:%s:%s; Received: %dftp://%s:%s@%s [ROUTER]%s", - ip, port, recd, lps.login, lps.pass, ip, lps.login, lps.pass, ip, ip, ps.headr); + ip, port, size, lps.login, lps.pass, ip, lps.login, lps.pass, ip, ip, ps.headr); sprintf(logEmit, "[FTP]:ftp://%s:%s@%s [ROUTER]", lps.login, lps.pass, ip, lps.login, lps.pass, ip, ip); fputsf (log, flag, "FTP"); - fillGlobalLogData(ip, hl, port, std::to_string(recd).c_str(), "[FTP service]", lps.login, lps.pass, "Router FTP detected.", cp, "FTP"); + fillGlobalLogData(ip, port, std::to_string(size).c_str(), "[FTP service]", lps.login, lps.pass, "Router FTP detected.", cp, "FTP"); stt->doEmitionFoundData(QString::fromLocal8Bit(logEmit)); } @@ -1455,13 +1454,13 @@ int Lexems::_filler(int p, const char* buffcpy, char* ip, int recd, Lexems *lx, ++PieBA; sprintf(log, "[FTP]:%s:%s; Received: %dftp://%s:%s@%s%s", - ip, port, recd, lps.login, lps.pass, ip, lps.login, lps.pass, ip, ps.headr); + ip, port, size, lps.login, lps.pass, ip, lps.login, lps.pass, ip, ps.headr); sprintf(logEmit, "[FTP]:ftp://%s:%s@%s (F:%d)", lps.login, lps.pass, ip, lps.login, lps.pass, ip, ps.directoryCount); fputsf(log, flag, "FTP"); - fillGlobalLogData(ip, hl, port, std::to_string(recd).c_str(), "[FTP service]", lps.login, lps.pass, "NULL", cp, "FTP"); + fillGlobalLogData(ip, port, std::to_string(size).c_str(), "[FTP service]", lps.login, lps.pass, "NULL", cp, "FTP"); stt->doEmitionFoundData(QString::fromLocal8Bit(logEmit)); @@ -1478,155 +1477,155 @@ int Lexems::_filler(int p, const char* buffcpy, char* ip, int recd, Lexems *lx, } else if(flag == 21) //Eyeon { - _specBrute(ip, p, hl, "Eyeon Camera", flag, "/user/index.htm", "Basic Authorization", cp, recd); + _specBrute(ip, p, "Eyeon Camera", flag, "/user/index.htm", "Basic Authorization", cp, size); } else if(flag == 22) //IP Camera control { - _specBrute(ip, p, hl, "IP camera Control webpage", flag, "/main/cs_motion.asp", "Basic Authorization", cp, recd); + _specBrute(ip, p, "IP camera Control webpage", flag, "/main/cs_motion.asp", "Basic Authorization", cp, size); } else if(flag == 23) //Network Camera BB-SC384 { - _specBrute(ip, p, hl, "Network Camera BB-SC384", flag, "/live/index2.html", "Basic Authorization", cp, recd); + _specBrute(ip, p, "Network Camera BB-SC384", flag, "/live/index2.html", "Basic Authorization", cp, size); } else if(flag == 24) //Network Camera VB-M40 { - _specBrute(ip, p, hl, "Network Camera VB-M40", flag, "/-wvhttp-01-/open.cgi?", "Basic Authorization", cp, recd); + _specBrute(ip, p, "Network Camera VB-M40", flag, "/-wvhttp-01-/open.cgi?", "Basic Authorization", cp, size); } else if(flag == 25) //Panasonic WTFISTHISAreaOMGIDONTEVEN-camera { - _specBrute(ip, 60002, hl, "Panasonic WTFISTHISAreaOMGIDONTEVEN-camera", flag, "/SnapshotJPEG", "Basic Authorization", cp, recd); + _specBrute(ip, 60002, "Panasonic WTFISTHISAreaOMGIDONTEVEN-camera", flag, "/SnapshotJPEG", "Basic Authorization", cp, size); } else if(flag == 26) //Sony Network Camera { - _specBrute(ip, p, hl, "Sony Network Camera", flag, "/oneshotimage?", "Basic Authorization", cp, recd); + _specBrute(ip, p, "Sony Network Camera", flag, "/oneshotimage?", "Basic Authorization", cp, size); } else if(flag == 27) //UA Network Camera { - _specBrute(ip, p, hl, "UA Network Camera", flag, "/webs.cgi?", "Basic Authorization", cp, recd); + _specBrute(ip, p, "UA Network Camera", flag, "/webs.cgi?", "Basic Authorization", cp, size); } else if(flag == 28) //Network Camera VB-M40 { - _specBrute(ip, p, hl, "Network Camera VB-??", flag, "/-wvhttp-01-/open.cgi?", "Basic Authorization", cp, recd); + _specBrute(ip, p, "Network Camera VB-??", flag, "/-wvhttp-01-/open.cgi?", "Basic Authorization", cp, size); } else if(flag == 29) //LG Smart IP Device { - _specBrute(ip, p, hl, "LG Smart IP Device Camera", flag, "/digest.php", "Basic Authorization", cp, recd); + _specBrute(ip, p, "LG Smart IP Device Camera", flag, "/digest.php", "Basic Authorization", cp, size); } else if(flag == 30) //NAS { - _specBrute(ip, p, hl, "NAS", flag, "/cgi-bin/data/viostor-220/viostor/viostor.cgi", "Basic Authorization", cp, recd); + _specBrute(ip, p, "NAS", flag, "/cgi-bin/data/viostor-220/viostor/viostor.cgi", "Basic Authorization", cp, size); } else if(flag == 31) //ip cam { - _specBrute(ip, p, hl, "IP Camera", flag, "/check_user.cgi", "Basic Authorization", cp, recd); + _specBrute(ip, p, "IP Camera", flag, "/check_user.cgi", "Basic Authorization", cp, size); } else if(flag == 32) //IPC WEB ip cam { - _specWEBIPCAMBrute(ip, p, hl, "[IPC] WEB IP Camera", flag, "WEB Authorization", cp, recd, "IPC"); + _specWEBIPCAMBrute(ip, p, "[IPC] WEB IP Camera", flag, "WEB Authorization", cp, size, "IPC"); } else if(flag == 33) //GEOvision ip cam { - _specWEBIPCAMBrute(ip, p, hl, "[GEO] WEB IP Camera", flag, "WEB Authorization", cp, recd, "GEO"); + _specWEBIPCAMBrute(ip, p, "[GEO] WEB IP Camera", flag, "WEB Authorization", cp, size, "GEO"); } else if(flag == 34) //Hikvision ip cam { - _specBrute(ip, p, hl, "[Hikvision] IP Camera", flag, "/PSIA/Custom/SelfExt/userCheck", "Basic Authorization", cp, recd); + _specBrute(ip, p, "[Hikvision] IP Camera", flag, "/PSIA/Custom/SelfExt/userCheck", "Basic Authorization", cp, size); } else if(flag == 35) //EasyCam { - _specWEBIPCAMBrute(ip, p, hl, "[EasyCam] WEB IP Camera", flag, "WEB Authorization", cp, recd, "EasyCam"); + _specWEBIPCAMBrute(ip, p, "[EasyCam] WEB IP Camera", flag, "WEB Authorization", cp, size, "EasyCam"); } else if(flag == 36) //Panasonic Cam { - _specBrute(ip, p, hl, "[Panasonic] IP Camera", flag, "/config/index.cgi", "Basic Authorization", cp, recd); + _specBrute(ip, p, "[Panasonic] IP Camera", flag, "/config/index.cgi", "Basic Authorization", cp, size); } else if(flag == 37) //Panasonic Cam { - _specBrute(ip, p, hl, "[Panasonic] IP Camera", flag, "/view/getuid.cgi", "Basic Authorization", cp, recd); + _specBrute(ip, p, "[Panasonic] IP Camera", flag, "/view/getuid.cgi", "Basic Authorization", cp, size); } else if(flag == 38) //Foscam { - _specWEBIPCAMBrute(ip, p, hl, "[Foscam] IP Camera", flag, "Web Authorization", cp, recd, "Foscam"); + _specWEBIPCAMBrute(ip, p, "[Foscam] IP Camera", flag, "Web Authorization", cp, size, "Foscam"); } else if(flag == 39) //EagleEye { - _specBrute(ip, p, hl, "[EagleEye] IP Camera", flag, "/cgi-bin/guest/Video.cgi?", "Basic Authorization", cp, recd); + _specBrute(ip, p, "[EagleEye] IP Camera", flag, "/cgi-bin/guest/Video.cgi?", "Basic Authorization", cp, size); } else if(flag == 40) //Network Camera VB-C?? { - _specBrute(ip, p, hl, "[Network Camera VB-C??] IP Camera", flag, "/admin/index.shtml?", "Basic Authorization", cp, recd); + _specBrute(ip, p, "[Network Camera VB-C??] IP Camera", flag, "/admin/index.shtml?", "Basic Authorization", cp, size); } else if(flag == 41) //AVIOSYS-camera { - _specWEBIPCAMBrute(ip, p, hl, "[AVIOSYS] IP Camera", flag, "Web Authorization", cp, recd, "AVIOSYS"); + _specWEBIPCAMBrute(ip, p, "[AVIOSYS] IP Camera", flag, "Web Authorization", cp, size, "AVIOSYS"); } else if(flag == 42) //NW_camera { - _specBrute(ip, p, hl, "[NW_camera] IP Camera", flag, "/cgi-bin/getuid?FILE=indexnw.html", "Basic Authorization", cp, recd); + _specBrute(ip, p, "[NW_camera] IP Camera", flag, "/cgi-bin/getuid?FILE=indexnw.html", "Basic Authorization", cp, size); } else if(flag == 43) //NW_camera { - _specBrute(ip, p, hl, "[Micros] IP Camera", flag, "/gui/rem_display.shtml", "Basic Authorization", cp, recd); + _specBrute(ip, p, "[Micros] IP Camera", flag, "/gui/rem_display.shtml", "Basic Authorization", cp, size); } else if(flag == 44) //Hikvision ip cam 2 { - _specBrute(ip, p, hl, "[Hikvision] IP Camera 2", flag, "/ISAPI/Security/userCheck", "Basic Authorization", cp, recd); + _specBrute(ip, p, "[Hikvision] IP Camera 2", flag, "/ISAPI/Security/userCheck", "Basic Authorization", cp, size); } else if(flag == 45) //Panasonic ip cam { - _specBrute(ip, p, hl, "[Panasonic] IP Camera", flag, "/config/index.cgi", "Basic Authorization", cp, recd); + _specBrute(ip, p, "[Panasonic] IP Camera", flag, "/config/index.cgi", "Basic Authorization", cp, size); } else if(flag == 46) //Buffalo disk { - _specWEBIPCAMBrute(ip, p, hl, "[Buffalo] Lan Disk", flag, "Web Authorization", cp, recd, "BUFFALO"); + _specWEBIPCAMBrute(ip, p, "[Buffalo] Lan Disk", flag, "Web Authorization", cp, size, "BUFFALO"); } else if(flag == 47) //Digital Video Server { - _specWEBIPCAMBrute(ip, p, hl, "[DVS] Camera", flag, "Web Authorization", cp, recd, "DVS"); + _specWEBIPCAMBrute(ip, p, "[DVS] Camera", flag, "Web Authorization", cp, size, "DVS"); } else if(flag == 48) //ipCAM { - _specWEBIPCAMBrute(ip, p, hl, "[ipCAM] Camera", flag, "Web Authorization", cp, recd, "IPCAM"); + _specWEBIPCAMBrute(ip, p, "[ipCAM] Camera", flag, "Web Authorization", cp, size, "IPCAM"); } else if (flag == 49) //IEORFOREFOX { - _specWEBIPCAMBrute(ip, p, hl, "[IEORFOREFOX] Camera", flag, "Web Authorization", cp, recd, "IEORFOREFOX"); + _specWEBIPCAMBrute(ip, p, "[IEORFOREFOX] Camera", flag, "Web Authorization", cp, size, "IEORFOREFOX"); } else if (flag == 50) //IP Camera { - _specBrute(ip, p, hl, "IP Camera", flag, "/app/multi/single.asp", "Basic Authorization", cp, recd); + _specBrute(ip, p, "IP Camera", flag, "/app/multi/single.asp", "Basic Authorization", cp, size); } else if(flag == 20) //AXIS Camera { - _specBrute(ip, p, hl, "AXIS Camera", flag, "/axis-cgi/com/ptz.cgi?", "Basic Authorization", cp, recd); + _specBrute(ip, p, "AXIS Camera", flag, "/axis-cgi/com/ptz.cgi?", "Basic Authorization", cp, size); } else if(flag == 19) //reecam cameras { - _specBrute(ip, p, hl, "Reecam (network camera)", flag, "/videostream.cgi", "Basic Authorization", cp, recd); + _specBrute(ip, p, "Reecam (network camera)", flag, "/videostream.cgi", "Basic Authorization", cp, size); } else if(flag == 18) //linksys camera { - _specBrute(ip, p, hl, "Linksys camera", flag, "/img/main.cgi", "Basic Authorization", cp, recd); + _specBrute(ip, p, "Linksys camera", flag, "/img/main.cgi", "Basic Authorization", cp, size); } else if(flag == 17) //Real-time IP Camera Monitoring System { - _specBrute(ip, p, hl, "Real-time IP Camera Monitoring System", flag, "/live.htm", "Basic Authorization", cp, recd); + _specBrute(ip, p, "Real-time IP Camera Monitoring System", flag, "/live.htm", "Basic Authorization", cp, size); } else if(flag == 11) { - _specBrute(ip, p, hl, "Netwave IP Camera", flag, "/videostream.cgi", "Basic Authorization", cp, recd); + _specBrute(ip, p, "Netwave IP Camera", flag, "/videostream.cgi", "Basic Authorization", cp, size); } else if(flag == 12) { - _specBrute(ip, p, hl, "IP Camera", flag, "/view/view.shtml?videos=", "Basic Authorization", cp, recd); + _specBrute(ip, p, "IP Camera", flag, "/view/view.shtml?videos=", "Basic Authorization", cp, size); } else if(flag == 13) { - _specBrute(ip, p, hl, "IP Camera", flag, "/eng/view/indexjava.html", "Basic Authorization", cp, recd); + _specBrute(ip, p, "IP Camera", flag, "/eng/view/indexjava.html", "Basic Authorization", cp, size); } else if(flag == 14) { - _specBrute(ip, p, hl, "IP Camera", flag, "/rdr.cgi", "Basic Authorization", cp, recd); + _specBrute(ip, p, "IP Camera", flag, "/rdr.cgi", "Basic Authorization", cp, size); } else if(flag == 15) //For HFS { @@ -1634,28 +1633,32 @@ int Lexems::_filler(int p, const char* buffcpy, char* ip, int recd, Lexems *lx, ++AnomC1; const lopaStr &lps = BA::BALobby((string(ip) + "/~login").c_str(), p); - sprintf(log, "[HFS]:%s :: %s:%s T: %s Pass: %s:%s", - hl, ip, port, ip, port, finalstr, lps.login, lps.pass); + sprintf(log, "[HFS]:%s:%s T: %s Pass: %s:%s", + ip, port, ip, port, finalstr, lps.login, lps.pass); - fillGlobalLogData(ip, hl, port, std::to_string(recd).c_str(), finalstr, lps.login, lps.pass, "HFS-FTP", cp, "Basic Authorization"); + fillGlobalLogData(ip, port, std::to_string(size).c_str(), finalstr, lps.login, lps.pass, "HFS-FTP", cp, "Basic Authorization"); fputsf (log , flag, "HFS"); stt->doEmitionFoundData(QString::fromLocal8Bit(log)); } else if(flag == 1) { - _specBrute(ip, p, hl, finalstr, flag, baPath, "[NORMAL]", cp, recd); + _specBrute(ip, p, finalstr, flag, baPath, "[NORMAL]", cp, size); } else if(flag == 101) { - _specBrute(ip, p, hl, finalstr, flag, baPath, "[DIGEST]", cp, recd); + _specBrute(ip, p, finalstr, flag, baPath, "[DIGEST]", cp, size); } else if(flag == 10) { - _specWFBrute(ip, p, hl, buffcpy, flag, baPath, "Web Form", "Web Form", cp, recd, finalstr); + _specWFBrute(ip, p, buffcpy, flag, baPath, "Web Form", "Web Form", cp, size, finalstr); } + else if(flag == 2) + { + putInFile(0, ip, port, size, "[OVERFLOW]", cp); + } else { - putInFile(flag, ip, port, recd, finalstr, hl, cp); + putInFile(flag, ip, port, size, finalstr, cp); }; return flag; @@ -1738,7 +1741,7 @@ int redirectReconnect(char *ip, int port, char *str, Lexems *ls, PathStr *ps, st { strcpy(ps->codepage, GetCodePage(buffer.c_str())); - ls->flag = ContentFilter(buffer.c_str(), tempPort, tempIP, ps->codepage); + ls->flag = ContentFilter(buffer.c_str(), tempPort, tempIP, ps->codepage, cSz); ps->flag = ls->flag; if(ls->flag == -1) @@ -1771,7 +1774,7 @@ int redirectReconnect(char *ip, int port, char *str, Lexems *ls, PathStr *ps, st strcat(ps->headr, " -> "); strcat(ps->headr, GetTitle(buffer.c_str())); - if (ls->_header(tempIP, tempPort, buffer.c_str(), ls, ps, redirStrLst) == -1) + if (ls->_header(tempIP, tempPort, buffer.c_str(), ls, ps, redirStrLst, cSz) == -1) { ps->flag = -1; strcpy(ps->path, tempPath); @@ -1855,7 +1858,7 @@ int redirectReconnect(char *ip, int port, char *str, Lexems *ls, PathStr *ps, st { strcpy(ps->codepage, GetCodePage(buffer.c_str())); - ls->flag = ContentFilter(buffer.c_str(), tempPort, tempIP, ps->codepage); + ls->flag = ContentFilter(buffer.c_str(), tempPort, tempIP, ps->codepage, cSz); ps->flag = ls->flag; if(ls->flag == -1) @@ -1888,7 +1891,7 @@ int redirectReconnect(char *ip, int port, char *str, Lexems *ls, PathStr *ps, st strcat(ps->headr, " -> "); strcat(ps->headr, GetTitle(buffer.c_str())); - if (ls->_header(tempIP, tempPort, buffer.c_str(), ls, ps, redirStrLst) == -1) + if (ls->_header(tempIP, tempPort, buffer.c_str(), ls, ps, redirStrLst, cSz) == -1) { ps->flag = -1; strcpy(ps->path, tempPath); @@ -1923,7 +1926,7 @@ int redirectReconnect(char *ip, int port, char *str, Lexems *ls, PathStr *ps, st { strcpy(ps->codepage, GetCodePage(buffer.c_str())); - ls->flag = ContentFilter(buffer.c_str(), port, ip, ps->codepage); + ls->flag = ContentFilter(buffer.c_str(), port, ip, ps->codepage, cSz); ps->flag = ls->flag; if(ls->flag == -1) @@ -1955,7 +1958,7 @@ int redirectReconnect(char *ip, int port, char *str, Lexems *ls, PathStr *ps, st strcat(ps->headr, "->"); strcat(ps->headr, GetTitle(buffer.c_str())); - if (ls->_header(tempIP, tempPort, buffer.c_str(), ls, ps, redirStrLst) == -1) + if (ls->_header(tempIP, tempPort, buffer.c_str(), ls, ps, redirStrLst, cSz) == -1) { ps->flag = -1; strcpy(ps->path, tempPath); @@ -1985,7 +1988,7 @@ int redirectReconnect(char *ip, int port, char *str, Lexems *ls, PathStr *ps, st { strcpy(ps->codepage, GetCodePage(buffer.c_str())); - ls->flag = ContentFilter(buffer.c_str(), port, ip, ps->codepage); + ls->flag = ContentFilter(buffer.c_str(), port, ip, ps->codepage, cSz); ps->flag = ls->flag; if(ls->flag == -1) @@ -2017,7 +2020,7 @@ int redirectReconnect(char *ip, int port, char *str, Lexems *ls, PathStr *ps, st strcat(ps->headr, " -> "); strcat(ps->headr, GetTitle(buffer.c_str())); - ls->_header(ip, port, buffer.c_str(), ls, ps, redirStrLst); + ls->_header(ip, port, buffer.c_str(), ls, ps, redirStrLst, cSz); ps->port = tempPort; } else @@ -2157,7 +2160,7 @@ void _getLinkFromJSLocation(char *dataBuff, char *str, char *tag, char *ip, int }; } -int Lexems::_header(char *ip, int port, const char str[], Lexems *l, PathStr *ps, std::vector *redirStrLst) +int Lexems::_header(char *ip, int port, const char str[], Lexems *l, PathStr *ps, std::vector *redirStrLst, int size) { std::string redirectStr = ""; @@ -2618,7 +2621,7 @@ int Lexems::_header(char *ip, int port, const char str[], Lexems *l, PathStr *ps }; }; - ps->flag = ContentFilter(str, port, ip, ps->codepage); + ps->flag = ContentFilter(str, port, ip, ps->codepage, size); if(strstri(str, "window.open(") != NULL) { diff --git a/mainResources.h b/mainResources.h index c707d39..db40366 100644 --- a/mainResources.h +++ b/mainResources.h @@ -107,12 +107,6 @@ struct lopaStr{ char other[128]; }; -struct conSTR{ - char *lowerBuff; - int size; - bool overflow = false; -}; - class Lexems { public: @@ -129,19 +123,18 @@ public: iterationCount = 0; } - int _header(char *ip, - int port, - const char str[], - Lexems *l, - PathStr *ps, - std::vector *lst); + int _header(char *ip, + int port, + const char str[], + Lexems *l, + PathStr *ps, + std::vector *lst, int size); - int _filler(int port, - const char *buffcpy, - char* ip, - int recd, - Lexems *lx, - char *hl); + int _filler(int port, + const char *buffcpy, + char* ip, + int size, + Lexems *lx); }; diff --git a/nesca.pro.user b/nesca.pro.user index 9d0b304..6e94c04 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 14fcde7..ae2e422 100644 --- a/nesca_3.cpp +++ b/nesca_3.cpp @@ -1919,7 +1919,8 @@ void nesca_3::IPScanSeq() if(ui->portLine->text() != "") { saveOptions(); - ui->labelParsed_Value->setText("0/0"); + ui->labelParsed_Value->setText("0/0"); + ui->labelOffline_Value->setText("0"); stopFirst = false; ui->tabMainWidget->setTabEnabled(1, false); ui->tabMainWidget->setTabEnabled(2, false); @@ -2004,6 +2005,7 @@ void nesca_3::DNSScanSeq() { saveOptions(); ui->labelParsed_Value->setText("0/0"); + ui->labelOffline_Value->setText("0"); if(ui->lineEditStartIPDNS->text().indexOf(".") > 0) { QStringList lst = ui->lineEditStartIPDNS->text().split("."); @@ -2063,6 +2065,9 @@ void nesca_3::ImportScanSeq() ui->tabMainWidget->setTabEnabled(0, false); ui->tabMainWidget->setTabEnabled(1, false); + ui->labelParsed_Value->setText("0/0"); + ui->labelOffline_Value->setText("0"); + strcpy(inputStr, ("DUMMY|-f|" + fileName + "|" + ui->importThreads->text() + "|-p" + ui->importPorts->text().replace(" ", "")).toLocal8Bit().data()); globalScanFlag = true; @@ -2292,8 +2297,10 @@ void nesca_3::ConnectEvrthng() } void _LoadPersInfoToLocalVars(int savedTabIndex) { - ZeroMemory(top_level_domain, sizeof(top_level_domain)); + ZeroMemory(currentIP, sizeof(currentIP)); + ZeroMemory(finalIP, sizeof(finalIP)); ZeroMemory(gPorts, sizeof(gPorts)); + ZeroMemory(gTLD, sizeof(gTLD)); if(savedTabIndex == 0) { @@ -2328,9 +2335,15 @@ void _LoadPersInfoToLocalVars(int savedTabIndex) { gThreads = ui->lineEditThread->text().toInt(); strcpy(currentIP, ui->lineEditStartIPDNS->text().toLocal8Bit().data()); - strcpy(top_level_domain, ui->lineILVL->text().toLocal8Bit().data()); + strcpy(gTLD, ui->lineILVL->text().toLocal8Bit().data()); strncpy(gPorts, ("-p" + ui->lineEditPort->text()).toLocal8Bit().data(), 65536); gPorts[ui->lineEditPort->text().length() + 2] = '\0'; + } + else if(savedTabIndex == 2) + { + gMode = -1; + gThreads = ui->importThreads->text().toInt(); + strncpy(gPorts, ("-p" + ui->importPorts->text()).toLocal8Bit().data(), 65536); }; strcpy(trcSrv, ui->lineTrackerSrv->text().toLocal8Bit().data()); @@ -2374,6 +2387,9 @@ void setUIText(char *field, QLineEdit *qle, const char *resStr) { } void RestoreSession() { + ZeroMemory(gPorts, sizeof(gPorts)); + ZeroMemory(gTLD, sizeof(gTLD)); + FILE *resFile = fopen("restore", "r"); char resStr[128] = {0}; char *lex; @@ -2431,13 +2447,14 @@ void RestoreSession() qLex.replace("[09]", "\\d"); ui->lineEditStartIPDNS->setText(qLex); lex = strtok(NULL, " "); - strcpy(gFirstDom, lex); - - lex = strtok(NULL, " "); + if(strstr(lex, ".") != NULL) { + strcpy(gTLD, lex); + lex = strtok(NULL, " "); + } gThreads = atoi(lex); ui->lineEditThread->setText(QString(lex)); - ui->lineILVL->setText(QString(gFirstDom)); + ui->lineILVL->setText(QString(gTLD)); ui->tabMainWidget->setCurrentIndex(1); ui->startScanButton_4->setText("RESTORE"); } diff --git a/nesca_startModule.cpp b/nesca_startModule.cpp index d9c0a95..b2e3a23 100644 --- a/nesca_startModule.cpp +++ b/nesca_startModule.cpp @@ -34,14 +34,13 @@ unsigned int Activity = 0; unsigned char **ipsstartfl = NULL, **ipsendfl = NULL, **starterIP = NULL; double ips = 0; -char top_level_domain[128] = {0}; char **GlobalNegatives = 0; char **loginLst, **passLst; char **wfLoginLst, **wfPassLst; char **sshlpLst; char saveEndIP[128] = {0}; char gRange[128] = {0}; -char gFirstDom[128] = {0}; +char gTLD[128] = {0}; char gPorts[65536] = {0}; char metaRange[256] = {0}; char metaPercent[256] = {0}; @@ -51,6 +50,7 @@ char metaETA[256] = {0}; char metaOffline[256] = {0}; char currentIP[MAX_ADDR_LEN] = {0}; +char currentMask[128] = {0}; char finalIP[32] = {0}; bool ErrLogFirstTime = true; @@ -212,10 +212,10 @@ void _SaveBackupToFile() char endStr[128] = {0}; if(gMode == 0 || gMode == 1) - { + { if(gMode == 1) - { - strcpy(endStr, currentIP); + { + strcpy(endStr, currentMask); } else { @@ -224,7 +224,8 @@ void _SaveBackupToFile() if(strlen(endStr) > 0) { - sprintf(saveStr, "[SESSION]:%d %s %s %d %s\n", gMode, endStr, (gMode ? top_level_domain : ""), gThreads, gPorts); + sprintf(saveStr, "[SESSION]:%d %s %s %d %s\n", + gMode, endStr, gTLD, gThreads, gPorts); strcat(saveBuffer, saveStr); ZeroMemory(saveStr, sizeof(saveStr)); }; @@ -379,8 +380,7 @@ void _timer() { strcat(timeLeft, (strcmp(dbuffer, "1.$d)") == 0 ? "INF)" : dbuffer)); - stt->doEmitionIPS(QString(timeLeft)); - stt->doEmitionOffline(QString::number(offlines)); + stt->doEmitionIPS(QString(timeLeft)); ZeroMemory(timeLeft, sizeof(timeLeft)); ZeroMemory(dbuffer, sizeof(dbuffer)); @@ -564,7 +564,7 @@ void _tracker() { else if(mode == -1) jsonMeta.insert("mode", QJsonValue(QString("Import"))); // jsonMeta.insert("range", QJsonValue(QString(metaRange)) ); jsonMeta.insert("current", QJsonValue(QString(currentIP)) ); - if(mode == 1) jsonMeta.insert("tld", QJsonValue(QString(top_level_domain))); //TLD + if(mode == 1) jsonMeta.insert("tld", QJsonValue(QString(gTLD))); //TLD jsonMeta.insert("targets", QJsonValue(QString(metaTargets)) ); jsonMeta.insert("percent", QJsonValue(QString(metaPercent)) ); jsonMeta.insert("saved", QJsonValue(QString::number(saved)) ); @@ -759,7 +759,8 @@ unsigned long int numOfIps(int ipsstart[], int ipsend[]) { } void _connect() { - std::string ip = ""; + + std::string ip = ""; while (globalScanFlag) { std::unique_lock lk(Threader::m); Threader::cv.wait(lk, []{return Threader::ready; }); @@ -772,25 +773,26 @@ void _connect() { } if (!Threader::ipQueue.empty()) { - ip = Threader::ipQueue.front(); + ip = Threader::ipQueue.front(); Threader::ipQueue.pop(); Threader::ready = false; lk.unlock(); - if (ip.size() == 0) return; - - ConInc(); + ConInc(); for (int i = 0; i <= overallPorts; ++i) { if (!globalScanFlag) break; - if (Connector::_ConnectToPort(ip, portArr[i], "") == -2) break; + if (Connector::_ConnectToPort((char*)ip.c_str(), portArr[i]) == -2) break; }; ConDec(); } } } -inline void progressOutput(unsigned long target) { +void verboseProgress(unsigned long target) { + + stt->doEmitionIPRANGE(QString(currentIP)); + char targetNPers[128] = {0}; float percent = (gTargetsOverall != 0 ? (100 - target/(double)gTargetsOverall * 100) : 0); @@ -801,18 +803,6 @@ inline void progressOutput(unsigned long target) { sprintf(metaPercent, "%.1f", percent); } -void verboseProgress(unsigned long target, const char *ip) { - - stt->doEmitionIPRANGE(QString(ip)); - strcpy(currentIP, ip); - progressOutput(target); -} -void verboseProgressDNS(unsigned long target, const char *ip, const char *TLD, const char *mask) { - - stt->doEmitionIPRANGE(QString(ip) + QString(TLD)); - strcpy(currentIP, mask); - progressOutput(target); -} #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) unsigned char* ASCIItoUNICODE (unsigned char ch) @@ -1511,29 +1501,9 @@ int ParseArgs(int argc, char *argv[]) { 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; - }; + { + FileLoader(argv[2]); + } if(gMode == 0) { @@ -1567,7 +1537,6 @@ int ParseArgs(int argc, char *argv[]) { strcpy(gRange, argv[2]); strcpy(saveEndIP, gRange); }; - }; for(int i = 1; i <= argc - 1; i++) @@ -1670,9 +1639,9 @@ int ParseArgs(int argc, char *argv[]) { return 0; } -char charAll[38] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', +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', '_', '-'}; + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}; int _getPos(char l) { for(int i = 0; i < 38; ++i) @@ -1748,17 +1717,15 @@ int _GetDNSFromMask(char *mask, char *saveMask, char *saveMaskEnder) { } else { - strcpy(currentIP, saveMask); - + strcpy(currentMask, saveMask); while(cons >= gThreads && globalScanFlag) Sleep(300); if(!globalScanFlag) return 0; - verboseProgressDNS(--gTargets, mask, top_level_domain, saveMask); - std::string res = std::string(mask) + std::string(top_level_domain); + ++indexIP; + sprintf(currentIP, "%s%s", mask, gTLD); + verboseProgress(--gTargets); - ++indexIP; - - Threader::fireThread(res, (void*(*)(void))_connect); + Threader::fireThread(currentIP, (void*(*)(void))_connect); }; } @@ -1767,12 +1734,13 @@ void runAuxiliaryThreads() { lpThread.detach(); std::thread fuThread(FileDownloader::checkWebFiles); fuThread.detach(); - std::thread saverThread(_saver); - saverThread.detach(); std::thread trackerThread(_tracker); trackerThread.detach(); std::thread timerThread(_timer); timerThread.detach(); + Sleep(1000); + std::thread saverThread(_saver); + saverThread.detach(); } int startScan(char* args) { @@ -1847,8 +1815,7 @@ int startScan(char* args) { unsigned long offset = ip2 - i; tAddr.s_addr = ntohl(i); - ipVec.push_back(inet_ntoa(tAddr)); - if (ipVec.size() != 0) strcpy(currentIP, ipVec[0].c_str()); + ipVec.push_back(inet_ntoa(tAddr)); if (ipVec.size() >= (offset < 1000 ? offset : 1000)) { @@ -1858,13 +1825,13 @@ int startScan(char* args) { while (cons >= gThreads && globalScanFlag) Sleep(500); if (!globalScanFlag) goto haters_gonna_hate_IPM; - ++indexIP; - std::string res = ipVec[0]; + ++indexIP; + strcpy(currentIP, ipVec[0].c_str()); ipVec.erase(ipVec.begin()); - verboseProgress(gTargets--, res.c_str()); + verboseProgress(--gTargets); - Threader::fireThread(res, (void*(*)(void))_connect); + Threader::fireThread(currentIP, (void*(*)(void))_connect); } } } @@ -1879,14 +1846,13 @@ int startScan(char* args) { while (cons >= gThreads && globalScanFlag) Sleep(500); if (!globalScanFlag) break; - std::string res = ""; ++indexIP; tAddr.s_addr = ntohl(i); - res = std::string(inet_ntoa(tAddr)); - verboseProgress(gTargets--, res.c_str()); + strcpy(currentIP, inet_ntoa(tAddr)); + verboseProgress(--gTargets); - Threader::fireThread(res, (void*(*)(void))_connect); + Threader::fireThread(currentIP, (void*(*)(void))_connect); } break; } @@ -1894,8 +1860,6 @@ int startScan(char* args) { } else if (gMode == 1) { - strcpy(top_level_domain, gFirstDom); - char dataEntry[1024] = { 0 }; int innerCounter = 0; int sz = strlen(saveEndIP); @@ -1946,7 +1910,8 @@ int startScan(char* args) { }; }; - memset(dataEntry + innerCounter + 1, '\0', 1); + memset(dataEntry + innerCounter + 1, '\0', 1); + strcpy(currentMask, dataEntry); for (int i = 0; i < sz; ++i) { @@ -2004,7 +1969,7 @@ int startScan(char* args) { stt->doEmitionYellowFoundData("Starting DNS-scan..."); stt->doEmitionChangeStatus("Scanning..."); - int y = _GetDNSFromMask(dataEntry, "", dataEntry); + int y = _GetDNSFromMask(dataEntry, dataEntry, dataEntry); if (y == -1) { stt->doEmitionRedFoundData("DNS-Mode error"); @@ -2054,8 +2019,7 @@ int startScan(char* args) { unsigned long offset = ip2 - i; tAddr.s_addr = ntohl(i); - ipVec.push_back(inet_ntoa(tAddr)); - if (ipVec.size() != 0) strcpy(currentIP, ipVec[0].c_str()); + ipVec.push_back(inet_ntoa(tAddr)); if (ipVec.size() >= (offset < 1000 ? offset : 1000)) { @@ -2065,13 +2029,12 @@ int startScan(char* args) { while (cons >= gThreads && globalScanFlag) Sleep(500); if (!globalScanFlag) goto haters_gonna_hate_IM; - ++indexIP; - std::string res = ipVec[0]; - ipVec.erase(ipVec.begin()); + ++indexIP; + strcpy(currentIP, ipVec[0].c_str()); + ipVec.erase(ipVec.begin()); + verboseProgress(--gTargets); - verboseProgress(gTargets--, res.c_str()); - - Threader::fireThread(res, (void*(*)(void))_connect); + Threader::fireThread(currentIP, (void*(*)(void))_connect); } } } @@ -2087,10 +2050,10 @@ int startScan(char* args) { ++indexIP; - tAddr.s_addr = ntohl(i); - std::string res = std::string(inet_ntoa(tAddr)); - verboseProgress(gTargets--, res.c_str()); - Threader::fireThread(res, (void*(*)(void))_connect); + tAddr.s_addr = ntohl(i); + strcpy(currentIP, inet_ntoa(tAddr)); + verboseProgress(--gTargets); + Threader::fireThread(currentIP, (void*(*)(void))_connect); } break; };