mirror of
https://github.com/ChronosX88/nesca.git
synced 2024-11-23 10:42:21 +00:00
File Downloader carcas
This commit is contained in:
parent
a514051bfd
commit
5c26625f85
51
FileDownloader.cpp
Normal file
51
FileDownloader.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
#include "FileDownloader.h"
|
||||
#include "Connector.h"
|
||||
#include "FileUpdater.h"
|
||||
#include "istream"
|
||||
|
||||
int getCL(std::string *buffer) {
|
||||
|
||||
std::size_t pos1 = buffer->find("Content-Length:");
|
||||
if(pos1 == std::string::npos) {
|
||||
stt->doEmitionFoundData("<font color=\"Pink\">Cannot find Content-Length.</font>");
|
||||
return -1;
|
||||
}
|
||||
int pos2 = buffer->find("\r\n", pos1);
|
||||
if(pos2 == std::string::npos) {
|
||||
stt->doEmitionFoundData("<font color=\"Pink\">Weird reply.</font>");
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::string res = buffer->substr(pos1 + 15, pos2 - pos1 - 15);
|
||||
return stoi(res);
|
||||
}
|
||||
|
||||
void checkWeb(const char *fileName, long *ptr, void *func(void)) {
|
||||
std::string buffer;
|
||||
Connector::nConnect(std::string("localhost/nesca/" + std::string(fileName)).c_str(), 8080, &buffer);
|
||||
|
||||
std::cout<<buffer<<std::endl;
|
||||
int cl = getCL(&buffer);
|
||||
if(cl == -1) return;
|
||||
|
||||
if(cl != *ptr) {
|
||||
std::ofstream out(fileName);
|
||||
out << buffer.substr(buffer.find("\r\n\r\n") + 4);
|
||||
out.close();
|
||||
|
||||
stt->doEmitionFoundData("<font color=\"Pink\">File " + QString(fileName) + " downloaded.</font>");
|
||||
}
|
||||
}
|
||||
|
||||
void loadNegatives(){
|
||||
}
|
||||
|
||||
void FileDownloader::checkWebFiles() {
|
||||
//checkWeb("negatives.txt", &FileUpdater::oldNegLstSize, (void*(*)(void))loadNegatives);
|
||||
//checkWeb("login.txt", (void*(*)(void))loadLogins);
|
||||
//checkWeb("pass.txt", (void*(*)(void))loadPass);
|
||||
//checkWeb("sshpass.txt", (void*(*)(void))loadSSHPass);
|
||||
//checkWeb("wflogin.txt", (void*(*)(void))loadWFLogins);
|
||||
//checkWeb("wfpass.txt", (void*(*)(void))loadWFPass);
|
||||
}
|
||||
|
9
FileDownloader.h
Normal file
9
FileDownloader.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef FILEDOWNLOADER_H
|
||||
#define FILEDOWNLOADER_H
|
||||
|
||||
class FileDownloader {
|
||||
public:
|
||||
static void checkWebFiles();
|
||||
};
|
||||
|
||||
#endif // FILEDOWNLOADER_H
|
@ -42,7 +42,8 @@ SOURCES +=\
|
||||
FTPAuth.cpp \
|
||||
Threader.cpp \
|
||||
SSHAuth.cpp \
|
||||
FileUpdater.cpp
|
||||
FileUpdater.cpp \
|
||||
FileDownloader.cpp
|
||||
|
||||
|
||||
HEADERS += ActivityDrawerTh_HorNet.h \
|
||||
@ -71,7 +72,8 @@ HEADERS += ActivityDrawerTh_HorNet.h \
|
||||
FTPAuth.h \
|
||||
Threader.h \
|
||||
SSHAuth.h \
|
||||
FileUpdater.h
|
||||
FileUpdater.h \
|
||||
FileDownloader.h
|
||||
|
||||
FORMS += nesca_3.ui
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 3.2.1, 2015-03-23T10:43:12. -->
|
||||
<!-- Written by QtCreator 3.2.1, 2015-03-30T17:30:31. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "Connector.h"
|
||||
#include "Threader.h"
|
||||
#include "FileUpdater.h"
|
||||
#include "FileDownloader.h"
|
||||
#include <thread>
|
||||
|
||||
QJsonArray *jsonArr = new QJsonArray();
|
||||
@ -1764,6 +1765,8 @@ int _GetDNSFromMask(char *mask, char *saveMask, char *saveMaskEnder) {
|
||||
void runAuxiliaryThreads() {
|
||||
std::thread lpThread(FileUpdater::updateLists);
|
||||
lpThread.detach();
|
||||
std::thread fuThread(FileDownloader::checkWebFiles);
|
||||
fuThread.detach();
|
||||
std::thread saverThread(_saver);
|
||||
saverThread.detach();
|
||||
std::thread trackerThread(_tracker);
|
||||
|
Loading…
Reference in New Issue
Block a user