Skip to content

Commit

Permalink
qwe
Browse files Browse the repository at this point in the history
  • Loading branch information
cora32 committed Dec 29, 2015
1 parent 38567a9 commit aeeb2d6
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 18 deletions.
66 changes: 49 additions & 17 deletions Connector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,12 @@ size_t nWriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
//return realsize;
}

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 pConnect(const char* ip, const int port, std::string *buffer,
const char *postData,
const std::vector<std::string> *customHeaders,
const std::string *lpString,
bool digestMode)
{
buffer->clear();
int res = 0;
CURL *curl = curl_easy_init();
Expand Down Expand Up @@ -174,7 +175,7 @@ int Connector::nConnect(const char* ip, const int port, std::string *buffer,
for (auto &ch : *customHeaders) chunk = curl_slist_append(chunk, ch.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
}

if (lpString != NULL) {
curl_easy_setopt(curl, CURLOPT_UNRESTRICTED_AUTH, 1L);
curl_easy_setopt(curl, CURLOPT_FTPLISTONLY, 1L);
Expand All @@ -183,7 +184,7 @@ int Connector::nConnect(const char* ip, const int port, std::string *buffer,
{
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) {
Expand All @@ -194,7 +195,7 @@ int Connector::nConnect(const char* ip, const int port, std::string *buffer,
else res = curl_easy_perform(curl);
}
else res = curl_easy_perform(curl);

int sz = buffer->size();

curl_easy_cleanup(curl);
Expand Down Expand Up @@ -233,14 +234,15 @@ int Connector::nConnect(const char* ip, const int port, std::string *buffer,
res != 56 &&
res != 35 &&
res != 19 &&
res != 23)
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) +
}
else if (res == 8) {
stt->doEmitionFoundData("Strange ftp reply. (" +
QString::number(res) + ") " + QString(ip) +
":" + QString::number(port));
return -2;
}
Expand All @@ -250,10 +252,10 @@ int Connector::nConnect(const char* ip, const int port, std::string *buffer,
":" + QString::number(port));
return -2;
}
else stt->doEmitionRedFoundData("CURL error: (" + QString::number(res) + ") " +
else stt->doEmitionRedFoundData("CURL error: (" + QString::number(res) + ") " +
QString(ip) + ":" + QString::number(port));
};

//if (res == 23 && sz > 0) {
// return sz;
//}
Expand All @@ -264,12 +266,42 @@ int Connector::nConnect(const char* ip, const int port, std::string *buffer,
if (MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString(buffer->c_str()));

return sz;
} else {
stt->doEmitionRedFoundData("Curl error.");
return -1;
}
else {
stt->doEmitionRedFoundData("Curl error.");
return -1;
};
}

void eraser(std::string *buffer, const std::string delim1, const std::string delim2) {
int pos = -1;
while ((pos = buffer->find(delim1)) != -1) {
int ePos = buffer->find(delim2, pos);
if (ePos != -1) {
buffer->erase(pos, ePos - pos - 1 + delim2.length());
}
else {
buffer->erase(pos, buffer->length() - pos - 1);
}
}
}
void cutoutComments(std::string *buffer) {
eraser(buffer, "<!--", "-->");
eraser(buffer, "/*", "*/");
eraser(buffer, "//", "\n");
}

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);
cutoutComments(buffer);

return buffer->size();
}

bool portCheck(const char * sDVRIP, int wDVRPort) {
// sockaddr_in sa;
// sa.sin_family = AF_INET;
Expand Down
5 changes: 4 additions & 1 deletion finder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3208,7 +3208,7 @@ int handleFramesets(std::string *buffcpy, char* ip, int port, int flag) {

Connector con;
int framePos = pos + 9;

int counter = 0;
while (framePos != -1) {
framePos = buffcpy->find("<frame ", framePos + 1);
if (-1 == framePos) {
Expand All @@ -3233,6 +3233,9 @@ int handleFramesets(std::string *buffcpy, char* ip, int port, int flag) {
int quotePos2 = frameString.find_first_of("\"'", quotePos1 + 1);

if (quotePos1 != quotePos2) {
if (counter++ > 5) {
return 0;
};
std::string location = frameString.substr(quotePos1 + 1, quotePos2 - quotePos1 - 1);
std::string tIP = std::string(ip) + (location[0] == '/' ? "" : "/") + location;
std::string buff;
Expand Down

0 comments on commit aeeb2d6

Please sign in to comment.