thread pooling 2

This commit is contained in:
cora48 2015-03-19 17:34:35 +03:00
parent 9b920a6e39
commit b2b246010e
6 changed files with 115 additions and 272 deletions

View File

@ -252,17 +252,16 @@ int Connector::nConnect(const char *ip, const int port, std::string *buffer,
buffer->clear(); buffer->clear();
CURL *curl = curl_easy_init(); CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 0L); curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 0L);
int res = 0;
if (curl) if (curl)
{ {
if (MapWidgetOpened) { if (MapWidgetOpened) {
struct data config; struct data config;
config.trace_ascii = 1; /* enable ascii tracing */ config.trace_ascii = 1; /* enable ascii tracing */
curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace); curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace);
curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &config); curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &config);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
} }
curl_easy_setopt(curl, CURLOPT_URL, ip); curl_easy_setopt(curl, CURLOPT_URL, ip);
curl_easy_setopt(curl, CURLOPT_PORT, port); curl_easy_setopt(curl, CURLOPT_PORT, port);
curl_easy_setopt(curl, CURLOPT_USERAGENT, curl_easy_setopt(curl, CURLOPT_USERAGENT,
@ -277,6 +276,8 @@ int Connector::nConnect(const char *ip, const int port, std::string *buffer,
if(strlen(gProxyIP) != 0 && (proxyPort > 0 && proxyPort < 65535)) { if(strlen(gProxyIP) != 0 && (proxyPort > 0 && proxyPort < 65535)) {
curl_easy_setopt(curl, CURLOPT_PROXY, gProxyIP); curl_easy_setopt(curl, CURLOPT_PROXY, gProxyIP);
curl_easy_setopt(curl, CURLOPT_PROXYPORT, proxyPort); curl_easy_setopt(curl, CURLOPT_PROXYPORT, proxyPort);
} else {
curl_easy_setopt(curl, CURLOPT_PROXY, "");
} }
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, gTimeOut); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, gTimeOut);
@ -303,10 +304,15 @@ int Connector::nConnect(const char *ip, const int port, std::string *buffer,
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_ANY); curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_ANY);
//curl_easy_setopt(curl, CURLOPT_FTPLISTONLY, TRUE); //curl_easy_setopt(curl, CURLOPT_FTPLISTONLY, TRUE);
curl_easy_setopt(curl, CURLOPT_USERPWD, lpString->c_str()); curl_easy_setopt(curl, CURLOPT_USERPWD, lpString->c_str());
};// };
if(curl_easy_perform(curl) == CURLE_OK) {
curl_easy_cleanup(curl);
} else {
curl_easy_cleanup(curl);
return -1;
}
if(curl_easy_perform(curl) != CURLE_OK) return -1;
curl_easy_cleanup(curl);
} else { } else {
stt->doEmitionRedFoundData("Curl error."); stt->doEmitionRedFoundData("Curl error.");
return -1; return -1;
@ -334,14 +340,14 @@ int Connector::_ConnectToPort(char *ip, int port, char *hl)
if(port == 22) size = _SSHLobby(ip, port, &buffer); if(port == 22) size = _SSHLobby(ip, port, &buffer);
else size = nConnect(ip, port, &buffer); else size = nConnect(ip, port, &buffer);
if(size > 0) // if(size > 0)
{ // {
++Alive; // ++Alive;
++found; // ++found;
stt->doEmitionChangeParsed(QString::number(saved) + "/" + QString::number(found)); // stt->doEmitionChangeParsed(QString::number(saved) + "/" + QString::number(found));
Lexems lx; // Lexems lx;
lx._filler(port, buffer.c_str(), ip, size, &lx, hl); // lx._filler(port, buffer.c_str(), ip, size, &lx, hl);
}; // };
return 0; return 0;
} }

View File

@ -102,13 +102,13 @@ void MakePolygonLine(int gWidth)
}; };
} }
if(xtx > 234 && xtx < 269) if(xtx > 234 && xtx < 278)
{ {
qp = QPointF(xtx, state ? qrand() % 3 + ME2YPOS - Alive * 2 - fact7 : ME2YPOS); qp = QPointF(xtx, state ? qrand() % 3 + ME2YPOS - Alive * 2 - fact7 : ME2YPOS);
if(Alive > 0) if(Alive > 0)
{ {
if(xtx < 252 ) fact7+=1; if(xtx < 261 ) fact7+=1;
else fact7-=1; else fact7-=1;
}; };
}; };

