diff --git a/CheckKey_Th.cpp b/CheckKey_Th.cpp index 2c1a694..901be01 100644 --- a/CheckKey_Th.cpp +++ b/CheckKey_Th.cpp @@ -67,7 +67,7 @@ int KeyCheckerMain() HOSTENT *host; -#if defined(WIN32) +#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 @@ -184,7 +184,7 @@ int KeyCheckerMain() strcat(msg, "\r\nConnection: close"); strcat(msg, "\r\n\r\n"); -#if defined(WIN32) +#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 diff --git a/CheckProxy_Th.cpp b/CheckProxy_Th.cpp index aebb53c..eb7c8b0 100644 --- a/CheckProxy_Th.cpp +++ b/CheckProxy_Th.cpp @@ -38,7 +38,7 @@ void CheckProxyLogic() HOSTENT *host; -#if defined(WIN32) +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) if(inet_addr(ircProxy) != INADDR_NONE) addr.sin_addr.S_un.S_addr = inet_addr(ircProxy); else if(host = gethostbyname (ircProxy)) ((unsigned long*) &addr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; #else diff --git a/connector.cpp b/connector.cpp index 1c3b7d5..0dcc020 100644 --- a/connector.cpp +++ b/connector.cpp @@ -142,12 +142,10 @@ int OpenConnection(SOCKET *sock, const char *hostname, int port) struct sockaddr_in addr; if(strlen(hostname) == 0) { - stt->doEmitionDebugFoundData("[" + QString(hostname) + ":" + QString::number(port) + "" + "] Rejecting in _connection: Bad IP."); return -1; }; if(port < 0 || port > 65535) { - stt->doEmitionDebugFoundData("[" + QString(hostname) + ":" + QString::number(port) + "" + "] Rejecting in _connection: Bad port."); return -1; }; @@ -410,7 +408,7 @@ lopaStr _BABrute(char *cookie, char *ip, int port, char *pathT, char *method) sockAddr.sin_family = AF_INET; sockAddr.sin_port = htons(port); HOSTENT *host; -#if defined(WIN32) +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) if(inet_addr(ip) != INADDR_NONE) sockAddr.sin_addr.S_un.S_addr = inet_addr(ip); else if(host=gethostbyname (ip)) ((unsigned long*) &sockAddr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; else @@ -865,7 +863,7 @@ lopaStr _FTPBrute(char *ip, int port, PathStr *ps) sockAddr.sin_port = htons(port); HOSTENT *host; -#if defined(WIN32) +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) if(inet_addr(ip) != INADDR_NONE) sockAddr.sin_addr.S_un.S_addr = inet_addr(ip); else if(host=gethostbyname (ip)) ((unsigned long*) &sockAddr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; else @@ -1441,12 +1439,10 @@ int Connector::_EstablishConnection(char *ip, int port, char *request, conSTR *C CSTR->lowerBuff = NULL; if(strlen(ip) == 0) { - stt->doEmitionDebugFoundData("[" + QString(ip) + ":" + QString::number(port) + "" + "] Rejecting in _connection: Bad IP."); return -1; }; if(port < 0 || port > 65535) { - stt->doEmitionDebugFoundData("[" + QString(ip) + ":" + QString::number(port) + "" + "] Rejecting in _connection: Bad port."); return -1; }; @@ -1456,7 +1452,7 @@ int Connector::_EstablishConnection(char *ip, int port, char *request, conSTR *C sockAddr.sin_port = htons(port); HOSTENT *host; -#if defined(WIN32) +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) if(inet_addr(ip) != INADDR_NONE) sockAddr.sin_addr.S_un.S_addr = inet_addr(ip); #else if(inet_addr(ip) != INADDR_NONE) sockAddr.sin_addr.s_addr = inet_addr(ip); @@ -1479,7 +1475,7 @@ int Connector::_EstablishConnection(char *ip, int port, char *request, conSTR *C sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); }; -#if defined(WIN32) +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) u_long FAR cmd = 1; if( ioctlsocket( sock , FIONBIO, &cmd ) != 0 ) #else @@ -2120,7 +2116,7 @@ int _webLoginSeq(char *request, char *login, char *pass, char *ip, int port, int sockAddr.sin_family = AF_INET; sockAddr.sin_port = htons(port); HOSTENT *host; -#if defined(WIN32) +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) if(inet_addr(ip) != INADDR_NONE) sockAddr.sin_addr.S_un.S_addr = inet_addr(ip); else if(host=gethostbyname (ip)) ((unsigned long*) &sockAddr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; else diff --git a/externData.h b/externData.h index 6f080c7..0dd92da 100644 --- a/externData.h +++ b/externData.h @@ -13,7 +13,7 @@ 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; + gDebugMode, horLineFlag, gPingNScan, gShuffle; extern int found, indexIP, gMode, MaxPass, MaxLogin, MaxWFLogin, MaxWFPass, MaxSSHPass, GlobalNegativeSize, isActive, gMaxBrutingThreads, diff --git a/finder.cpp b/finder.cpp index f1a5dd4..07743d9 100644 --- a/finder.cpp +++ b/finder.cpp @@ -1531,6 +1531,7 @@ int Lexems::_filler(int p, char* buffcpy, char* ip, int recd, Lexems *lx, char * { int rh = _header(ip, p, buffcpy, lx, &ps, &redirStrLst, rBuff); strcpy(cp, ps.codepage); + if (rh == -1) return -1; if(rh <= -2) { flag = ps.flag; diff --git a/nesca_3.cpp b/nesca_3.cpp index b81f612..ca565cd 100644 --- a/nesca_3.cpp +++ b/nesca_3.cpp @@ -2825,7 +2825,8 @@ void nesca_3::ConnectEvrthng() connect ( ui->importButton, SIGNAL( clicked() ), this, SLOT( importAndScan() ) ); connect ( ui->startScanButton_3, SIGNAL( clicked() ), this, SLOT( startScanButtonClicked() ) ); connect ( ui->startScanButton_4, SIGNAL( clicked() ), this, SLOT( startScanButtonClickedDNS() ) ); - connect ( ui->trackerOnOff, SIGNAL( toggled(bool) ), this, SLOT( ChangeTrackerOK(bool) ) ); + connect ( ui->shuffle_onoff, SIGNAL(toggled(bool)), this, SLOT(ChangeShuffle(bool))); + connect ( ui->trackerOnOff, SIGNAL(toggled(bool)), this, SLOT(ChangeTrackerOK(bool))); connect ( ui->pingingOnOff, SIGNAL( toggled(bool) ), this, SLOT( ChangePingerOK(bool) ) ); connect ( ui->debugFileOnOff, SIGNAL( toggled(bool) ), this, SLOT( ChangeDebugFileState(bool) ) ); connect ( ui->importThreads, SIGNAL( textChanged(QString) ), this, SLOT( ChangeLabelThreads_ValueChanged(QString) ) ); @@ -3332,7 +3333,7 @@ void _startMsgCheck() pbPointerFont.setFamily("Eurostile"); pbPointerFont.setPixelSize(8); -#if defined(WIN32) +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) WSADATA wsda; if (WSAStartup(0x0101, &wsda)) { @@ -3389,7 +3390,7 @@ void nesca_3::exitButtonClicked() { globalScanFlag = false; stt->terminate(); -#if defined(WIN32) +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) WSACleanup(); #endif qApp->quit(); @@ -3407,6 +3408,10 @@ void nesca_3::trayButtonClicked() tray->show(); }; }; +void nesca_3::ChangeShuffle(bool val) +{ + gShuffle = val; +}; void nesca_3::ChangeTrackerOK(bool val) { trackerOK = val; diff --git a/nesca_3.h b/nesca_3.h index 8033f14..5c39a60 100644 --- a/nesca_3.h +++ b/nesca_3.h @@ -128,6 +128,7 @@ protected: void startScanButtonClickedDNS(); void saveOptions(); void ChangeTrackerOK(bool val); + void ChangeShuffle(bool val); void ChangeLabelThreads_ValueChanged(QString); void PingTO_ChangeValue(QString); void ChangeLabelTO_ValueChanged(QString); diff --git a/nesca_3.ui b/nesca_3.ui index f82fef6..c88ef91 100644 --- a/nesca_3.ui +++ b/nesca_3.ui @@ -1146,7 +1146,7 @@ border-radius: 3px; 30 - 90 + 100 208 17 @@ -1314,7 +1314,7 @@ border-radius: 3px; 30 - 110 + 116 276 17 @@ -1341,8 +1341,8 @@ border-radius: 3px; 30 - 70 - 85 + 84 + 75 17 @@ -1358,7 +1358,7 @@ border-radius: 3px; color: rgb(216, 216, 216); background-color: rgba(2, 2, 2, 0); - Ping hosts + Ping hosts: Ctrl+S @@ -1373,10 +1373,10 @@ border-radius: 3px; - 390 - 70 + 108 + 86 51 - 20 + 15 @@ -1403,9 +1403,9 @@ border-radius: 3px; - 320 - 71 - 68 + 163 + 85 + 17 16 @@ -1418,7 +1418,7 @@ border-radius: 3px; color: rgb(216, 216, 216); background-color: rgba(2, 2, 2, 0); - Ping timeout: + ms @@ -1428,7 +1428,7 @@ border-radius: 3px; 390 - 90 + 69 51 20 @@ -1458,7 +1458,7 @@ border-radius: 3px; 320 - 90 + 69 68 16 @@ -1479,7 +1479,7 @@ border-radius: 3px; 320 - 105 + 84 62 26 @@ -1505,7 +1505,7 @@ border-radius: 3px; 390 - 110 + 89 51 20 @@ -1531,6 +1531,36 @@ border-radius: 3px; 100 + + + + 30 + 68 + 100 + 17 + + + + + Eurostile + + + + Shuffle ip-ranges before scan. + + + color: rgb(216, 216, 216); background-color: rgba(2, 2, 2, 0); + + + Shuffle ip ranges + + + Ctrl+S + + + true + + diff --git a/nesca_startModule.cpp b/nesca_startModule.cpp index 06c140d..cbd4f17 100644 --- a/nesca_startModule.cpp +++ b/nesca_startModule.cpp @@ -10,6 +10,7 @@ typedef struct ST{ QJsonArray *jsonArr = new QJsonArray(); +bool gShuffle = true; bool __savingBackUpFile = false; bool horLineFlag = false; static int portArr[65536] = {0}; @@ -64,7 +65,7 @@ void SaveErrorLog(char *sender, char *MesSent, char *ReplRecv) { fclose(errFile); }; -#if defined(WIN32) +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) CreateDirectory(L"./logs", NULL); #else struct stat st = {0}; @@ -378,7 +379,7 @@ void _saver() }; }; -#if defined(WIN32) +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) void _timer() #else void *_timer() @@ -420,7 +421,7 @@ void *_timer() }; }; bool trackAlreadyGoing = false; -#if defined(WIN32) +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) void _tracker() #else void *_tracker() @@ -450,7 +451,7 @@ void *_tracker() HOSTENT *host; -#if defined(WIN32) +#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 @@ -649,7 +650,7 @@ void *_tracker() delete jsonArr; jsonArr = new QJsonArray(); -#if defined(WIN32) +#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 @@ -789,11 +790,16 @@ void *_tracker() unsigned long int numOfIps(int ipsstart[], int ipsend[]) { - gTargets += 256*256*256*(ipsend[0] - ipsstart[0]); - gTargets += 256*256*(ipsend[1] - ipsstart[1]); - gTargets += 256*(ipsend[2] - ipsstart[2]); + gTargets += 16777216 * (ipsend[0] - ipsstart[0]); + gTargets += 65536 * (ipsend[1] - ipsstart[1]); + gTargets += 256 * (ipsend[2] - ipsstart[2]); gTargets += (ipsend[3] - ipsstart[3]); gTargetsOverall = gTargets - 1; + + //unsigned long ip1 = (ipsstart[0] * 16777216) + (ipsstart[1] * 65536) + (ipsstart[2] * 256) + ipsstart[3]; + //unsigned long ip2 = (ipsend[0] * 16777216) + (ipsend[1] * 65536) + (ipsend[2] * 256) + ipsend[3]; + //unsigned long gTargets = ip2 - ip1; + return gTargets; }; //#include @@ -868,7 +874,7 @@ unsigned long int numOfIps(int ipsstart[], int ipsend[]) //}; Connector con; -#if defined(WIN32) +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) void _connect(void* ss) #else void *_connect(void* ss) @@ -2209,7 +2215,7 @@ int _GetDNSFromMask(char *mask, char *saveMask, char *saveMaskEnder) targetAndIPWriter(--gTargets, st->argv); ConInc(); -#if defined(WIN32) +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) if(globalScanFlag) _beginthread( (void(*)(void*))_connect, 0, st ); #else if(globalScanFlag) @@ -2245,7 +2251,7 @@ int startScan(char* args) ZeroMemory(ipsstart, sizeof(ipsstart)); ZeroMemory(ipsend, sizeof(ipsend)); -#if defined(WIN32) +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) CreateDirectory(L"./result_files", NULL); #else struct stat st = {0}; @@ -2283,25 +2289,101 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads)); _NegativeFapper(); char res[256] = {0}; - if(gMode == 0) + if (gMode == 0) { -#if defined(WIN32) - _beginthread( (void(*)(void*))_saver, 0, NULL ); +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + _beginthread((void(*)(void*))_saver, 0, NULL); #else pthread_t thrs; pthread_create(&thrs, NULL, (void *(*)(void*))&_saver, NULL); #endif -#if defined(WIN32) - if(trackerOK) _beginthread( (void(*)(void*))_tracker, 0, NULL ); +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + if (trackerOK) _beginthread((void(*)(void*))_tracker, 0, NULL); Sleep(50); - _beginthread( (void(*)(void*))_timer, 0, NULL ); + _beginthread((void(*)(void*))_timer, 0, NULL); #else pthread_t thrt; pthread_t thrtt; if(trackerOK) pthread_create(&thrt, NULL, (void *(*)(void*))&_tracker, NULL); pthread_create(&thrtt, NULL, (void *(*)(void*))&_timer, NULL); #endif - int eor0 = 0, eor1 = 0, eor2 = 0, eor3 = 0; + + unsigned long ip1 = (ipsstart[0] * 16777216) + (ipsstart[1] * 65536) + (ipsstart[2] * 256) + ipsstart[3]; + unsigned long ip2 = (ipsend[0] * 16777216) + (ipsend[1] * 65536) + (ipsend[2] * 256) + ipsend[3]; + + switch (gShuffle) { + case true: { + std::vector ipVec; + struct in_addr tAddr; + + for (unsigned long i = ip1; i <= ip2; ++i) { + if (globalScanFlag == false) break; + int offset = ip2 - i; + + tAddr.s_addr = i; + ipVec.push_back(std::to_string(tAddr.S_un.S_un_b.s_b4) + "." + std::to_string(tAddr.S_un.S_un_b.s_b3) + "." + std::to_string(tAddr.S_un.S_un_b.s_b2) + "." + std::to_string(tAddr.S_un.S_un_b.s_b1)); + + if (ipVec.size() >= (offset < 1000 ? offset : 1000)) { + + std::random_shuffle(ipVec.begin(), ipVec.end()); + while (ipVec.size() != 0) { + + if (globalScanFlag == false) goto haters_gonna_hate_IPM; + st = new sockstruct(); + ZeroMemory(st->argv, sizeof(st->argv)); + + while (cons >= gThreads) Sleep(500); + ++indexIP; + strcpy(st->argv, ipVec[0].c_str()); + strcpy(saveStartIP, ipVec[0].c_str()); + ipVec.erase(ipVec.begin()); + + targetAndIPWriter(gTargets--, st->argv); + ConInc(); +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + _beginthread((void(*)(void*))_connect, 0, st); +#else + pthread_t thrc; + pthread_create(&thrc, NULL, (void *(*)(void*))&_connect, st); +#endif + Sleep(gThreadDelay); + } + } + } + + haters_gonna_hate_IPM:; + break; + } + case false: { + struct in_addr tAddr; + for (unsigned long i = ip1; i <= ip2; ++i) { + if (globalScanFlag == false) break; + st = new sockstruct(); + ZeroMemory(st->argv, sizeof(st->argv)); + ZeroMemory(res, sizeof(res)); + while (cons >= gThreads) Sleep(500); + ++indexIP; + + tAddr.s_addr = i; + strcpy(res, (std::to_string(tAddr.S_un.S_un_b.s_b4) + "." + std::to_string(tAddr.S_un.S_un_b.s_b3) + "." + std::to_string(tAddr.S_un.S_un_b.s_b2) + "." + std::to_string(tAddr.S_un.S_un_b.s_b1)).c_str()); + strcpy(st->argv, res); + strcpy(saveStartIP, res); + + targetAndIPWriter(gTargets--, st->argv); + ConInc(); +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + _beginthread((void(*)(void*))_connect, 0, st); +#else + pthread_t thrc; + pthread_create(&thrc, NULL, (void *(*)(void*))&_connect, st); +#endif + Sleep(gThreadDelay); + } + break; + } + } + + /*int eor0 = 0, eor1 = 0, eor2 = 0, eor3 = 0; stt->doEmitionChangeStatus("Scanning..."); sockstruct *st = NULL; while ((eor0 == 0 || eor1 == 0 || eor2 == 0 || eor3 == 0 ) && globalScanFlag) @@ -2342,7 +2424,7 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads)); targetAndIPWriter(gTargets--, st->argv); ConInc(); -#if defined(WIN32) +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) _beginthread( (void(*)(void*))_connect, 0, st ); #else pthread_t thrc; @@ -2366,11 +2448,11 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads)); ipsstart[3] = 0; ipsstart[2] = 0; ipsstart[1] = 0; - }; + };*/ } else if(gMode == 1 ) { -#if defined(WIN32) +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) _beginthread( (void(*)(void*))_saver, 0, NULL ); #else pthread_t thrs; @@ -2382,7 +2464,7 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads)); if(trackerOK) { -#if defined(WIN32) +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) if(trackerOK) _beginthread( (void(*)(void*))_tracker, 0, NULL ); #else pthread_t thrt; @@ -2391,7 +2473,7 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads)); }; Sleep(40); -#if defined(WIN32) +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) _beginthread( (void(*)(void*))_timer, 0, NULL ); #else pthread_t thrtt; @@ -2490,7 +2572,6 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads)); stt->doEmitionRedFoundData(errStr); return -1; - }; }; @@ -2511,9 +2592,9 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads)); stt->doEmitionRedFoundData("DNS-Mode error"); }; } - else if(gMode == -1) + else if (gMode == -1) { - if(flCounter == 0) + if (flCounter == 0) { stt->doEmitionRedFoundData("Empty IP list."); isActive = 0; @@ -2522,34 +2603,33 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads)); return -1; }; -#if defined(WIN32) - _beginthread( (void(*)(void*))_saver, 0, NULL ); +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + _beginthread((void(*)(void*))_saver, 0, NULL); #else pthread_t thrs; pthread_create(&thrs, NULL, (void *(*)(void*))&_saver, NULL); #endif - if(trackerOK) + if (trackerOK) { -#if defined(WIN32) - _beginthread( (void(*)(void*))_tracker, 0, NULL ); +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + _beginthread((void(*)(void*))_tracker, 0, NULL); #else - pthread_t thrt; - pthread_create(&thrt, NULL, (void *(*)(void*))&_tracker, NULL); + pthread_t thrt; + pthread_create(&thrt, NULL, (void *(*)(void*))&_tracker, NULL); #endif }; Sleep(40); -#if defined(WIN32) - _beginthread( (void(*)(void*))_timer, 0, NULL ); +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + _beginthread((void(*)(void*))_timer, 0, NULL); #else pthread_t thrtt; pthread_create(&thrtt, NULL, (void *(*)(void*))&_timer, NULL); #endif - int eor0 = 0, eor1 = 0, eor2 = 0, eor3 = 0; stt->doEmitionChangeStatus("Scanning..."); sockstruct *st = NULL; - for(gC = 0; gC < flCounter; ++gC) + for (gC = 0; gC < flCounter; ++gC) { strcpy(metaRange, std::to_string(ipsstartfl[gC][0]).c_str()); strcat(metaRange, "."); @@ -2567,79 +2647,153 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads)); strcat(metaRange, "."); strcat(metaRange, std::to_string(ipsendfl[gC][3]).c_str()); - eor0 = 0, eor1 = 0, eor2 = 0, eor3 = 0; - while ((eor0 == 0 || eor1 == 0 || eor2 == 0 || eor3 == 0) && globalScanFlag) - { - if(globalScanFlag == false) break; - while(ipsstartfl[gC][0] < 256 && eor0 == 0) - { - if(globalScanFlag == false) break; - if(ipsstartfl[gC][0] == ipsendfl[gC][0]) eor0 = 1; - while(ipsstartfl[gC][1] < 256 && eor1 == 0) - { - if(globalScanFlag == false) break; - if(ipsstartfl[gC][1] == ipsendfl[gC][1] && eor0 == 1) eor1 = 1; - while(ipsstartfl[gC][2] < 256 && eor2 == 0) - { - if(globalScanFlag == false) break; - if(ipsstartfl[gC][2] == ipsendfl[gC][2] && eor1 == 1) eor2 = 1; - while(ipsstartfl[gC][3] < 256 && eor3 == 0) - { - if(globalScanFlag == false) break; + unsigned long ip1 = (ipsstartfl[gC][0] * 16777216) + (ipsstartfl[gC][1] * 65536) + (ipsstartfl[gC][2] * 256) + ipsstartfl[gC][3]; + unsigned long ip2 = (ipsendfl[gC][0] * 16777216) + (ipsendfl[gC][1] * 65536) + (ipsendfl[gC][2] * 256) + ipsendfl[gC][3]; + + switch (gShuffle) { + case true: { + std::vector ipVec; + struct in_addr tAddr; + + for (unsigned long i = ip1; i <= ip2; ++i) { + if (globalScanFlag == false) break; + int offset = ip2 - i; + + tAddr.s_addr = i; + ipVec.push_back(std::to_string(tAddr.S_un.S_un_b.s_b4) + "." + std::to_string(tAddr.S_un.S_un_b.s_b3) + "." + std::to_string(tAddr.S_un.S_un_b.s_b2) + "." + std::to_string(tAddr.S_un.S_un_b.s_b1)); + + if (ipVec.size() >= (offset < 1000 ? offset : 1000)) { + + std::random_shuffle(ipVec.begin(), ipVec.end()); + while (ipVec.size() != 0) { + + if (globalScanFlag == false) goto haters_gonna_hate_IM; + st = new sockstruct(); + ZeroMemory(st->argv, sizeof(st->argv)); + + while (cons >= gThreads) Sleep(500); + ++indexIP; + strcpy(st->argv, ipVec[0].c_str()); + strcpy(saveStartIP, ipVec[0].c_str()); + ipVec.erase(ipVec.begin()); + + targetAndIPWriter(gTargets--, st->argv); + ConInc(); +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + _beginthread((void(*)(void*))_connect, 0, st); +#else + pthread_t thrc; + pthread_create(&thrc, NULL, (void *(*)(void*))&_connect, st); +#endif + Sleep(gThreadDelay); + } + } + } + haters_gonna_hate_IM:; + break; + } + case false: { + struct in_addr tAddr; + for (unsigned long i = ip1; i <= ip2; ++i) { + if (globalScanFlag == false) break; st = new sockstruct(); ZeroMemory(st->argv, sizeof(st->argv)); ZeroMemory(res, sizeof(res)); - - while(cons >= gThreads) Sleep(300); - - if(ipsstartfl[gC][3] == ipsendfl[gC][3] && eor2 == 1) eor3 = 1; - + while (cons >= gThreads) Sleep(500); ++indexIP; - strcat(res, std::to_string(ipsstartfl[gC][0]).c_str()); - strcat(res, "."); - strcat(res, std::to_string(ipsstartfl[gC][1]).c_str()); - strcat(res, "."); - strcat(res, std::to_string(ipsstartfl[gC][2]).c_str()); - strcat(res, "."); - strcat(res, std::to_string(ipsstartfl[gC][3]).c_str()); - + tAddr.s_addr = i; + strcpy(res, (std::to_string(tAddr.S_un.S_un_b.s_b4) + "." + std::to_string(tAddr.S_un.S_un_b.s_b3) + "." + std::to_string(tAddr.S_un.S_un_b.s_b2) + "." + std::to_string(tAddr.S_un.S_un_b.s_b1)).c_str()); strcpy(st->argv, res); strcpy(saveStartIP, res); targetAndIPWriter(gTargets--, st->argv); - ConInc(); -#if defined(WIN32) - _beginthread( (void(*)(void*))_connect, 0, st ); +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + _beginthread((void(*)(void*))_connect, 0, st); #else pthread_t thrc; - pthread_create(&thrc, NULL, (void *(*)(void*))&_connect, st ); + pthread_create(&thrc, NULL, (void *(*)(void*))&_connect, st); #endif Sleep(gThreadDelay); - if(ipsstartfl[gC][3] == 255) break; - if(ipsstartfl[gC][3] <= ipsendfl[gC][3]) ++ipsstartfl[gC][3]; - }; - ipsstartfl[gC][3] = 0; - if(ipsstartfl[gC][2] == 255) break; - if(ipsstartfl[gC][2] <= ipsendfl[gC][2]) ++ipsstartfl[gC][2]; - }; - ipsstartfl[gC][3] = 0; - ipsstartfl[gC][2] = 0; - if(ipsstartfl[gC][1] == 255) break; - if(ipsstartfl[gC][1] <= ipsendfl[gC][1]) ++ipsstartfl[gC][1]; - }; - ipsstartfl[gC][3] = 0; - ipsstartfl[gC][2] = 0; - ipsstartfl[gC][1] = 0; - if(ipsstartfl[gC][0] == 255) break; - if(ipsstartfl[gC][0] <= ipsendfl[gC][0]) ++ipsstartfl[gC][0]; - }; - ipsstartfl[gC][3] = 0; - ipsstartfl[gC][2] = 0; - ipsstartfl[gC][1] = 0; + + } + break; + /*int eor0 = 0, eor1 = 0, eor2 = 0, eor3 = 0; + while ((eor0 == 0 || eor1 == 0 || eor2 == 0 || eor3 == 0) && globalScanFlag) + { + if (globalScanFlag == false) break; + while (ipsstartfl[gC][0] < 256 && eor0 == 0) + { + if (globalScanFlag == false) break; + if (ipsstartfl[gC][0] == ipsendfl[gC][0]) eor0 = 1; + while (ipsstartfl[gC][1] < 256 && eor1 == 0) + { + if (globalScanFlag == false) break; + if (ipsstartfl[gC][1] == ipsendfl[gC][1] && eor0 == 1) eor1 = 1; + while (ipsstartfl[gC][2] < 256 && eor2 == 0) + { + if (globalScanFlag == false) break; + if (ipsstartfl[gC][2] == ipsendfl[gC][2] && eor1 == 1) eor2 = 1; + while (ipsstartfl[gC][3] < 256 && eor3 == 0) + { + if (globalScanFlag == false) break; + st = new sockstruct(); + ZeroMemory(st->argv, sizeof(st->argv)); + ZeroMemory(res, sizeof(res)); + + while (cons >= gThreads) Sleep(300); + + if (ipsstartfl[gC][3] == ipsendfl[gC][3] && eor2 == 1) eor3 = 1; + + ++indexIP; + + strcat(res, std::to_string(ipsstartfl[gC][0]).c_str()); + strcat(res, "."); + strcat(res, std::to_string(ipsstartfl[gC][1]).c_str()); + strcat(res, "."); + strcat(res, std::to_string(ipsstartfl[gC][2]).c_str()); + strcat(res, "."); + strcat(res, std::to_string(ipsstartfl[gC][3]).c_str()); + + strcpy(st->argv, res); + strcpy(saveStartIP, res); + + targetAndIPWriter(gTargets--, st->argv); + + ConInc(); +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + _beginthread((void(*)(void*))_connect, 0, st); +#else + pthread_t thrc; + pthread_create(&thrc, NULL, (void *(*)(void*))&_connect, st); +#endif + Sleep(gThreadDelay); + if (ipsstartfl[gC][3] == 255) break; + if (ipsstartfl[gC][3] <= ipsendfl[gC][3]) ++ipsstartfl[gC][3]; + }; + ipsstartfl[gC][3] = 0; + if (ipsstartfl[gC][2] == 255) break; + if (ipsstartfl[gC][2] <= ipsendfl[gC][2]) ++ipsstartfl[gC][2]; + }; + ipsstartfl[gC][3] = 0; + ipsstartfl[gC][2] = 0; + if (ipsstartfl[gC][1] == 255) break; + if (ipsstartfl[gC][1] <= ipsendfl[gC][1]) ++ipsstartfl[gC][1]; + }; + ipsstartfl[gC][3] = 0; + ipsstartfl[gC][2] = 0; + ipsstartfl[gC][1] = 0; + if (ipsstartfl[gC][0] == 255) break; + if (ipsstartfl[gC][0] <= ipsendfl[gC][0]) ++ipsstartfl[gC][0]; + }; + ipsstartfl[gC][3] = 0; + ipsstartfl[gC][2] = 0; + ipsstartfl[gC][1] = 0; + };*/ }; - }; + } + } } else { diff --git a/oIRC_Th.cpp b/oIRC_Th.cpp index ef6fab5..286177d 100644 --- a/oIRC_Th.cpp +++ b/oIRC_Th.cpp @@ -315,7 +315,7 @@ void IRCLoop() { addr.sin_port = htons(atoi(ircProxyPort)); -#if defined(WIN32) +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) if(inet_addr(ircProxy) != INADDR_NONE) addr.sin_addr.S_un.S_addr = inet_addr(ircProxy); else if(host = gethostbyname (ircProxy)) ((unsigned long*) &addr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; #else @@ -327,7 +327,7 @@ void IRCLoop() { addr.sin_port = htons(atoi(ircPort)); -#if defined(WIN32) +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) if(inet_addr(ircServer) != INADDR_NONE) addr.sin_addr.S_un.S_addr = inet_addr(ircServer); else if(host = gethostbyname (ircServer)) ((unsigned long*) &addr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0]; #else