Added resources + some refactoring

This commit is contained in:
cora32 2014-11-22 19:22:24 +03:00
parent 61e0d2ecbf
commit 369f6440fe
14 changed files with 262 additions and 318 deletions

View File

@ -80,22 +80,19 @@ int KeyCheckerMain()
int test = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr));
if(test == -1)
{
#pragma region QTGUI_Area
stt->doEmitionRedFoundData("[Key check] -connect() returned. Cannot connect to balancer! " + QString::number(WSAGetLastError()) + ".");
closesocket(sock);
CSSOCKET(sock);
return -1;
#pragma endregion
};
test = send(sock, msg, strlen(msg), 0);
if(test == -1)
{
#pragma region QTGUI_Area
stt->doEmitionRedFoundData("[Key check] -send() returned. Cannot send to balancer! " + QString::number(WSAGetLastError()) + ".");
closesocket(sock);
CSSOCKET(sock);
return -1;
#pragma endregion
};
ZeroMemory(msg, sizeof(msg));
@ -110,11 +107,10 @@ int KeyCheckerMain()
if(test == -1)
{
#pragma region QTGUI_Area
stt->doEmitionRedFoundData("[Key check] -recv() returned. Cannot recv from balancer! " + QString::number(WSAGetLastError()) + ".");
closesocket(sock);
CSSOCKET(sock);
return -1;
#pragma endregion
};
char *t1;
@ -128,20 +124,17 @@ int KeyCheckerMain()
int ln = t2 - t1 - strlen("http://");
if(ln > 64)
{
#pragma region QTGUI_Area
stt->doEmitionRedFoundData("[Key check] -Received server string is not valid!");
closesocket(sock);
CSSOCKET(sock);
return -1;
#pragma endregion
}
else strncpy(ndbServer, (char*)(t1 + strlen("http://")), ln);
if(strlen(t2) > 64)
{
#pragma region QTGUI_Area
stt->doEmitionYellowFoundData("[Key check] -Fragmentation detected!");
#pragma endregion
if(strstr(t2, "\r\n") != NULL)
{
char *t3 = strstr(t2, "\r\n");
@ -149,11 +142,10 @@ int KeyCheckerMain()
if(y > 64)
{
#pragma region QTGUI_Area
stt->doEmitionRedFoundData("[Key check] -Received server string is not valid!");
closesocket(sock);
CSSOCKET(sock);
return -1;
#pragma endregion
}
else
{
@ -162,29 +154,25 @@ int KeyCheckerMain()
}
else
{
#pragma region QTGUI_Area
stt->doEmitionRedFoundData("[Key check] -Received server string is not valid!");
closesocket(sock);
CSSOCKET(sock);
return -1;
#pragma endregion
};
} else strcpy(ndbScript, t2);
}
else
{
#pragma region QTGUI_Area
stt->doEmitionRedFoundData("[Key check] -Cannot receive script value!");
closesocket(sock);
CSSOCKET(sock);
return -1;
#pragma endregion
};
ZeroMemory(msg, sizeof(msg));
#pragma region QTGUI_Area
stt->doEmitionGreenFoundData("[Key check] -OK. -Server string aquired! Checking key...");
closesocket(sock);
#pragma endregion
CSSOCKET(sock);
sockAddr.sin_family = AF_INET;
sockAddr.sin_port = htons(atoi(trcSrvPortLine));
@ -209,14 +197,14 @@ int KeyCheckerMain()
if(c == SOCKET_ERROR)
{
stt->doEmitionRedFoundData("[Key check] -Connection timeout.");
closesocket(sock);
CSSOCKET(sock);
return -1;
};
c = send(sock, msg, strlen(msg), 0);
if(c == SOCKET_ERROR)
{
stt->doEmitionRedFoundData("[Key check] -Send error.");
closesocket(sock);
CSSOCKET(sock);
return -1;
};
ZeroMemory(msg, sizeof(msg));
@ -227,7 +215,8 @@ int KeyCheckerMain()
#pragma region QTGUI_Area
stt->doEmitionGreenFoundData("[Key check] -OK. Key is valid!");
#pragma endregion
closesocket(sock);
CSSOCKET(sock);
if(emitIfOK == 0) stt->doEmitionStartScanIP();
else if(emitIfOK == 1) stt->doEmitionStartScanDNS();
else if(emitIfOK == 2) stt->doEmitionStartScanImport();
@ -240,13 +229,13 @@ int KeyCheckerMain()
if(errorDef == "Invalid access key") stt->doEmitionYellowFoundData("[NS-Track] [Key is unauthorized] A valid key is required.");
else stt->doEmitionYellowFoundData("[NS-Track] -FAIL! [400 Bad Request : " + GetNSErrorDefinition(msg, "notify") + "]");
#pragma endregion
closesocket(sock);
CSSOCKET(sock);
return -1;
}
else if(strstr(msg, "503 Bad Gateway") != NULL)
{
stt->doEmitionYellowFoundData("[NS-Track] 503 Backend not responding!");
closesocket(sock);
CSSOCKET(sock);
return -1;
}
else
@ -257,19 +246,19 @@ int KeyCheckerMain()
stt->doEmitionYellowFoundData("[Key check] -FAIL! An error occured. (" + QString::number(WSAGetLastError()) + ") Header: <u>" + QString::fromLocal8Bit(header) + "</u>");
if(gDebugMode) stt->doEmitionDebugFoundData(QString(msg));
#pragma endregion
closesocket(sock);
CSSOCKET(sock);
return -1;
};
ZeroMemory(msg, sizeof(msg));
closesocket(sock);
CSSOCKET(sock);
}
else
{
#pragma region QTGUI_Area
stt->doEmitionRedFoundData("[Key check] -Balancer replied with invalid string.");
if(gDebugMode) stt->doEmitionDebugFoundData(QString(msg));
closesocket(sock);
CSSOCKET(sock);
return -1;
#pragma endregion
};

