Frameset fix

This commit is contained in:
cora32 2016-01-07 06:55:10 +03:00
parent 73c24d990e
commit 5bff76ac40
3 changed files with 54 additions and 38 deletions

View File

@ -56,14 +56,18 @@ lopaStr BA::BABrute(const char *ip, const int port) {
std::string buff; std::string buff;
Connector con; Connector con;
con.nConnect(ip, port, &buff); int sz = con.nConnect(ip, port, &buff);
//QString ipString = QString(ip).mid(0, QString(ip).indexOf("/", 8)) + ":" + QString::number(port); //QString ipString = QString(ip).mid(0, QString(ip).indexOf("/", 8)) + ":" + QString::number(port);
QString ipString = QString(ip); QString ipString = QString(ip);
if (buff.size() == 0) { if (sz == 0) {
stt->doEmitionFoundData("<span style=\"color:orange;\">Empty BA probe - <a style=\"color:orange;\" href=\"" + ipString + "/\">" + //Retry
ipString + "</a></span>"); Sleep(2000);
if (sz == 0) {
stt->doEmitionFoundData("<span style=\"color:orange;\">Empty BA probe - <a style=\"color:orange;\" href=\"" + ipString + "/\">" + ipString + "</a></span>");
return lps; return lps;
} }
}
int isDig = Utils::isDigest(&buff); int isDig = Utils::isDigest(&buff);
if (isDig == -1) { if (isDig == -1) {
stt->doEmitionFoundData("<span style=\"color:orange;\">No 401 found - <a style=\"color:orange;\" href=\"" + ipString + "/\">" + stt->doEmitionFoundData("<span style=\"color:orange;\">No 401 found - <a style=\"color:orange;\" href=\"" + ipString + "/\">" +

View File

@ -299,7 +299,7 @@ int Connector::nConnect(const char* ip, const int port, std::string *buffer,
int res = pConnect(ip, port, buffer, postData, customHeaders, lpString, digestMode); int res = pConnect(ip, port, buffer, postData, customHeaders, lpString, digestMode);
cutoutComments(buffer); cutoutComments(buffer);
return buffer->size(); return res;
} }
bool portCheck(const char * sDVRIP, int wDVRPort) { bool portCheck(const char * sDVRIP, int wDVRPort) {
@ -387,8 +387,8 @@ bool portCheck(const char * sDVRIP, int wDVRPort) {
if (res != CURLE_OK) { if (res != CURLE_OK) {
if (gNegDebugMode) if (gNegDebugMode)
{ {
stt->doEmitionDebugFoundData("Port check failed (curl_code: " + QString::number(res) + ") [<a href=\"" + QString(sDVRIP) + ":" + QString::number(wDVRPort) + /*stt->doEmitionDebugFoundData("Port check failed (curl_code: " + QString::number(res) + ") [<a href=\"" + QString(sDVRIP) + ":" + QString::number(wDVRPort) +
"/\"><font color=\"#0084ff\">" + QString(sDVRIP) + ":" + QString::number(wDVRPort) + "</font></a>]"); "/\"><font color=\"#0084ff\">" + QString(sDVRIP) + ":" + QString::number(wDVRPort) + "</font></a>]");*/
SOCKET eNobuffSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); SOCKET eNobuffSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
shutdown(eNobuffSocket, SD_BOTH); shutdown(eNobuffSocket, SD_BOTH);
closesocket(eNobuffSocket); closesocket(eNobuffSocket);
@ -409,11 +409,11 @@ bool portCheck(const char * sDVRIP, int wDVRPort) {
} }
} }
else { else {
if (gNegDebugMode) //if (gNegDebugMode)
{ //{
stt->doEmitionDebugFoundData("Port check failed - curl_easy_init() error. [<a href=\"" + QString(sDVRIP) + ":" + QString::number(wDVRPort) + // stt->doEmitionDebugFoundData("Port check failed - curl_easy_init() error. [<a href=\"" + QString(sDVRIP) + ":" + QString::number(wDVRPort) +
"/\"><font color=\"#0084ff\">" + QString(sDVRIP) + ":" + QString::number(wDVRPort) + "</font></a>]"); // "/\"><font color=\"#0084ff\">" + QString(sDVRIP) + ":" + QString::number(wDVRPort) + "</font></a>]");
} //}
return false; return false;
} }
} }

View File

@ -258,7 +258,7 @@ bool isNegative(const std::string *buff, const char *ip, int port, const char *c
QTextCodec *nCodec = QTextCodec::codecForName("Windows-1251"); QTextCodec *nCodec = QTextCodec::codecForName("Windows-1251");
stt->doEmitionDebugFoundData("[<a href=\"" + QString(ip) + ":" + QString::number(port) + stt->doEmitionDebugFoundData("[<a href=\"" + QString(ip) + ":" + QString::number(port) +
"/\"><font color=\"#0084ff\">" + QString(ip) + ":" + QString::number(port) + "/\"><font color=\"#0084ff\">" + QString(ip) + ":" + QString::number(port) +
"</font></a>" + "]\tNegative hit: Size:" + QString::number(nSz)); "</font></a>]\tNegative hit: Size:" + QString::number(nSz));
} }
return true; return true;
} }
@ -284,7 +284,7 @@ int globalSearchPrnt(const std::string *buff)
if (gNegDebugMode) if (gNegDebugMode)
{ {
QTextCodec *nCodec = QTextCodec::codecForName("Windows-1251"); /*QTextCodec *nCodec = QTextCodec::codecForName("Windows-1251");*/
stt->doEmitionDebugFoundData("Printer ignored"); stt->doEmitionDebugFoundData("Printer ignored");
} }
return -1; return -1;
@ -336,6 +336,11 @@ int sharedDetector(const char * ip, int port, const std::string *buffcpy, const
} }
return -1; return -1;
} }
} else {
//stt->doEmitionDebugFoundData("[<a href=\"" + QString(ip) + ":" + QString::number(port) +
// "/\"><font color=\"#0084ff\">" + QString(ip) + ":" + QString::number(port) +
// "</font></a>]\tNegative hit: Size: 0");
//return -1;
} }
} }
@ -531,9 +536,7 @@ int contentFilter(const std::string *buff, int port, const char *ip, const char
//return res; //return res;
if (sz < 180000) { if (sz < 180000) {
int result = 1; //Other - default return firstStage(buff, port, ip, cp, sz);
result = firstStage(buff, port, ip, cp, sz);
return result;
} }
else { else {
return 1; return 1;
@ -2766,8 +2769,13 @@ std::string getHeader(const std::string *buffcpy, const int flag) {
return "[Mobotic IPCam]"; return "[Mobotic IPCam]";
} }
else if (STRSTR(buffcpy, "iomega=") != -1) { else if (STRSTR(buffcpy, "iomega=") != -1) {
if (STRSTR(buffcpy, "<div id=\"nocontent\">")) {
return "[IOmega NAS] (Empty)";
}
else {
return "[IOmega NAS]"; return "[IOmega NAS]";
} }
}
else { else {
std::string tempBuff = buffcpy->c_str(); std::string tempBuff = buffcpy->c_str();
const std::string &result_ref = getTitle(tempBuff.c_str(), flag); const std::string &result_ref = getTitle(tempBuff.c_str(), flag);
@ -3202,33 +3210,27 @@ void handleRedirects(std::string *buffcpy, char* ip, int port) {
counter.iterationCount = 0; counter.iterationCount = 0;
jsRedirectHandler(buffcpy, ip, port, &counter); jsRedirectHandler(buffcpy, ip, port, &counter);
} }
int handleFramesets(std::string *buffcpy, char* ip, int port, int flag) { int handleFramesets(std::string *buffcpyOrig, char* ip, int port, int flag) {
if (NULL == buffcpy || 0 == buffcpy->size()) { if (NULL == buffcpyOrig || 0 == buffcpyOrig->size()) {
return flag; return flag;
} }
std::string buffcpy = *buffcpyOrig;
std::transform(buffcpy.begin(), buffcpy.end(), buffcpy.begin(), ::tolower);
int pos; int pos;
if ((pos = STRSTR((const std::string *) buffcpy, "<frameset ")) != -1) { if ((pos = STRSTR(buffcpy, "<frameset ")) != -1) {
Connector con; Connector con;
int framePos = pos + 9; int framePos = buffcpy.find("<frame ", pos + 10);
int counter = 0; int counter = 0;
while (framePos != -1) { while (framePos != -1) {
framePos = buffcpy->find("<frame ", framePos + 1); int framePosEnd = buffcpy.find(">", framePos);
if (-1 == framePos) {
framePos = buffcpy->find("<FRAME ", framePos + 1);
if (-1 == framePos) {
break;
}
}
int framePosEnd = buffcpy->find(">", framePos);
std::string frameString = buffcpy->substr(framePos, framePosEnd - framePos); std::string frameString = buffcpy.substr(framePos, framePosEnd - framePos);
framePos = buffcpy.find("<frame ", framePos + 1);
int frameSrcPos = frameString.find("src"); int frameSrcPos = frameString.find("src");
if (-1 == frameSrcPos) {
frameSrcPos = frameString.find("SRC");
}
if (-1 != frameSrcPos) { if (-1 != frameSrcPos) {
int eqPos = frameString.find_first_of("=", frameSrcPos); int eqPos = frameString.find_first_of("=", frameSrcPos);
if (-1 != eqPos) { if (-1 != eqPos) {
@ -3236,19 +3238,29 @@ int handleFramesets(std::string *buffcpy, char* ip, int port, int flag) {
if (-1 != quotePos1) { if (-1 != quotePos1) {
int quotePos2 = frameString.find_first_of("\"'", quotePos1 + 1); int quotePos2 = frameString.find_first_of("\"'", quotePos1 + 1);
if (quotePos1 != quotePos2) { //if (quotePos1 != quotePos2) {
std::string location = frameString.substr(quotePos1 + 1, quotePos2 - quotePos1 - 1);
if (counter++ > 5) { if (counter++ > 5) {
return 0; return 0;
}; };
std::string location = frameString.substr(quotePos1 + 1, quotePos2 - quotePos1 - 1); if (location.size() == 0) {
continue;
}
std::string tIP = std::string(ip) + (location[0] == '/' ? "" : "/") + location; std::string tIP = std::string(ip) + (location[0] == '/' ? "" : "/") + location;
std::string buff; std::string buff;
Sleep(5000);
int sz = con.nConnect(tIP.c_str(), port, &buff); int sz = con.nConnect(tIP.c_str(), port, &buff);
if (-1 == sz) {
continue;
}
int flg = contentFilter((const std::string *) &buff, port, ip, "UTF-8", sz); int flg = contentFilter((const std::string *) &buff, port, ip, "UTF-8", sz);
if (flg == -1) { if (flg == -1) {
return -1; return -1;
} }
else if (flg > 1) {
return flg;
} }
//}
} }
} }
} }