Fake overflows fixed.

This commit is contained in:
cora32 2015-02-19 21:02:49 +03:00
parent a9f8a4eb68
commit 2689ab2246
4 changed files with 25 additions and 32 deletions

View File

@ -1495,15 +1495,6 @@ int Connector::_EstablishConnection(char *ip, int port, char *request, conSTR *C
setsockopt(sock, SOL_SOCKET, SO_LINGER, (const char *) &linger, sizeof(linger)); setsockopt(sock, SOL_SOCKET, SO_LINGER, (const char *) &linger, sizeof(linger));
int iError, iResult = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr)); int iError, iResult = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr));
//CSSOCKET(sock);
//sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
//setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char *) &on, sizeof(on));
//int sResult = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr));
// iError = WSAGetLastError();
//sResult = send(sock, request, strlen(request), 0);
//char r[128419];
//recv(sock, r, 128419, 0);
while(sock == INVALID_SOCKET) while(sock == INVALID_SOCKET)
{ {
if(gDebugMode) stt->doEmitionDebugFoundData("[Invalid socket]: " + QString::number(WSAGetLastError())); if(gDebugMode) stt->doEmitionDebugFoundData("[Invalid socket]: " + QString::number(WSAGetLastError()));
@ -1557,7 +1548,7 @@ int Connector::_EstablishConnection(char *ip, int port, char *request, conSTR *C
{ {
if(MapWidgetOpened) stt->doEmitionAddOutData(QString(ip), QString(request)); if(MapWidgetOpened) stt->doEmitionAddOutData(QString(ip), QString(request));
Activity += strlen(request); Activity += strlen(request);
char recvBuff[4096] = {0}; char recvBuff[8192] = {0};
recvBuff2 = new char[RECV_MAX_SIZE]; recvBuff2 = new char[RECV_MAX_SIZE];
ZeroMemory(recvBuff2, RECV_MAX_SIZE); ZeroMemory(recvBuff2, RECV_MAX_SIZE);
@ -1565,22 +1556,22 @@ int Connector::_EstablishConnection(char *ip, int port, char *request, conSTR *C
int x = 256; int x = 256;
while (x > 0) while (x > 0)
{ {
ZeroMemory(recvBuff, sizeof(recvBuff)); ZeroMemory(recvBuff, 8192);
x = recvWT(sock, recvBuff, sizeof(recvBuff), gTimeOut, &bTO); x = recvWT(sock, recvBuff, 8192, gTimeOut, &bTO);
if(x <= 0) break; if(x <= 0) break;
Activity += x; Activity += x;
recvBuffSize += x; recvBuffSize += x;
if( recvBuffSize > RECV_MAX_SIZE ) if( recvBuffSize > RECV_MAX_SIZE )
{ {
delete[] recvBuff2;
recvBuff2 = NULL;
CSSOCKET(sock); CSSOCKET(sock);
++Overl; ++Overl;
CSTR->lowerBuff = new char[11]; CSTR->lowerBuff = new char[recvBuffSize];
strcpy(CSTR->lowerBuff, "[OVERFLOW]"); strncpy(CSTR->lowerBuff, recvBuff2, recvBuffSize);
CSTR->size = 10; CSTR->size = recvBuffSize;
CSTR->overflow = true;
delete[] recvBuff2;
recvBuff2 = NULL;
return 0; return 0;
}; };
strncat(recvBuff2, recvBuff, x); strncat(recvBuff2, recvBuff, x);
@ -1596,22 +1587,22 @@ int Connector::_EstablishConnection(char *ip, int port, char *request, conSTR *C
x = 1; x = 1;
while (x > 0) while (x > 0)
{ {
ZeroMemory(recvBuff, sizeof(recvBuff)); ZeroMemory(recvBuff, 8192);
x = recvWT(sock, recvBuff, sizeof(recvBuff), gTimeOut, &bTO); x = recvWT(sock, recvBuff, 8192, gTimeOut, &bTO);
if(x <= 0) break; if(x <= 0) break;
Activity += x; Activity += x;
recvBuffSize += x; recvBuffSize += x;
if( recvBuffSize > RECV_MAX_SIZE ) if( recvBuffSize > RECV_MAX_SIZE )
{ {
delete[] recvBuff2;
recvBuff2 = NULL;
CSSOCKET(sock); CSSOCKET(sock);
++Overl; ++Overl;
CSTR->lowerBuff = new char[11]; CSTR->lowerBuff = new char[recvBuffSize];
strcpy(CSTR->lowerBuff, "[OVERFLOW]"); strncpy(CSTR->lowerBuff, recvBuff2, recvBuffSize);
CSTR->size = 10; CSTR->size = recvBuffSize;
CSTR->overflow = true;
delete[] recvBuff2;
recvBuff2 = NULL;
return 0; return 0;
}; };
strncat(recvBuff2, recvBuff, x); strncat(recvBuff2, recvBuff, x);

View File

@ -518,7 +518,7 @@ bool ftsBA = true;
bool ftsLF = true; bool ftsLF = true;
bool fOpened = false; bool fOpened = false;
char styleBuff[1024] = {"<style> #recvSpan{display: inline-block;width: 150px;} #hostSpan{display: inline-block;width: 150px;}body { background-color: #141414; font-family: monospace; font-size:95%;} #ipd{background:black;width:100%;white-space:nowrap;overflow-x:none;display:inline-block;}#ipd:hover{color: #909090;background:#202020;}#tit{text-align:center;border:1px solid #5d5d5d;}a{color: gray;text-decoration: underline;} a:focus{ outline-style: dashed;outline-width:1px; outline-color: red;}</style>"}; char styleBuff[1024] = {"<style> #recvSpan{display: inline-block;width: 150px;} #hostSpan{display: inline-block;width: 200px;}body { background-color: #141414; font-family: monospace; font-size:95%;} #ipd{background:black;width:100%;white-space:nowrap;overflow-x:none;display:inline-block;}#ipd:hover{color: #909090;background:#202020;}#tit{text-align:center;border:1px solid #5d5d5d;}a{color: gray;text-decoration: underline;} a:focus{ outline-style: dashed;outline-width:1px; outline-color: red;}</style>"};
char topBuff[1024] = {"<div id=\"tit\"><a href=\"strange.html\">.strange</a> <a href=\"other.html\">.other</a> <a href=\"Basicauth.html\">.BasicAuth</a> <a href=\"FTP.html\">.FTP</a> <a href=\"low_loads.html\">.LowLoads</a> <a href=\"LoginForms.html\">.loginforms</a> <a href=\"SSH.html\">.SSH</a></div><br><br>"}; char topBuff[1024] = {"<div id=\"tit\"><a href=\"strange.html\">.strange</a> <a href=\"other.html\">.other</a> <a href=\"Basicauth.html\">.BasicAuth</a> <a href=\"FTP.html\">.FTP</a> <a href=\"low_loads.html\">.LowLoads</a> <a href=\"LoginForms.html\">.loginforms</a> <a href=\"SSH.html\">.SSH</a></div><br><br>"};
void fputsf(char *ip, char *port, char *text, int flag, char *msg) void fputsf(char *ip, char *port, char *text, int flag, char *msg)
{ {
@ -2007,7 +2007,7 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
ps->flag = 3; ps->flag = 3;
ls->flag = 3; ls->flag = 3;
} }
else if(strstr(cstr.lowerBuff, "[OVERFLOW]") != NULL) else if(cstr.overflow == true)
{ {
ls->flag = 0; ls->flag = 0;
ps->flag = 0; ps->flag = 0;
@ -2139,7 +2139,7 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
ps->flag = 3; ps->flag = 3;
ls->flag = 3; ls->flag = 3;
} }
else if(strstr(cstr.lowerBuff, "[OVERFLOW]") != NULL) else if(cstr.overflow == true)
{ {
ls->flag = 0; ls->flag = 0;
ps->flag = 0; ps->flag = 0;
@ -2235,7 +2235,7 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
ps->flag = 3; ps->flag = 3;
ls->flag = 3; ls->flag = 3;
} }
else if(strstr(cstr.lowerBuff, "[OVERFLOW]") != NULL) else if(cstr.overflow == true)
{ {
ls->flag = 0; ls->flag = 0;
ps->flag = 0; ps->flag = 0;
@ -2318,7 +2318,7 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
ps->flag = 3; ps->flag = 3;
ls->flag = 3; ls->flag = 3;
} }
else if(strstr(cstr.lowerBuff, "[OVERFLOW]") != NULL) else if(cstr.overflow == true)
{ {
ls->flag = 0; ls->flag = 0;
ps->flag = 0; ps->flag = 0;

View File

@ -72,6 +72,7 @@ struct lopaStr{
struct conSTR{ struct conSTR{
char *lowerBuff; char *lowerBuff;
int size; int size;
bool overflow = false;
}; };
class Lexems class Lexems

View File

@ -1,4 +1,5 @@
yadro.ru yadro.ru
Authorization Required
Firewall Authentication required before Firewall Authentication required before
liveinternet liveinternet
#[Dlink] #[Dlink]