updating installer

i updated all installers to use tasks instead of services, made the uninstaller to work, and overworked the whole installing process
This commit is contained in:
jakani24
2024-02-18 15:34:20 +01:00
parent 0700eeb257
commit 48884fddb3
98 changed files with 1450 additions and 175 deletions

View File

@@ -0,0 +1,87 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_installer\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{AAE7A550-D2C0-45AC-8C26-ED57DF20BFC3}|ma_installer.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_installer\\ma_installer.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{AAE7A550-D2C0-45AC-8C26-ED57DF20BFC3}|ma_installer.vcxproj|solutionrelative:ma_installer.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{
"AbsoluteMoniker": "D:0:0:{AAE7A550-D2C0-45AC-8C26-ED57DF20BFC3}|ma_installer.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_installer\\well_known.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{AAE7A550-D2C0-45AC-8C26-ED57DF20BFC3}|ma_installer.vcxproj|solutionrelative:well_known.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{
"AbsoluteMoniker": "D:0:0:{AAE7A550-D2C0-45AC-8C26-ED57DF20BFC3}|ma_installer.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_installer\\download.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{AAE7A550-D2C0-45AC-8C26-ED57DF20BFC3}|ma_installer.vcxproj|solutionrelative:download.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{
"AbsoluteMoniker": "D:0:0:{AAE7A550-D2C0-45AC-8C26-ED57DF20BFC3}|ma_installer.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_installer\\download.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{AAE7A550-D2C0-45AC-8C26-ED57DF20BFC3}|ma_installer.vcxproj|solutionrelative:download.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 3,
"Children": [
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "well_known.h",
"DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_installer\\well_known.h",
"RelativeDocumentMoniker": "well_known.h",
"ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_installer\\well_known.h",
"RelativeToolTip": "well_known.h",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABoAAAAOAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|",
"WhenOpened": "2024-02-17T10:06:35.859Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 2,
"Title": "download.cpp",
"DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_installer\\download.cpp",
"RelativeDocumentMoniker": "download.cpp",
"ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_installer\\download.cpp",
"RelativeToolTip": "download.cpp",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAwAAAABAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
"WhenOpened": "2023-12-22T19:47:31.583Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 3,
"Title": "download.h",
"DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_installer\\download.h",
"RelativeDocumentMoniker": "download.h",
"ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_installer\\download.h",
"RelativeToolTip": "download.h",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAQAAABIAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|",
"WhenOpened": "2023-12-22T19:47:23.597Z"
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "ma_installer.cpp",
"DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_installer\\ma_installer.cpp",
"RelativeDocumentMoniker": "ma_installer.cpp",
"ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_installer\\ma_installer.cpp",
"RelativeToolTip": "ma_installer.cpp",
"ViewState": "AQIAACwAAAAAAAAAAAAuwDwAAAAyAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
"WhenOpened": "2023-12-22T18:52:51.74Z",
"EditorCaption": ""
}
]
}
]
}
]
}

View File

@@ -0,0 +1,21 @@
#cyberhex installer downloader
@echo off
echo "Downloading Cyberhex installer"
curl -O -L https://github.com/jakani24/cyberhex_bin_distro/raw/main/ma_installer.exe
echo "Downloading dll files"
curl -O -L https://github.com/jakani24/cyberhex_bin_distro/raw/main/libcrypto-3-x64.dll
curl -O -L https://github.com/jakani24/cyberhex_bin_distro/raw/main/libcurl.dll
curl -O -L https://github.com/jakani24/cyberhex_bin_distro/raw/main/zlib1.dll
curl -O -L https://github.com/jakani24/cyberhex_bin_distro/raw/main/client_frontend.exe
curl -O -L https://github.com/jakani24/cyberhex_bin_distro/raw/main/client_backend.exe
curl -O -L https://github.com/jakani24/cyberhex_bin_distro/raw/main/ma_uninstaller.exe
curl -O -L https://github.com/jakani24/cyberhex_bin_distro/raw/main/libcurl-d.dll
curl -O -L https://github.com/jakani24/cyberhex_bin_distro/raw/main/msvcp140.dll
curl -O -L https://github.com/jakani24/cyberhex_bin_distro/raw/main/vcruntime140.dll
curl -O -L https://github.com/jakani24/cyberhex_bin_distro/raw/main/vcruntime140_1d.dll
curl -O -L https://github.com/jakani24/cyberhex_bin_distro/raw/main/msvcp140d.dll
curl -O -L https://github.com/jakani24/cyberhex_bin_distro/raw/main/vcruntime140d.dll
curl -O -L https://github.com/jakani24/cyberhex_bin_distro/raw/main/ucrtbased.dll
curl -O -L https://github.com/jakani24/cyberhex_bin_distro/raw/main/zlibd1.dll
echo "Download finished, starting installer"
start ma_installer.exe