View File

@ -1,39 +1,13 @@
#include <Threader.h> #include <Threader.h>
std::vector<char*> Threader::threadPool; std::vector<char*> Threader::threadPool;
int Threader::threadPoolSize; std::vector<std::condition_variable*> cvPool;
bool Threader::mayRun; std::vector<bool> Threader::readyPool;
void *Threader::lFunc; int Threader::threadId = 0;
void Threader::recreateThreadPool(int poolSize) {
if(mayRun) {
createThreadPool(poolSize, (void* (*)(int))lFunc);
}
}
void Threader::createThreadPool(int poolSize, void *func(int)) {
cleanUp();
lFunc = (void*)func;
threadPoolSize = poolSize;
for(int i = 0; i < threadPoolSize; ++i) {
char *res = NULL;
threadPool.push_back(res);
std::thread thr12(func, i);
thr12.detach();
//#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
// _beginthread((void(*)(void*))_connect, 0, (void *)i);
//#else
// pthread_t thrc;
// pthread_create(&thrc, NULL, (void *(*)(void*))func, (void *)i);
//#endif
Sleep(1);
}
mayRun = true;
}
int Threader::getFreeDataSlotId() { int Threader::getFreeDataSlotId() {
for(int i = 0; i != threadPoolSize; ++i) { int tps = threadPool.size();
for(int i = 0; i != (gThreads > tps ? tps : gThreads); ++i) {
if(threadPool[i] == NULL) return i; if(threadPool[i] == NULL) return i;
} }
return -1; return -1;
@ -41,19 +15,29 @@ int Threader::getFreeDataSlotId() {
int Threader::getFreeThreadId() { int Threader::getFreeThreadId() {
int res; int res;
while((res = getFreeDataSlotId()) < 0) Sleep(10); while((res = getFreeDataSlotId()) < 0) Sleep(50);
return res; return res;
} }
void Threader::cleanUp() { void Threader::fireThread(char *res, void *func(int,std::condition_variable*)) {
mayRun = false; if(threadId < gThreads) {
//for(int i = 0; i != threadPoolSize; ++i) { threadPool.push_back(res);
//if(threadPool[i] != NULL) delete threadPool[i]; std::condition_variable cv;
//} cvPool.push_back(&cv);
threadPool.clear(); std::thread workerThread(func, threadId++, &cv);
workerThread.detach();
readyPool.push_back(true);
cv.notify_one();
} else {
int id = getFreeThreadId();
threadPool[id] = res;
readyPool[id] = true;
cvPool[id]->notify_one();
}
} }
void Threader::fireThread(char *res) { void Threader::cleanUp() {
//while(!mayRun) sleep(10); threadId = 0;
threadPool[getFreeThreadId()] = res; threadPool.clear();
cvPool.clear();
} }

View File

@ -2,29 +2,28 @@
#define THREADER_H #define THREADER_H
#include <mainResources.h> #include <mainResources.h>
#include <externData.h>
#include <thread> #include <thread>
#include <chrono>
//typedef struct { #include <future>
// char argv[MAX_ADDR_LEN] = {0}; #include <mutex>
//} ST; #include <condition_variable>
class Threader { class Threader {
private: private:
static int threadPoolSize;
static void* lFunc;
public: public:
static std::vector<char *> threadPool; static std::vector<char *> threadPool;
static bool mayRun; static int threadId;
static std::condition_variable cv;
static std::vector<bool> readyPool;
private: private:
static int getFree();
static int getFreeDataSlotId(); static int getFreeDataSlotId();
static int getFreeThreadId(); static int getFreeThreadId();
public: public:
static void recreateThreadPool(int poolSize); static void fireThread(char *st,
static void createThreadPool(int poolSize, void *func(int)); void* func(int,std::condition_variable*));
static void fireThread(char *st);
static void cleanUp(); static void cleanUp();
}; };

View File

@ -2531,6 +2531,7 @@ void nesca_3::IPScanSeq()
{ {
if(ui->portLine->text() != "") if(ui->portLine->text() != "")
{ {
saveOptions();
ui->labelParsed_Value->setText("0/0"); ui->labelParsed_Value->setText("0/0");
stopFirst = false; stopFirst = false;
ui->tabMainWidget->setTabEnabled(1, false); ui->tabMainWidget->setTabEnabled(1, false);
@ -2614,6 +2615,7 @@ void nesca_3::DNSScanSeq()
{ {
if(ui->lineEditPort->text() != "") if(ui->lineEditPort->text() != "")
{ {
saveOptions();
ui->labelParsed_Value->setText("0/0"); ui->labelParsed_Value->setText("0/0");
if(ui->lineEditStartIPDNS->text().indexOf(".") > 0) if(ui->lineEditStartIPDNS->text().indexOf(".") > 0)
{ {
@ -2670,6 +2672,7 @@ void nesca_3::ImportScanSeq()
else fileName = importFileName; else fileName = importFileName;
if(fileName != "") if(fileName != "")
{ {
saveOptions();
ui->tabMainWidget->setTabEnabled(0, false); ui->tabMainWidget->setTabEnabled(0, false);
ui->tabMainWidget->setTabEnabled(1, false); ui->tabMainWidget->setTabEnabled(1, false);
@ -3571,8 +3574,7 @@ void nesca_3::ChangeLabelTO_ValueChanged(QString str)
void nesca_3::ChangeLabelThreads_ValueChanged(QString str) void nesca_3::ChangeLabelThreads_ValueChanged(QString str)
{ {
gThreads = str.toInt(); gThreads = str.toInt();
//Threader::recreateThreadPool(gThreads);
} }
void nesca_3::PingTO_ChangeValue(QString str) void nesca_3::PingTO_ChangeValue(QString str)

View File

@ -6,8 +6,6 @@
#include "Threader.h" #include "Threader.h"
#include <thread> #include <thread>
//ST *st = NULL;
QJsonArray *jsonArr = new QJsonArray(); QJsonArray *jsonArr = new QJsonArray();
bool gShuffle = true; bool gShuffle = true;
@ -810,184 +808,82 @@ unsigned long int numOfIps(int ipsstart[], int ipsend[])
return gTargets; return gTargets;
} }
//#include <sys/types.h>
//#include <stdio.h>
//#include <signal.h>
//#include <adns.h>
//char *GetHost(char *ip)
//{
// char res[256] = {0};
// adns_state ads = NULL;
// adns_init(&ads, adns_if_nosigpipe, 0);
//
// adns_query aquery = 0;
// adns_answer* answer = NULL;
// sockaddr_in sockAddr;
// sockAddr.sin_family = AF_INET;
// sockAddr.sin_addr.S_un.S_addr = inet_addr(ip);
//
// adns_submit_reverse(ads,
// (struct sockaddr *)&sockAddr,
// (adns_rrtype)adns_r_ptr,
// (adns_queryflags)adns_qf_quoteok_anshost,
// NULL,
// &aquery);
// adns_wait(ads, &aquery, &answer, NULL);
//
// if(answer->status == adns_s_ok)
// {
// strncpy(res, (const char*)answer->rrs.bytes, 256);
// };
//
// adns_finish(ads);
// //struct hostent *result;
// //unsigned long addr = inet_addr(ip);
// //result = gethostbyaddr((char*)&addr, sizeof(addr), AF_INET);
// return res;
//
//#pragma region Reverse-ip
// //struct hostent *result;
// //unsigned long addr = inet_addr(ip);
// //result = gethostbyaddr((char*)&addr, sizeof(addr), AF_INET);
// //char res[256] = {0};
//
// //if( result == NULL )
// //{
// // strcpy(res, "");
// //}
// //else
// //{
// // if( result->h_name == NULL )
// // {
// // strcpy(res, "");
// // }
// // else
// // {
// // strcpy(res, "Hostname: ");
// // //if(result->h_length != NULL) strcat(res, std::to_string(result->h_length).c_str());
// // //strcat(res, " ");
// // //if(result->h_name != NULL) strcat(res, (result->h_name));
// // //strcat(res, ":");
// // if(result->h_addr_list[0] != NULL)
// // {
// // int sz = strlen((result->h_addr_list[0] + 4));
// // if(sz > 200) stt->doEmitionYellowFoundData("[LOL] Very long host detected [<a href=\"http://" + QString(ip) + "/\">" + QString(ip) + "</a>]");
// // strncpy(res, (result->h_addr_list[0] + 4), sz < 256 ? sz : 256);
// // };
// // };
// //};
//
//
// return res;
//}
//#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) //#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
//void _connect(int ss) //void _connect(int ss)
//#else //#else
//void _connect(int ss) //void _connect(char *ip)
//#endif //#endif
//{ //{
// while(globalScanFlag) {
// while(Threader::threadPool[ss] == NULL) {
// if(!globalScanFlag) return;
// Sleep(10);
// }
// ++ipCounter; // ++ipCounter;
// //char ip[MAX_ADDR_LEN] = {0};
// //strcpy(ip, Threader::threadPool[ss]);
// //char hostLog[256] = {0};
// //strcpy(hostLog, GetHost(ip));
// //delete Threader::threadPool[ss];
// ConInc(); // ConInc();
// for(int i = 0; i <= overallPorts; ++i) // for(int i = 0; i <= overallPorts; ++i)
// { // {
// if(globalScanFlag == false) break; // if(globalScanFlag == false) break;
// //if(Connector::_ConnectToPort( ip, portArr[i], "" ) == -2) break; // if(Connector::_ConnectToPort( ip, portArr[i], "" ) == -2) break;
// //if(Connector::_ConnectToPort( Threader::threadPool[ss], portArr[i], "" ) == -2) break;
// }; // };
// ConDec(); // ConDec();
// Threader::threadPool[ss] = NULL;
// }
//} //}
std::mutex m;
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
void _connect(char* ip) void _connect(int ss)
#else #else
void _connect(char* ip) void _connect(int ss, std::condition_variable *cv)
#endif #endif
{ {
//std::chrono::duration<int, std::milli> duration(200);
while(globalScanFlag) {
// std::future<int> f2 = Threader::threadPool[ss];
// f2.wait();
std::unique_lock<std::mutex> lk(m);
cv->wait(lk, [ss]{return Threader::readyPool[ss];});
// while(Threader::threadPool[ss] == NULL) {
// if(!globalScanFlag) return;
// std::this_thread::sleep_for(duration);
// }
// if(Threader::threadPool[ss] == (char*)-1) {
// --Threader::threadId;
// return;
// }
++ipCounter; ++ipCounter;
ConInc(); ConInc();
for(int i = 0; i <= overallPorts; ++i) for(int i = 0; i <= overallPorts; ++i)
{ {
if(globalScanFlag == false) break; if(globalScanFlag == false) break;
if(Connector::_ConnectToPort( ip, portArr[i], "" ) == -2) break; if(Connector::_ConnectToPort( Threader::threadPool[ss], portArr[i], "" ) == -2) break;
}; };
ConDec(); ConDec();
Threader::readyPool[ss] = false;
Threader::threadPool[ss] = NULL;
lk.unlock();
}
} }
void targetAndIPWriter(long long unsigned int target, const char *buff) void targetAndIPWriter(long long unsigned int target, const char *ip)
{ {
char curIPBuff[256] = {0}, targetNPers[32] = {0}; char targetNPers[32] = {0};
float percent = (gTargetsOverall != 0 ? (100 - target/(double)gTargetsOverall * 100) : 0);
stt->doEmitionIPRANGE(QString(ip));
strcpy(metaIPDNS, ip);
strcpy(metaIPDNS, buff);
sprintf(targetNPers, "%Lu (%.1f%%)", sprintf(targetNPers, "%Lu (%.1f%%)",
target, (gTargetsOverall != 0 ? (100 - target/(double)gTargetsOverall * 100) : 0)); target,
percent);
stt->doEmitionTargetsLeft(QString(targetNPers));
sprintf(metaTargets, "%Lu", target); sprintf(metaTargets, "%Lu", target);
sprintf(metaPercent, "%.1f", sprintf(metaPercent, "%.1f",
(gTargetsOverall != 0 ? (100 - target/(double)gTargetsOverall * 100) : 0)); percent);
sprintf(curIPBuff, "--->%s", buff);
stt->doEmitionIPRANGE(QString(curIPBuff));
stt->doEmitionTargetsLeft(QString(targetNPers));
} }
void _passLoginLoader() void _passLoginLoader()
@ -2300,9 +2196,7 @@ int _GetDNSFromMask(char *mask, char *saveMask, char *saveMaskEnder)
else else
{ {
strcpy(endIP2, saveMask); strcpy(endIP2, saveMask);
//st = new ST();
//ZeroMemory(st->argv, sizeof(st->argv));
ZeroMemory(iip, sizeof(iip)); ZeroMemory(iip, sizeof(iip));
while(cons >= gThreads && globalScanFlag) Sleep(300); while(cons >= gThreads && globalScanFlag) Sleep(300);
@ -2319,21 +2213,8 @@ int _GetDNSFromMask(char *mask, char *saveMask, char *saveMaskEnder)
targetAndIPWriter(--gTargets, res); targetAndIPWriter(--gTargets, res);
// std::thread thr(_connect, res); Threader::fireThread(res, (void* (*)(int,std::condition_variable*))_connect);
// thr.detach();
//Threader::fireThread(st);
//#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
// if(globalScanFlag) _beginthread( (void(*)(void*))_connect, 0, st );
//#else
// if(globalScanFlag)
// {
// pthread_t thrc;
// pthread_create(&thrc, NULL, (void *(*)(void*))&_connect, st );
// };
//#endif
Sleep(gThreadDelay); Sleep(gThreadDelay);
}; };
} }
@ -2344,8 +2225,6 @@ int startScan(char* args)
OpenSSL_add_all_algorithms(); /* Load cryptos, et.al. */ OpenSSL_add_all_algorithms(); /* Load cryptos, et.al. */
SSL_load_error_strings(); /* Bring in and register error messages */ SSL_load_error_strings(); /* Bring in and register error messages */
// Threader::createThreadPool(gThreads, (void* (*)(int))_connect);
horLineFlag = false; horLineFlag = false;
flCounter = 0; flCounter = 0;
PieAnomC1 = 0, PieWF = 0, PieBA = 0, PieSusp = 0, PieLowl = 0, PieSSH = 0; PieAnomC1 = 0, PieWF = 0, PieBA = 0, PieSusp = 0, PieLowl = 0, PieSSH = 0;
@ -2358,6 +2237,7 @@ int startScan(char* args)
overallPorts = 0; overallPorts = 0;
found = 0; found = 0;
indexIP = 0; indexIP = 0;
ZeroMemory(octet, sizeof(octet)); ZeroMemory(octet, sizeof(octet));
ZeroMemory(ipsstart, sizeof(ipsstart)); ZeroMemory(ipsstart, sizeof(ipsstart));
ZeroMemory(ipsend, sizeof(ipsend)); ZeroMemory(ipsend, sizeof(ipsend));
@ -2392,8 +2272,8 @@ int startScan(char* args)
return -1; return -1;
}; };
stt->doEmitionIPRANGE(QString(saveEndIP)); stt->doEmitionIPRANGE(QString(saveEndIP));
stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads)); stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads));
_passLoginLoader(); _passLoginLoader();
_NegativeLoader(); _NegativeLoader();
@ -2408,8 +2288,7 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads));
pthread_create(&thrs, NULL, (void *(*)(void*))&_saver, NULL); pthread_create(&thrs, NULL, (void *(*)(void*))&_saver, NULL);
#endif #endif
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
if (trackerOK) _beginthread((void(*)(void*))_tracker, 0, NULL); if (trackerOK) _beginthread((void(*)(void*))_tracker, 0, NULL);
Sleep(50);
_beginthread((void(*)(void*))_timer, 0, NULL); _beginthread((void(*)(void*))_timer, 0, NULL);
#else #else
pthread_t thrt; pthread_t thrt;
@ -2448,19 +2327,15 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads));
while (cons >= gThreads && globalScanFlag) Sleep(500); while (cons >= gThreads && globalScanFlag) Sleep(500);
if (globalScanFlag == false) goto haters_gonna_hate_IPM; if (globalScanFlag == false) goto haters_gonna_hate_IPM;
//st = new ST(); ZeroMemory(res, sizeof(res));
//ZeroMemory(st->argv, MAX_ADDR_LEN);
++indexIP; ++indexIP;
//strcpy(st->argv, ipVec[0].c_str());
strcpy(res, ipVec[0].c_str()); strcpy(res, ipVec[0].c_str());
strcpy(saveStartIP, res); strcpy(saveStartIP, res);
ipVec.erase(ipVec.begin()); ipVec.erase(ipVec.begin());
targetAndIPWriter(gTargets--, res); targetAndIPWriter(gTargets--, res);
//std::thread workerThread(_connect, res);
std::thread thr(_connect, res); //workerThread.detach();
thr.detach(); Threader::fireThread(res, (void* (*)(int,std::condition_variable*))_connect);
//Threader::fireThread(res);
Sleep(gThreadDelay); Sleep(gThreadDelay);
} }
} }
@ -2475,8 +2350,6 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads));
while (cons >= gThreads && globalScanFlag) Sleep(500); while (cons >= gThreads && globalScanFlag) Sleep(500);
if (globalScanFlag == false) break; if (globalScanFlag == false) break;
//st = new ST();
//ZeroMemory(st->argv, sizeof(st->argv));
ZeroMemory(res, sizeof(res)); ZeroMemory(res, sizeof(res));
++indexIP; ++indexIP;
@ -2490,16 +2363,9 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads));
tAddr.s_addr = ntohl(tAddr.s_addr); tAddr.s_addr = ntohl(tAddr.s_addr);
strcpy(res, inet_ntoa(tAddr)); strcpy(res, inet_ntoa(tAddr));
#endif #endif
//strcpy(st->argv, res);
strcpy(saveStartIP, res); strcpy(saveStartIP, res);
targetAndIPWriter(gTargets--, res); targetAndIPWriter(gTargets--, res);
Threader::fireThread(res, (void* (*)(int,std::condition_variable*))_connect);
// std::thread thr(_connect, res);
// thr.detach();
//Threader::fireThread(st);
Sleep(gThreadDelay); Sleep(gThreadDelay);
} }
break; break;
@ -2727,19 +2593,14 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads));
while (cons >= gThreads && globalScanFlag) Sleep(500); while (cons >= gThreads && globalScanFlag) Sleep(500);
if (globalScanFlag == false) goto haters_gonna_hate_IM; if (globalScanFlag == false) goto haters_gonna_hate_IM;
//st = new ST(); ZeroMemory(res, sizeof(res));
//ZeroMemory(st->argv, MAX_ADDR_LEN); ++indexIP;
++indexIP;
strcpy(res, ipVec[0].c_str()); strcpy(res, ipVec[0].c_str());
strcpy(saveStartIP, res); strcpy(saveStartIP, res);
ipVec.erase(ipVec.begin()); ipVec.erase(ipVec.begin());
targetAndIPWriter(gTargets--, res); targetAndIPWriter(gTargets--, res);
Threader::fireThread(res, (void* (*)(int,std::condition_variable*))_connect);
// std::thread thr(_connect, res);
// thr.detach();
//Threader::fireThread(st);
Sleep(gThreadDelay); Sleep(gThreadDelay);
} }
} }
@ -2753,8 +2614,6 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads));
while (cons >= gThreads && globalScanFlag) Sleep(500); while (cons >= gThreads && globalScanFlag) Sleep(500);
if (globalScanFlag == false) break; if (globalScanFlag == false) break;
//st = new ST();
//ZeroMemory(st->argv, sizeof(st->argv));
ZeroMemory(res, sizeof(res)); ZeroMemory(res, sizeof(res));
++indexIP; ++indexIP;
@ -2765,16 +2624,9 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads));
tAddr.s_addr = ntohl(tAddr.s_addr); tAddr.s_addr = ntohl(tAddr.s_addr);
strcpy(res, inet_ntoa(tAddr)); strcpy(res, inet_ntoa(tAddr));
#endif #endif
//strcpy(st->argv, res);
strcpy(saveStartIP, res); strcpy(saveStartIP, res);
targetAndIPWriter(gTargets--, res); targetAndIPWriter(gTargets--, res);
Threader::fireThread(res, (void* (*)(int,std::condition_variable*))_connect);
// std::thread thr(_connect, res);
// thr.detach();
//Threader::fireThread(st);
Sleep(gThreadDelay); Sleep(gThreadDelay);
} }
break; break;