View File

@ -111,7 +111,7 @@ void CheckProxyLogic()
#pragma endregion
proxyEnabledFlag = 1;
closesocket(pSock);
CSSOCKET(pSock);
break;
}
else
@ -121,7 +121,7 @@ void CheckProxyLogic()
#pragma endregion
proxyEnabledFlag = 0;
closesocket(pSock);
CSSOCKET(pSock);
break;
};
};
@ -134,7 +134,7 @@ void CheckProxyLogic()
#pragma endregion
proxyEnabledFlag = 0;
closesocket(pSock);
CSSOCKET(pSock);
break;
};
};

View File

@ -3,10 +3,9 @@
#include <libssh/libssh.h>
#include <sstream>
#include <openssl/md5.h>
#include "resource.h"
#include "mainResources.h"
#include "externFunctions.h"
#include "externData.h"
#pragma once
#if defined(Q_OS_WIN32)
#include <iphlpapi.h>
@ -14,6 +13,7 @@
#pragma comment(lib, "iphlpapi.lib")
#endif
int gMaxBrutingThreads = 200;
fd_set write_fs;
void BConInc()
{
@ -172,7 +172,7 @@ int OpenConnection(SOCKET *sock, const char *hostname, int port)
if ( connect(*sock, (struct sockaddr*)&addr, sizeof(addr)) == SOCKET_ERROR )
{
++offlines;
closesocket(*sock);
CSSOCKET(*sock);
return -1;
};
return 0;
@ -185,6 +185,7 @@ void _baSSLWorker(char *ip, char *request, char *rvBuff)
ctx = SSL_CTX_new(method); /* Create new context */
SSL_CTX_set_timeout(ctx, gTimeOut);
SOCKET sock;
if(ctx != NULL)
{
int result = OpenConnection(&sock, ip, 443);
@ -220,12 +221,12 @@ void _baSSLWorker(char *ip, char *request, char *rvBuff)
};
SSL_shutdown(ssl);
SSL_free(ssl);
closesocket(sock); /* close socket */
CSSOCKET(sock);
SSL_CTX_free(ctx); /* release context */
return;
};
};
closesocket(sock); /* close socket */
CSSOCKET(sock);
SSL_CTX_free(ctx); /* release context */
}
else
@ -468,8 +469,7 @@ lopaStr _BABrute(char *cookie, char *ip, int port, char *pathT, char *method)
{
if(strstri(headerMsg, "400 Bad") != NULL)
{
shutdown(sock, SD_BOTH);
closesocket(sock);
CSSOCKET(sock);
strcpy(lps.other, "[400 Bad Request]");
isActive = 0;
@ -490,8 +490,7 @@ lopaStr _BABrute(char *cookie, char *ip, int port, char *pathT, char *method)
}
else
{
shutdown(sock, SD_BOTH);
closesocket(sock);
CSSOCKET(sock);
strcpy(lps.other, QString("[404 Not Found (" + QString(path) + ")]").toLocal8Bit().data());
isActive = 0;
@ -515,8 +514,7 @@ lopaStr _BABrute(char *cookie, char *ip, int port, char *pathT, char *method)
if(goon == false)
{
shutdown(sock, SD_BOTH);
closesocket(sock);
CSSOCKET(sock);
strcpy(lps.login, "NULL");
strcpy(lps.pass, "NULL");
@ -525,8 +523,7 @@ lopaStr _BABrute(char *cookie, char *ip, int port, char *pathT, char *method)
};
};
shutdown(sock, SD_BOTH);
closesocket(sock);
CSSOCKET(sock);
#pragma endregion
isActive = 1;
@ -661,8 +658,7 @@ lopaStr _BABrute(char *cookie, char *ip, int port, char *pathT, char *method)
while(cErrCode == 10038)
{
if(gDebugMode) stt->doEmitionDebugFoundData("[BA] 10038 occured -- [" + QString(ip) + ":" + QString::number(port) + "]");
shutdown(sock, SD_BOTH);
closesocket(sock);
CSSOCKET(sock);
sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
cCode = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr));
cErrCode = WSAGetLastError();
@ -693,8 +689,7 @@ lopaStr _BABrute(char *cookie, char *ip, int port, char *pathT, char *method)
{
stt->doEmitionRedFoundData("[BA] Send error! [" + QString(ip) + "]");
shutdown(sock, SD_BOTH);
closesocket(sock);
CSSOCKET(sock);
isActive = 0;
strcpy(lps.login, "UNKNOWN");
return lps;
@ -708,17 +703,14 @@ lopaStr _BABrute(char *cookie, char *ip, int port, char *pathT, char *method)
stt->doEmitionRedFoundData("[BA] Cannot connect to " + QString(ip) + "[" + QString::number(WSAErr) + "]");
};
shutdown(sock, SD_BOTH);
closesocket(sock);
CSSOCKET(sock);
isActive = 0;
strcpy(lps.login, "UNKNOWN");
return lps;
};
shutdown(sock, SD_BOTH);
closesocket(sock);
CSSOCKET(sock);
};
#pragma endregion
@ -755,9 +747,7 @@ lopaStr _BABrute(char *cookie, char *ip, int port, char *pathT, char *method)
|| strstr(recvBuff, "403 Forbidden") != NULL
)
{
#pragma region QTGUI_Area
stt->doEmition_BARedData("[.] 503/400/403 - Waiting 30sec (" + QString(ip) + ":" + QString::number(port) + ")");
#pragma endregion
if(j > 0) --j;
Sleep(30000);
@ -770,9 +760,8 @@ lopaStr _BABrute(char *cookie, char *ip, int port, char *pathT, char *method)
{
if(HTMLDebugMode) _DebugWriteHTMLToFile(request, recvBuff);
#pragma region QTGUI_Area
stt->doEmitionRedFoundData("[-] 404 - Wrong path detected. (" + QString(ip) + ":" + QString::number(port) + QString(path) + ")");
#pragma endregion
isActive = 0;
strcpy(lps.login, "UNKNOWN");
return lps;
@ -912,8 +901,7 @@ lopaStr _FTPBrute(char *ip, int port, PathStr *ps)
while(cErrCode == 10038)
{
if(gDebugMode) stt->doEmitionDebugFoundData("[FTP] 10038 occured -- [" + QString(ip) + ":" + QString::number(port) + "]");
shutdown(sockFTP, SD_BOTH);
closesocket(sockFTP);
CSSOCKET(sockFTP);
sockFTP = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
connectionResult = connect(sockFTP, (sockaddr*)&sockAddr, sizeof(sockAddr));
cErrCode = WSAGetLastError();
@ -940,8 +928,7 @@ lopaStr _FTPBrute(char *ip, int port, PathStr *ps)
if(strstr(recvBuff, "451 The parameter is incorrect") != NULL
)
{
shutdown(sockFTP, SD_BOTH);
closesocket(sockFTP);
CSSOCKET(sockFTP);
isActive = 0;
stt->doEmition_BARedData("[*] Unknown protocol (451 Error) - " + QString(ip));
strcpy(lps.other, "Unknown protocol (451 Error)");
@ -950,12 +937,10 @@ lopaStr _FTPBrute(char *ip, int port, PathStr *ps)
if(strstri(recvBuff, "only anonymous") != NULL)
{
shutdown(sockFTP, SD_BOTH);
closesocket(sockFTP);
CSSOCKET(sockFTP);
isActive = 0;
#pragma region QTGUI_Area
stt->doEmition_BAGreenData("[*] Anonymous access detected - " + QString(ip));
#pragma endregion
strcpy(lps.login, "anonymous");
strcpy(lps.pass, "1");
return lps;
@ -965,8 +950,7 @@ lopaStr _FTPBrute(char *ip, int port, PathStr *ps)
|| strstr(recvBuff, "550-") != NULL
)
{
shutdown(sockFTP, SD_BOTH);
closesocket(sockFTP);
CSSOCKET(sockFTP);
isActive = 0;
@ -980,8 +964,7 @@ lopaStr _FTPBrute(char *ip, int port, PathStr *ps)
if(strstr(recvBuff, "no such command"))
{
shutdown(sockFTP, SD_BOTH);
closesocket(sockFTP);
CSSOCKET(sockFTP);
isActive = 0;
stt->doEmition_BARedData("[-] 500 (Sorry, no such command) " + QString(ip));
@ -996,8 +979,7 @@ lopaStr _FTPBrute(char *ip, int port, PathStr *ps)
)
{
j = 0;
shutdown(sockFTP, SD_BOTH);
closesocket(sockFTP);
CSSOCKET(sockFTP);
closedSocket = 1;
ZeroMemory(recvBuff, sizeof(recvBuff));
break;
@ -1005,8 +987,7 @@ lopaStr _FTPBrute(char *ip, int port, PathStr *ps)
if(strstr(recvBuff, "421 ") != NULL || strstr(recvBuff, "421-") != NULL)
{
shutdown(sockFTP, SD_BOTH);
closesocket(sockFTP);
CSSOCKET(sockFTP);
closedSocket = 1;
ZeroMemory(recvBuff, sizeof(recvBuff));
break;
@ -1015,8 +996,7 @@ lopaStr _FTPBrute(char *ip, int port, PathStr *ps)
if(strstri(recvBuff, "530 Sorry, no ANONYMOUS access allowed.") != NULL)
{
++i;
shutdown(sockFTP, SD_BOTH);
closesocket(sockFTP);
CSSOCKET(sockFTP);
closedSocket = 1;
ZeroMemory(recvBuff, sizeof(recvBuff));
break;
@ -1032,8 +1012,7 @@ lopaStr _FTPBrute(char *ip, int port, PathStr *ps)
#pragma region QTGUI_Area
stt->doEmition_BARedData("[-] FTP: 530 - Ban detected? Waiting 30sec (" + QString(ip) + ")");
#pragma endregion
shutdown(sockFTP, SD_BOTH);
closesocket(sockFTP);
CSSOCKET(sockFTP);
closedSocket = 1;
if(j > 0) --j;
ZeroMemory(recvBuff, sizeof(recvBuff));
@ -1079,8 +1058,7 @@ lopaStr _FTPBrute(char *ip, int port, PathStr *ps)
)
{
stt->doEmition_BARedData("FTP server (" + QString(ip) + ") appears to require SSL for specified user: " + QString(loginLst[i]));
shutdown(sockFTP, SD_BOTH);
closesocket(sockFTP);
CSSOCKET(sockFTP);
isActive = 0;
@ -1146,8 +1124,7 @@ lopaStr _FTPBrute(char *ip, int port, PathStr *ps)
if(strstri(recvBuff2, "unknown command") != NULL || strstri(recvBuff2, "invalid command") != NULL)
{
stt->doEmitionYellowFoundData("[-] PASV failed. Router detected?");
shutdown(sockFTP, SD_BOTH);
closesocket(sockFTP);
CSSOCKET(sockFTP);
strcpy(lps.login, loginLst[i]);
strcpy(lps.pass, passLst[j]);
strcpy(lps.other, "ROUTER");
@ -1197,10 +1174,9 @@ lopaStr _FTPBrute(char *ip, int port, PathStr *ps)
if(x <= 0 || strstr(recvBuff, "unknown command") != NULL)
{
stt->doEmition_BAGreenData("[?] " + QString(pass) + " [MLSD&LIST failed or server closed connection.]");
shutdown(sockFTP, SD_BOTH);
closesocket(sockFTP);
shutdown(newSockFTP, SD_BOTH);
closesocket(newSockFTP);
CSSOCKET(sockFTP);
CSSOCKET(newSockFTP);
closedSocket = 1;
isActive = 0;
strcpy(lps.login, "UNKNOWN");
@ -1210,8 +1186,7 @@ lopaStr _FTPBrute(char *ip, int port, PathStr *ps)
}
else stt->doEmition_BAGreenData("[+] " + QString(pass) + " [LIST succeeded]");
shutdown(newSockFTP, SD_BOTH);
closesocket(newSockFTP);
CSSOCKET(newSockFTP);
}
else
{
@ -1239,8 +1214,7 @@ lopaStr _FTPBrute(char *ip, int port, PathStr *ps)
strcpy(lps.login, loginLst[i]);
strcpy(lps.pass, passLst[j]);
shutdown(sockFTP, SD_BOTH);
closesocket(sockFTP);
CSSOCKET(sockFTP);
isActive = 0;
return lps;
}
@ -1251,15 +1225,14 @@ lopaStr _FTPBrute(char *ip, int port, PathStr *ps)
strcpy(lps.login, loginLst[i]);
strcpy(lps.pass, passLst[j]);
shutdown(sockFTP, SD_BOTH);
closesocket(sockFTP);
CSSOCKET(sockFTP);
isActive = 0;
return lps;
};
};
};
shutdown(sockFTP, SD_BOTH);
closesocket(sockFTP);
CSSOCKET(sockFTP);
closedSocket = 1;
ZeroMemory(recvBuff, sizeof(recvBuff));
}
@ -1273,19 +1246,9 @@ lopaStr _FTPBrute(char *ip, int port, PathStr *ps)
if(gThreads > 1 && WSAerr != 10060/*Timeout*/ && WSAerr != 10055/*POOLOVERFLOW*/ && WSAerr != 10061/*WSAECONNREFUSED*/ && WSAerr != 10054/*WSACONNABORTED*/ && WSAerr != 0)
{
strcpy(err, "[FTPBrute] Cannot connect to ");
strcat(err, ip);
strcat(err, " [");
strcat(err, std::to_string((long double)WSAerr).c_str());
strcat(err, "]");
#pragma region QTGUI_Area
stt->doEmitionRedFoundData(QString(err));
#pragma endregion
stt->doEmitionRedFoundData("[FTPBrute] Cannot connect to " + QString(ip) + " " + QString(std::to_string((long double)WSAerr).c_str()));
};
shutdown(sockFTP, SD_BOTH);
closesocket(sockFTP);
CSSOCKET(sockFTP);
isActive = 0;
strcpy(lps.login, "UNKNOWN");
return lps;
@ -1299,8 +1262,7 @@ lopaStr _FTPBrute(char *ip, int port, PathStr *ps)
};
};
};
shutdown(sockFTP, SD_BOTH);
closesocket(sockFTP);
CSSOCKET(sockFTP);
isActive = 0;
strcpy(lps.login, "UNKNOWN");
return lps;
@ -1366,8 +1328,8 @@ int _sslConnectTo(char *iph, int porth, char *requesth, conSTR *CSTR)
if(HTMLDebugMode) _DebugWriteHTMLToFile(requesth, recvBuff2);
delete[] recvBuff2;
recvBuff2 = NULL;
shutdown(sock, SD_BOTH);
closesocket(sock);
CSSOCKET(sock);
++Overl;
CSTR->lowerBuff = new char[11];
@ -1392,8 +1354,7 @@ int _sslConnectTo(char *iph, int porth, char *requesth, conSTR *CSTR)
delete[] recvBuff2;
recvBuff2 = NULL;
shutdown(sock, SD_BOTH);
closesocket(sock);
CSSOCKET(sock);
CSTR->lowerBuff = new char[12];
strcpy(CSTR->lowerBuff, "[IGNR_ADDR]");
@ -1411,8 +1372,7 @@ int _sslConnectTo(char *iph, int porth, char *requesth, conSTR *CSTR)
};
SSL_free(ssl);
shutdown(sock, SD_BOTH);
closesocket(sock); /* close socket */
CSSOCKET(sock);
SSL_CTX_free(ctx); /* release context */
if(bytes == 0 || recvBuff2 == NULL)
@ -1442,8 +1402,7 @@ int _sslConnectTo(char *iph, int porth, char *requesth, conSTR *CSTR)
{
delete[] recvBuff2;
recvBuff2 = NULL;
shutdown(sock, SD_BOTH);
closesocket(sock); /* close socket */
CSSOCKET(sock);
SSL_free(ssl);
SSL_CTX_free(ctx); /* release context */
CSTR->lowerBuff = new char[1];
@ -1469,7 +1428,7 @@ void __deleteExcessiveNullBytes(char *buff, int sz)
};
};
struct linger linger = { 0 };
int Connector::_EstablishConnection(char *ip, int port, char *requesth, conSTR *CSTR, int force)
int Connector::_EstablishConnection(char *ip, int port, char *request, conSTR *CSTR, int force)
{
CSTR->lowerBuff = NULL;
if(strlen(ip) == 0)
@ -1483,10 +1442,7 @@ int Connector::_EstablishConnection(char *ip, int port, char *requesth, conSTR *
return -1;
};
int recvBuffSize = 0;
char *recvBuff2 = NULL;
char request[2049] = {0};
strcpy(request, requesth);
sockaddr_in sockAddr;
sockAddr.sin_family = AF_INET;
sockAddr.sin_port = htons(port);
@ -1508,33 +1464,19 @@ int Connector::_EstablishConnection(char *ip, int port, char *requesth, conSTR *
SOCKET sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
while(sock == INVALID_SOCKET)
{
char temp[64] = {0};
strcpy(temp, "Cannot create socket - ");
strcat(temp, std::to_string((long double)WSAGetLastError()).c_str());
strcat(temp, " - ");
strcat(temp, ip);
strcat(temp, ":");
strcat(temp, std::to_string((long double)port).c_str());
stt->doEmitionRedFoundData("[Cannot create socket]");
#pragma region QTGUI_Area
stt->doEmitionRedFoundData(QString(temp));
#pragma endregion
shutdown(sock, SD_BOTH);
closesocket(sock);
CSSOCKET(sock);
Sleep(500);
sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
};
int iiError = WSAGetLastError();
while(iiError == 10038)
while(WSAGetLastError() == 10038)
{
if(gDebugMode) stt->doEmitionDebugFoundData("[ConnectTo] 10038 occured -- [" + QString(ip) + ":" + QString::number(port) + "]");
if(gDebugMode) stt->doEmitionDebugFoundData("10038 occured - [" + QString(ip) + ":" + QString::number(port) + "]");
shutdown(sock, SD_BOTH);
closesocket(sock);
CSSOCKET(sock);
sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
iiError = WSAGetLastError();
};
#if defined(WIN32)
u_long FAR cmd = 1;
@ -1543,82 +1485,48 @@ int Connector::_EstablishConnection(char *ip, int port, char *requesth, conSTR *
if( fcntl( sock , F_SETFL, O_NDELAY ) == -1 )
#endif
{
char temp[64] = {0};
strcpy(temp, "Error setting non-blocking mode - ");
strcat(temp, std::to_string((long double)WSAGetLastError()).c_str());
strcat(temp, " - ");
strcat(temp, ip);
strcat(temp, ":");
strcat(temp, std::to_string((long double)port).c_str());
#pragma region QTGUI_Area
stt->doEmitionRedFoundData(QString(temp));
#pragma endregion
shutdown(sock, SD_BOTH);
closesocket(sock);
}
stt->doEmitionRedFoundData("[FIONBIO failed]");
};
int recvBuffSize = 0;
int on = 1;
linger.l_onoff = 1;
linger.l_linger = 30;
linger.l_onoff = 0;
linger.l_linger = 10;
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char *) &on, sizeof(on));
setsockopt(sock, SOL_SOCKET, SO_LINGER, (const char *) &linger, sizeof(linger));
fd_set read_fs;
FD_ZERO(&read_fs);
FD_SET(sock, &read_fs);
int iError, iResult = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr));
if(iResult == SOCKET_ERROR)
{
iError = WSAGetLastError();
while(iError == 10038)
{
if(gDebugMode) stt->doEmitionDebugFoundData("[ConnectTo] 10038 occured -- [" + QString(ip) + ":" + QString::number(port) + "]");
if(gDebugMode) stt->doEmitionDebugFoundData("10038 occured - [" + QString(ip) + ":" + QString::number(port) + "]");
shutdown(sock, SD_BOTH);
closesocket(sock);
CSSOCKET(sock);
sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
iResult = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr));
iError = WSAGetLastError();
};
if(iError == 10035)
{
fd_set read_fs;
FD_ZERO(&read_fs);
FD_SET(sock, &read_fs);
timeval tv = { gTimeOut, 0 };
iResult = select(sock + 1, NULL, &read_fs, NULL, &tv);
iResult = select(sock + 1, NULL, &read_fs, 0, &tv);
int cErrCode = WSAGetLastError();
while(cErrCode == 10038)
{
if(gDebugMode) stt->doEmitionDebugFoundData("[ConnectTo] 10038 occured -- [" + QString(ip) + ":" + QString::number(port) + "]");
shutdown(sock, SD_BOTH);
closesocket(sock);
FD_CLR(sock, &read_fs);
sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr));
iResult = WSAGetLastError();
if(iResult == 10038) continue;
FD_SET(sock, &read_fs);
iResult = select(sock + 1, NULL, &read_fs, 0, &tv);
cErrCode = WSAGetLastError();
};
int cErrCode;
if (iResult == SOCKET_ERROR)
{
++offlines;
char temp[128] = {0};
strcpy(temp, "[Omitting IP!] Select error - ");
strcat(temp, std::to_string((long double)cErrCode).c_str());
strcat(temp, " - ");
strcat(temp, ip);
strcat(temp, ":");
strcat(temp, std::to_string((long double)port).c_str());
strcat(temp, ";");
#pragma region QTGUI_Area
stt->doEmitionRedFoundData(QString(temp));
#pragma endregion
ZeroMemory(temp, sizeof(temp));
stt->doEmitionRedFoundData("[Omitting IP] Select error - " +
QString(std::to_string((long double)cErrCode).c_str()) +
" - " + QString(ip) + ":" + QString(std::to_string((long double)port).c_str()));
}
else
{
@ -1629,12 +1537,12 @@ int Connector::_EstablishConnection(char *ip, int port, char *requesth, conSTR *
{
if(MapWidgetOpened) stt->doEmitionAddOutData(QString(ip), QString(request));
Activity += strlen(request);
int x = 256;
char recvBuff[4096] = {0};
recvBuff2 = new char[RECV_MAX_SIZE];
ZeroMemory(recvBuff2, RECV_MAX_SIZE);
int bTO;
int x = 256;
while (x > 0)
{
ZeroMemory(recvBuff, sizeof(recvBuff));
@ -1647,9 +1555,7 @@ int Connector::_EstablishConnection(char *ip, int port, char *requesth, conSTR *
delete[] recvBuff2;
recvBuff2 = NULL;
FD_CLR(sock, &read_fs);
shutdown(sock, SD_BOTH);
closesocket(sock);
CSSOCKET(sock);
++Overl;
CSTR->lowerBuff = new char[11];
@ -1663,89 +1569,40 @@ int Connector::_EstablishConnection(char *ip, int port, char *requesth, conSTR *
else
{
++offlines;
char temp[128] = {0};
strcpy(temp, "Send error! - ");
strcat(temp, std::to_string((long double)WSAGetLastError()).c_str());
strcat(temp, " - ");
strcat(temp, ip);
strcat(temp, "; sock: ");
strcat(temp, std::to_string((long double)sock).c_str());
stt->doEmitionRedFoundData("Send error " + QString(ip) + " - " + QString(std::to_string((long double)WSAGetLastError()).c_str()));
};
};
};
}
else
{
++offlines;
if(iError == 10055)
{
stt->doEmitionRedFoundData("[SOCKERR 10055] " + QString("Connection pool depleted ") + QString(ip) + ":" + QString::number(port));
}
else if(iError == 10049)
{
stt->doEmitionRedFoundData("[ADDR_NOT_AVAIL] " + QString(ip) +
":" + QString(std::to_string((long double)port).c_str()) +
" - " + std::to_string((long double)iError).c_str());
}
else
{
stt->doEmitionRedFoundData("[Unpredictable error] " + QString(ip) +
":" + QString(std::to_string((long double)port).c_str()) +
" - " + std::to_string((long double)iError).c_str());
};
};
}
else
{
stt->doEmitionRedFoundData("[?!] Strange behavior detected - " +
QString(std::to_string((long double)WSAGetLastError()).c_str()) +
" - " + QString(ip) + ":" + QString(std::to_string((long double)port).c_str()));
};
#pragma region QTGUI_Area
stt->doEmitionRedFoundData(QString(temp));
#pragma endregion
ZeroMemory(temp, sizeof(temp));
};
};
};
FD_CLR(sock, &read_fs);
shutdown(sock, SD_BOTH);
closesocket(sock);
}
else
{
++offlines;
char temp[128] = {0};
int err = iError;
if(err == 10055)
{
strcpy(temp, "-Connection pool depleted- ");
#pragma region QTGUI_Area
stt->doEmitionRedFoundData("[SOCKERR 10055] " + QString(temp) + QString(ip) + ":" + QString::number(port));
#pragma endregion
shutdown(sock, SD_BOTH);
closesocket(sock);
Sleep(60000);
}
else if(err == 10049)
{
strcpy(temp, "[ADDR_NOT_AVAIL - ");
strcat(temp, ip);
strcat(temp, ":");
strcat(temp, std::to_string((long double)port).c_str());
strcat(temp, " - ");
strcat(temp, std::to_string((long double)err).c_str());
strcat(temp, "]");
#pragma region QTGUI_Area
stt->doEmitionRedFoundData(QString(temp));
#pragma endregion
shutdown(sock, SD_BOTH);
closesocket(sock);
}
else
{
strcpy(temp, "[Unpredictable error - ");
strcat(temp, ip);
strcat(temp, ":");
strcat(temp, std::to_string((long double)port).c_str());
strcat(temp, " - ");
strcat(temp, std::to_string((long double)err).c_str());
strcat(temp, "]");
strcat(temp, "; sock: ");
strcat(temp, std::to_string((long double)sock).c_str());
#pragma region QTGUI_Area
stt->doEmitionRedFoundData(QString(temp));
#pragma endregion
shutdown(sock, SD_BOTH);
closesocket(sock);
};
};
}
else
{
char temp[128] = {0};
strcpy(temp, "[?!] Strange behavior detected - ");
strcat(temp, std::to_string((long double)WSAGetLastError()).c_str());
strcat(temp, " - ");
strcat(temp, ip);
strcat(temp, ":");
strcat(temp, std::to_string((long double)port).c_str());
strcat(temp, "; sock: ");
strcat(temp, std::to_string((long double)sock).c_str());
#pragma region QTGUI_Area
stt->doEmitionRedFoundData(QString(temp));
#pragma endregion
};
CSSOCKET(sock);
if( globalScanFlag == false && force == 0)
{
@ -1765,7 +1622,7 @@ int Connector::_EstablishConnection(char *ip, int port, char *requesth, conSTR *
delete []recvBuff2;
recvBuff2 = NULL;
if(HTMLDebugMode) _DebugWriteHTMLToFile(requesth, CSTR->lowerBuff);
if(HTMLDebugMode) _DebugWriteHTMLToFile(request, CSTR->lowerBuff);
return 0;
}
else
@ -2240,8 +2097,7 @@ int _webLoginSeq(char *request, char *login, char *pass, char *ip, int port, int
while(cErrCode == 10038)
{
shutdown(sock, SD_BOTH);
closesocket(sock);
CSSOCKET(sock);
sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
cCode = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr));
cErrCode = WSAGetLastError();
@ -2255,11 +2111,8 @@ int _webLoginSeq(char *request, char *login, char *pass, char *ip, int port, int
if(send(sock, request, strlen(request), 0) == SOCKET_ERROR)
{
#pragma region QTGUI_Area
stt->doEmitionRedFoundData("[" + QString(type) + "] Send error! [" + QString(ip) + "]");
#pragma endregion
shutdown(sock, SD_BOTH);
closesocket(sock);
CSSOCKET(sock);
return 0;
}
else
@ -2293,15 +2146,13 @@ int _webLoginSeq(char *request, char *login, char *pass, char *ip, int port, int
if(result)
{
shutdown(sock, SD_BOTH);
closesocket(sock);
CSSOCKET(sock);
return 1;
};
};
};
shutdown(sock, SD_BOTH);
closesocket(sock);
CSSOCKET(sock);
return 0;
};
lopaStr _IPCameraBrute(char *ip, int port, char *SPEC)

