nesca/nesca_startModule.cpp

136 lines
3.3 KiB
C++
Raw Normal View History

2015-03-10 14:35:50 +00:00
#include "STh.h"
2015-02-24 14:00:19 +00:00
#include "mainResources.h"
#include "externData.h"
#include "externFunctions.h"
bool __savingBackUpFile = false;
2015-02-24 14:00:19 +00:00
int gThreadDelay = 10;
int gC = 0;
int gTimeOut = 3;
int PieAnomC1 = 0, PieBA = 0, PieSusp = 0, PieLowl = 0, PieWF = 0, PieSSH = 0;
int AnomC1 = 0, Filt = 0, Overl = 0, Lowl = 0, Alive = 0, saved = 0, Susp = 0, WF = 0, offlines = 0, ssh = 0;
int GlobalNegativeSize = 0;
2015-04-03 14:36:22 +00:00
int found = 0, indexIP = 0;
2015-02-24 14:00:19 +00:00
int gMode;
int MaxPass = 0, MaxLogin = 0, MaxTags = 0, MaxWFLogin = 0, MaxWFPass = 0, MaxSSHPass = 0;
2015-04-02 19:07:25 +00:00
int ipsstart[4], ipsend[4],
overallPorts,
octet[4];
2015-04-04 12:43:22 +00:00
int baCount = 0;
2015-02-26 14:20:37 +00:00
int gPingTimeout = 1;
2015-04-02 12:33:49 +00:00
int gMaxBrutingThreads = 50;
2015-03-10 14:35:50 +00:00
unsigned int Activity = 0;
2015-02-24 14:00:19 +00:00
double ips = 0;
char **GlobalNegatives = 0;
char **loginLst, **passLst;
char **wfLoginLst, **wfPassLst;
char **sshlpLst;
2015-04-02 19:07:25 +00:00
char saveEndIP[128] = { 0 };
char gTLD[128] = { 0 };
char gPorts[65536] = { 0 };
char currentIP[MAX_ADDR_LEN] = { 0 };
char finalIP[32] = { 0 };
2015-03-20 14:28:51 +00:00
2015-02-24 14:00:19 +00:00
bool ErrLogFirstTime = true;
bool gPingNScan = false;
volatile int gThreads;
volatile int cons = 0;
volatile int BrutingThrds = 0;
volatile int threads = 20;
unsigned char tl(unsigned char d)
{
2015-04-02 19:07:25 +00:00
if (d >= 192 && d <= 223)
{
return (unsigned char)(d + 32);
}
else
{
return tolower(d);
};
}
std::string toLowerStr(const char *str)
{
2015-04-02 19:07:25 +00:00
if (str != NULL) {
int tsz = strlen(str);
char *strr = new char[tsz + 1];
ZeroMemory(strr, tsz);
for (int i = 0; i < tsz; i++)
{
strr[i] = tl(str[i]);
};
memset(strr + tsz, '\0', 1);
std::string tstr = std::string(strr);
delete[]strr;
return tstr;
}
else return "";
}
2015-03-06 14:32:36 +00:00
QString GetNSErrorDefinition(const char *str, const char *elem)
2015-02-24 14:00:19 +00:00
{
2015-04-02 19:07:25 +00:00
const char *temp = strstr(str, elem);
2015-02-24 14:00:19 +00:00
2015-04-02 19:07:25 +00:00
if (temp != NULL)
2015-02-24 14:00:19 +00:00
{
2015-04-02 19:07:25 +00:00
char definition[128] = { 0 };
const char *firstComma = strstr(temp + strlen(elem) + 1, "\"");
const char *lastComma = strstr(firstComma + 1, "\"");
2015-02-24 14:00:19 +00:00
int sz = lastComma - firstComma - 1;
strncpy(definition, firstComma + 1, (sz < 128 ? sz : 128));
return QString(definition);
}
else return QString("No definition found!");
2015-02-26 14:20:37 +00:00
}
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
2015-04-02 19:07:25 +00:00
unsigned char* ASCIItoUNICODE(unsigned char ch)
2015-02-26 14:20:37 +00:00
{
2015-04-02 19:07:25 +00:00
unsigned char Val[2];
if ((ch < 192) && (ch != 168) && (ch != 184)) { Val[0] = 0; Val[1] = ch; return Val; }
if (ch == 168) { Val[0] = 208; Val[1] = 129; return Val; }
if (ch == 184) { Val[0] = 209; Val[1] = 145; return Val; }
if (ch < 240) { Val[0] = 208; Val[1] = ch - 48; return Val; }
if (ch < 249) { Val[0] = 209; Val[1] = ch - 112; return Val; }
2015-02-26 14:20:37 +00:00
}
#endif
2015-03-20 14:28:51 +00:00
std::string xcode(LPCSTR src, UINT srcCodePage, UINT dstCodePage) {
2015-04-02 19:07:25 +00:00
std::string res;
2015-02-26 14:20:37 +00:00
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
2015-04-02 19:07:25 +00:00
int wsize = MultiByteToWideChar(srcCodePage, 0, src, -1, 0, 0);
LPWSTR wbuf = (LPWSTR)new char[wsize * sizeof(WCHAR)];
MultiByteToWideChar(srcCodePage, 0, src, -1, wbuf, wsize);
int size = WideCharToMultiByte(dstCodePage, 0, wbuf, -1, 0, 0, 0, 0);
char * buf = (char *)new char[size];
WideCharToMultiByte(dstCodePage, 0, wbuf, -1, buf, size, 0, 0);
delete wbuf;
2015-02-26 14:20:37 +00:00
2015-02-24 14:00:19 +00:00
res.append(buf);
2015-04-02 19:07:25 +00:00
delete buf;
2015-02-26 14:20:37 +00:00
#else
2015-04-02 19:07:25 +00:00
unsigned int size = 0;
while (src[size++]!=0);
char * buf = (char *)new char[size];
unsigned char uni[16] = {0};
2015-02-26 14:20:37 +00:00
2015-04-02 19:07:25 +00:00
size=0;
while (src[size]!=0)
{
2015-02-26 14:20:37 +00:00
2015-04-02 19:07:25 +00:00
};
delete buf;
2015-02-26 14:20:37 +00:00
#endif
2015-02-24 14:00:19 +00:00
return res;
}