diff --git a/src/client_backend/.vs/client_backend/v17/.suo b/src/client_backend/.vs/client_backend/v17/.suo index fc99c62..15f18c8 100644 Binary files a/src/client_backend/.vs/client_backend/v17/.suo and b/src/client_backend/.vs/client_backend/v17/.suo differ diff --git a/src/client_backend/.vs/client_backend/v17/Browse.VC.db b/src/client_backend/.vs/client_backend/v17/Browse.VC.db index b368acb..8c378a3 100644 Binary files a/src/client_backend/.vs/client_backend/v17/Browse.VC.db and b/src/client_backend/.vs/client_backend/v17/Browse.VC.db differ diff --git a/src/client_backend/.vs/client_backend/v17/DocumentLayout.json b/src/client_backend/.vs/client_backend/v17/DocumentLayout.json index 3a4aa37..95fa152 100644 --- a/src/client_backend/.vs/client_backend/v17/DocumentLayout.json +++ b/src/client_backend/.vs/client_backend/v17/DocumentLayout.json @@ -2,6 +2,18 @@ "Version": 1, "WorkspaceRootPath": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\", "Documents": [ + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:log.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:connect.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:connect.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, { "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\virus_ctrl.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:virus_ctrl.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" @@ -11,33 +23,37 @@ "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:thread_ctrl.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, { - "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:settings.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" - }, - { - "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\update.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:update.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:log.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, { "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\client_backend.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:client_backend.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, { - "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:connect.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" - }, - { - "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_com.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:local_com.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\update.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:update.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, { "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:scan.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\check_dir.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:check_dir.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, { "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_schedule.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:local_schedule.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:settings.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_com.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:local_com.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, { "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\queue _ctrl.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:queue _ctrl.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" @@ -54,11 +70,62 @@ "DocumentGroups": [ { "DockedWidth": 200, - "SelectedChildIndex": 10, + "SelectedChildIndex": 2, "Children": [ { "$type": "Document", - "DocumentIndex": 6, + "DocumentIndex": 1, + "Title": "connect.h", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.h", + "RelativeDocumentMoniker": "connect.h", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.h", + "RelativeToolTip": "connect.h", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAAoAAAABAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", + "WhenOpened": "2024-03-09T12:32:01.859Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 9, + "Title": "check_dir.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\check_dir.cpp", + "RelativeDocumentMoniker": "check_dir.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\check_dir.cpp", + "RelativeToolTip": "check_dir.cpp", + "ViewState": "AQIAACIBAAAAAAAAAAAkwEwBAAAZAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-02-25T13:36:05.414Z" + }, + { + "$type": "Document", + "DocumentIndex": 0, + "Title": "log.h", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.h", + "RelativeDocumentMoniker": "log.h", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.h", + "RelativeToolTip": "log.h", + "ViewState": "AQIAAFEAAAAAAAAAAAAAAHEAAABCAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", + "WhenOpened": "2024-02-25T09:02:55.874Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 5, + "Title": "log.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.cpp", + "RelativeDocumentMoniker": "log.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.cpp", + "RelativeToolTip": "log.cpp", + "ViewState": "AQIAAAAAAAAAAAAAAAAAABkAAAAeAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-02-25T09:08:59.07Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 12, "Title": "local_com.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_com.cpp", "RelativeDocumentMoniker": "local_com.cpp", @@ -66,25 +133,23 @@ "RelativeToolTip": "local_com.cpp", "ViewState": "AQIAAAAAAAAAAAAAAAAAAAgAAAApAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-01-28T20:40:06.217Z", - "EditorCaption": "" + "WhenOpened": "2024-01-28T20:40:06.217Z" }, { "$type": "Document", - "DocumentIndex": 2, + "DocumentIndex": 11, "Title": "settings.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.cpp", "RelativeDocumentMoniker": "settings.cpp", "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.cpp", "RelativeToolTip": "settings.cpp", - "ViewState": "AQIAAC0AAAAAAAAAAAAAAD4AAAAFAAAA", + "ViewState": "AQIAAAYAAAAAAAAAAAAAABkAAAAUAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-01-28T20:40:06.264Z", - "EditorCaption": "" + "WhenOpened": "2024-01-28T20:40:06.264Z" }, { "$type": "Document", - "DocumentIndex": 1, + "DocumentIndex": 4, "Title": "thread_ctrl.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\thread_ctrl.cpp", "RelativeDocumentMoniker": "thread_ctrl.cpp", @@ -97,46 +162,46 @@ }, { "$type": "Document", - "DocumentIndex": 4, + "DocumentIndex": 6, "Title": "client_backend.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\client_backend.cpp", "RelativeDocumentMoniker": "client_backend.cpp", "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\client_backend.cpp", "RelativeToolTip": "client_backend.cpp", - "ViewState": "AQIAAAAAAAAAAAAAAAAAADEAAAAGAAAA", + "ViewState": "AQIAAAAAAAAAAAAAAAAAACwAAAAiAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", "WhenOpened": "2024-01-28T20:40:06.279Z", "EditorCaption": "" }, { "$type": "Document", - "DocumentIndex": 7, + "DocumentIndex": 8, "Title": "scan.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.cpp", "RelativeDocumentMoniker": "scan.cpp", "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.cpp", "RelativeToolTip": "scan.cpp", - "ViewState": "AQIAAC8AAAAAAAAAAAAkwLEAAAAAAAAA", + "ViewState": "AQIAABgAAAAAAAAAAAAAAA4AAAAVAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", "WhenOpened": "2024-01-28T20:40:06.248Z", "EditorCaption": "" }, { "$type": "Document", - "DocumentIndex": 3, + "DocumentIndex": 7, "Title": "update.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\update.cpp", "RelativeDocumentMoniker": "update.cpp", "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\update.cpp", "RelativeToolTip": "update.cpp", - "ViewState": "AQIAAAAAAAAAAAAAAAAAAEAAAAAvAAAA", + "ViewState": "AQIAABMAAAAAAAAAAAAkwEQAAABzAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", "WhenOpened": "2024-01-28T20:40:06.248Z", "EditorCaption": "" }, { "$type": "Document", - "DocumentIndex": 8, + "DocumentIndex": 10, "Title": "local_schedule.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_schedule.cpp", "RelativeDocumentMoniker": "local_schedule.cpp", @@ -144,12 +209,11 @@ "RelativeToolTip": "local_schedule.cpp", "ViewState": "AQIAAEgAAAAAAAAAAAAAAFoAAAAKAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-01-28T20:40:06.279Z", - "EditorCaption": "" + "WhenOpened": "2024-01-28T20:40:06.279Z" }, { "$type": "Document", - "DocumentIndex": 10, + "DocumentIndex": 14, "Title": "scan.h", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.h", "RelativeDocumentMoniker": "scan.h", @@ -157,12 +221,11 @@ "RelativeToolTip": "scan.h", "ViewState": "AQIAAAAAAAAAAAAAAAAAABEAAAADAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", - "WhenOpened": "2024-01-28T20:40:06.295Z", - "EditorCaption": "" + "WhenOpened": "2024-01-28T20:40:06.295Z" }, { "$type": "Document", - "DocumentIndex": 9, + "DocumentIndex": 13, "Title": "queue _ctrl.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\queue _ctrl.cpp", "RelativeDocumentMoniker": "queue _ctrl.cpp", @@ -170,31 +233,30 @@ "RelativeToolTip": "queue _ctrl.cpp", "ViewState": "AQIAAAAAAAAAAAAAAAAAACsAAAABAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-01-28T20:40:06.295Z", - "EditorCaption": "" + "WhenOpened": "2024-01-28T20:40:06.295Z" }, { "$type": "Document", - "DocumentIndex": 5, + "DocumentIndex": 2, "Title": "connect.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.cpp", "RelativeDocumentMoniker": "connect.cpp", "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.cpp", "RelativeToolTip": "connect.cpp", - "ViewState": "AQIAAAYAAAAAAAAAAAAAACwAAAAAAAAA", + "ViewState": "AQIAAG8AAAAAAAAAAAAAAIMAAAABAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", "WhenOpened": "2024-01-28T20:40:06.315Z", "EditorCaption": "" }, { "$type": "Document", - "DocumentIndex": 0, + "DocumentIndex": 3, "Title": "virus_ctrl.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\virus_ctrl.cpp", "RelativeDocumentMoniker": "virus_ctrl.cpp", "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\virus_ctrl.cpp", "RelativeToolTip": "virus_ctrl.cpp", - "ViewState": "AQIAAAAAAAAAAAAAAAAAABwAAAAxAAAA", + "ViewState": "AQIAADYAAAAAAAAAAAAAAGEAAAAvAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", "WhenOpened": "2024-02-18T12:49:41.861Z", "EditorCaption": "" diff --git a/src/client_backend/check_dir.cpp b/src/client_backend/check_dir.cpp index 47313ea..4662798 100644 --- a/src/client_backend/check_dir.cpp +++ b/src/client_backend/check_dir.cpp @@ -292,7 +292,7 @@ void monitor_directory(LPCSTR directory) { buffer, bufferSize, TRUE, - FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_SIZE, + FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_FILE_NAME, NULL, &overlapped, NULL) == 0) { @@ -331,7 +331,7 @@ void monitor_directory(LPCSTR directory) { buffer, bufferSize, TRUE, - FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_LAST_WRITE, + FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_FILE_NAME, NULL, &overlapped, NULL) == 0) { diff --git a/src/client_backend/client_backend.cpp b/src/client_backend/client_backend.cpp index 27f120f..bf94af7 100644 --- a/src/client_backend/client_backend.cpp +++ b/src/client_backend/client_backend.cpp @@ -19,127 +19,92 @@ #include "virus_ctrl.h" #include "update.h" int main() { + //log(LOGLEVEL::INFO, "[main()]:Starting main thread."); + //return 0; + + log(LOGLEVEL::INFO_NOSEND, "[main()]:Starting main thread."); int err = 0; - log(LOGLEVEL::INFO, "[main()]:Starting main thread."); printf("welcome to the jakach security tool main thread\n"); if (load_settings() == 0) {//load the settings from the settings file if (update_settings("settings")!=0) { //update the settings from the server - log(LOGLEVEL::ERR, "[main()]:Could not update settings (settings) from server."); + log(LOGLEVEL::ERR_NOSEND, "[main()]:Could not update settings (settings) from server."); } if (update_settings("rtp_included")!=0) { //update the settings from the server - log(LOGLEVEL::ERR, "[main()]:Could not update settings (rtp_included) from server."); + log(LOGLEVEL::ERR_NOSEND, "[main()]:Could not update settings (rtp_included) from server."); } if (update_settings("rtp_excluded")!=0) { //update the settings from the server - log(LOGLEVEL::ERR, "[main()]:Could not update settings (rtp_excluded) from server."); + log(LOGLEVEL::ERR_NOSEND, "[main()]:Could not update settings (rtp_excluded) from server."); } if (update_settings("sched")!=0) { //update the settings from the server - log(LOGLEVEL::ERR, "[main()]:Could not update settings (scheduled_tasks) from server."); + log(LOGLEVEL::ERR_NOSEND, "[main()]:Could not update settings (scheduled_tasks) from server."); } load_settings(); //load the updated settings from the settings file } else { - log(LOGLEVEL::ERR, "[main()]:Could not load settings from file."); - log(LOGLEVEL::PANIC, "[main()]:Panic, no settings file loaded, terminating process!"); + log(LOGLEVEL::ERR_NOSEND, "[main()]:Could not load settings from file."); + log(LOGLEVEL::PANIC_NOSEND, "[main()]:Panic, no settings file loaded, terminating process!"); exit(1); } - if ((err=initialize(DB_DIR)) != 0) { //load the hash databases into memory + + // Initialize hash databases + err = initialize(DB_DIR); + if (err != 0) { switch (err) { - case 1: - log(LOGLEVEL::ERR, "[main()]:Error opening database file in: ", DB_DIR); - break; - case 2: - log(LOGLEVEL::ERR, "[main()]:Error creating database file mapping in: ", DB_DIR); - break; - case 3: - log(LOGLEVEL::ERR, "[main()]:Error mapping database file in: ", DB_DIR); - break; - default: - log(LOGLEVEL::ERR, "[main()]:Unknown error while loading database file in: ", DB_DIR); - break; + case 1: + log(LOGLEVEL::ERR, "[main()]:Error opening database file in: ", DB_DIR); + break; + case 2: + log(LOGLEVEL::ERR, "[main()]:Error creating database file mapping in: ", DB_DIR); + break; + case 3: + log(LOGLEVEL::ERR, "[main()]:Error mapping database file in: ", DB_DIR); + break; + default: + log(LOGLEVEL::ERR, "[main()]:Unknown error while loading database file in: ", DB_DIR); + break; } } - //start a second thread which will scan for new files + + // Start a second thread for real-time protection 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(); + std::thread folder_scanner_thread(folder_scanner); + folder_scanner_thread.detach(); } - - //main thread: - /* watches for notifications on bus - * start threads (scans etc); only one at a time may run - * updates settings etc - * start scheduled tasks - */ + + // Main thread loop while (!app_stop()) { - //run all the tasks described above - //check for tasks in com - //check for scheduled tasks - //execute tasks auto start = std::chrono::high_resolution_clock::now(); - if ((err = check_for_com_tasks(MAIN_COM, MAIN_COM_PATH)) != 0) { //check for tasks from user interface and add them to the queue - switch (err) { - case 1: - //the log here is not needed, because default state is that this file does not exist - //log(LOGLEVEL::ERR, "[main()]:Error opening communication file in: ", MAIN_COM_PATH); - break; - } - } - if ((err = check_for_sched_tasks(SCHED, SCHED_PATH)) != 0) { //check for scheduled tasks and add them to the queue - switch (err) { - case 1: - log(LOGLEVEL::ERR, "[main()]:Error opening schedule file in: ", SCHED_PATH); - break; - } + + // Check for tasks from user interface + if (check_for_com_tasks(MAIN_COM, MAIN_COM_PATH) != 0) { + // Log message commented out as this error is expected when the file doesn't exist + // log(LOGLEVEL::ERR, "[main()]:Error opening communication file in: ", MAIN_COM_PATH); } + // Check for scheduled tasks + if (check_for_sched_tasks(SCHED, SCHED_PATH) != 0) { + log(LOGLEVEL::ERR, "[main()]:Error opening schedule file in: ", SCHED_PATH); + } + + // Execute tasks from the queue if (can_run_thread()) { int queue_size = get_queue_size(); for (int i = 0; i < queue_size; i++) { char* queue_entry = new char[300 * 2 + 5]; queue_entry[0] = '\0'; queue_pop(queue_entry); - //execute the function which starts the threads start_thread(queue_entry); delete[] queue_entry; } } - //to ensure that the loop takes at least 1 second else it will run too fast nd destroy you CPU :) + + // Sleep to ensure loop takes at least 1 second auto stop = std::chrono::high_resolution_clock::now(); auto duration = std::chrono::duration_cast(stop - start); if (duration.count() < 1000) Sleep(1000 - duration.count()); } - - - //ListFilesRecursive("C:\\", 0); - /*char md5Hash[2 * MD5_DIGEST_LENGTH + 1]; // +1 for null-terminator - printf("Hash of the executable: "); - md5_file("C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\x64\\Debug\\client_backend.exe", md5Hash); - printf("%s", md5Hash); - char a_[2000]; - printf("\nerror:%d\n",connect_to_srv("https://self-signed.badssl.com/", a_, 2000,1)); //error 60: self signed => option für self-signed ignorieren aktivieren (bool ignore_invalid=true) - printf("%s", a_); //error 6: not reachable - download_file_from_srv("https://jakach.duckdns.org/php/login/v3/login.php", "c:\\programdata\\jakach\\out12.txt"); - /* - const int numThreads = 12; - std::thread threads[numThreads]; - - for (int i = 0; i < numThreads; ++i) { - threads[i] = std::thread(ListFilesRecursive, "C:\\Users\\janis\\Documents\\ma_av_tests",i); - } - - // Join threads to wait for them to finish - for (int i = 0; i < numThreads; ++i) { - threads[i].join(); - } - - std::cout << "All threads have finished." << std::endl; - */ - - //printf("code:%d",scan_hash("C:\\Users\\janis\\Documents\\ma_av_tests\\OutputFile.txt", "1fddc13c02a79442c911a44b02ee0f58")); - - return 0; + return 0; } - diff --git a/src/client_backend/client_backend/x64/Debug/client_backend.ilk b/src/client_backend/client_backend/x64/Debug/client_backend.ilk index b70b84a..d0072bd 100644 Binary files a/src/client_backend/client_backend/x64/Debug/client_backend.ilk and b/src/client_backend/client_backend/x64/Debug/client_backend.ilk differ diff --git a/src/client_backend/client_backend/x64/Debug/client_backend.log b/src/client_backend/client_backend/x64/Debug/client_backend.log index 3b70d82..2463717 100644 --- a/src/client_backend/client_backend/x64/Debug/client_backend.log +++ b/src/client_backend/client_backend/x64/Debug/client_backend.log @@ -1,6 +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.39.33519\include\xutility(4537,18): warning C4244: "=": Konvertierung von "wchar_t" in "char", möglicher Datenverlust + (Quelldatei „check_dir.cpp“ wird kompiliert) + C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\xutility(4537,18): + 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,std::allocator>::basic_string>>,0>(_Iter,_Iter,const _Alloc &)" der Funktions-Vorlage. + with + [ + _Elem=wchar_t, + _Iter=std::_String_iterator>>, + _Alloc=std::allocator + ] + C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\check_dir.cpp(155,29): + Ersten Verweis auf "std::basic_string,std::allocator>::basic_string" in "process_changes" anzeigen + C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\xstring(2600,17): + Siehe Verweis auf die gerade kompilierte Instanziierung "void std::basic_string,std::allocator>::_Construct_from_iter(_Iter,const _Sent,_Size)" der Funktions-Vorlage. + with + [ + _Size_type=unsigned __int64, + _Iter=wchar_t *, + _Sent=wchar_t *, + _Size=unsigned __int64 + ] + C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\xstring(2756,18): + Siehe Verweis auf die gerade kompilierte Instanziierung "_OutIt *std::_Copy_n_unchecked4(_InIt,_SizeTy,_OutIt)" der Funktions-Vorlage. + with + [ + _OutIt=char *, + _Size=unsigned __int64, + _InIt=wchar_t *, + _SizeTy=unsigned __int64 + ] + + client_backend.cpp +C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\client_backend.cpp(106,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(106,24): warning C4244: with +C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\client_backend.cpp(106,24): warning C4244: [ +C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\client_backend.cpp(106,24): warning C4244: _Rep=__int64 +C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\client_backend.cpp(106,24): warning C4244: ] + local_schedule.cpp + log.cpp + md5hash.cpp + scan.cpp settings.cpp + thread_ctrl.cpp update.cpp virus_ctrl.cpp Code wird generiert... -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. +C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\md5hash.cpp(36,1): warning C4715: "md5_file": Nicht alle Codepfade geben einen Wert zurück. + client_backend.vcxproj -> C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\client_backend.exe diff --git a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.command.1.tlog b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.command.1.tlog index d25db11..696c8b0 100644 Binary files a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.command.1.tlog and b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.command.1.tlog differ diff --git a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.read.1.tlog b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.read.1.tlog index d70f8ee..9a90bde 100644 Binary files a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.read.1.tlog and b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.read.1.tlog differ diff --git a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.write.1.tlog b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.write.1.tlog index 6e6f430..bc52c1c 100644 Binary files a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.write.1.tlog and b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.write.1.tlog differ diff --git a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/client_backend.write.1u.tlog b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/client_backend.write.1u.tlog index e72bead..38529c9 100644 Binary files a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/client_backend.write.1u.tlog and b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/client_backend.write.1u.tlog differ diff --git a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/link.command.1.tlog b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/link.command.1.tlog index 46b134b..b5f3197 100644 Binary files a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/link.command.1.tlog and b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/link.command.1.tlog differ diff --git a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/link.read.1.tlog b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/link.read.1.tlog index 46b134b..d81366e 100644 Binary files a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/link.read.1.tlog and b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/link.read.1.tlog differ diff --git a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/link.write.1.tlog b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/link.write.1.tlog index 46b134b..1e38ebc 100644 Binary files a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/link.write.1.tlog and b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/link.write.1.tlog differ diff --git a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/unsuccessfulbuild b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/unsuccessfulbuild deleted file mode 100644 index e69de29..0000000 diff --git a/src/client_backend/client_backend/x64/Debug/vc143.idb b/src/client_backend/client_backend/x64/Debug/vc143.idb index eddfd09..ab1bd6e 100644 Binary files a/src/client_backend/client_backend/x64/Debug/vc143.idb and b/src/client_backend/client_backend/x64/Debug/vc143.idb differ diff --git a/src/client_backend/client_backend/x64/Debug/vc143.pdb b/src/client_backend/client_backend/x64/Debug/vc143.pdb index 4e0a57c..5e925d3 100644 Binary files a/src/client_backend/client_backend/x64/Debug/vc143.pdb and b/src/client_backend/client_backend/x64/Debug/vc143.pdb differ diff --git a/src/client_backend/connect.cpp b/src/client_backend/connect.cpp index 6280584..4ebac91 100644 --- a/src/client_backend/connect.cpp +++ b/src/client_backend/connect.cpp @@ -5,7 +5,29 @@ #include "well_known.h" #include "security.h" -static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp) + +int fast_send(const char * url,bool ignore_insecure) { + //send get rewuest to server, and cloe connection after maximum 1 second + CURL* curl; + CURLcode res; + curl = curl_easy_init(); + if (curl) { + curl_easy_setopt(curl, CURLOPT_URL, url); + if(ignore_insecure==true) + curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); + curl_easy_setopt(curl, CURLOPT_TIMEOUT, 1L); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + if (res == CURLE_OK) { + return 0; + } + else { + return res; + } + } + return 1; +} +static size_t write_callback_connect(void* contents, size_t size, size_t nmemb, void* userp) { ((std::string*)userp)->append((char*)contents, size * nmemb); return size * nmemb; @@ -19,7 +41,7 @@ int connect_to_srv(const char*url,char*out,int max_len, bool ignore_insecure) { curl = curl_easy_init(); if (curl) { curl_easy_setopt(curl, CURLOPT_URL, url); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback_connect); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer); if(ignore_insecure==true) curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); @@ -34,7 +56,7 @@ int connect_to_srv(const char*url,char*out,int max_len, bool ignore_insecure) { } return 2; } -size_t write_callback(void* contents, size_t size, size_t nmemb, void* userp) { +size_t write_callback_download(void* contents, size_t size, size_t nmemb, void* userp) { size_t totalSize = size * nmemb; FILE* file = (FILE*)userp; if (file) { @@ -69,7 +91,7 @@ int download_file_from_srv(const char* url, const char* output_file_path, bool i } // Set the write callback function - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback_download); curl_easy_setopt(curl, CURLOPT_WRITEDATA, output_file); if (ignore_insecure == true) curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); @@ -106,4 +128,40 @@ int download_file_from_srv(const char* url, const char* output_file_path, bool i delete[] temp_path; return 0; } + +char* url_encode(const char* input) { + // Allocate memory for the encoded string (worst case: every character needs encoding) + size_t input_len = strlen(input); + char* encoded = (char*)malloc(input_len * 3 + 1); // +1 for null terminator + if (!encoded) { + fprintf(stderr, "Memory allocation failed\n"); + exit(EXIT_FAILURE); + } + + // Define the characters that don't need encoding + const char* safe_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~"; + + // Initialize variables for input and output string indices + size_t i = 0; // index for input string + size_t j = 0; // index for output string + + // Loop through each character in the input string + while (input[i]) { + // Check if the character is a safe character + if (strchr(safe_chars, input[i]) != NULL) { + encoded[j++] = input[i++]; // Copy safe character as is + } + else { + // Encode non-safe character as percent-encoded representation + sprintf(encoded + j, "%%%02X", (unsigned char)input[i]); + j += 3; // Increment output index by 3 to account for encoding (%XX) + i++; // Move to the next character in the input string + } + } + + // Null-terminate the encoded string + encoded[j] = '\0'; + + return encoded; +} #endif \ No newline at end of file diff --git a/src/client_backend/connect.h b/src/client_backend/connect.h index 104ce2c..09f8dc5 100644 --- a/src/client_backend/connect.h +++ b/src/client_backend/connect.h @@ -6,4 +6,6 @@ #include #include int connect_to_srv(const char* url, char* out, int max_len, bool ignore_insecure); -int download_file_from_srv(const char* url, const char* outputFileName,bool ignore_insecure); \ No newline at end of file +int download_file_from_srv(const char* url, const char* outputFileName,bool ignore_insecure); +int fast_send(const char* url, bool ignore_insecure); +char* url_encode(const char* input); \ No newline at end of file diff --git a/src/client_backend/log.cpp b/src/client_backend/log.cpp index 67c628d..fac76fd 100644 --- a/src/client_backend/log.cpp +++ b/src/client_backend/log.cpp @@ -16,7 +16,14 @@ std::string get_loglevel(LOGLEVEL level) { return "RISK"; case LOGLEVEL::PANIC: return "PANIC"; - + case LOGLEVEL::INFO_NOSEND: + return "INFO_NOSEND"; + case LOGLEVEL::WARN_NOSEND: + return "WARNING_NOSEND"; + case LOGLEVEL::ERR_NOSEND: + return "ERROR_NOSEND"; + case LOGLEVEL::PANIC_NOSEND: + return "PANIC_NOSEND"; default: return "UNKNOWN"; } diff --git a/src/client_backend/log.h b/src/client_backend/log.h index 1a18eb4..8db41f1 100644 --- a/src/client_backend/log.h +++ b/src/client_backend/log.h @@ -5,14 +5,21 @@ #include #include #include +#include "connect.h" #include "well_known.h" +#include "settings.h" +#include "security.h" enum class LOGLEVEL { INFO, WARN, ERR, VIRUS, RISK, - PANIC + PANIC, + INFO_NOSEND, + WARN_NOSEND, + ERR_NOSEND, + PANIC_NOSEND }; std::string get_loglevel(LOGLEVEL level); @@ -30,10 +37,10 @@ void log(LOGLEVEL level, const std::string& message, Args&&... args) { logStream << std::put_time(&tm, "%Y-%m-%d %H:%M:%S") << " " << prefix << " " << message; if constexpr (sizeof...(args) > 0) { ((logStream << ' ' << std::forward(args)), ...); - ((to_srv << ' ' << std::forward(args)), ...); + ((to_srv << ' ' << std::forward(args)), ...); } logStream << std::endl; - to_srv << std::endl; + //to_srv << std::endl; std::string logString = logStream.str(); std::string to_srv_string = to_srv.str(); printf("info from logger: %s", logString.c_str()); @@ -41,68 +48,79 @@ void log(LOGLEVEL level, const std::string& message, Args&&... args) { FILE* fp; switch (level) { case LOGLEVEL::INFO: - error=fopen_s(&fp, INFOFILE, "a"); + error = fopen_s(&fp, INFOFILE, "a"); break; case LOGLEVEL::WARN: - error=fopen_s(&fp, WARNFILE, "a"); + error = fopen_s(&fp, WARNFILE, "a"); break; case LOGLEVEL::ERR: - error=fopen_s(&fp, ERRORFILE, "a"); + error = fopen_s(&fp, ERRORFILE, "a"); break; case LOGLEVEL::VIRUS: - error=fopen_s(&fp, VIRUSFILE, "a"); - break; + error = fopen_s(&fp, VIRUSFILE, "a"); + break; case LOGLEVEL::RISK: - error=fopen_s(&fp, RISKFILE, "a"); - break; + error = fopen_s(&fp, RISKFILE, "a"); + break; case LOGLEVEL::PANIC: error = fopen_s(&fp, PANICFILE, "a"); break; - - default: - error=fopen_s(&fp, LOGFILE, "a"); - break; - } - if (error != 0) { - //panic, create log entry, return 1; - //printf("a"); - return; + case LOGLEVEL::INFO_NOSEND: + error = fopen_s(&fp, INFOFILE, "a"); + break; + case LOGLEVEL::WARN_NOSEND: + error = fopen_s(&fp, WARNFILE, "a"); + break; + case LOGLEVEL::ERR_NOSEND: + error = fopen_s(&fp, ERRORFILE, "a"); + break; + default: + error = fopen_s(&fp, LOGFILE, "a"); + break; + } + if (error != 0) { + //panic, create log entry, return 1; + return; } else { - switch (level) { - case LOGLEVEL::INFO: - fprintf_s(fp, "%s", logString.c_str()); - break; - case LOGLEVEL::WARN: - fprintf_s(fp, "%s", logString.c_str()); - break; - case LOGLEVEL::ERR: - fprintf_s(fp, "%s", logString.c_str()); - break; - case LOGLEVEL::VIRUS: - fprintf_s(fp, "%s", logString.c_str()); - break; - case LOGLEVEL::RISK: - fprintf_s(fp, "%s", logString.c_str()); - break; - case LOGLEVEL::PANIC: - fprintf_s(fp, "%s", logString.c_str()); - break; - - default: - fprintf_s(fp, "%s", logString.c_str()); - break; - } + //write log entry to disk + fprintf_s(fp, "%s", logString.c_str()); fclose(fp); + + //write to general log file if (fopen_s(&fp, LOGFILE, "a") == 0) { fprintf_s(fp, "%s", logString.c_str()); fclose(fp); } + //write to server log file if (fopen_s(&fp, SRV_LOGFILE, "a") == 0) { - fprintf_s(fp, "%s", to_srv_string.c_str()); + fprintf_s(fp, "%s\n", to_srv_string.c_str()); fclose(fp); } } + //send log so srv + //build up the log string: loglevel&logtext&machineid&date + //to_srv_string=includes the log message + //we now need to build up the request string and append the machineid + if (level!=LOGLEVEL::INFO_NOSEND && level!=LOGLEVEL::WARN_NOSEND && level!=LOGLEVEL::ERR_NOSEND && level!=LOGLEVEL::PANIC_NOSEND) { + char* url = new char[3000]; + if (get_setting("server:server_url", url) == 0 or strcmp(url, "nan") == 0) { + strcat_s(url, 3000, "/api/php/log/add_entry.php?logtext=");//need to add machine_id and apikey + strcat_s(url, 3000, url_encode(to_srv_string.c_str())); + strcat_s(url, 3000, "&machine_id="); + strcat_s(url, 3000, get_machineid(SECRETS)); + strcat_s(url, 3000, "&apikey="); + strcat_s(url, 3000, get_apikey(SECRETS)); + fast_send(url, get_setting("communication:unsafe_tls"); + //we might not want to log an error occuring here because it will create a loop + delete[] url; + } + else { + delete[] url; + return; + } + }//else we do not send the log to the server + } #endif // LOGGER_H diff --git a/src/client_backend/settings.cpp b/src/client_backend/settings.cpp index 29846b4..6c9bc76 100644 --- a/src/client_backend/settings.cpp +++ b/src/client_backend/settings.cpp @@ -23,7 +23,7 @@ int load_settings() { } else { char*settings_cmd=new char[505]; - char*settings_arg= new char[300]; + char*settings_arg=new char[300]; fscanf_s(fp, "%s", settings_cmd, 500); //the cert is always the firs tline while (!feof(fp)) { fscanf_s(fp, "%s", settings_cmd, 295); // get the command diff --git a/src/client_backend/update.cpp b/src/client_backend/update.cpp index 8c16057..8eea6d0 100644 --- a/src/client_backend/update.cpp +++ b/src/client_backend/update.cpp @@ -66,7 +66,7 @@ int update_settings(const char*settings_type) { res = download_file_from_srv(url, SCHED_PATH, get_setting("communication:unsafe_tls")); //int res = 0; if (res != 0) { - log(LOGLEVEL::ERR, "[update_settings()]: Error downloading settings database file from server", url, " ERROR:", res); + log(LOGLEVEL::ERR, "[update_settings()]: Error downloading settings database file from server", " ERROR:", res); return 1; } diff --git a/src/client_backend/x64/Debug/client_backend.pdb b/src/client_backend/x64/Debug/client_backend.pdb index c18916b..f97cf01 100644 Binary files a/src/client_backend/x64/Debug/client_backend.pdb and b/src/client_backend/x64/Debug/client_backend.pdb differ diff --git a/src/server/cyberhex-code/api/php/log/add_entry.php b/src/server/cyberhex-code/api/php/log/add_entry.php index 3f02d0d..4657ea2 100644 --- a/src/server/cyberhex-code/api/php/log/add_entry.php +++ b/src/server/cyberhex-code/api/php/log/add_entry.php @@ -8,13 +8,16 @@ if(check_apikey()!==true){ //add the entry to the log db //this page has no gui, it may return ok or error -if(!isset($_GET["loglevel"]) or !isset($_GET["logtext"]) or !isset($_GET["machine_id"]) or !isset($_GET["time"])) +if(!isset($_GET["logtext"]) or !isset($_GET["machine_id"])) echo("syn_err"); else{ - $loglevel=htmlspecialchars($_GET["loglevel"]); $logtext=htmlspecialchars($_GET["logtext"]); + $log=explode(";",$logtext); + $message=$log[2]; + $loglevel=$log[1]; $machine_id=htmlspecialchars($_GET["machine_id"]); - $time=htmlspecialchars($_GET["time"]); + $time=log[0]; + //include db pw include "../../../config.php"; $conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD, $DB_DATABASE); diff --git a/src/server/cyberhex-code/system/secure_zone/php/index.php b/src/server/cyberhex-code/system/secure_zone/php/index.php index 69ca192..2bc88b8 100644 --- a/src/server/cyberhex-code/system/secure_zone/php/index.php +++ b/src/server/cyberhex-code/system/secure_zone/php/index.php @@ -49,7 +49,7 @@ if(isset($_GET["page"])){

Home

User