mirror of
https://github.com/ChronosX88/nesca.git
synced 2024-11-23 18:52:19 +00:00
Import mode fix.
This commit is contained in:
parent
9bba24c952
commit
ff53c9bc8c
165
MainStarter.cpp
165
MainStarter.cpp
@ -50,7 +50,7 @@ char metaTargets[256] = { 0 };
|
|||||||
char metaETA[256] = { 0 };
|
char metaETA[256] = { 0 };
|
||||||
char metaOffline[256] = { 0 };
|
char metaOffline[256] = { 0 };
|
||||||
|
|
||||||
std::vector<std::string> splitToStringVector(const std::string &s, char delim) {
|
std::vector<std::string> splitToStrVector(const std::string &s, char delim) {
|
||||||
std::vector<std::string> elems;
|
std::vector<std::string> elems;
|
||||||
std::stringstream ss(s);
|
std::stringstream ss(s);
|
||||||
std::string item;
|
std::string item;
|
||||||
@ -91,19 +91,13 @@ void MainStarter::fileLoader(const char *fileName) {
|
|||||||
ZeroMemory(curIP, sizeof(curIP));
|
ZeroMemory(curIP, sizeof(curIP));
|
||||||
};
|
};
|
||||||
|
|
||||||
ipsstartfl = new unsigned int*[importFileSize + 2];
|
ipsstartfl = new unsigned int*[importFileSize + 1];
|
||||||
ipsendfl = new unsigned int*[importFileSize + 2];
|
ipsendfl = new unsigned int*[importFileSize + 1];
|
||||||
|
|
||||||
ZeroMemory(ipsstartfl, importFileSize);
|
|
||||||
ZeroMemory(ipsendfl, importFileSize);
|
|
||||||
|
|
||||||
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], 4);
|
|
||||||
ZeroMemory(ipsendfl[i], 4);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
rewind(fl);
|
rewind(fl);
|
||||||
@ -130,39 +124,19 @@ void MainStarter::fileLoader(const char *fileName) {
|
|||||||
|
|
||||||
if (strstr(curIP, "-") != NULL)
|
if (strstr(curIP, "-") != NULL)
|
||||||
{
|
{
|
||||||
bool firstPart = true;
|
std::vector<std::string> tmpIPVec = splitToStrVector(curIP, '-');
|
||||||
int offset = 0;
|
std::vector<int> tmpIPIntVec1 = splitToIntVector(tmpIPVec[0], '.');
|
||||||
int curNIndex = 0;
|
std::vector<int> tmpIPIntVec2 = splitToIntVector(tmpIPVec[1], '.');
|
||||||
char curS;
|
|
||||||
char curN[32] = { 0 };
|
ipsstartfl[MainStarter::flCounter][0] = tmpIPIntVec1[0];
|
||||||
for (int i = 0; i < strlen(curIP); ++i)
|
ipsstartfl[MainStarter::flCounter][1] = tmpIPIntVec1[1];
|
||||||
{
|
ipsstartfl[MainStarter::flCounter][2] = tmpIPIntVec1[2];
|
||||||
curS = curIP[i];
|
ipsstartfl[MainStarter::flCounter][3] = tmpIPIntVec1[3];
|
||||||
if (curS == '.')
|
|
||||||
{
|
ipsendfl[MainStarter::flCounter][0] = tmpIPIntVec2[0];
|
||||||
if (firstPart) ipsstartfl[MainStarter::flCounter][offset] = atoi(curN);
|
ipsendfl[MainStarter::flCounter][1] = tmpIPIntVec2[1];
|
||||||
else ipsendfl[MainStarter::flCounter][offset] = atoi(curN);
|
ipsendfl[MainStarter::flCounter][2] = tmpIPIntVec2[2];
|
||||||
++offset;
|
ipsendfl[MainStarter::flCounter][3] = tmpIPIntVec2[3];
|
||||||
curNIndex = 0;
|
|
||||||
ZeroMemory(curN, 32);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (curS == '-')
|
|
||||||
{
|
|
||||||
if (firstPart) ipsstartfl[MainStarter::flCounter][offset] = atoi(curN);
|
|
||||||
else ipsendfl[MainStarter::flCounter][offset] = atoi(curN);
|
|
||||||
offset = 0;
|
|
||||||
firstPart = false;
|
|
||||||
curNIndex = 0;
|
|
||||||
ZeroMemory(curN, 32);
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
curN[curNIndex++] = curS;
|
|
||||||
if (i == strlen(curIP) - 1)
|
|
||||||
{
|
|
||||||
ipsendfl[MainStarter::flCounter][offset] = atoi(curN);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
if (ipsstartfl[MainStarter::flCounter][0] > ipsendfl[MainStarter::flCounter][0]
|
if (ipsstartfl[MainStarter::flCounter][0] > ipsendfl[MainStarter::flCounter][0]
|
||||||
|| (ipsstartfl[MainStarter::flCounter][0] >= ipsendfl[MainStarter::flCounter][0]
|
|| (ipsstartfl[MainStarter::flCounter][0] >= ipsendfl[MainStarter::flCounter][0]
|
||||||
@ -179,20 +153,28 @@ void MainStarter::fileLoader(const char *fileName) {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
char tempMsg[256] = { 0 };
|
stt->doEmitionRedFoundData("[IP Loader]Wrong list format. Line-> [" +
|
||||||
strcpy(tempMsg, "[IP Loader]Wrong list format. Line-> [");
|
QString::number(MainStarter::flCounter) +
|
||||||
strcat(tempMsg, std::to_string(MainStarter::flCounter).c_str());
|
"] String-> [" +
|
||||||
strcat(tempMsg, "] String-> [");
|
QString(curIPCopy) + "]");
|
||||||
strcat(tempMsg, curIPCopy);
|
|
||||||
strcat(tempMsg, "]");
|
|
||||||
stt->doEmitionRedFoundData(QString(tempMsg));
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
gTargets += 256 * 256 * 256 * (ipsendfl[MainStarter::flCounter][0] - ipsstartfl[MainStarter::flCounter][0]);
|
unsigned long ip1 = (ipsstartfl[MainStarter::flCounter][0] * 16777216) +
|
||||||
gTargets += 256 * 256 * (ipsendfl[MainStarter::flCounter][1] - ipsstartfl[MainStarter::flCounter][1]);
|
(ipsstartfl[MainStarter::flCounter][1] * 65536) +
|
||||||
gTargets += 256 * (ipsendfl[MainStarter::flCounter][2] - ipsstartfl[MainStarter::flCounter][2]);
|
(ipsstartfl[MainStarter::flCounter][2] * 256) +
|
||||||
gTargets += (ipsendfl[MainStarter::flCounter][3] - ipsstartfl[MainStarter::flCounter][3]);
|
ipsstartfl[MainStarter::flCounter][3];
|
||||||
|
unsigned long ip2 = (ipsendfl[MainStarter::flCounter][0] * 16777216) +
|
||||||
|
(ipsendfl[MainStarter::flCounter][1] * 65536) +
|
||||||
|
(ipsendfl[MainStarter::flCounter][2] * 256) +
|
||||||
|
ipsendfl[MainStarter::flCounter][3];
|
||||||
|
|
||||||
|
if (ip1 > ip2) {
|
||||||
|
stt->doEmitionRedFoundData("Malformed input: check your range (" +
|
||||||
|
QString(curIP) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
gTargets += ip2 - ip1 + 1;
|
||||||
++MainStarter::flCounter;
|
++MainStarter::flCounter;
|
||||||
}
|
}
|
||||||
else if (strstr(curIP, "/") != NULL)
|
else if (strstr(curIP, "/") != NULL)
|
||||||
@ -241,6 +223,12 @@ void MainStarter::fileLoader(const char *fileName) {
|
|||||||
(ip_max[1] * 65536) +
|
(ip_max[1] * 65536) +
|
||||||
(ip_max[2] * 256) +
|
(ip_max[2] * 256) +
|
||||||
ip_max[3];
|
ip_max[3];
|
||||||
|
|
||||||
|
if (ip1 > ip2) {
|
||||||
|
stt->doEmitionRedFoundData("Malformed input: check your range (" +
|
||||||
|
QString(curIP) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
gTargets += ip2 - ip1 + 1;
|
gTargets += ip2 - ip1 + 1;
|
||||||
++MainStarter::flCounter;
|
++MainStarter::flCounter;
|
||||||
}
|
}
|
||||||
@ -271,10 +259,7 @@ void MainStarter::fileLoader(const char *fileName) {
|
|||||||
stt->doEmitionYellowFoundData("List loader - [OK] (" + QString::number(gTargetsNumber + 1) + " hosts)");
|
stt->doEmitionYellowFoundData("List loader - [OK] (" + QString::number(gTargetsNumber + 1) + " hosts)");
|
||||||
fclose(fl);
|
fclose(fl);
|
||||||
}
|
}
|
||||||
else
|
else stt->doEmitionRedFoundData("[IP Loader] Cannot open IP list.");
|
||||||
{
|
|
||||||
stt->doEmitionRedFoundData("[IP Loader] Cannot open IP list.");
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
int MainStarter::loadTargets(const char *data) {
|
int MainStarter::loadTargets(const char *data) {
|
||||||
|
|
||||||
@ -312,9 +297,9 @@ int MainStarter::loadTargets(const char *data) {
|
|||||||
char newRangeString[128] = { 0 };
|
char newRangeString[128] = { 0 };
|
||||||
sprintf(newRangeString, "%u.%u.%u.%u-%u.%u.%u.%u",
|
sprintf(newRangeString, "%u.%u.%u.%u-%u.%u.%u.%u",
|
||||||
ip_min[0], ip_min[1], ip_min[2], ip_min[3], ip_max[0], ip_max[1], ip_max[2], ip_max[3]);
|
ip_min[0], ip_min[1], ip_min[2], ip_min[3], ip_max[0], ip_max[1], ip_max[2], ip_max[3]);
|
||||||
rangeVec = splitToStringVector(std::string(newRangeString), '-');
|
rangeVec = splitToStrVector(std::string(newRangeString), '-');
|
||||||
}
|
}
|
||||||
else rangeVec = splitToStringVector(data, '-');
|
else rangeVec = splitToStrVector(data, '-');
|
||||||
|
|
||||||
std::vector<int> ip1TmpVec = splitToIntVector(rangeVec[0], '.');
|
std::vector<int> ip1TmpVec = splitToIntVector(rangeVec[0], '.');
|
||||||
std::vector<int> ip2TmpVec = splitToIntVector(rangeVec[1], '.');
|
std::vector<int> ip2TmpVec = splitToIntVector(rangeVec[1], '.');
|
||||||
@ -337,35 +322,30 @@ int MainStarter::loadTargets(const char *data) {
|
|||||||
(ipsend[1] * 65536) +
|
(ipsend[1] * 65536) +
|
||||||
(ipsend[2] * 256) +
|
(ipsend[2] * 256) +
|
||||||
ipsend[3];
|
ipsend[3];
|
||||||
|
|
||||||
|
if (ip1 > ip2) {
|
||||||
|
stt->doEmitionRedFoundData("Malformed input: check your range");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
sprintf(finalIP, "%d.%d.%d.%d",
|
sprintf(finalIP, "%d.%d.%d.%d",
|
||||||
ipsend[0], ipsend[1], ipsend[2], ipsend[3]);
|
ipsend[0], ipsend[1], ipsend[2], ipsend[3]);
|
||||||
|
|
||||||
|
gTargets = ip2 - ip1 + 1;
|
||||||
|
gTargetsNumber = gTargets;
|
||||||
}
|
}
|
||||||
else if (gMode == 1) {
|
else if (gMode == 1) {
|
||||||
strncpy(dnsTarget, data, 256);
|
strncpy(dnsTarget, data, 256);
|
||||||
|
|
||||||
|
gTargets = ip2 - ip1 + 1;
|
||||||
|
gTargetsNumber = gTargets;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fileLoader(data);
|
fileLoader(data);
|
||||||
|
sprintf(finalIP, "%d.%d.%d.%d",
|
||||||
ip1 = (ipsstartfl[gflIndex][0] * 16777216) +
|
ipsendfl[gflIndex][0], ipsendfl[gflIndex][1], ipsendfl[gflIndex][2], ipsendfl[gflIndex][3]);
|
||||||
(ipsstartfl[gflIndex][1] * 65536) +
|
|
||||||
(ipsstartfl[gflIndex][2] * 256) +
|
|
||||||
ipsstartfl[gflIndex][3];
|
|
||||||
ip2 = (ipsendfl[gflIndex][0] * 16777216) +
|
|
||||||
(ipsendfl[gflIndex][1] * 65536) +
|
|
||||||
(ipsendfl[gflIndex][2] * 256) +
|
|
||||||
ipsendfl[gflIndex][3];
|
|
||||||
sprintf(finalIP, "%d.%d.%d.%d",
|
|
||||||
ipsendfl[0], ipsendfl[1], ipsendfl[2], ipsendfl[3]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gMode != 1 && ip1 > ip2) {
|
|
||||||
stt->doEmitionRedFoundData("Malformed input: check your range");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
gTargets = ip2 - ip1 + 1;
|
|
||||||
gTargetsNumber = gTargets;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int MainStarter::loadPorts(const char *data, char delim) {
|
int MainStarter::loadPorts(const char *data, char delim) {
|
||||||
@ -1238,22 +1218,19 @@ void MainStarter::startImportScan(){
|
|||||||
|
|
||||||
stt->doEmitionChangeStatus("Scanning...");
|
stt->doEmitionChangeStatus("Scanning...");
|
||||||
for (gflIndex = 0; gflIndex < MainStarter::flCounter; ++gflIndex)
|
for (gflIndex = 0; gflIndex < MainStarter::flCounter; ++gflIndex)
|
||||||
{
|
{
|
||||||
strcpy(metaRange, std::to_string(ipsstartfl[gflIndex][0]).c_str());
|
sprintf(metaRange, "%d.%d.%d.%d-%d.%d.%d.%d",
|
||||||
strcat(metaRange, ".");
|
ipsstartfl[gflIndex][0], ipsstartfl[gflIndex][1], ipsstartfl[gflIndex][2], ipsstartfl[gflIndex][3],
|
||||||
strcat(metaRange, std::to_string(ipsstartfl[gflIndex][1]).c_str());
|
ipsendfl[gflIndex][0], ipsendfl[gflIndex][1], ipsendfl[gflIndex][2], ipsendfl[gflIndex][3]);
|
||||||
strcat(metaRange, ".");
|
|
||||||
strcat(metaRange, std::to_string(ipsstartfl[gflIndex][2]).c_str());
|
ip1 = (ipsstartfl[gflIndex][0] * 16777216) +
|
||||||
strcat(metaRange, ".");
|
(ipsstartfl[gflIndex][1] * 65536) +
|
||||||
strcat(metaRange, std::to_string(ipsstartfl[gflIndex][3]).c_str());
|
(ipsstartfl[gflIndex][2] * 256) +
|
||||||
strcat(metaRange, "-");
|
ipsstartfl[gflIndex][3];
|
||||||
strcat(metaRange, std::to_string(ipsendfl[gflIndex][0]).c_str());
|
ip2 = (ipsendfl[gflIndex][0] * 16777216) +
|
||||||
strcat(metaRange, ".");
|
(ipsendfl[gflIndex][1] * 65536) +
|
||||||
strcat(metaRange, std::to_string(ipsendfl[gflIndex][1]).c_str());
|
(ipsendfl[gflIndex][2] * 256) +
|
||||||
strcat(metaRange, ".");
|
ipsendfl[gflIndex][3];
|
||||||
strcat(metaRange, std::to_string(ipsendfl[gflIndex][2]).c_str());
|
|
||||||
strcat(metaRange, ".");
|
|
||||||
strcat(metaRange, std::to_string(ipsendfl[gflIndex][3]).c_str());
|
|
||||||
|
|
||||||
switch (gShuffle) {
|
switch (gShuffle) {
|
||||||
case true: {
|
case true: {
|
||||||
|
Loading…
Reference in New Issue
Block a user