mirror of
https://github.com/ChronosX88/nesca.git
synced 2024-11-23 18:52:19 +00:00
Import mode crash fix.
This commit is contained in:
parent
ff53c9bc8c
commit
d5bf3ef9e8
@ -72,7 +72,7 @@ std::vector<int> splitToIntVector(const std::string &s, char delim) {
|
|||||||
|
|
||||||
return elems;
|
return elems;
|
||||||
}
|
}
|
||||||
void MainStarter::fileLoader(const char *fileName) {
|
int MainStarter::fileLoader(const char *fileName) {
|
||||||
|
|
||||||
char curIP[256] = { 0 }, curIPCopy[256] = { 0 };
|
char curIP[256] = { 0 }, curIPCopy[256] = { 0 };
|
||||||
unsigned int importFileSize = 0;
|
unsigned int importFileSize = 0;
|
||||||
@ -84,20 +84,28 @@ void MainStarter::fileLoader(const char *fileName) {
|
|||||||
{
|
{
|
||||||
if (curIP[0] != '#' && curIP[0] != ' ' && curIP[0] != '\n' && curIP[0] != '\r' && strcmp(curIP, "") != 0 &&
|
if (curIP[0] != '#' && curIP[0] != ' ' && curIP[0] != '\n' && curIP[0] != '\r' && strcmp(curIP, "") != 0 &&
|
||||||
((curIP[0] == '/' && curIP[1] == '/') == false) && ((curIP[0] == '\t' && curIP[1] == '\t' && curIP[2] == '\t' && (curIP[3] == 13 || curIP[3] == 10 || curIP[3] == '#')) == false)
|
((curIP[0] == '/' && curIP[1] == '/') == false) && ((curIP[0] == '\t' && curIP[1] == '\t' && curIP[2] == '\t' && (curIP[3] == 13 || curIP[3] == 10 || curIP[3] == '#')) == false)
|
||||||
&& (curIP[0] == '\t' && curIP[1] == '\t' && curIP[2] == '\t' && (curIP[3] == '/' && curIP[4] == '/')) == false)
|
&& (curIP[0] == '\t' && curIP[1] == '\t' && curIP[2] == '\t' && (curIP[3] == '/' && curIP[4] == '/')) == false
|
||||||
{
|
) ++importFileSize;
|
||||||
++importFileSize;
|
|
||||||
};
|
|
||||||
ZeroMemory(curIP, sizeof(curIP));
|
ZeroMemory(curIP, sizeof(curIP));
|
||||||
};
|
};
|
||||||
|
|
||||||
ipsstartfl = new unsigned int*[importFileSize + 1];
|
if (importFileSize == 0) {
|
||||||
ipsendfl = new unsigned int*[importFileSize + 1];
|
fclose(fl);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ipsstartfl = new unsigned int*[importFileSize + 1000];
|
||||||
|
ipsendfl = new unsigned int*[importFileSize + 1000];
|
||||||
|
ZeroMemory(ipsstartfl, sizeof(ipsstartfl));
|
||||||
|
ZeroMemory(ipsendfl, sizeof(ipsendfl));
|
||||||
|
|
||||||
for (int i = 0; i < importFileSize; ++i)
|
for (int i = 0; i < importFileSize; ++i)
|
||||||
{
|
{
|
||||||
ipsstartfl[i] = new unsigned int[4];
|
ipsstartfl[i] = new unsigned int[4];
|
||||||
ipsendfl[i] = new unsigned int[4];
|
ipsendfl[i] = new unsigned int[4];
|
||||||
|
|
||||||
|
ZeroMemory(ipsstartfl[i], sizeof(ipsstartfl[i]));
|
||||||
|
ZeroMemory(ipsendfl[i], sizeof(ipsendfl[i]));
|
||||||
};
|
};
|
||||||
|
|
||||||
rewind(fl);
|
rewind(fl);
|
||||||
@ -157,7 +165,7 @@ void MainStarter::fileLoader(const char *fileName) {
|
|||||||
QString::number(MainStarter::flCounter) +
|
QString::number(MainStarter::flCounter) +
|
||||||
"] String-> [" +
|
"] String-> [" +
|
||||||
QString(curIPCopy) + "]");
|
QString(curIPCopy) + "]");
|
||||||
return;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned long ip1 = (ipsstartfl[MainStarter::flCounter][0] * 16777216) +
|
unsigned long ip1 = (ipsstartfl[MainStarter::flCounter][0] * 16777216) +
|
||||||
@ -179,9 +187,16 @@ void MainStarter::fileLoader(const char *fileName) {
|
|||||||
}
|
}
|
||||||
else if (strstr(curIP, "/") != NULL)
|
else if (strstr(curIP, "/") != NULL)
|
||||||
{
|
{
|
||||||
|
if (strlen(curIP) > 18) {
|
||||||
|
stt->doEmitionRedFoundData("[IP Loader]Wrong list format. Line-> [" +
|
||||||
|
QString::number(MainStarter::flCounter) +
|
||||||
|
"] String-> [" +
|
||||||
|
QString(curIPCopy) +
|
||||||
|
"]");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
unsigned int ip[4] = { 0 }, ip_min[4] = { 0 }, ip_max[4] = { 0 }, tmp1, tmp2;
|
unsigned int ip[4] = { 0 }, ip_min[4] = { 0 }, ip_max[4] = { 0 }, tmp1, tmp2;
|
||||||
unsigned int netmask = atoi(strstr(curIP, "/") + 1);
|
unsigned int netmask = atoi(strstr(curIP, "/") + 1);
|
||||||
char ip_string[19];
|
|
||||||
|
|
||||||
std::vector<int> tmpIPVec = splitToIntVector(curIP, '.');
|
std::vector<int> tmpIPVec = splitToIntVector(curIP, '.');
|
||||||
|
|
||||||
@ -238,18 +253,12 @@ void MainStarter::fileLoader(const char *fileName) {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char tempMsg[256] = { 0 };
|
|
||||||
strcpy(tempMsg, "[IP Loader]Wrong list format. Line-> [");
|
|
||||||
strcat(tempMsg, std::to_string(MainStarter::flCounter).c_str());
|
|
||||||
strcat(tempMsg, "] String-> [");
|
|
||||||
strcat(tempMsg, curIPCopy);
|
|
||||||
strcat(tempMsg, "]");
|
|
||||||
stt->doEmitionRedFoundData("[IP Loader]Wrong list format. Line-> [" +
|
stt->doEmitionRedFoundData("[IP Loader]Wrong list format. Line-> [" +
|
||||||
QString::number(MainStarter::flCounter) +
|
QString::number(MainStarter::flCounter) +
|
||||||
"] String-> [" +
|
"] String-> [" +
|
||||||
QString(curIPCopy) +
|
QString(curIPCopy) +
|
||||||
"]");
|
"]");
|
||||||
return;
|
return -1;
|
||||||
};
|
};
|
||||||
ZeroMemory(curIP, sizeof(curIP));
|
ZeroMemory(curIP, sizeof(curIP));
|
||||||
};
|
};
|
||||||
@ -270,7 +279,6 @@ int MainStarter::loadTargets(const char *data) {
|
|||||||
|
|
||||||
unsigned int ip[4] = { 0 }, ip_min[4] = { 0 }, ip_max[4] = { 0 }, tmp1, tmp2;
|
unsigned int ip[4] = { 0 }, ip_min[4] = { 0 }, ip_max[4] = { 0 }, tmp1, tmp2;
|
||||||
unsigned int netmask = atoi(strstr(data, "/") + 1);
|
unsigned int netmask = atoi(strstr(data, "/") + 1);
|
||||||
char ip_string[19];
|
|
||||||
|
|
||||||
std::vector<int> tmpIPVec = splitToIntVector(data, '.');
|
std::vector<int> tmpIPVec = splitToIntVector(data, '.');
|
||||||
|
|
||||||
@ -341,7 +349,10 @@ int MainStarter::loadTargets(const char *data) {
|
|||||||
gTargetsNumber = gTargets;
|
gTargetsNumber = gTargets;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fileLoader(data);
|
if (fileLoader(data) == -1) {
|
||||||
|
stt->doEmitionRedFoundData("IP list is empty.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
sprintf(finalIP, "%d.%d.%d.%d",
|
sprintf(finalIP, "%d.%d.%d.%d",
|
||||||
ipsendfl[gflIndex][0], ipsendfl[gflIndex][1], ipsendfl[gflIndex][2], ipsendfl[gflIndex][3]);
|
ipsendfl[gflIndex][0], ipsendfl[gflIndex][1], ipsendfl[gflIndex][2], ipsendfl[gflIndex][3]);
|
||||||
}
|
}
|
||||||
@ -1306,7 +1317,14 @@ void MainStarter::runAuxiliaryThreads() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainStarter::start() {
|
void MainStarter::start(const char* targets, const char* ports) {
|
||||||
|
|
||||||
|
if (loadTargets(targets) == -1 ||
|
||||||
|
loadPorts(ports, ',') == -1) {
|
||||||
|
stt->doEmitionKillSttThread();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
globalScanFlag = true;
|
globalScanFlag = true;
|
||||||
runAuxiliaryThreads();
|
runAuxiliaryThreads();
|
||||||
|
|
||||||
@ -1317,9 +1335,7 @@ void MainStarter::start() {
|
|||||||
stt->doEmitionYellowFoundData("Stopping threads...");
|
stt->doEmitionYellowFoundData("Stopping threads...");
|
||||||
stt->doEmitionChangeStatus("Stopping...");
|
stt->doEmitionChangeStatus("Stopping...");
|
||||||
|
|
||||||
while (cons > 0 || jsonArr->size() > 0) {
|
while (cons > 0 || jsonArr->size() > 0) Sleep(2000);
|
||||||
Sleep(2000);
|
|
||||||
};
|
|
||||||
|
|
||||||
stt->doEmitionGreenFoundData("Done. Saved <u>" + QString::number(saved) +
|
stt->doEmitionGreenFoundData("Done. Saved <u>" + QString::number(saved) +
|
||||||
"</u> of <u>" + QString::number(found) + "</u> nodes.");
|
"</u> of <u>" + QString::number(found) + "</u> nodes.");
|
||||||
|
@ -27,7 +27,7 @@ public:
|
|||||||
static bool savingBackUpFile;
|
static bool savingBackUpFile;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainStarter(const char* targets, const char* ports)
|
MainStarter()
|
||||||
{
|
{
|
||||||
horLineFlag = false;
|
horLineFlag = false;
|
||||||
PieAnomC1 = 0, PieWF = 0, PieBA = 0, PieSusp = 0, PieLowl = 0, PieSSH = 0;
|
PieAnomC1 = 0, PieWF = 0, PieBA = 0, PieSusp = 0, PieLowl = 0, PieSSH = 0;
|
||||||
@ -45,9 +45,6 @@ public:
|
|||||||
ZeroMemory(ipsstart, sizeof(ipsstart));
|
ZeroMemory(ipsstart, sizeof(ipsstart));
|
||||||
ZeroMemory(ipsend, sizeof(ipsend));
|
ZeroMemory(ipsend, sizeof(ipsend));
|
||||||
|
|
||||||
if (loadTargets(targets) == -1 ||
|
|
||||||
loadPorts(ports, ',') == -1) return;
|
|
||||||
|
|
||||||
curl_global_init(CURL_GLOBAL_ALL);
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
|
|
||||||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
|
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
|
||||||
@ -115,8 +112,8 @@ public:
|
|||||||
void runAuxiliaryThreads();
|
void runAuxiliaryThreads();
|
||||||
void saver();
|
void saver();
|
||||||
void saveBackupToFile();
|
void saveBackupToFile();
|
||||||
void fileLoader(const char *fileName);
|
int fileLoader(const char *fileName);
|
||||||
void start();
|
void start(const char* targets, const char* ports);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINSTARTER_H
|
#endif // MAINSTARTER_H
|
7
STh.cpp
7
STh.cpp
@ -85,8 +85,7 @@ void STh::setPorts(QString ports) {
|
|||||||
}
|
}
|
||||||
void STh::run()
|
void STh::run()
|
||||||
{
|
{
|
||||||
MainStarter ms(this->target.toLocal8Bit().data(),
|
MainStarter ms;
|
||||||
this->ports.toLocal8Bit().data()
|
ms.start(this->target.toLocal8Bit().data(),
|
||||||
);
|
this->ports.toLocal8Bit().data());
|
||||||
ms.start();
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ void ProgressbarDrawer::update()
|
|||||||
int nesca_3::perc = 0;
|
int nesca_3::perc = 0;
|
||||||
void ProgressbarDrawer::run()
|
void ProgressbarDrawer::run()
|
||||||
{
|
{
|
||||||
|
globalScanFlag = true;
|
||||||
while(globalScanFlag)
|
while(globalScanFlag)
|
||||||
{
|
{
|
||||||
msleep(1000);
|
msleep(1000);
|
||||||
|
Loading…
Reference in New Issue
Block a user