DNS-mode fix. Speed increasing.

This commit is contained in:
cora32 2014-10-19 13:39:27 +03:00
parent 3d4f51f19c
commit e784b1d566
4 changed files with 44 additions and 26 deletions

View File

@ -1476,21 +1476,16 @@ int Connector::_EstablishConnection(char *ip, int port, char *requesth, conSTR *
HOSTENT *host;
#if defined(WIN32)
if(inet_addr(ip) != INADDR_NONE) sockAddr.sin_addr.S_un.S_addr = inet_addr(ip);
else if(host = gethostbyname (ip)) ((unsigned long*) &sockAddr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0];
else
{
++offlines;
return -1;
};
#else
if(inet_addr(ip) != INADDR_NONE) sockAddr.sin_addr.s_addr = inet_addr(ip);
#endif
else if(host = gethostbyname (ip)) ((unsigned long*) &sockAddr.sin_addr)[0] = ((unsigned long**)host->h_addr_list)[0][0];
else
{
++offlines;
return -1;
if(host == NULL) return -2;
else return -1;
};
#endif
SOCKET sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
while(sock == INVALID_SOCKET)
@ -2518,13 +2513,13 @@ int _SSHLobby(char *ip, int port, conSTR *CSTR)
return _EstablishSSHConnection(ip, port, CSTR, banner);
};
};
void Connector::_ConnectToPort(char *ip, const char *portC, char *hl)
int Connector::_ConnectToPort(char *ip, const char *portC, char *hl)
{
if(gPingNScan)
{
if(_pingMyTarget(ip) == 0)
{
return;
return -2;
};
};
@ -2545,6 +2540,8 @@ void Connector::_ConnectToPort(char *ip, const char *portC, char *hl)
else cRes = _EstablishConnection(ip, port, mes, &CSTR);
int size = CSTR.size;
if(cRes == -2) return -2;
if(size > 0 && cRes != -1)
{
++Alive;

View File

@ -1839,10 +1839,11 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
{
tempPort = 443;
char *ptr1 = strstri(str, "https://");
char *ptr2 = _findFirstOcc(str + 8, ":/");
char *ptr2 = _findFirstOcc(str + 8, ":/?");
if(ptr2 != NULL)
{
int sz = ptr2 - ptr1 - 8;
ZeroMemory(tempIP, MAX_ADDR_LEN);
strncpy(tempIP, ptr1 + 8, sz < 128 ? sz : 128);
if(ptr2[0] == ':')
{
@ -1867,6 +1868,11 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
{
strncpy(tempPath, ptr2, strlen(ptr2));
}
else if(ptr2[0] == '?')
{
strcpy(tempPath, "/");
strncat(tempPath, ptr2, strlen(ptr2));
}
else
{
stt->doEmitionRedFoundData("[Redirect] Unknown protocol (" + QString(ip) + ":" + QString::number(port) + ")");
@ -1874,6 +1880,7 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
}
else
{
ZeroMemory(tempIP, MAX_ADDR_LEN);
strncpy(tempIP, ptr1 + 8, strlen(str) - 8);
strcpy(tempPath, "/");
};
@ -1893,7 +1900,7 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
conSTR cstr;
cstr.size = 0;
cstr.lowerBuff = NULL;
if(con._EstablishSSLConnection(tempIP, tempPort, mes, &cstr) != -1)
if(con._EstablishSSLConnection(tempIP, tempPort, mes, &cstr) > -1)
{
strncpy(buff, cstr.lowerBuff, (cstr.size < 65535 ? cstr.size : 65535));
strcpy(ps->codepage, GetCodePage(cstr.lowerBuff));
@ -1958,10 +1965,11 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
else if(strstr(str, "http://") != NULL) //http
{
char *ptr1 = strstri(str, "http://");
char *ptr2 = _findFirstOcc(str + 7, ":/");
char *ptr2 = _findFirstOcc(str + 7, ":/?");
if(ptr2 != NULL)
{
int sz = ptr2 - ptr1 - 7;
ZeroMemory(tempIP, MAX_ADDR_LEN);
strncpy(tempIP, ptr1 + 7, sz < 128 ? sz : 128);
if(ptr2[0] == ':')
{
@ -1986,6 +1994,11 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
{
strncpy(tempPath, ptr2, strlen(ptr2));
}
else if(ptr2[0] == '?')
{
strcpy(tempPath, "/");
strncat(tempPath, ptr2, strlen(ptr2));
}
else
{
stt->doEmitionRedFoundData("[Redirect] Unknown protocol (" + QString(ip) + ":" + QString::number(port) + ")");
@ -1993,6 +2006,7 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
}
else
{
ZeroMemory(tempIP, MAX_ADDR_LEN);
strncpy(tempIP, ptr1 + 7, strlen(str) - 7);
strcpy(tempPath, "/");
};
@ -2013,7 +2027,7 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
conSTR cstr;
cstr.size = 0;
cstr.lowerBuff = NULL;
if(con._EstablishConnection(tempIP, tempPort, mes, &cstr) != -1)
if(con._EstablishConnection(tempIP, tempPort, mes, &cstr) > -1)
{
strncpy(buff, cstr.lowerBuff, (cstr.size < 65535 ? cstr.size : 65535));
strcpy(ps->codepage, GetCodePage(cstr.lowerBuff));
@ -2122,7 +2136,7 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
{
strncpy(buff, cstr.lowerBuff, 65535);
};
if(cRes != -1)
if(cRes > -1)
{
strcpy(ps->codepage, GetCodePage(cstr.lowerBuff));

View File

@ -884,7 +884,7 @@ void *_connect(void* ss)
for(int i = 0; i <= overallPorts; ++i)
{
if(globalScanFlag == false) break;
con._ConnectToPort( ip, std::to_string((long double)portArr[i]).c_str(), "" );
if(con._ConnectToPort( ip, std::to_string((long double)portArr[i]).c_str(), "" ) == -2) break;
};
ConDec();
@ -1604,8 +1604,8 @@ int fInit(int InitMode, char *gR)
};
void FileLoader(char *str)
{
char res[64] = {0};
char curIP[64] = {0}, curIPCopy[64] = {0};
char res[256] = {0};
char curIP[256] = {0}, curIPCopy[256] = {0};
char tempBuff[4] = {0};
FILE *fl = fopen(str, "r");
@ -1641,7 +1641,7 @@ void FileLoader(char *str)
rewind(fl);
while(fgets(curIP, 64, fl) != NULL)
while(fgets(curIP, 256, fl) != NULL)
{
if(curIP[0] != '#' && curIP[0] != ' ' && curIP[0] != '\n' && curIP[0] != '\r' && strcmp(curIP, "") != 0 &&
((curIP[0] == '/' && curIP[1] == '/') == false) && ((curIP[0] == '\t' && curIP[1] == '\t' && curIP[2] == '\t' && (curIP[3] == 13 || curIP[3] == 10 || curIP[3] == '#')) == false)
@ -1720,8 +1720,8 @@ void FileLoader(char *str)
)
)
{
char tempMsg[64] = {0};
strcpy(tempMsg, "[IP Loader]Error in IP list. Line-> [");
char tempMsg[256] = {0};
strcpy(tempMsg, "[IP Loader]Wrong list format. Line-> [");
strcat(tempMsg, std::to_string((long double)flCounter).c_str());
strcat(tempMsg, "] String-> [");
strcat(tempMsg, curIPCopy);
@ -1821,7 +1821,14 @@ void FileLoader(char *str)
}
else
{
stt->doEmitionRedFoundData("[IP Loader] Wrong list format. String: " + QString(curIP));
char tempMsg[256] = {0};
strcpy(tempMsg, "[IP Loader]Wrong list format. Line-> [");
strcat(tempMsg, std::to_string((long double)flCounter).c_str());
strcat(tempMsg, "] String-> [");
strcat(tempMsg, curIPCopy);
strcat(tempMsg, "]");
stt->doEmitionRedFoundData(QString(tempMsg));
return;
};
ZeroMemory(curIP, sizeof(curIP));
};

View File

@ -243,6 +243,6 @@ class Connector
int _EstablishSSLConnection(char *ip, int port, char *request, conSTR *cstr);
void _StartRangeFapping(int ipsstart[], int ipsend[], int &cons, char *argv2, ST *st);
void _Connect(void *s);
void _ConnectToPort(char *ip, const char *port, char *hl);
int _ConnectToPort(char *ip, const char *port, char *hl);
};