View File

@@ -19,6 +19,243 @@ Tasks to do:
- create folder for communication
*/
//create task thx chatgpt ;)#define _WIN32_DCOM
#include <windows.h>
#include <iostream>
#include <stdio.h>
#include <comdef.h>
#include <taskschd.h>
#pragma comment(lib, "taskschd.lib")
#pragma comment(lib, "comsupp.lib")
using namespace std;
int CreateTask()
{
HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
if (FAILED(hr))
{
cout << "CoInitializeEx failed: " << hex << hr << endl;
return 1;
}
hr = CoInitializeSecurity(
NULL,
-1,
NULL,
NULL,
RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
RPC_C_IMP_LEVEL_IMPERSONATE,
NULL,
0,
NULL);
if (FAILED(hr))
{
cout << "CoInitializeSecurity failed: " << hex << hr << endl;
CoUninitialize();
return 1;
}
LPCWSTR wszTaskName = L"CyberhexBackgroundTask";
wstring wstrExecutablePath = L"c:\\program files\\cyberhex\\secure\\app\\cyberhex.exe";
ITaskService* pService = NULL;
hr = CoCreateInstance(CLSID_TaskScheduler,
NULL,
CLSCTX_INPROC_SERVER,
IID_ITaskService,
(void**)&pService);
if (FAILED(hr))
{
cout << "Failed to create an instance of ITaskService: " << hex << hr << endl;
CoUninitialize();
return 1;
}
hr = pService->Connect(_variant_t(), _variant_t(),
_variant_t(), _variant_t());
if (FAILED(hr))
{
cout << "ITaskService::Connect failed: " << hex << hr << endl;
pService->Release();
CoUninitialize();
return 1;
}
ITaskFolder* pRootFolder = NULL;
hr = pService->GetFolder(_bstr_t(L"\\"), &pRootFolder);
if (FAILED(hr))
{
cout << "Cannot get Root Folder pointer: " << hex << hr << endl;
pService->Release();
CoUninitialize();
return 1;
}
pRootFolder->DeleteTask(_bstr_t(wszTaskName), 0);
ITaskDefinition* pTask = NULL;
hr = pService->NewTask(0, &pTask);
pService->Release();
if (FAILED(hr))
{
cout << "Failed to create a task definition: " << hex << hr << endl;
pRootFolder->Release();
CoUninitialize();
return 1;
}
IPrincipal* pPrincipal = NULL;
hr = pTask->get_Principal(&pPrincipal);
if (FAILED(hr))
{
cout << "Cannot get principal pointer: " << hex << hr << endl;
pRootFolder->Release();
pTask->Release();
CoUninitialize();
return 1;
}
hr = pPrincipal->put_RunLevel(TASK_RUNLEVEL_HIGHEST);
pPrincipal->Release();
if (FAILED(hr))
{
cout << "Cannot set highest privilege level: " << hex << hr << endl;
pRootFolder->Release();
pTask->Release();
CoUninitialize();
return 1;
}
ITaskSettings* pSettings = NULL;
hr = pTask->get_Settings(&pSettings);
if (FAILED(hr))
{
cout << "Cannot get settings pointer: " << hex << hr << endl;
pRootFolder->Release();
pTask->Release();
CoUninitialize();
return 1;
}
hr = pSettings->put_DisallowStartIfOnBatteries(VARIANT_FALSE); // Set to allow start on batteries
pSettings->Release();
if (FAILED(hr))
{
cout << "Cannot set start on batteries: " << hex << hr << endl;
pRootFolder->Release();
pTask->Release();
CoUninitialize();
return 1;
}
ITriggerCollection* pTriggerCollection = NULL;
hr = pTask->get_Triggers(&pTriggerCollection);
if (FAILED(hr))
{
cout << "Cannot get trigger collection: " << hex << hr << endl;
pRootFolder->Release();
pTask->Release();
CoUninitialize();
return 1;
}
ITrigger* pTrigger = NULL;
hr = pTriggerCollection->Create(TASK_TRIGGER_BOOT, &pTrigger);
pTriggerCollection->Release();
if (FAILED(hr))
{
cout << "Cannot create the trigger: " << hex << hr << endl;
pRootFolder->Release();
pTask->Release();
CoUninitialize();
return 1;
}
IActionCollection* pActionCollection = NULL;
hr = pTask->get_Actions(&pActionCollection);
if (FAILED(hr))
{
cout << "Cannot get Task collection pointer: " << hex << hr << endl;
pRootFolder->Release();
pTask->Release();
CoUninitialize();
return 1;
}
IAction* pAction = NULL;
hr = pActionCollection->Create(TASK_ACTION_EXEC, &pAction);
pActionCollection->Release();
if (FAILED(hr))
{
cout << "Cannot create the action: " << hex << hr << endl;
pRootFolder->Release();
pTask->Release();
CoUninitialize();
return 1;
}
IExecAction* pExecAction = NULL;
hr = pAction->QueryInterface(
IID_IExecAction, (void**)&pExecAction);
pAction->Release();
if (FAILED(hr))
{
cout << "QueryInterface call failed for IExecAction: " << hex << hr << endl;
pRootFolder->Release();
pTask->Release();
CoUninitialize();
return 1;
}
hr = pExecAction->put_Path(_bstr_t(wstrExecutablePath.c_str()));
pExecAction->Release();
if (FAILED(hr))
{
cout << "Cannot set path of executable: " << hex << hr << endl;
pRootFolder->Release();
pTask->Release();
CoUninitialize();
return 1;
}
IRegisteredTask* pRegisteredTask = NULL;
VARIANT varPassword;
varPassword.vt = VT_EMPTY;
hr = pRootFolder->RegisterTaskDefinition(
_bstr_t(wszTaskName),
pTask,
TASK_CREATE_OR_UPDATE,
_variant_t(L"SYSTEM"),
varPassword,
TASK_LOGON_SERVICE_ACCOUNT,
_variant_t(L""),
&pRegisteredTask);
if (FAILED(hr))
{
cout << "Error saving the Task : " << hex << hr << endl;
pRootFolder->Release();
pTask->Release();
CoUninitialize();
return 1;
}
cout << "Success! Task successfully registered." << endl;
pRootFolder->Release();
pTask->Release();
pRegisteredTask->Release();
CoUninitialize();
return 0;
}
//check if programm is run as admin
bool is_admin() {
BOOL fIsRunAsAdmin = FALSE;
@@ -205,11 +442,11 @@ int check_cert(const char* cert, const char* secrets_path) {
return 1;
}
else {
char* secrets = new char[300];
char* secrets = new char[505];
while (!feof(fp)) {
fscanf_s(fp, "%s", secrets, 295); // get the secret
fscanf_s(fp, "%s", secrets, 500); // get the secret
if (strcmp("cert", secrets) == 0) {
fscanf_s(fp, "%s", secrets, 295); // get the secret
fscanf_s(fp, "%s", secrets, 500); // get the secret
if (strcmp(cert, secrets) == 0) {
delete[] secrets;
return 0;
@@ -227,17 +464,20 @@ char* get_apikey(const char* secrets_path) {
return 0;
}
else {
char* secrets = new char[300];
char* secrets = new char[505];
while (!feof(fp)) {
fscanf_s(fp, "%s", secrets, 295); // get the secret
fscanf_s(fp, "%s", secrets, 500); // get the secret
if (strcmp("apikey", secrets) == 0) {
fscanf_s(fp, "%s", secrets, 295); // get the secret
fscanf_s(fp, "%s", secrets, 500); // get the secret
fclose(fp);
return secrets;
}
}
fclose(fp);
delete[] secrets;
return 0;
}
}
char* get_machineid(const char* secrets_path) {
FILE* fp;
@@ -250,12 +490,15 @@ char* get_machineid(const char* secrets_path) {
fscanf_s(fp, "%s", secrets, 295); // get the secret
if (strcmp("machineid", secrets) == 0) {
fscanf_s(fp, "%s", secrets, 295); // get the secret
fclose(fp);
return secrets;
}
}
fclose(fp);
delete[] secrets;
return 0;
}
fclose(fp);
}
char* get_server(const char* secrets_path) {
FILE* fp;
@@ -268,12 +511,130 @@ char* get_server(const char* secrets_path) {
fscanf_s(fp, "%s", secrets, 295); // get the secret
if (strcmp("server", secrets) == 0) {
fscanf_s(fp, "%s", secrets, 295); // get the secret
fclose(fp);
return secrets;
}
}
fclose(fp);
delete[] secrets;
return 0;
}
fclose(fp);
}
int update_db(const char* folder_path) {
//download the databases from the server
for (char firstChar = '0'; firstChar <= 'f'; ++firstChar) {
for (char secondChar = '0'; secondChar <= 'f'; ++secondChar) {
// Ensure that the characters are valid hexadecimal digits
if (!std::isxdigit(firstChar) || !std::isxdigit(secondChar) or std::isupper(firstChar) or std::isupper(secondChar)) {
continue;
}
// Create the filename based on the naming convention
char file_name[]= { firstChar, secondChar ,'.','j','d','b','f','\0' };
//create the strings to download the files
char* url = new char[300];
char* output_path = new char[300];
strcpy_s(url, 295, get_server("setup.txt"));
strcat_s(url, 295, "/database_srv/");
strcat_s(url, 295, file_name);
strcpy_s(output_path, 295, folder_path);
strcat_s(output_path, 295, "\\");
strcat_s(output_path, 295, file_name);
printf("%s\n", url);
int res = download_file_from_srv(url, output_path);
if (res != 0) {
return 10;
}
delete[] url;
delete[] output_path;
}
}
return 0;
}
int update_settings(const char* settings_type) {
//create the strings to download the files
char* url = new char[1000];
strcpy_s(url, 1000, get_server("setup.txt"));
strcat_s(url, 1000, "/api/php/settings/get_settings.php?");//need to add machine_id and apikey
strcat_s(url, 1000, settings_type);
strcat_s(url, 1000, "&machine_id=");
strcat_s(url, 1000, get_machineid(SECRETS));
strcat_s(url, 1000, "&apikey=");
strcat_s(url, 1000, get_apikey(SECRETS));
int res = 1;
if (strcmp(settings_type, "settings") == 0)
res = download_file_from_srv(url, SETTINGS_DB);
else if (strcmp(settings_type, "rtp_included") == 0)
res = download_file_from_srv(url, INCLUDED_FOLDERS);
else if (strcmp(settings_type, "rtp_excluded") == 0)
res = download_file_from_srv(url, EXCLUDED_FOLDERS);
else if (strcmp(settings_type, "sched") == 0)
res = download_file_from_srv(url, SCHED_PATH);
//int res = 0;
if (res != 0) {
return 1;
}
delete[] url;
return 0;
}
int action_update_settings() {
//update the settings
int err = 0;
if (update_settings("settings") != 0) {
err = 9;
}
//update the included folders
if (update_settings("rtp_included") != 0) {
err = 9;
}
//update the excluded folders
if (update_settings("rtp_excluded") != 0) {
err = 9;
}
//update the schedule
if (update_settings("sched") != 0) {
err = 9;
}
return err;
}
int action_update_db() {
//update the databases
return update_db(DB_DIR);
}
int copy(const char* source_path, const char* destination_path) {
FILE* source_file, * destination_file;
char buffer[4096]; // Buffer to store data read from source file
// Open source file for reading
if (fopen_s(&source_file, source_path, "rb") != 0) {
return 1;
}
// Open destination file for writing
if (fopen_s(&destination_file, destination_path, "wb") != 0) {
fclose(source_file);
return 1;
}
// Copy contents from source to destination
size_t bytes_read;
while ((bytes_read = fread(buffer, 1, sizeof(buffer), source_file)) > 0) {
fwrite(buffer, 1, bytes_read, destination_file);
}
// Close files
fclose(source_file);
fclose(destination_file);
return 0;
}
int main()
{
@@ -283,7 +644,7 @@ int main()
printf("We are not administrator, requesting UAC\n");
if (!run_as_admin()) {
printf("We did not get administrative rights. Please restart the installer!\n");
MessageBox(NULL, L"Please start the installer with amdin privileges!", L"Error", MB_OK);
MessageBox(NULL, L"Please start the installer with admin privileges!", L"Error", MB_OK);
exit(1);
}
else {
@@ -332,92 +693,98 @@ int main()
FILE* fp;
char*apikey=get_apikey("secrets.txt");
char*machineid=get_machineid("secrets.txt");
char* server_url = get_server("setup.txt");
char*server_url = get_server("setup.txt");
printf("%s\n", server_url);
//copy secrets.txt into the secrets folder
if (rename("secrets.txt", SECRETS)!=0) {
error = 8;
}
//download all the other files
//download the settings:
if (error == 0) {
printf("Downloading settings from server\n");
error = action_update_settings();
}
if (error == 0) {
printf("Downloading databases from server\n");
error = action_update_db();
}
if (error == 0) {
printf("Downloading files from server\n");
printf("Downloading cyberhex.exe\n");
error=download_file_from_srv("https://cyberhex.org/download/cyberhex.exe", "C:\\Program Files\\cyberhex\\secure\\app\\cyberhex.exe");
printf("Moving files into secure directorys\n");
printf("Movin cyberhex.exe\n");
//!!need to change: download in advance and then move to the correct folder
//error=download_file_from_srv("https://github.com/jakani24/cyberhex_bin_distro/raw/main/client_backend.exe", "C:\\Program Files\\cyberhex\\secure\\app\\cyberhex.exe");
if(rename("client_backend.exe", "C:\\Program Files\\cyberhex\\secure\\app\\cyberhex.exe")!=0)
error = 7;
if (error == 0) {
printf("Downloading libcrypto-3-x64.dll\n");
error = download_file_from_srv("https://cyberhex.org/download/libcrypto-3-x64.dll", "C:\\Program Files\\cyberhex\\secure\\app\\libcrypto-3-x64.dll");
printf("Moving libcrypto-3-x64.dll\n");
//error = download_file_from_srv("https://github.com/jakani24/cyberhex_bin_distro/raw/main/libcrypto-3-x64.dll", "C:\\Program Files\\cyberhex\\secure\\app\\libcrypto-3-x64.dll");
if(rename("libcrypto-3-x64.dll", "C:\\Program Files\\cyberhex\\secure\\app\\libcrypto-3-x64.dll")!=0)
error = 7;
}if (error == 0) {
printf("Downloading libcurl.dll\n");
error = download_file_from_srv("https://cyberhex.org/download/libcurl.dll", "C:\\Program Files\\cyberhex\\secure\\app\\libcurl.dll");
printf("Moving libcurl.dll\n");
//error = download_file_from_srv("https://github.com/jakani24/cyberhex_bin_distro/raw/main/libcurl.dll", "C:\\Program Files\\cyberhex\\secure\\app\\libcurl.dll");
if(rename("libcurl.dll", "C:\\Program Files\\cyberhex\\secure\\app\\libcurl.dll")!=0)
error = 7;
}if (error == 0) {
printf("Downloading zlib1.dll\n");
error = download_file_from_srv("https://cyberhex.org/download/zlib1.dll", "C:\\Program Files\\cyberhex\\secure\\app\\zlib1.dll");
printf("Moving zlib1.dll\n");
if(rename("zlib1.dll", "C:\\Program Files\\cyberhex\\secure\\app\\zlib1.dll")!=0)
error = 7;
//error = download_file_from_srv("https://github.com/jakani24/cyberhex_bin_distro/raw/main/zlib1.dll", "C:\\Program Files\\cyberhex\\secure\\app\\zlib1.dll");
}if (error == 0) {
printf("Downloading cyberhex_desktop.dll\n");
error = download_file_from_srv("https://cyberhex.org/download/cyberhex_desktop.exe", "C:\\Program Files\\cyberhex\\app\\cyberhex_desktop.exe");
printf("Moving cyberhex_desktop.exe\n");
if(rename("client_frontend.exe", "C:\\Program Files\\cyberhex\\app\\cyberhex_desktop.exe")!=0)
error = 7;
//error = download_file_from_srv("https://github.com/jakani24/cyberhex_bin_distro/raw/main/client_frontend.exe", "C:\\Program Files\\cyberhex\\app\\cyberhex_desktop.exe");
}if (error == 0) {
printf("Moving msvcp140.dll\n");
//error = download_file_from_srv("https://github.com/jakani24/cyberhex_bin_distro/raw/main/libcurl.dll", "C:\\Program Files\\cyberhex\\secure\\app\\libcurl.dll");
if (copy("msvcp140.dll", "C:\\Program Files\\cyberhex\\secure\\app\\msvcp140.dll") != 0)
error = 7;
if (copy("msvcp140.dll", "C:\\Program Files\\cyberhex\\app\\msvcp140.dll") != 0)
error = 7;
}if (error == 0) {
printf("Moving msvcp140d.dll\n");
//error = download_file_from_srv("https://github.com/jakani24/cyberhex_bin_distro/raw/main/libcurl.dll", "C:\\Program Files\\cyberhex\\secure\\app\\libcurl.dll");
if (copy("msvcp140d.dll", "C:\\Program Files\\cyberhex\\secure\\app\\msvcp140d.dll") != 0)
error = 7;
if (copy("msvcp140d.dll", "C:\\Program Files\\cyberhex\\app\\msvcp140d.dll") != 0)
error = 7;
}if (error == 0) {
printf("Moving vcruntime140.dll\n");
if (copy("vcruntime140.dll", "C:\\Program Files\\cyberhex\\secure\\app\\vcruntime140.dll") != 0)
error = 7;
if (copy("vcruntime140.dll", "C:\\Program Files\\cyberhex\\app\\vcruntime140.dll") != 0)
error = 7;
}if (error == 0) {
printf("Moving vcruntime140d.dll\n");
if (copy("vcruntime140d.dll", "C:\\Program Files\\cyberhex\\secure\\app\\vcruntime140d.dll") != 0)
error = 7;
if (copy("vcruntime140d.dll", "C:\\Program Files\\cyberhex\\app\\vcruntime140d.dll") != 0)
error = 7;
}if (error == 0) {
printf("Moving vcruntime140_1d.dll\n");
if (copy("vcruntime140_1d.dll", "C:\\Program Files\\cyberhex\\secure\\app\\vcruntime140_1d.dll") != 0)
error = 7;
if (copy("vcruntime140_1d.dll", "C:\\Program Files\\cyberhex\\app\\vcruntime140_1d.dll") != 0)
error = 7;
}if (error == 0) {
printf("Moving ucrtbased.dll\n");
if (copy("ucrtbased.dll", "C:\\Program Files\\cyberhex\\secure\\app\\ucrtbased.dll") != 0)
error = 7;
if (copy("ucrtbased.dll", "C:\\Program Files\\cyberhex\\app\\ucrtbased.dll") != 0)
error = 7;
}
}
//create background service
if (error == 0) {
printf("Creating background service\n");
SC_HANDLE hSCManager = OpenSCManager(nullptr, nullptr, SC_MANAGER_ALL_ACCESS);
if (!hSCManager) {
//std::cerr << "Failed to open service control manager. Error code: " << GetLastError() << std::endl;
error = 4;
}
LPCWSTR serviceName = L"cyberhex_background_service";
LPCWSTR servicePath = L"C:\\Program Files\\cyberhex\\secure\\app\\cyberhex.exe";
SC_HANDLE hService = CreateService(
hSCManager,
serviceName,
serviceName,
SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS,
SERVICE_AUTO_START,
SERVICE_ERROR_NORMAL,
servicePath,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr
);
if (!hService) {
//std::cerr << "Failed to create service. Error code: " << GetLastError() << std::endl;
CloseServiceHandle(hSCManager);
error = 5;
}
// Configure the service to run with LocalSystem account (administrator rights)
if (!ChangeServiceConfig(
hService,
SERVICE_NO_CHANGE,
SERVICE_NO_CHANGE,
SERVICE_NO_CHANGE,
nullptr,
nullptr,
nullptr,
nullptr,
L"LocalSystem",
nullptr,
nullptr
)) {
//std::cerr << "Failed to configure service. Error code: " << GetLastError() << std::endl
error = 6;
}
else {
//std::cout << "Service created and configured successfully." << std::endl;
//no error
}
CloseServiceHandle(hService);
CloseServiceHandle(hSCManager);
HRESULT hr = CreateTask();
if (FAILED(hr))
{
std::cerr << "Task creation failed!" << std::endl;
error=5;
}
}
switch (error) {
@@ -451,14 +818,23 @@ int main()
MessageBox(NULL, L"Failed to configure service", L"Error", MB_OK);
break;
case 7:
printf("Failed to download file\n");
MessageBox(NULL, L"Failed to download file", L"Error", MB_OK);
printf("Failed to move file\n");
MessageBox(NULL, L"Failed to move file", L"Error", MB_OK);
break;
case 8:
printf("Failed to open secrets.txt\n");
MessageBox(NULL, L"Failed to open secrets.txt", L"Error", MB_OK);
printf("Failed to move secrets.txt\n");
MessageBox(NULL, L"Failed to move secrets.txt", L"Error", MB_OK);
break;
case 9:
printf("Failed to download settings\n");
MessageBox(NULL, L"Failed to download settings", L"Error", MB_OK);
break;
case 10:
printf("Failed to download database file\n");
MessageBox(NULL, L"Failed to download database file", L"Error", MB_OK);
break;
default:
break;
}
system("pause");
}

View File

@@ -132,6 +132,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="download.h" />
<ClInclude Include="well_known.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@@ -26,5 +26,8 @@
<ClInclude Include="download.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="well_known.h">
<Filter>Headerdateien</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<ProjectOutputs>
<ProjectOutput>
<FullPath>C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\ma_installer\x64\Debug\ma_installer.exe</FullPath>
</ProjectOutput>
</ProjectOutputs>
<ContentFiles />
<SatelliteDlls />
<NonRecipeFileRefs />
</Project>

View File

@@ -0,0 +1,3 @@
 ma_installer.cpp
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\ma_installer\ma_installer.cpp(693,15): warning C4101: "fp": Unreferenzierte lokale Variable
ma_installer.vcxproj -> C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\ma_installer\x64\Debug\ma_installer.exe

View File

@@ -0,0 +1,2 @@
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\ma_installer\download.cpp;C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\ma_installer\ma_installer\x64\Debug\download.obj
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\ma_installer\ma_installer.cpp;C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\ma_installer\ma_installer\x64\Debug\ma_installer.obj

View File

@@ -0,0 +1,2 @@
^C:\USERS\JANIS\DOCUMENTS\PROJEKTE_MIT_C\MA\MA\SRC\MA_INSTALLER\MA_INSTALLER\X64\DEBUG\DOWNLOAD.OBJ|C:\USERS\JANIS\DOCUMENTS\PROJEKTE_MIT_C\MA\MA\SRC\MA_INSTALLER\MA_INSTALLER\X64\DEBUG\MA_INSTALLER.OBJ
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\ma_installer\ma_installer\x64\Debug\ma_installer.ilk

View File

@@ -0,0 +1,2 @@
PlatformToolSet=v143:VCToolArchitecture=Native64Bit:VCToolsVersion=14.39.33519:TargetPlatformVersion=10.0.22621.0:VcpkgTriplet=x64-windows:
Debug|x64|C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\ma_installer\|

View File

@@ -0,0 +1,3 @@
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\ma_installer\x64\Debug\libcurl-d.dll
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\ma_installer\x64\Debug\zlibd1.dll
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\ma_installer\ma_installer\x64\Debug\ma_insta.BC7E6B48.Up2Date

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,3 @@
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\ma_installer\x64\Debug\libcurl-d.dll
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\ma_installer\x64\Debug\zlibd1.dll