adding add_client to server
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.
@@ -27,7 +27,6 @@ int main() {
|
||||
}
|
||||
load_settings();
|
||||
initialize(DB_DIR); //load the hash databases into memory
|
||||
//download_file_from_srv("http://192.168.27.13/api/php/settings/get_settings.php?settings", "c:\\programdata\\jakach\\out12.txt");
|
||||
|
||||
//start a second thread which will scan for new files
|
||||
if (get_setting("rtp_folder_scan:status") == 1) {
|
||||
|
||||
@@ -148,6 +148,7 @@
|
||||
<ClCompile Include="permissions.cpp" />
|
||||
<ClCompile Include="queue _ctrl.cpp" />
|
||||
<ClCompile Include="scan.cpp" />
|
||||
<ClCompile Include="security.cpp" />
|
||||
<ClCompile Include="settings.cpp" />
|
||||
<ClCompile Include="thread_ctrl.cpp" />
|
||||
<ClCompile Include="update.cpp" />
|
||||
@@ -164,6 +165,7 @@
|
||||
<ClInclude Include="queue_ctrl.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="scan.h" />
|
||||
<ClInclude Include="security.h" />
|
||||
<ClInclude Include="settings.h" />
|
||||
<ClInclude Include="thread_ctrl.h" />
|
||||
<ClInclude Include="update.h" />
|
||||
|
||||
@@ -63,6 +63,9 @@
|
||||
<ClCompile Include="update.cpp">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="security.cpp">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="md5hash.h">
|
||||
@@ -110,6 +113,9 @@
|
||||
<ClInclude Include="update.h">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="security.h">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="client_backend.rc">
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#ifndef CONNECT_CPP
|
||||
#define CONNECT_CPP
|
||||
#include "connect.h"
|
||||
#include "well_known.h"
|
||||
#include "security.h"
|
||||
|
||||
static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp)
|
||||
{
|
||||
@@ -43,11 +45,14 @@ size_t write_callback(void* contents, size_t size, size_t nmemb, void* userp) {
|
||||
|
||||
int download_file_from_srv(const char* url, const char* output_file_path) {
|
||||
//use curl to download a file from a server
|
||||
|
||||
char*temp_path = new char[515];
|
||||
char* buf = new char[55];
|
||||
strcpy_s(temp_path,495, output_file_path);
|
||||
strcat_s(temp_path,505, ".temp");
|
||||
CURL* curl;
|
||||
CURLcode res;
|
||||
FILE* output_file;
|
||||
char*buf=new char[55];
|
||||
|
||||
curl = curl_easy_init();
|
||||
if (!curl) {
|
||||
return 1;
|
||||
@@ -57,7 +62,7 @@ int download_file_from_srv(const char* url, const char* output_file_path) {
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||
|
||||
// Create a file to write the downloaded data
|
||||
output_file = fopen(output_file_path, "wb");
|
||||
output_file = fopen(temp_path, "wb");
|
||||
if (!output_file) {
|
||||
curl_easy_cleanup(curl);
|
||||
return 2;
|
||||
@@ -75,7 +80,7 @@ int download_file_from_srv(const char* url, const char* output_file_path) {
|
||||
// Cleanup and close the file
|
||||
curl_easy_cleanup(curl);
|
||||
fclose(output_file);
|
||||
if ((output_file = fopen(output_file_path, "r")) == 0) {
|
||||
if ((output_file = fopen(temp_path, "r")) == 0) {
|
||||
return 4;
|
||||
}
|
||||
else {
|
||||
@@ -84,9 +89,19 @@ int download_file_from_srv(const char* url, const char* output_file_path) {
|
||||
fclose(output_file);
|
||||
return 5;
|
||||
}
|
||||
else if(check_cert(buf, SECRETS)!=0){
|
||||
if (rename(temp_path, output_file_path)) {
|
||||
fclose(output_file);
|
||||
return 6;
|
||||
}
|
||||
}else {
|
||||
fclose(output_file);
|
||||
return 7;
|
||||
}
|
||||
fclose(output_file);
|
||||
}
|
||||
delete[] buf;
|
||||
delete[] temp_path;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
60
src/client_backend/security.cpp
Normal file
60
src/client_backend/security.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#include "security.h"
|
||||
|
||||
int check_cert(const char*cert,const char*secrets_path) {
|
||||
FILE* fp;
|
||||
if (fopen_s(&fp, secrets_path, "r") != 0) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
char*secrets = new char[300];
|
||||
while (!feof(fp)) {
|
||||
fscanf_s(fp, "%s", secrets, 295); // get the secret
|
||||
if (strcmp("cert", secrets) == 0) {
|
||||
fscanf_s(fp, "%s", secrets, 295); // get the secret
|
||||
if (strcmp(cert, secrets) == 0) {
|
||||
delete[] secrets;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
delete[] secrets;
|
||||
return 2;
|
||||
}
|
||||
|
||||
}
|
||||
char* get_apikey(const char* secrets_path) {
|
||||
FILE* fp;
|
||||
if (fopen_s(&fp, secrets_path, "r") != 0) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
char*secrets = new char[300];
|
||||
while (!feof(fp)) {
|
||||
fscanf_s(fp, "%s", secrets, 295); // get the secret
|
||||
if (strcmp("apikey", secrets) == 0) {
|
||||
fscanf_s(fp, "%s", secrets, 295); // get the secret
|
||||
return secrets;
|
||||
}
|
||||
}
|
||||
delete[] secrets;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
char* get_machineid(const char*secrets_path){
|
||||
FILE* fp;
|
||||
if (fopen_s(&fp, secrets_path, "r") != 0) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
char* secrets = new char[300];
|
||||
while (!feof(fp)) {
|
||||
fscanf_s(fp, "%s", secrets, 295); // get the secret
|
||||
if (strcmp("machineid", secrets) == 0) {
|
||||
fscanf_s(fp, "%s", secrets, 295); // get the secret
|
||||
return secrets;
|
||||
}
|
||||
}
|
||||
delete[] secrets;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
10
src/client_backend/security.h
Normal file
10
src/client_backend/security.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#ifndef SECURITY_H
|
||||
#define SECURITY_H
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
int check_cert(const char* cert,const char* secrets_path);
|
||||
char*get_apikey(const char*secrets_path);
|
||||
char* get_machineid(const char*secrets_path);
|
||||
#endif // !SECURITY_H
|
||||
@@ -46,9 +46,9 @@ int update_settings() {
|
||||
get_setting("server:server_url", url);
|
||||
strcat_s(url, 500, "/api/php/settings/get_settings.php?settings");
|
||||
int res = download_file_from_srv(url, SETTINGS_DB);
|
||||
//res = 0;
|
||||
//int res = 0;
|
||||
if (res != 0) {
|
||||
log(LOGLEVEL::ERR, "[update_db()]: Error downloading settings database file from server", url, " ERROR:",res);
|
||||
log(LOGLEVEL::ERR, "[update_settings()]: Error downloading settings database file from server", url, " ERROR:",res);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
|
||||
#define QUARANTINE_PATH "C:\\Program Files\\cyberhex\\secure\\quarantine"
|
||||
|
||||
#define SECRETS "C:\\Program Files\\cyberhex\\secure\\settings\\secrets.txt"
|
||||
|
||||
#define PERIODIC_FOLDER_SCAN "C:\\Program Files\\cyberhex\\secure\\database\\folder\\periodic_folder_scan.txt"
|
||||
#define PERIODIC_FOLDER_SCAN_TEMP_DB "C:\\Program Files\\cyberhex\\secure\\database\\folder\\temp_db.txt"
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,4 +1,53 @@
|
||||
Quellen werden auf Modulabhängigkeiten überprüft...
|
||||
check_dir.cpp
|
||||
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\check_dir.cpp(361,7): warning C4101: "fp": Unreferenzierte lokale Variable
|
||||
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xstring(2749,53): warning C4244: "Argument": Konvertierung von "wchar_t" in "const _Elem", möglicher Datenverlust
|
||||
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xstring(2749,53): warning C4244: with
|
||||
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xstring(2749,53): warning C4244: [
|
||||
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xstring(2749,53): warning C4244: _Elem=char
|
||||
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xstring(2749,53): warning C4244: ]
|
||||
(Quelldatei „check_dir.cpp“ wird kompiliert)
|
||||
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xstring(2749,53):
|
||||
der Vorlageninstanziierungskontext (der älteste zuerst) ist
|
||||
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\check_dir.cpp(155,29):
|
||||
Siehe Verweis auf die gerade kompilierte Instanziierung "std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string<std::_String_iterator<std::_String_val<std::_Simple_types<_Elem>>>,0>(_Iter,_Iter,const _Alloc &)" der Funktions-Vorlage.
|
||||
with
|
||||
[
|
||||
_Elem=wchar_t,
|
||||
_Iter=std::_String_iterator<std::_String_val<std::_Simple_types<wchar_t>>>,
|
||||
_Alloc=std::allocator<char>
|
||||
]
|
||||
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\check_dir.cpp(155,29):
|
||||
Ersten Verweis auf "std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string" in "process_changes" anzeigen
|
||||
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xstring(2590,17):
|
||||
Siehe Verweis auf die gerade kompilierte Instanziierung "void std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Construct_from_iter<wchar_t*,wchar_t*,_Size_type>(_Iter,const _Sent,_Size)" der Funktions-Vorlage.
|
||||
with
|
||||
[
|
||||
_Size_type=unsigned __int64,
|
||||
_Iter=wchar_t *,
|
||||
_Sent=wchar_t *,
|
||||
_Size=unsigned __int64
|
||||
]
|
||||
|
||||
client_backend.cpp
|
||||
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\client_backend.cpp(73,24): warning C4244: "Argument": Konvertierung von "_Rep" in "DWORD", möglicher Datenverlust
|
||||
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\client_backend.cpp(73,24): warning C4244: with
|
||||
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\client_backend.cpp(73,24): warning C4244: [
|
||||
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\client_backend.cpp(73,24): warning C4244: _Rep=__int64
|
||||
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\client_backend.cpp(73,24): warning C4244: ]
|
||||
connect.cpp
|
||||
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\connect.cpp(103,65): warning C4267: "Argument": Konvertierung von "size_t" nach "int", Datenverlust möglich
|
||||
client_backend.vcxproj -> C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\client_backend.exe
|
||||
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\connect.cpp(118,65): warning C4267: "Argument": Konvertierung von "size_t" nach "int", Datenverlust möglich
|
||||
local_com.cpp
|
||||
local_schedule.cpp
|
||||
log.cpp
|
||||
md5hash.cpp
|
||||
scan.cpp
|
||||
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\scan.cpp(153,32): warning C4018: ">=": Konflikt zwischen "signed" und "unsigned"
|
||||
security.cpp
|
||||
settings.cpp
|
||||
thread_ctrl.cpp
|
||||
update.cpp
|
||||
virus_ctrl.cpp
|
||||
Code wird generiert...
|
||||
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\md5hash.cpp(36): warning C4715: "md5_file": Nicht alle Codepfade geben einen Wert zurück.
|
||||
LINK : fatal error LNK1168: "C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\client_backend.exe" kann nicht zum Schreiben geöffnet werden.
|
||||
|
||||
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