mirror of
https://github.com/ChronosX88/nesca.git
synced 2024-11-23 18:52:19 +00:00
Fix
This commit is contained in:
parent
f1d0e32ed5
commit
09dcdee82e
119
finder.cpp
119
finder.cpp
@ -2493,9 +2493,9 @@ bool equivRedirectHandler(std::string *buff, char* ip, int port, Lexems *counter
|
|||||||
Connector con;
|
Connector con;
|
||||||
int newPort = port;
|
int newPort = port;
|
||||||
if (location[0] == '/') {
|
if (location[0] == '/') {
|
||||||
std::string tIP = std::string(ip) + location;
|
std::string tIP = std::string(ip) + ":" + std::to_string(port) + location;
|
||||||
stt->doEmitionYellowFoundData("Redirecting to -> " + QString(tIP.c_str()));
|
stt->doEmitionYellowFoundData("Redirecting to -> " + QString(tIP.c_str()));
|
||||||
con.nConnect(location.c_str(), port, &buffcpy);
|
con.nConnect(tIP.c_str(), port, &buffcpy);
|
||||||
}
|
}
|
||||||
else if (-1 != STRSTR(location, "http://")) {
|
else if (-1 != STRSTR(location, "http://")) {
|
||||||
int httpProto = STRSTR(location, "http://");
|
int httpProto = STRSTR(location, "http://");
|
||||||
@ -2503,9 +2503,14 @@ bool equivRedirectHandler(std::string *buff, char* ip, int port, Lexems *counter
|
|||||||
int portPos = location.find(":", 7);
|
int portPos = location.find(":", 7);
|
||||||
if (-1 != portPos) {
|
if (-1 != portPos) {
|
||||||
int portPosEnd = location.find("/ \n>\"'", portPos + 7);
|
int portPosEnd = location.find("/ \n>\"'", portPos + 7);
|
||||||
newPort = std::stoi(location.substr(portPos + 1, portPosEnd));
|
if (-1 != portPosEnd) {
|
||||||
stt->doEmitionYellowFoundData("Redirecting to -> " + QString(location.c_str()));
|
newPort = std::stoi(location.substr(portPos + 1, portPosEnd));
|
||||||
con.nConnect(location.c_str(), newPort, &buffcpy);
|
stt->doEmitionYellowFoundData("Redirecting to -> " + QString(location.c_str()));
|
||||||
|
con.nConnect(location.c_str(), newPort, &buffcpy);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stt->doEmitionYellowFoundData(QString(ip) + ":" + QString(port) + " Redirector error -> " + QString(location.c_str()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
stt->doEmitionYellowFoundData("Redirecting to -> " + QString(location.c_str()));
|
stt->doEmitionYellowFoundData("Redirecting to -> " + QString(location.c_str()));
|
||||||
@ -2518,9 +2523,14 @@ bool equivRedirectHandler(std::string *buff, char* ip, int port, Lexems *counter
|
|||||||
int portPos = location.find(":", 8);
|
int portPos = location.find(":", 8);
|
||||||
if (-1 != portPos) {
|
if (-1 != portPos) {
|
||||||
int portPosEnd = location.find("/ \n>\"'", portPos + 8);
|
int portPosEnd = location.find("/ \n>\"'", portPos + 8);
|
||||||
newPort = std::stoi(location.substr(portPos + 1, portPosEnd));
|
if (-1 != portPosEnd) {
|
||||||
stt->doEmitionYellowFoundData("Redirecting to -> " + QString(location.c_str()));
|
newPort = std::stoi(location.substr(portPos + 1, portPosEnd));
|
||||||
con.nConnect(location.c_str(), newPort, &buffcpy);
|
stt->doEmitionYellowFoundData("Redirecting to -> " + QString(location.c_str()));
|
||||||
|
con.nConnect(location.c_str(), newPort, &buffcpy);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stt->doEmitionYellowFoundData(QString(ip) + ":" + QString(port) + " Redirector error -> " + QString(location.c_str()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
stt->doEmitionYellowFoundData("Redirecting to -> " + QString(location.c_str()));
|
stt->doEmitionYellowFoundData("Redirecting to -> " + QString(location.c_str()));
|
||||||
@ -2535,24 +2545,69 @@ bool equivRedirectHandler(std::string *buff, char* ip, int port, Lexems *counter
|
|||||||
|
|
||||||
++counter->iterationCount;
|
++counter->iterationCount;
|
||||||
|
|
||||||
|
equivRedirectHandler(&buffcpy, ip, newPort, counter);
|
||||||
|
|
||||||
if (equivRedirectHandler(&buffcpy, ip, newPort, counter)) {
|
buff->clear();
|
||||||
*buff = buffcpy;
|
buff->assign(buffcpy);
|
||||||
}
|
|
||||||
|
|
||||||
return buff->size() > 0;
|
return buff->size() > 0;
|
||||||
}
|
}
|
||||||
|
std::string getScriptField(std::string *buff) {
|
||||||
|
int pos1 = STRSTR((const std::string *)buff, "<script");
|
||||||
|
pos1 = buff->find(">", pos1) + 1;
|
||||||
|
int pos2 = STRSTR((const std::string *)buff, "</script>");
|
||||||
|
if (-1 == pos2) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
while (pos1 == pos2) {
|
||||||
|
std::string tempBuff;
|
||||||
|
tempBuff.assign(buff->substr(pos1 + 9));
|
||||||
|
buff->clear();
|
||||||
|
buff->assign(tempBuff);
|
||||||
|
pos1 = STRSTR((const std::string *)buff, "<script");
|
||||||
|
pos1 = buff->find(">", pos1) + 1;
|
||||||
|
pos2 = STRSTR((const std::string *)buff, "</script>");
|
||||||
|
if (-1 == pos2) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-1 == pos1 || -1 == pos2) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string scriptBuff = buff->substr(pos1, pos2 - pos1);
|
||||||
|
|
||||||
|
int commentPos1 = scriptBuff.find("<!--");
|
||||||
|
if (-1 != commentPos1) {
|
||||||
|
int commentPos2 = scriptBuff.find("-->");
|
||||||
|
|
||||||
|
if (-1 != commentPos2) {
|
||||||
|
std::string finalScriptBuff = scriptBuff.substr(0, commentPos1);
|
||||||
|
finalScriptBuff.append(scriptBuff.substr(commentPos2 + 3, scriptBuff.size() - (commentPos2 + 3)));
|
||||||
|
|
||||||
|
return finalScriptBuff;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return scriptBuff;
|
||||||
|
}
|
||||||
|
}
|
||||||
bool jsRedirectHandler(std::string *buff, char* ip, int port, Lexems *counter) {
|
bool jsRedirectHandler(std::string *buff, char* ip, int port, Lexems *counter) {
|
||||||
if (NULL == buff || 0 == buff->size()) {
|
if (NULL == buff || 0 == buff->size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (counter->iterationCount > 2) {
|
if (counter->iterationCount > 3) {
|
||||||
stt->doEmitionFoundData(QString(ip) + ":" + QString::number(port) + " - infinite loop detected.");
|
stt->doEmitionFoundData(QString(ip) + ":" + QString::number(port) + " - infinite loop detected.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string buffcpy = *buff;
|
std::string &buffcpy = getScriptField(buff);
|
||||||
|
|
||||||
int pos = STRSTR((const std::string *) &buffcpy, "location.href =");
|
int pos = STRSTR((const std::string *) &buffcpy, "location.href =");
|
||||||
if (-1 == pos) pos = STRSTR((const std::string *) &buffcpy, "location.href=");
|
if (-1 == pos) pos = STRSTR((const std::string *) &buffcpy, "location.href=");
|
||||||
@ -2572,7 +2627,28 @@ bool jsRedirectHandler(std::string *buff, char* ip, int port, Lexems *counter) {
|
|||||||
int quotePosSecond = subRedirect.find_first_of("\"'", quotePosFirst + 1);
|
int quotePosSecond = subRedirect.find_first_of("\"'", quotePosFirst + 1);
|
||||||
|
|
||||||
std::string subLocation = subRedirect.substr(quotePosFirst + 1, quotePosSecond - quotePosFirst - 1);
|
std::string subLocation = subRedirect.substr(quotePosFirst + 1, quotePosSecond - quotePosFirst - 1);
|
||||||
std::string location = std::string(ip) + (subLocation[0] == '/' ? "" : "/") + subLocation;
|
std::string location = "";
|
||||||
|
if (-1 != STRSTR((const std::string *) &buffcpy, "http")) {
|
||||||
|
if (-1 != STRSTR((const std::string *) &buffcpy, "https")) {
|
||||||
|
location += "https://";
|
||||||
|
}
|
||||||
|
else if (-1 != STRSTR((const std::string *) &buffcpy, "http")) {
|
||||||
|
location += "http://";
|
||||||
|
}
|
||||||
|
|
||||||
|
int quotePosSecond2 = subRedirect.find_first_of(";\n", quotePosFirst + 1);
|
||||||
|
std::string redirectLine = subRedirect.substr(quotePosFirst + 1, quotePosSecond2 - (quotePosFirst + 1));
|
||||||
|
int posFinalAddition = redirectLine.find_last_of("+");
|
||||||
|
std::string finalAddition = redirectLine.substr(posFinalAddition + 1);
|
||||||
|
int pos1 = finalAddition.find_first_of("'\"");
|
||||||
|
int pos2 = finalAddition.find_first_of("'\"", pos1 + 1);
|
||||||
|
|
||||||
|
std::string path = finalAddition.substr(pos1 + 1, pos2 - (pos1 + 1));
|
||||||
|
location += std::string(ip) + "/" + path;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
location = std::string(ip) + (subLocation[0] == '/' ? "" : "/") + subLocation;
|
||||||
|
}
|
||||||
|
|
||||||
Connector con;
|
Connector con;
|
||||||
stt->doEmitionYellowFoundData("Redirecting to -> " + QString(location.c_str()));
|
stt->doEmitionYellowFoundData("Redirecting to -> " + QString(location.c_str()));
|
||||||
@ -2580,18 +2656,23 @@ bool jsRedirectHandler(std::string *buff, char* ip, int port, Lexems *counter) {
|
|||||||
|
|
||||||
++counter->iterationCount;
|
++counter->iterationCount;
|
||||||
|
|
||||||
if (jsRedirectHandler(&buffcpy, ip, port, counter)) {
|
jsRedirectHandler(&buffcpy, ip, port, counter);
|
||||||
*buff = buffcpy;
|
|
||||||
}
|
buff->clear();
|
||||||
|
buff->assign(buffcpy);
|
||||||
|
|
||||||
return buff->size() > 0;
|
return buff->size() > 0;
|
||||||
}
|
}
|
||||||
std::string getHeader(const std::string *buffcpy, const int flag) {
|
std::string getHeader(const std::string *buffcpy, const int flag) {
|
||||||
if (STRSTR(buffcpy, "<frame name=\"mainframe\" src=\"main.html\"") != -1) {
|
if (STRSTR(buffcpy, "<frame name=\"mainframe\" src=\"main.html\"") != -1) {
|
||||||
return "[IP-camera]";
|
return "[IPCam]";
|
||||||
|
}
|
||||||
|
else if (STRSTR(buffcpy, "MOBOTIX AG") != -1) {
|
||||||
|
return "[MOBOTIC IPCam]";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::string &result = getTitle(buffcpy->c_str(), flag);
|
std::string tempBuff = buffcpy->c_str();
|
||||||
|
std::string &result = getTitle(tempBuff.c_str(), flag);
|
||||||
|
|
||||||
if (result.size() == 0) {
|
if (result.size() == 0) {
|
||||||
if (Utils::ustrstr(buffcpy, "redir") != std::string::npos) {
|
if (Utils::ustrstr(buffcpy, "redir") != std::string::npos) {
|
||||||
|
76
main.cpp
76
main.cpp
@ -8,46 +8,46 @@
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
bool isWM = false;
|
bool isWM = false;
|
||||||
DWORD Type;
|
//DWORD Type;
|
||||||
char value[512] = { 0 };
|
//char value[512] = { 0 };
|
||||||
char resultString[512] = { 0 };
|
//char resultString[512] = { 0 };
|
||||||
HKEY hkey;
|
//HKEY hkey;
|
||||||
if (RegOpenKey(HKEY_LOCAL_MACHINE,
|
//if (RegOpenKey(HKEY_LOCAL_MACHINE,
|
||||||
TEXT("HARDWARE\\DESCRIPTION\\System"), &hkey) == ERROR_SUCCESS)
|
// TEXT("HARDWARE\\DESCRIPTION\\System"), &hkey) == ERROR_SUCCESS)
|
||||||
{
|
//{
|
||||||
DWORD value_length = 512;
|
// DWORD value_length = 512;
|
||||||
RegQueryValueEx(hkey, L"VideoBiosVersion", 0, &Type, (BYTE*)&value, &value_length);
|
// RegQueryValueEx(hkey, L"VideoBiosVersion", 0, &Type, (BYTE*)&value, &value_length);
|
||||||
RegCloseKey(hkey);
|
// RegCloseKey(hkey);
|
||||||
|
|
||||||
for (int i = 0, j = 0; i < 256; ++i, j += 2) {
|
// for (int i = 0, j = 0; i < 256; ++i, j += 2) {
|
||||||
char ch = value[j];
|
// char ch = value[j];
|
||||||
if (ch != '\0') {
|
// if (ch != '\0') {
|
||||||
resultString[i] = ch;
|
// resultString[i] = ch;
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
resultString[i] = '\n';
|
// resultString[i] = '\n';
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
resultString[256] = '\0';
|
// resultString[256] = '\0';
|
||||||
}
|
//}
|
||||||
if (strstr(resultString, "VirtualBox") ||
|
//if (strstr(resultString, "VirtualBox") ||
|
||||||
strstr(resultString, "virtualbox")) {
|
// strstr(resultString, "virtualbox")) {
|
||||||
isWM = true;
|
// isWM = true;
|
||||||
};
|
//};
|
||||||
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
if (isWM) {
|
if (isWM) {
|
||||||
QMessageBox msgBox(
|
//QMessageBox msgBox(
|
||||||
QMessageBox::Information,
|
// QMessageBox::Information,
|
||||||
"Nope",
|
// "Nope",
|
||||||
"");
|
// "");
|
||||||
QPalette palette;
|
//QPalette palette;
|
||||||
palette.setBrush(QPalette::Background, Qt::cyan);
|
//palette.setBrush(QPalette::Background, Qt::cyan);
|
||||||
msgBox.setIconPixmap(QPixmap(":/nesca_3/xc.jpg"));
|
//msgBox.setIconPixmap(QPixmap(":/nesca_3/xc.jpg"));
|
||||||
msgBox.setPalette(palette);
|
//msgBox.setPalette(palette);
|
||||||
msgBox.setVisible(true);
|
//msgBox.setVisible(true);
|
||||||
msgBox.exec();
|
//msgBox.exec();
|
||||||
} else {
|
} else {
|
||||||
QStringList list;
|
QStringList list;
|
||||||
list << "small_font.ttf";
|
list << "small_font.ttf";
|
||||||
@ -69,9 +69,9 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
nesca_3 *gui = new nesca_3(isWM, 0);
|
nesca_3 *gui = new nesca_3(isWM, 0);
|
||||||
if (isWM) {
|
//if (isWM) {
|
||||||
Utils::emitScaryError();
|
// Utils::emitScaryError();
|
||||||
}
|
//}
|
||||||
gui->showNormal();
|
gui->showNormal();
|
||||||
}
|
}
|
||||||
return a.exec();
|
return a.exec();
|
||||||
|
13
nesca_3.cpp
13
nesca_3.cpp
@ -3257,9 +3257,9 @@ void nesca_3::CheckPersKey()
|
|||||||
|
|
||||||
nesca_3::nesca_3(bool isWM, QWidget *parent = 0) : QMainWindow(parent)
|
nesca_3::nesca_3(bool isWM, QWidget *parent = 0) : QMainWindow(parent)
|
||||||
{
|
{
|
||||||
if (isWM) {
|
/*if (isWM) {
|
||||||
Utils::emitScaryError();
|
Utils::emitScaryError();
|
||||||
}
|
}*/
|
||||||
setWindowFlags(Qt::FramelessWindowHint);
|
setWindowFlags(Qt::FramelessWindowHint);
|
||||||
|
|
||||||
gthis = this;
|
gthis = this;
|
||||||
@ -3322,7 +3322,7 @@ nesca_3::nesca_3(bool isWM, QWidget *parent = 0) : QMainWindow(parent)
|
|||||||
ui->BATableView->setModel(BAModel);
|
ui->BATableView->setModel(BAModel);
|
||||||
ui->BATableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
ui->BATableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||||
|
|
||||||
bool DONOTSCAN = true;
|
/*bool DONOTSCAN = true;
|
||||||
if (isWM) {
|
if (isWM) {
|
||||||
Utils::emitScaryError();
|
Utils::emitScaryError();
|
||||||
}
|
}
|
||||||
@ -3383,7 +3383,12 @@ nesca_3::nesca_3(bool isWM, QWidget *parent = 0) : QMainWindow(parent)
|
|||||||
ui->tabMainWidget->setTabEnabled(1, true);
|
ui->tabMainWidget->setTabEnabled(1, true);
|
||||||
ui->tabMainWidget->setTabEnabled(2, true);
|
ui->tabMainWidget->setTabEnabled(2, true);
|
||||||
finishLoading();
|
finishLoading();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
ui->tabMainWidget->setTabEnabled(0, true);
|
||||||
|
ui->tabMainWidget->setTabEnabled(1, true);
|
||||||
|
ui->tabMainWidget->setTabEnabled(2, true);
|
||||||
|
finishLoading();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
FILE* pipe = NULL;
|
FILE* pipe = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user