View File

@ -3,6 +3,7 @@
#define SD_BOTH 2
#define PORTSET "80,81,88,8080,8081,60001,60002,8008,8888,554,9000,441,4111,6667,3536,22,21"
#define IRC_CHAN "iskopasi_lab03"
#define CSSOCKET(Socket) shutdown(Socket, SD_BOTH); closesocket(Socket);
extern QJsonArray *jsonArr;

View File

@ -15,3 +15,4 @@ extern char *_findFirst(char *str, char *delim);
extern void nCleanup();
extern void getSubStr(char *src, char *startStr, char *endStr, char *dest, int szDest);
extern void getSubStrEx(char *src, char *startStr, char *endStr, char *dest, int szDest);

View File

@ -1,6 +1,6 @@
#pragma once
#include "STh.h"
#include "resource.h"
#include "mainResources.h"
#include "externFunctions.h"
#include "externData.h"

112
mainResources.h Normal file
View File

@ -0,0 +1,112 @@
#pragma once
#include "base64.h"
#if defined(Q_OS_WIN32)
#pragma once
#include "iostream"
#include <time.h>
#include <process.h>
#include <conio.h>
#include <openssl/ssl.h>
#endif
#if defined(Q_OS_LINUX)
#pragma once
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <pthread.h>
#include <netdb.h>
#include <errno.h>
#include <fcntl.h>
#include <math.h>
#include <cstring>
#define ZeroMemory(Destination,Length) memset((Destination),0,(Length))
#define Sleep(secs) usleep((secs)*1000)
#define WSAGetLastError() errno
#define closesocket(sock) ::close((sock))
typedef unsigned int UINT;
typedef const char * LPCSTR;
typedef int SOCKET;
typedef hostent HOSTENT;
typedef struct linger LINGER;
typedef int BOOL;
#define INVALID_SOCKET (SOCKET)(~0)
#define SOCKET_ERROR (-1)
#define SD_BOTH 0x02
#define FAR far
#endif
#define MAX_ADDR_LEN 128
#define TITLE_MAX_SIZE 512
#define COOKIE_MAX_SIZE 1024
struct PathStr{
char codepage[32];
char headr[TITLE_MAX_SIZE];
char path[1024];
int flag;
int port;
char ip[MAX_ADDR_LEN];
char cookie[COOKIE_MAX_SIZE];
};
struct lopaStr{
char login[128];
char pass[32];
char other[128];
};
struct conSTR{
char *lowerBuff;
int size;
};
class Lexems
{
public:
int iterationCount, flag;
Lexems()
{
iterationCount = 0;
flag = 0;
};
~Lexems()
{
iterationCount = 0;
};
int _header(char *ip, int port, char str[], Lexems *l, PathStr *ps, std::vector<std::string> *lst, char *rBuff);
int _filler(int p, char* buffcpy, char* ipi, int recd, Lexems *lx, char *hl);
int globalSearchNeg(const char *buffcpy, char *ip, int port);
};
class Connector
{
public:
int _Updater();
lopaStr _FTPLobby(char *ip, int port, PathStr *ps);
lopaStr _BALobby(char *cookie, char *ip, int port, char *path, char *method, char *data);
lopaStr _WFLobby(char *cookie, char *ip, int port, char *methodVal, char *actionVal, char *userVal, char *passVal, char *formVal);
lopaStr _IPCameraBLobby(char *ip, int port, char *SPEC);
int _SSHLobby(char *ip, int port, conSTR *CSTR);
int _EstablishConnection(char *ip, int port, char *request, conSTR *cstr, int force = 0);
int _EstablishSSLConnection(char *ip, int port, char *request, conSTR *cstr);
void _Connect(void *s);
int _ConnectToPort(char *ip, const char *port, char *hl);
};

