update
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -20,10 +20,11 @@
|
||||
int main() {
|
||||
log(LOGLEVEL::INFO, "[main()]:Starting main thread.");
|
||||
printf("welcome to the jakach security tool main thread\n");
|
||||
load_settings();
|
||||
initialize(DB_DIR);
|
||||
load_settings();//load the settings from the settings file
|
||||
initialize(DB_DIR); //load the hash databases into memory
|
||||
|
||||
//start a second thread which will scan for new files
|
||||
if (get_setting("rtp:status") == 1) {
|
||||
if (get_setting("rtp_folder_scan:status") == 1) {
|
||||
log(LOGLEVEL::INFO, "[main()]:Starting real time protection.");
|
||||
std::thread folder_scannner_thread(folder_scanner);
|
||||
folder_scannner_thread.detach();
|
||||
@@ -42,12 +43,9 @@ int main() {
|
||||
//check for tasks in com
|
||||
//check for scheduled tasks
|
||||
//execute tasks
|
||||
//call_srv("8.8.8.8","","");
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
// printf("check_from_com:%d\n",check_for_com_tasks(MAIN_COM, MAIN_COM_PATH));
|
||||
check_for_com_tasks(MAIN_COM, MAIN_COM_PATH);
|
||||
check_for_sched_tasks(SCHED, SCHED_PATH);
|
||||
// printf("check_from_task:%d\n", check_for_sched_tasks(SCHED,SCHED_PATH));
|
||||
check_for_com_tasks(MAIN_COM, MAIN_COM_PATH); //check for tasks from user interface and add them to the queue
|
||||
check_for_sched_tasks(SCHED, SCHED_PATH); //check for scheduled tasks and add them to the queue
|
||||
//unlock_task("tsk1"); else it will only be executed once. but this function has to be called at the end of the task. else it will nvr be executed again. this would be bad :(
|
||||
//start a thread that executes check_scan_dir to scan folders for new files. this thread then should start a ock so only one scanfolder thread runs at a time
|
||||
//Sleep(1000);
|
||||
@@ -68,8 +66,6 @@ int main() {
|
||||
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(stop - start);
|
||||
if (duration.count() < 1000)
|
||||
Sleep(1000 - duration.count());
|
||||
|
||||
// printf("\n\n\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -37,9 +37,7 @@ int check_for_com_tasks(const char* com_name, const char* com_path) {
|
||||
queue_entry[0] = '\0';
|
||||
strcpy_s(queue_entry,600, command); //copy the command
|
||||
strcat_s(queue_entry, 600, ";"); //add a ; to seperate command and path
|
||||
//printf("%d\n", strlen(path));
|
||||
strcat_s(queue_entry, 600, path); //add the path
|
||||
//printf("%s::%d\n",queue_entry,strlen(queue_entry));
|
||||
|
||||
queue_push(queue_entry);
|
||||
//(queue_entry);
|
||||
|
||||
@@ -64,7 +64,7 @@ bool is_task_due(const std::string& task_name, const std::string& cron_expressio
|
||||
is_valid_field(fields[3], current_time.tm_mon + 1) &&
|
||||
is_valid_field(fields[4], current_time.tm_wday + 1)) {
|
||||
|
||||
// Check if the task has already been executed
|
||||
// Check if the task has not already been executed
|
||||
if (!task_states[task_name]) {
|
||||
// Set the flag to indicate that the task has been executed
|
||||
task_states[task_name] = true;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "queue_ctrl.h"
|
||||
#include <string.h>
|
||||
#define queue_limit 1000
|
||||
#define command_limit 300
|
||||
#define command_limit 3000
|
||||
char queue[queue_limit][command_limit];
|
||||
int queue_size = 0;
|
||||
int queue_start = 0;
|
||||
|
||||
@@ -128,7 +128,7 @@ void scan_folder(const std::string& directory) {
|
||||
HANDLE hFind = FindFirstFile(search_path.c_str(), &find_file_data);
|
||||
|
||||
if (hFind == INVALID_HANDLE_VALUE) {
|
||||
log(LOGLEVEL::ERR, "[ListFilesRecursive()]: Error opening directory: ", directory, " while scanning files inside folder.");
|
||||
log(LOGLEVEL::ERR, "[scan_folder()]: Error opening directory: ", search_path.c_str() , " while scanning files inside folder.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -189,16 +189,18 @@ void action_scanfile(const char*filepath) {
|
||||
delete[] db_path;
|
||||
thread_shutdown();
|
||||
}
|
||||
void action_scanfolder(const char* folderpath) {
|
||||
void action_scanfolder(const char*folderpath) {
|
||||
thread_init();
|
||||
scan_folder(folderpath);
|
||||
cnt = 0;
|
||||
thread_local std::string folderpath_ (folderpath);
|
||||
scan_folder(folderpath_);
|
||||
thread_shutdown();
|
||||
}
|
||||
|
||||
void scan_file_t(const std::string& filepath_) {
|
||||
thread_local const std::string filepath (filepath_);
|
||||
thread_local char* db_path = new char[300];
|
||||
thread_local char*hash = new char[300];
|
||||
thread_local char* hash = new char[300];
|
||||
strcpy_s(hash,295 ,md5_file_t(filepath).c_str());
|
||||
sprintf_s(db_path, 295, "%s\\%c%c.jdbf", DB_DIR, hash[0], hash[1]);
|
||||
search_hash(db_path, hash, filepath);
|
||||
|
||||
@@ -7,7 +7,7 @@ int setting_virus_ctrl_virus_found_action = 0;
|
||||
char*setting_server_server_url = new char[300];
|
||||
char exluded_folders[100][300];
|
||||
int excluded_folders_size = 0;
|
||||
bool setting_rtp_status = 1; //0=off, 1=on
|
||||
bool setting_rtp_folder_scan_status = 1; //0=off, 1=on
|
||||
void load_excluded_folders();
|
||||
int load_settings() {
|
||||
FILE* fp;
|
||||
@@ -41,13 +41,13 @@ int load_settings() {
|
||||
fscanf_s(fp, "%s", settings_arg, 295); // get the argument
|
||||
strcpy_s(setting_server_server_url, 295, settings_arg);
|
||||
}
|
||||
else if (strcmp(settings_cmd, "rtp:status") == 0) {
|
||||
else if (strcmp(settings_cmd, "rtp_folder_scan:status") == 0) {
|
||||
fscanf_s(fp, "%s", settings_arg, 295); // get the argument
|
||||
if (strcmp(settings_arg, "on") == 0) {
|
||||
setting_rtp_status = 1; //1=on
|
||||
setting_rtp_folder_scan_status = 1; //1=on
|
||||
}
|
||||
else if (strcmp(settings_arg, "off") == 0) {
|
||||
setting_rtp_status = 0; //0=off
|
||||
setting_rtp_folder_scan_status = 0; //0=off
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,8 +67,8 @@ int get_setting(const char*setting_name) {
|
||||
if (strcmp(setting_name, "virus_ctrl:virus_found:action") == 0) {
|
||||
return setting_virus_ctrl_virus_found_action;
|
||||
}
|
||||
else if (strcmp(setting_name, "rtp:status") == 0) {
|
||||
return setting_rtp_status;
|
||||
else if (strcmp(setting_name, "rtp_folder_scan:status") == 0) {
|
||||
return setting_rtp_folder_scan_status;
|
||||
}
|
||||
|
||||
return -1;
|
||||
@@ -115,9 +115,9 @@ void load_excluded_folders() {
|
||||
log(LOGLEVEL::ERR, "[load_excluded_folders()]: Excluded folders array is full. Cannot add more folders.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
log(LOGLEVEL::ERR, "[load_excluded_folders()]: Error while processing excluded folders database. Expected \" but got ", chr);
|
||||
}
|
||||
//else { we dont need to error out here. it is normal that it givs errors at the last lien of the file. but nothing bad happens, so errors arent needed
|
||||
// log(LOGLEVEL::ERR, "[load_excluded_folders()]: Error while processing excluded folders database. Expected \" but got ", chr);
|
||||
//}
|
||||
}
|
||||
fclose(fp);
|
||||
delete[] path;
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
#include "well_known.h"
|
||||
#include "scan.h"
|
||||
#include "app_ctrl.h"
|
||||
void split(char* input,char*delimiter, char* out1, char* out2) {
|
||||
void split(char* input,const char delimiter, char* out1, char* out2) {
|
||||
//split a string at the delimiter. the delimiter only occurs once. so the first part is out1 and the second part is out2
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int k = 0;
|
||||
while (input[i] != '\0') {
|
||||
if (input[i] == delimiter[0]) {
|
||||
if (input[i] == delimiter) {
|
||||
out1[j] = '\0';
|
||||
i++;
|
||||
while (input[i] != '\0') {
|
||||
@@ -33,18 +33,25 @@ int start_thread(const char* command) {
|
||||
if (can_run_thread()) {
|
||||
char* out2 = new char[100]; //for the command
|
||||
char* out1 = new char[300]; //for the arguments
|
||||
split((char*)command, (char*)";", (char*)out1, (char*)out2);
|
||||
|
||||
split((char*)command,';', (char*)out1, (char*)out2);
|
||||
log(LOGLEVEL::INFO, "[start_thread()]: starting command: ", out1, " with arguments: ",out2);
|
||||
//printf("out1: %s\n", out1);
|
||||
//printf("out2: %s\n", out2);
|
||||
//determine what should be executed
|
||||
if (strcmp(out1, "scanfile") == 0) {
|
||||
//start a new thread with the scanfile function
|
||||
std::thread t1(action_scanfile, out2);
|
||||
t1.detach();
|
||||
}
|
||||
else if (strcmp(out1, "scanfolder") == 0) {
|
||||
//start a new thread with the scanfolder function
|
||||
std::thread t1(action_scanfolder, out2);
|
||||
t1.detach();
|
||||
}
|
||||
|
||||
while (can_run_thread()) {
|
||||
//delay a bit, in order to wait until the thread is started
|
||||
Sleep(10);
|
||||
}
|
||||
delete[] out1;
|
||||
delete[] out2;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#ifndef UPDATE_H
|
||||
#define UPDATE_H
|
||||
#include <curl/curl.h>
|
||||
#include<string>
|
||||
int update_db(const std::string& folder_path);
|
||||
int update_settings(const std::string& folder_path);
|
||||
#endif
|
||||
@@ -101,9 +101,9 @@ int virus_ctrl_process( const char* id) {
|
||||
delete[] url_path;
|
||||
delete[] additional;
|
||||
}
|
||||
else {
|
||||
log(LOGLEVEL::ERR, "[virus_ctrl_process()]:Error while processing virus control database. Expected \" but got ", chr);
|
||||
}
|
||||
//else { creates to many log entrys => entrys are not needed
|
||||
// log(LOGLEVEL::ERR, "[virus_ctrl_process()]:Error while processing virus control database. Expected \" but got ", chr);
|
||||
//}
|
||||
delete[] path;
|
||||
delete[] hash;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#define WELL_KNOWN_H
|
||||
#define MAIN_COM "main_com.txt"
|
||||
#define MAIN_COM_PATH "C:\\Program Files\\cyberhex\\com\\main_com.txt"
|
||||
#define ANSWER_COM "answer_com.txt"
|
||||
#define ANSWER_COM_PATH "C:\\Program Files\\cyberhex\\com\\answer_com.txt"
|
||||
|
||||
#define SECURE_COM "secure_com.txt"
|
||||
#define SECURE_COM_PATH "C:\\Program Files\\cyberhex\\secure\\com\\secure_com.txt"
|
||||
|
||||
Binary file not shown.
@@ -1,3 +1,2 @@
|
||||
Quellen werden auf Modulabhängigkeiten überprüft...
|
||||
update.cpp
|
||||
client_backend.vcxproj -> C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\client_backend.exe
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user