View File

@ -1,6 +1,6 @@
#include "msgcheckerthread.h"
#include "externData.h"
#include "resource.h"
#include "mainResources.h"
void MSGCheckerThread::doEmitionShowNewMsg(QString str)
{

View File

@ -1350,8 +1350,7 @@ void nesca_3::CheckProxy()
};
void nesca_3::slotIRCOfflined()
{
shutdown(lSock, 2);
closesocket(lSock);
CSSOCKET(lSock);
ui->IRCConnectBut->setStyleSheet(
" #IRCConnectBut {"
"background-color: qlineargradient(spread:none, x1:1, y1:0, x2:1, y2:1, stop:0.681818 rgba(0, 0, 0, 250), stop:1 rgba(255, 255, 255, 130));"
@ -1421,8 +1420,7 @@ void nesca_3::ConnectToIRCServer()
ui->IRCConnectBut->setText("Connect");
ui->ircText->append("<span style=\"color:#efe100;\">[-//-] Disconnected.</span>");
shutdown(lSock, 2);
closesocket(lSock);
CSSOCKET(lSock);
};
}
else
@ -1808,8 +1806,7 @@ void nesca_3::slotRestartIRC()
{
ircPTh->terminate();
globalPinger = 0;
shutdown(lSock, 2);
closesocket(lSock);
CSSOCKET(lSock);
ircTh->terminate();
ircTh->start();
};

Binary file not shown.

View File

@ -1,6 +1,6 @@
#pragma once
#include "STh.h"
#include "resource.h"
#include "mainResources.h"
#include "externData.h"
#include "externFunctions.h"
@ -462,7 +462,7 @@ void *_tracker()
int test = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr));
if(test == -1)
{
closesocket(sock);
CSSOCKET(sock);
#pragma region QTGUI_Area
stt->doEmitionRedFoundData("[NS-Track] -Cannot connect to balancer! " + QString::number(WSAGetLastError()) + ".");
#pragma endregion
@ -473,7 +473,7 @@ void *_tracker()
if(test == -1)
{
closesocket(sock);
CSSOCKET(sock);
#pragma region QTGUI_Area
stt->doEmitionRedFoundData("[NS-Track] -Cannot send to balancer! " + QString::number(WSAGetLastError()) + ".");
#pragma endregion
@ -496,7 +496,7 @@ void *_tracker()
};
if(test == -1)
{
closesocket(sock);
CSSOCKET(sock);
#pragma region QTGUI_Area
stt->doEmitionRedFoundData("[NS-Track] -Cannot recv from balancer! " + QString::number(WSAGetLastError()) + ".");
#pragma endregion
@ -514,7 +514,7 @@ void *_tracker()
int ln = t2 - t1 - strlen("http://");
if(ln > 64)
{
closesocket(sock);
CSSOCKET(sock);
#pragma region QTGUI_Area
stt->doEmitionRedFoundData("[NS-Track] -Received server string is not valid!");
SaveErrorLog("NS-Track", msg, rBuffT);
@ -535,7 +535,7 @@ void *_tracker()
if(y > 64)
{
closesocket(sock);
CSSOCKET(sock);
#pragma region QTGUI_Area
stt->doEmitionRedFoundData("[NS-Track] -Received server string is not valid!");
#pragma endregion
@ -545,7 +545,7 @@ void *_tracker()
else
{
strncpy(ndbScriptT, t2, y);
closesocket(sock);
CSSOCKET(sock);;
#pragma region QTGUI_Area
stt->doEmitionGreenFoundData("[NS-Track] -OK! -Fragmented server string aquired! Starting NS-Track loop...");
#pragma endregion
@ -554,7 +554,7 @@ void *_tracker()
}
else
{
closesocket(sock);
CSSOCKET(sock);
#pragma region QTGUI_Area
stt->doEmitionRedFoundData("[NS-Track] -Received server string is not valid!");
#pragma endregion
@ -568,13 +568,13 @@ void *_tracker()
#pragma region QTGUI_Area
stt->doEmitionGreenFoundData("[NS-Track] -OK! -Server string aquired! Starting NS-Track loop...");
#pragma endregion
closesocket(sock);
CSSOCKET(sock);
strncpy(ndbScript, ndbScriptT, strlen(ndbScriptT) - 2 );
};
}
else
{
closesocket(sock);
CSSOCKET(sock);
#pragma region QTGUI_Area
stt->doEmitionRedFoundData("[NS-Track] -Cannot receive script value!");
#pragma endregion
@ -745,9 +745,7 @@ void *_tracker()
}
else
{
#pragma region QTGUI_Area
stt->doEmitionYellowFoundData("[NS-Track] -FAIL! An error occured [" + QString(msgR) + "]");
#pragma endregion
SaveErrorLog("NS-Track", msg, rBuffT);
};
@ -760,20 +758,17 @@ void *_tracker()
msg = 0;
};
shutdown(sock, 2);
closesocket(sock);
CSSOCKET(sock);
};
Sleep(10000);
};
}
else
{
shutdown(sock, 2);
closesocket(sock);
#pragma region QTGUI_Area
CSSOCKET(sock);
stt->doEmitionRedFoundData("[NS-Track] -Balancer replied with invalid string.");
SaveErrorLog("NS-Track", msg, rBuffT);
#pragma endregion
};
};

View File

@ -806,12 +806,10 @@ void IRCLoop()
#pragma endregion
};
shutdown(lSock, 2);
closesocket(lSock);
CSSOCKET(lSock);
};
//};
shutdown(lSock, 2);
closesocket(lSock);
CSSOCKET(lSock);
};
void oIRC_Th::run()

Binary file not shown.

View File

@ -1,6 +1,6 @@
#include "vercheckerthread.h"
#include "externData.h"
#include "resource.h"
#include "mainResources.h"
void _checkVer()
{