From 3c1ee3a14bd89625052b07c4e55b3b21d2b4f37d Mon Sep 17 00:00:00 2001 From: donnaskiez Date: Sun, 9 Jun 2024 22:09:18 +1000 Subject: [PATCH] BIG CLEANUP --- ac.sln | 118 ---- dblayout.drawio | 16 - module/kernel_interface/kernel_interface.cpp | 17 - notes.md | 8 - .../Database/Entity/HardwareConfiguration.cs | 37 -- .../Database/Entity/Report/IReportEntity.cs | 19 - server/Database/Entity/Report/ReportEntity.cs | 26 - .../Report/Types/AttachProcessEntity.cs | 26 - .../Report/Types/HiddenSystemThreadEntity.cs | 26 - .../Types/IllegalHandleOperationEntity.cs | 25 - .../Types/InvalidProcessAllocationEntity.cs | 26 - .../Entity/Report/Types/NmiCallbackEntity.cs | 26 - .../Report/Types/PageProtectionEntity.cs | 26 - .../Entity/Report/Types/PatternScanEntity.cs | 26 - .../ProcessModuleIntegrityCheckEntity.cs | 27 - .../Entity/Report/Types/StartAddressEntity.cs | 26 - .../Types/SystemModuleValidationEntity.cs | 26 - server/Database/Entity/User.cs | 48 -- server/Database/Model/Model.cs | 137 ---- server/Database/Model/ModelContext.cs | 290 --------- server/Helper.cs | 89 --- server/Message/ClientReport.cs | 607 ------------------ server/Message/ClientRequest.cs | 53 -- server/Message/ClientSend.cs | 157 ----- server/Message/IClientMessage.cs | 28 - server/Message/MessageHandler.cs | 108 ---- server/Program.cs | 25 - server/Server.cs | 72 --- server/Types.cs | 134 ---- server/main.go | 7 + server/server.csproj | 25 - service/Client.cs | 65 -- service/Program.cs | 27 - service/Properties/launchSettings.json | 11 - service/Worker.cs | 110 ---- service/appsettings.Development.json | 8 - service/appsettings.json | 21 - service/helper.cs | 42 -- service/service.csproj | 22 - test/cli/driver.h | 38 -- test/cli/main.cpp | 57 -- test/cli/testcli.vcxproj | 201 ------ test/cli/testcli.vcxproj.filters | 27 - test/driver/common.hpp | 11 - test/driver/driver.hpp | 3 - test/driver/framework.hpp | 9 - test/driver/main.cpp | 67 -- test/driver/patch.cpp | 7 - test/driver/patch.hpp | 17 - test/driver/testdrv.inf | 77 --- test/driver/testdrv.vcxproj | 221 ------- test/driver/testdrv.vcxproj.filters | 48 -- 52 files changed, 7 insertions(+), 3363 deletions(-) delete mode 100644 dblayout.drawio delete mode 100644 notes.md delete mode 100644 server/Database/Entity/HardwareConfiguration.cs delete mode 100644 server/Database/Entity/Report/IReportEntity.cs delete mode 100644 server/Database/Entity/Report/ReportEntity.cs delete mode 100644 server/Database/Entity/Report/Types/AttachProcessEntity.cs delete mode 100644 server/Database/Entity/Report/Types/HiddenSystemThreadEntity.cs delete mode 100644 server/Database/Entity/Report/Types/IllegalHandleOperationEntity.cs delete mode 100644 server/Database/Entity/Report/Types/InvalidProcessAllocationEntity.cs delete mode 100644 server/Database/Entity/Report/Types/NmiCallbackEntity.cs delete mode 100644 server/Database/Entity/Report/Types/PageProtectionEntity.cs delete mode 100644 server/Database/Entity/Report/Types/PatternScanEntity.cs delete mode 100644 server/Database/Entity/Report/Types/ProcessModuleIntegrityCheckEntity.cs delete mode 100644 server/Database/Entity/Report/Types/StartAddressEntity.cs delete mode 100644 server/Database/Entity/Report/Types/SystemModuleValidationEntity.cs delete mode 100644 server/Database/Entity/User.cs delete mode 100644 server/Database/Model/Model.cs delete mode 100644 server/Database/Model/ModelContext.cs delete mode 100644 server/Helper.cs delete mode 100644 server/Message/ClientReport.cs delete mode 100644 server/Message/ClientRequest.cs delete mode 100644 server/Message/ClientSend.cs delete mode 100644 server/Message/IClientMessage.cs delete mode 100644 server/Message/MessageHandler.cs delete mode 100644 server/Program.cs delete mode 100644 server/Server.cs delete mode 100644 server/Types.cs create mode 100644 server/main.go delete mode 100644 server/server.csproj delete mode 100644 service/Client.cs delete mode 100644 service/Program.cs delete mode 100644 service/Properties/launchSettings.json delete mode 100644 service/Worker.cs delete mode 100644 service/appsettings.Development.json delete mode 100644 service/appsettings.json delete mode 100644 service/helper.cs delete mode 100644 service/service.csproj delete mode 100644 test/cli/driver.h delete mode 100644 test/cli/main.cpp delete mode 100644 test/cli/testcli.vcxproj delete mode 100644 test/cli/testcli.vcxproj.filters delete mode 100644 test/driver/common.hpp delete mode 100644 test/driver/driver.hpp delete mode 100644 test/driver/framework.hpp delete mode 100644 test/driver/main.cpp delete mode 100644 test/driver/patch.cpp delete mode 100644 test/driver/patch.hpp delete mode 100644 test/driver/testdrv.inf delete mode 100644 test/driver/testdrv.vcxproj delete mode 100644 test/driver/testdrv.vcxproj.filters diff --git a/ac.sln b/ac.sln index 9a90e3b..d973f62 100644 --- a/ac.sln +++ b/ac.sln @@ -5,12 +5,6 @@ VisualStudioVersion = 17.5.33502.453 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "driver", "driver\driver.vcxproj", "{0AE83EC6-DDEA-4EDE-B1B2-1B2AB1E8BB54}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "service", "service\service.csproj", "{6228E9DD-E1EA-45D8-8054-A00FC2D63414}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "server", "server\server.csproj", "{4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testdrv", "test\driver\testdrv.vcxproj", "{3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "module", "module\module.vcxproj", "{3B18467A-4358-45EF-81B1-5C6F9B0B6728}" EndProject Global @@ -81,118 +75,6 @@ Global {0AE83EC6-DDEA-4EDE-B1B2-1B2AB1E8BB54}.Release|x86.ActiveCfg = Release|x64 {0AE83EC6-DDEA-4EDE-B1B2-1B2AB1E8BB54}.Release|x86.Build.0 = Release|x64 {0AE83EC6-DDEA-4EDE-B1B2-1B2AB1E8BB54}.Release|x86.Deploy.0 = Release|x64 - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Debug|ARM64.Build.0 = Debug|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Debug|x64.ActiveCfg = Debug|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Debug|x64.Build.0 = Debug|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Debug|x86.ActiveCfg = Debug|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Debug|x86.Build.0 = Debug|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release - No Server - Win10|Any CPU.ActiveCfg = Release - No Server|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release - No Server - Win10|Any CPU.Build.0 = Release - No Server|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release - No Server - Win10|ARM64.ActiveCfg = Release - No Server|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release - No Server - Win10|ARM64.Build.0 = Release - No Server|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release - No Server - Win10|x64.ActiveCfg = Release - No Server|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release - No Server - Win10|x64.Build.0 = Release - No Server|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release - No Server - Win10|x86.ActiveCfg = Release - No Server|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release - No Server - Win10|x86.Build.0 = Release - No Server|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release - No Server - Win11|Any CPU.ActiveCfg = Release - No Server|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release - No Server - Win11|Any CPU.Build.0 = Release - No Server|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release - No Server - Win11|ARM64.ActiveCfg = Release - No Server|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release - No Server - Win11|ARM64.Build.0 = Release - No Server|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release - No Server - Win11|x64.ActiveCfg = Release - No Server|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release - No Server - Win11|x64.Build.0 = Release - No Server|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release - No Server - Win11|x86.ActiveCfg = Release - No Server|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release - No Server - Win11|x86.Build.0 = Release - No Server|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release|Any CPU.Build.0 = Release|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release|ARM64.ActiveCfg = Release|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release|ARM64.Build.0 = Release|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release|x64.ActiveCfg = Release|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release|x64.Build.0 = Release|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release|x86.ActiveCfg = Release|Any CPU - {6228E9DD-E1EA-45D8-8054-A00FC2D63414}.Release|x86.Build.0 = Release|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Debug|ARM64.Build.0 = Debug|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Debug|x64.ActiveCfg = Debug|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Debug|x64.Build.0 = Debug|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Debug|x86.ActiveCfg = Debug|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Debug|x86.Build.0 = Debug|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release - No Server - Win10|Any CPU.ActiveCfg = Release - No Server|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release - No Server - Win10|Any CPU.Build.0 = Release - No Server|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release - No Server - Win10|ARM64.ActiveCfg = Release - No Server|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release - No Server - Win10|ARM64.Build.0 = Release - No Server|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release - No Server - Win10|x64.ActiveCfg = Release - No Server|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release - No Server - Win10|x64.Build.0 = Release - No Server|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release - No Server - Win10|x86.ActiveCfg = Release - No Server|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release - No Server - Win10|x86.Build.0 = Release - No Server|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release - No Server - Win11|Any CPU.ActiveCfg = Release - No Server|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release - No Server - Win11|Any CPU.Build.0 = Release - No Server|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release - No Server - Win11|ARM64.ActiveCfg = Release - No Server|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release - No Server - Win11|ARM64.Build.0 = Release - No Server|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release - No Server - Win11|x64.ActiveCfg = Release - No Server|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release - No Server - Win11|x64.Build.0 = Release - No Server|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release - No Server - Win11|x86.ActiveCfg = Release - No Server|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release - No Server - Win11|x86.Build.0 = Release - No Server|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release|Any CPU.Build.0 = Release|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release|ARM64.ActiveCfg = Release|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release|ARM64.Build.0 = Release|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release|x64.ActiveCfg = Release|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release|x64.Build.0 = Release|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release|x86.ActiveCfg = Release|Any CPU - {4D0777F0-2D3D-4FD7-9C0F-CD4DEC1A99E9}.Release|x86.Build.0 = Release|Any CPU - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Debug|Any CPU.ActiveCfg = Debug|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Debug|Any CPU.Build.0 = Debug|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Debug|Any CPU.Deploy.0 = Debug|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Debug|ARM64.Build.0 = Debug|ARM64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Debug|ARM64.Deploy.0 = Debug|ARM64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Debug|x64.ActiveCfg = Debug|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Debug|x64.Build.0 = Debug|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Debug|x64.Deploy.0 = Debug|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Debug|x86.ActiveCfg = Debug|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Debug|x86.Build.0 = Debug|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Debug|x86.Deploy.0 = Debug|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win10|Any CPU.ActiveCfg = Release - No Server|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win10|Any CPU.Build.0 = Release - No Server|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win10|Any CPU.Deploy.0 = Release - No Server|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win10|ARM64.ActiveCfg = Release - No Server|ARM64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win10|ARM64.Build.0 = Release - No Server|ARM64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win10|ARM64.Deploy.0 = Release - No Server|ARM64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win10|x64.ActiveCfg = Release - No Server|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win10|x64.Build.0 = Release - No Server|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win10|x64.Deploy.0 = Release - No Server|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win10|x86.ActiveCfg = Release - No Server|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win10|x86.Build.0 = Release - No Server|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win10|x86.Deploy.0 = Release - No Server|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win11|Any CPU.ActiveCfg = Release - No Server|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win11|Any CPU.Build.0 = Release - No Server|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win11|Any CPU.Deploy.0 = Release - No Server|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win11|ARM64.ActiveCfg = Release - No Server|ARM64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win11|ARM64.Build.0 = Release - No Server|ARM64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win11|ARM64.Deploy.0 = Release - No Server|ARM64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win11|x64.ActiveCfg = Release - No Server|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win11|x64.Build.0 = Release - No Server|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win11|x64.Deploy.0 = Release - No Server|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win11|x86.ActiveCfg = Release - No Server|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win11|x86.Build.0 = Release - No Server|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release - No Server - Win11|x86.Deploy.0 = Release - No Server|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release|Any CPU.ActiveCfg = Release|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release|Any CPU.Build.0 = Release|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release|Any CPU.Deploy.0 = Release|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release|ARM64.ActiveCfg = Release|ARM64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release|ARM64.Build.0 = Release|ARM64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release|ARM64.Deploy.0 = Release|ARM64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release|x64.ActiveCfg = Release|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release|x64.Build.0 = Release|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release|x64.Deploy.0 = Release|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release|x86.ActiveCfg = Release|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release|x86.Build.0 = Release|x64 - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0}.Release|x86.Deploy.0 = Release|x64 {3B18467A-4358-45EF-81B1-5C6F9B0B6728}.Debug|Any CPU.ActiveCfg = Debug|x64 {3B18467A-4358-45EF-81B1-5C6F9B0B6728}.Debug|Any CPU.Build.0 = Debug|x64 {3B18467A-4358-45EF-81B1-5C6F9B0B6728}.Debug|ARM64.ActiveCfg = Debug|x64 diff --git a/dblayout.drawio b/dblayout.drawio deleted file mode 100644 index e19612a..0000000 --- a/dblayout.drawio +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/module/kernel_interface/kernel_interface.cpp b/module/kernel_interface/kernel_interface.cpp index 5bbb421..526f4dc 100644 --- a/module/kernel_interface/kernel_interface.cpp +++ b/module/kernel_interface/kernel_interface.cpp @@ -292,23 +292,6 @@ void kernel_interface::kernel_interface::send_pending_irp() { LOG_ERROR("failed to insert irp into irp queue %x", status); } -// void kernel_interface::kernel_interface::query_deferred_reports() { -// unsigned long bytes_returned = 0; -// void *buffer = malloc(MAXIMUM_REPORT_BUFFER_SIZE); -// if (!buffer) -// return; -// for (int i = 0; i < QUERY_DEFERRED_REPORT_COUNT; i++) { -// unsigned int status = -// generic_driver_call_output(ioctl_code::QueryDeferredReports, buffer, -// MAXIMUM_REPORT_BUFFER_SIZE, -// &bytes_returned); -// if (status && bytes_returned > 0) -// helper::print_kernel_report(buffer); -// memset(buffer, 0, MAXIMUM_REPORT_BUFFER_SIZE); -// } -// free(buffer); -// } - void kernel_interface::kernel_interface::write_shared_mapping_operation( shared_state_operation_id operation_id) { InterlockedExchange16( diff --git a/notes.md b/notes.md deleted file mode 100644 index 652ff98..0000000 --- a/notes.md +++ /dev/null @@ -1,8 +0,0 @@ -new feature notes: - -- random heartbeat timer event callback. These timers should be single shot events, once fired we get a new random time and insert that. This way the timer objects are always fresh and we dont use a global timer object. -- session cookie new value per session -- session statistics need to be updated each time a new irp is inserted into the queue -- same with when we receive an irp -- this information can be used to detect malicious interferrence with the system -- use a reverse irp method, user mode program receives and irp and checks if it contains a special code indicating it must send an irp to tthe driver ? \ No newline at end of file diff --git a/server/Database/Entity/HardwareConfiguration.cs b/server/Database/Entity/HardwareConfiguration.cs deleted file mode 100644 index 6ebb550..0000000 --- a/server/Database/Entity/HardwareConfiguration.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Serilog; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using server.Database.Model; -using System.Reflection.Metadata.Ecma335; -using Microsoft.EntityFrameworkCore; - -namespace server.Database.Entity -{ - public class HardwareConfigurationEntity : HardwareConfiguration - { - private readonly ModelContext _modelContext; - public UserEntity UserEntity { get; set; } - - public HardwareConfigurationEntity(ModelContext modelContext) - { - UserEntity = new UserEntity(modelContext); - _modelContext = modelContext; - } - - public bool CheckIfHardwareIsBanned() - { - return _modelContext.HardwareConfiguration.Any( - h => h.MotherboardSerial == MotherboardSerial && - h.DeviceDrive0Serial == DeviceDrive0Serial && - h.IsBanned); - } - - public void InsertHardwareConfiguration() - { - _modelContext.HardwareConfiguration.Add(this); - } - } -} diff --git a/server/Database/Entity/Report/IReportEntity.cs b/server/Database/Entity/Report/IReportEntity.cs deleted file mode 100644 index 051bb64..0000000 --- a/server/Database/Entity/Report/IReportEntity.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace server.Database.Entity.Report -{ - /// - /// Implements the IReport interface - /// - public interface IReportEntity - { - /// - /// Inserts the report into the database. - /// - void InsertReport(); - } -} diff --git a/server/Database/Entity/Report/ReportEntity.cs b/server/Database/Entity/Report/ReportEntity.cs deleted file mode 100644 index f561d92..0000000 --- a/server/Database/Entity/Report/ReportEntity.cs +++ /dev/null @@ -1,26 +0,0 @@ -using server.Database.Model; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace server.Database.Entity.Report -{ - public class ReportEntity : Model.Report - { - private readonly ModelContext _modelContext; - private UserEntity UserEntity { get; set; } - - public ReportEntity(ModelContext modelContext) - { - UserEntity = new UserEntity(modelContext); - _modelContext = modelContext; - } - - public void InsertReport() - { - _modelContext.Reports.Add(this); - } - } -} diff --git a/server/Database/Entity/Report/Types/AttachProcessEntity.cs b/server/Database/Entity/Report/Types/AttachProcessEntity.cs deleted file mode 100644 index 03eebe9..0000000 --- a/server/Database/Entity/Report/Types/AttachProcessEntity.cs +++ /dev/null @@ -1,26 +0,0 @@ -using server.Database.Model; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace server.Database.Entity.Report.Types -{ - public class AttachProcessEntity : ReportTypeAttachProcess, IReportEntity - { - private readonly ModelContext _modelContext; - public ReportEntity ReportEntity { get; set; } - - public AttachProcessEntity(ModelContext modelContext) - { - ReportEntity = new ReportEntity(modelContext); - _modelContext = modelContext; - } - - public void InsertReport() - { - _modelContext.ReportTypeAttachProcess.Add(this); - } - } -} diff --git a/server/Database/Entity/Report/Types/HiddenSystemThreadEntity.cs b/server/Database/Entity/Report/Types/HiddenSystemThreadEntity.cs deleted file mode 100644 index c76dfed..0000000 --- a/server/Database/Entity/Report/Types/HiddenSystemThreadEntity.cs +++ /dev/null @@ -1,26 +0,0 @@ -using server.Database.Model; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace server.Database.Entity.Report.Types -{ - public class HiddenSystemThreadEntity : ReportTypeHiddenSystemThread, IReportEntity - { - private readonly ModelContext _modelContext; - public ReportEntity ReportEntity { get; set; } - - public HiddenSystemThreadEntity(ModelContext modelContext) - { - ReportEntity = new ReportEntity(modelContext); - _modelContext = modelContext; - } - - public void InsertReport() - { - _modelContext.ReportTypeHiddenSystemThread.Add(this); - } - } -} diff --git a/server/Database/Entity/Report/Types/IllegalHandleOperationEntity.cs b/server/Database/Entity/Report/Types/IllegalHandleOperationEntity.cs deleted file mode 100644 index 9b557bf..0000000 --- a/server/Database/Entity/Report/Types/IllegalHandleOperationEntity.cs +++ /dev/null @@ -1,25 +0,0 @@ -using server.Database.Model; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace server.Database.Entity.Report.Types -{ - public class ReportTypeIllegalHandleOperationEntity : ReportTypeIllegalHandleOperation, IReportEntity - { - private readonly ModelContext _modelContext; - public ReportEntity ReportEntity { get; set; } - - public ReportTypeIllegalHandleOperationEntity(ModelContext modelContext) - { - ReportEntity = new ReportEntity(modelContext); - _modelContext = modelContext; - } - public void InsertReport() - { - _modelContext.ReportTypeIllegalHandleOperation.Add(this); - } - } -} diff --git a/server/Database/Entity/Report/Types/InvalidProcessAllocationEntity.cs b/server/Database/Entity/Report/Types/InvalidProcessAllocationEntity.cs deleted file mode 100644 index 2cee551..0000000 --- a/server/Database/Entity/Report/Types/InvalidProcessAllocationEntity.cs +++ /dev/null @@ -1,26 +0,0 @@ -using server.Database.Model; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace server.Database.Entity.Report.Types -{ - public class InvalidProcessAllocationEntity : ReportTypeInvalidProcessAllocation, IReportEntity - { - private readonly ModelContext _modelContext; - public ReportEntity ReportEntity { get; set; } - - public InvalidProcessAllocationEntity(ModelContext modelContext) - { - ReportEntity = new ReportEntity(modelContext); - _modelContext = modelContext; - } - - public void InsertReport() - { - _modelContext.ReportTypeInvalidProcessAllocation.Add(this); - } - } -} diff --git a/server/Database/Entity/Report/Types/NmiCallbackEntity.cs b/server/Database/Entity/Report/Types/NmiCallbackEntity.cs deleted file mode 100644 index ae4b66c..0000000 --- a/server/Database/Entity/Report/Types/NmiCallbackEntity.cs +++ /dev/null @@ -1,26 +0,0 @@ -using server.Database.Model; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace server.Database.Entity.Report.Types -{ - public class NmiCallbackEntity : ReportTypeNmiCallback, IReportEntity - { - private readonly ModelContext _modelContext; - public ReportEntity ReportEntity { get; set; } - - public NmiCallbackEntity(ModelContext modelContext) - { - ReportEntity = new ReportEntity(modelContext); - _modelContext = modelContext; - } - - public void InsertReport() - { - _modelContext.ReportTypeNmiCallback.Add(this); - } - } -} diff --git a/server/Database/Entity/Report/Types/PageProtectionEntity.cs b/server/Database/Entity/Report/Types/PageProtectionEntity.cs deleted file mode 100644 index 6e23b83..0000000 --- a/server/Database/Entity/Report/Types/PageProtectionEntity.cs +++ /dev/null @@ -1,26 +0,0 @@ -using server.Database.Model; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace server.Database.Entity.Report.Types -{ - public class PageProtectionEntity : ReportTypePageProtection, IReportEntity - { - private readonly ModelContext _modelContext; - public ReportEntity ReportEntity { get; set; } - - public PageProtectionEntity(ModelContext modelContext) - { - ReportEntity = new ReportEntity(modelContext); - _modelContext = modelContext; - } - - public void InsertReport() - { - _modelContext.ReportTypePageProtection.Add(this); - } - } -} diff --git a/server/Database/Entity/Report/Types/PatternScanEntity.cs b/server/Database/Entity/Report/Types/PatternScanEntity.cs deleted file mode 100644 index 5d1c557..0000000 --- a/server/Database/Entity/Report/Types/PatternScanEntity.cs +++ /dev/null @@ -1,26 +0,0 @@ -using server.Database.Model; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace server.Database.Entity.Report.Types -{ - public class PatternScanEntity : ReportTypePatternScan, IReportEntity - { - private readonly ModelContext _modelContext; - public ReportEntity ReportEntity { get; set; } - - public PatternScanEntity(ModelContext modelContext) - { - ReportEntity = new ReportEntity(modelContext); - _modelContext = modelContext; - } - - public void InsertReport() - { - _modelContext.ReportTypePatternScan.Add(this); - } - } -} diff --git a/server/Database/Entity/Report/Types/ProcessModuleIntegrityCheckEntity.cs b/server/Database/Entity/Report/Types/ProcessModuleIntegrityCheckEntity.cs deleted file mode 100644 index 5f1fe5d..0000000 --- a/server/Database/Entity/Report/Types/ProcessModuleIntegrityCheckEntity.cs +++ /dev/null @@ -1,27 +0,0 @@ -using server.Database.Model; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace server.Database.Entity.Report.Types -{ - public class ProcessModuleIntegrityCheckEntity : ReportTypeProcessModuleIntegrityCheck, IReportEntity - { - private readonly ModelContext _modelContext; - - public ReportEntity ReportEntity { get; set; } - - public ProcessModuleIntegrityCheckEntity(ModelContext modelContext) - { - ReportEntity = new ReportEntity(modelContext); - _modelContext = modelContext; - } - - public void InsertReport() - { - _modelContext.ReportTypeProcessModuleIntegrityCheck.Add(this); - } - } -} diff --git a/server/Database/Entity/Report/Types/StartAddressEntity.cs b/server/Database/Entity/Report/Types/StartAddressEntity.cs deleted file mode 100644 index 794ab7a..0000000 --- a/server/Database/Entity/Report/Types/StartAddressEntity.cs +++ /dev/null @@ -1,26 +0,0 @@ -using server.Database.Model; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace server.Database.Entity.Report.Types -{ - public class StartAddressEntity : ReportTypeStartAddress, IReportEntity - { - private readonly ModelContext _modelContext; - public ReportEntity ReportEntity { get; set; } - - public StartAddressEntity(ModelContext modelContext) - { - ReportEntity = new ReportEntity(modelContext); - _modelContext = modelContext; - } - - public void InsertReport() - { - _modelContext.ReportTypeStartAddress.Add(this); - } - } -} diff --git a/server/Database/Entity/Report/Types/SystemModuleValidationEntity.cs b/server/Database/Entity/Report/Types/SystemModuleValidationEntity.cs deleted file mode 100644 index 509ef62..0000000 --- a/server/Database/Entity/Report/Types/SystemModuleValidationEntity.cs +++ /dev/null @@ -1,26 +0,0 @@ -using server.Database.Model; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace server.Database.Entity.Report.Types -{ - public class SystemModuleValidationEntity : ReportTypeSystemModuleValidation, IReportEntity - { - private readonly ModelContext _modelContext; - public ReportEntity ReportEntity { get; set; } - - public SystemModuleValidationEntity(ModelContext modelContext) - { - ReportEntity = new ReportEntity(modelContext); - _modelContext = modelContext; - } - - public void InsertReport() - { - _modelContext.ReportTypeSystemModuleValidation.Add(this); - } - } -} diff --git a/server/Database/Entity/User.cs b/server/Database/Entity/User.cs deleted file mode 100644 index b9eeb15..0000000 --- a/server/Database/Entity/User.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using server.Database.Model; -using Serilog; - -namespace server.Database.Entity -{ - public class UserEntity : User - { - private readonly ModelContext _modelContext; - - public UserEntity(ModelContext modelContext) - { - _modelContext = modelContext; - } - - public bool CheckIfUserExists() - { - return _modelContext.Users.Any(u => u.Steam64Id == Steam64Id); - } - - public bool CheckIfUserIsBanned() - { - return _modelContext.Users.Any(u => u.Steam64Id == Steam64Id && u.IsBanned); - } - - public User GetUserBySteamId(ulong steamId) - { - return _modelContext.Users.First(u => u.Steam64Id == steamId); - } - - public bool CheckIfUsersHardwareExists() - { - List hardwareConfigurations = _modelContext.HardwareConfiguration - .Where(h => h.User.Steam64Id == Steam64Id).ToList(); - - return hardwareConfigurations.Count > 0; - } - - public void InsertUser() - { - _modelContext.Users.Add(this); - } - } -} diff --git a/server/Database/Model/Model.cs b/server/Database/Model/Model.cs deleted file mode 100644 index c7657ea..0000000 --- a/server/Database/Model/Model.cs +++ /dev/null @@ -1,137 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Internal; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using static Microsoft.EntityFrameworkCore.DbLoggerCategory; - -namespace server.Database.Model -{ - public class User - { - public int UserId { get; set; } - public ulong Steam64Id { get; set; } - public bool IsBanned { get; set; } - public virtual ICollection HardwareConfigurations { get; set; } - public virtual ICollection Reports { get; set; } - } - - public class HardwareConfiguration - { - public int HardwareId { get; set; } - public virtual User User { get; set; } - public bool IsBanned { get; set; } - public string DeviceDrive0Serial { get; set; } - public string MotherboardSerial { get; set; } - } - - public class Report - { - public int ReportId { get; set; } - public virtual User User { get; set; } - public int ReportCode { get; set; } - public virtual ICollection ReportTypeIllegalHandleOperations { get; set; } - public virtual ICollection ReportTypeStartAddresses { get; set; } - public virtual ICollection ReportTypePageProtections { get; set; } - public virtual ICollection ReportTypePatternScans { get; set; } - public virtual ICollection ReportTypeNmiCallbacks { get; set; } - public virtual ICollection ReportTypeSystemModuleValidations { get; set; } - public virtual ICollection ReportTypeHiddenSystemThreads { get; set; } - public virtual ICollection ReportTypeAttachProcesses { get; set; } - public virtual ICollection ReportTypeInvalidProcessAllocations { get; set; } - public virtual ICollection ReportTypeProcessModuleIntegrityChecks { get; set; } - } - - public class ReportTypeIllegalHandleOperation - { - public int ReportNumber { get; set; } - public virtual Report Report { get; set; } - public int IsKernelHandle { get; set; } - public uint ProcessId { get; set; } - public uint ThreadId { get; set; } - public uint DesiredAccess { get; set; } - public string ProcessName { get; set; } - } - - public class ReportTypeStartAddress - { - public int ReportNumber { get; set; } - public virtual Report Report { get; set; } - public int ThreadId { get; set; } - public long ThreadStartAddress { get; set; } - } - - public class ReportTypePageProtection - { - public virtual Report Report { get; set; } - public int ReportNumber { get; set; } - public ulong PageBaseAddress { get; set; } - public long AllocationProtection { get; set; } - public long AllocationState { get; set; } - public long AllocationType { get; set; } - } - - public class ReportTypePatternScan - { - public virtual Report Report { get; set; } - public int ReportNumber { get; set; } - public int SignatureId { get; set; } - public ulong Address { get; set; } - } - - public class ReportTypeNmiCallback - { - public virtual Report Report { get; set; } - public int ReportNumber { get; set; } - public int WereNmisDisabled { get; set; } - public ulong KThreadAddress { get; set; } - public ulong InvalidRip { get; set; } - } - - public class ReportTypeSystemModuleValidation - { - public virtual Report Report { get; set; } - public int ReportNumber { get; set; } - public int ReportType { get; set; } - public long DriverBaseAddress { get; set; } - public long DriverSize { get; set; } - public string ModuleName { get; set; } - } - - public class ReportTypeHiddenSystemThread - { - public virtual Report Report { get; set; } - public int ReportNumber { get; set; } - public int FoundInKThreadList { get; set; } - public int FoundInPspCidTable { get; set; } - public long ThreadAddress { get; set; } - public int ThreadId { get; set; } - public byte[] ThreadStructure { get; set; } - } - - public class ReportTypeAttachProcess - { - public virtual Report Report { get; set; } - public int ReportNumber { get; set; } - public int ThreadId { get; set; } - public long ThreadAddress { get; set; } - } - - public class ReportTypeInvalidProcessAllocation - { - public virtual Report Report { get; set; } - public int ReportNumber { get; set; } - public byte[] ProcessStructure { get; set; } - } - - public class ReportTypeProcessModuleIntegrityCheck - { - public virtual Report Report { get; set; } - public int ReportNumber { get; set; } - public long ModuleBaseAddress { get; set; } - public int ModuleSize { get; set; } - public string ModuleName { get; set; } - } -} \ No newline at end of file diff --git a/server/Database/Model/ModelContext.cs b/server/Database/Model/ModelContext.cs deleted file mode 100644 index c1d3925..0000000 --- a/server/Database/Model/ModelContext.cs +++ /dev/null @@ -1,290 +0,0 @@ -using Google.Protobuf.Reflection; -using Microsoft.EntityFrameworkCore; -using MySql.EntityFrameworkCore.Extensions; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection.Emit; -using System.Text; -using System.Threading.Tasks; - -namespace server.Database.Model -{ - public class ModelContext : DbContext - { - public DbSet Users { get; set; } - public DbSet HardwareConfiguration { get; set; } - public DbSet Reports { get; set; } - public DbSet ReportTypeIllegalHandleOperation { get; set; } - public DbSet ReportTypeStartAddress { get; set; } - public DbSet ReportTypePageProtection { get; set; } - public DbSet ReportTypePatternScan { get; set; } - public DbSet ReportTypeNmiCallback { get; set; } - public DbSet ReportTypeSystemModuleValidation { get; set; } - public DbSet ReportTypeHiddenSystemThread { get; set; } - public DbSet ReportTypeAttachProcess { get; set; } - public DbSet ReportTypeInvalidProcessAllocation { get; set; } - public DbSet ReportTypeProcessModuleIntegrityCheck { get; set; } - - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - optionsBuilder.UseMySQL("server=localhost;userid=root;password=root;database=ac_db"); - } - - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - base.OnModelCreating(modelBuilder); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.UserId); - - entity.Property(e => e.UserId) - .UseMySQLAutoIncrementColumn(entity.Property(e => e.UserId).Metadata.Name); - - entity.Property(e => e.Steam64Id) - .IsRequired(); - - entity.Property(e => e.IsBanned) - .HasDefaultValue(false); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.HardwareId); - - entity.Property(e => e.HardwareId) - .UseMySQLAutoIncrementColumn(entity.Property(e => e.HardwareId).Metadata.Name); - - entity.Property(e => e.IsBanned) - .HasDefaultValue(false); - - entity.Property(e => e.MotherboardSerial) - .IsRequired(); - - entity.Property(e => e.DeviceDrive0Serial) - .IsRequired(); - - entity.HasOne(d => d.User) - .WithMany(f => f.HardwareConfigurations); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.ReportId); - - entity.Property(e => e.ReportId) - .UseMySQLAutoIncrementColumn(entity.Property(e => e.ReportId).Metadata.Name); - - entity.HasOne(d => d.User) - .WithMany(e => e.Reports); - - entity.Property(e => e.ReportCode) - .IsRequired(); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.ReportNumber); - - entity.Property(e => e.ReportNumber) - .UseMySQLAutoIncrementColumn(entity.Property(e => e.ReportNumber).Metadata.Name); - - entity.Property(e => e.IsKernelHandle) - .IsRequired(); - - entity.Property(e => e.ProcessId) - .IsRequired(); - - entity.Property(e => e.ThreadId) - .IsRequired(); - - entity.Property(e => e.DesiredAccess) - .IsRequired(); - - entity.Property(e => e.ProcessName) - .IsRequired(); - - entity.HasOne(d => d.Report) - .WithMany(f => f.ReportTypeIllegalHandleOperations); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.ReportNumber); - - entity.Property(e => e.ReportNumber) - .UseMySQLAutoIncrementColumn(entity.Property(e => e.ReportNumber).Metadata.Name); - - entity.Property(e => e.ThreadId) - .IsRequired(); - - entity.Property(e => e.ThreadStartAddress) - .IsRequired(); - - entity.HasOne(d => d.Report) - .WithMany(f => f.ReportTypeStartAddresses); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.ReportNumber); - - entity.Property(e => e.ReportNumber) - .UseMySQLAutoIncrementColumn(entity.Property(e => e.ReportNumber).Metadata.Name); - - entity.Property(e => e.AllocationProtection) - .IsRequired(); - - entity.Property(e => e.AllocationState) - .IsRequired(); - - entity.Property(e => e.AllocationType) - .IsRequired(); - - entity.HasOne(d => d.Report) - .WithMany(f => f.ReportTypePageProtections); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.ReportNumber); - - entity.Property(e => e.ReportNumber) - .UseMySQLAutoIncrementColumn(entity.Property(e => e.ReportNumber).Metadata.Name); - - entity.Property(e => e.SignatureId) - .IsRequired(); - - entity.Property(e => e.Address) - .IsRequired(); - - entity.HasOne(d => d.Report) - .WithMany(f => f.ReportTypePatternScans); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.ReportNumber); - - entity.Property(e => e.ReportNumber) - .UseMySQLAutoIncrementColumn(entity.Property(e => e.ReportNumber).Metadata.Name); - - entity.Property(e => e.WereNmisDisabled) - .IsRequired(); - - entity.Property(e => e.KThreadAddress) - .IsRequired(); - - entity.Property(e => e.InvalidRip) - .IsRequired(); - - entity.HasOne(d => d.Report) - .WithMany(f => f.ReportTypeNmiCallbacks); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.ReportNumber); - - entity.Property(e => e.ReportNumber) - .UseMySQLAutoIncrementColumn(entity.Property(e => e.ReportNumber).Metadata.Name); - - entity.Property(e => e.ReportType) - .IsRequired(); - - entity.Property(e => e.DriverBaseAddress) - .IsRequired(); - - entity.Property(e => e.DriverSize) - .IsRequired(); - - entity.Property(e => e.ModuleName) - .IsRequired(); - - entity.HasOne(d => d.Report) - .WithMany(f => f.ReportTypeSystemModuleValidations); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.ReportNumber); - - entity.Property(e => e.ReportNumber) - .UseMySQLAutoIncrementColumn(entity.Property(e => e.ReportNumber).Metadata.Name); - - entity.Property(e => e.FoundInKThreadList) - .IsRequired(); - - entity.Property(e => e.FoundInPspCidTable) - .IsRequired(); - - entity.Property(e => e.ThreadAddress) - .IsRequired(); - - entity.Property(e => e.ThreadId) - .IsRequired(); - - entity.Property(e => e.ThreadStructure) - .IsRequired(); - - entity.HasOne(d => d.Report) - .WithMany(f => f.ReportTypeHiddenSystemThreads); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.ReportNumber); - - entity.Property(e => e.ReportNumber) - .UseMySQLAutoIncrementColumn(entity.Property(e => e.ReportNumber).Metadata.Name); - - entity.Property(e => e.ThreadId) - .IsRequired(); - - entity.Property(e => e.ThreadAddress) - .IsRequired(); - - entity.Property(e => e.ThreadAddress) - .IsRequired(); - - entity.HasOne(d => d.Report) - .WithMany(f => f.ReportTypeAttachProcesses); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.ReportNumber); - - entity.Property(e => e.ReportNumber) - .UseMySQLAutoIncrementColumn(entity.Property(e => e.ReportNumber).Metadata.Name); - - entity.Property(e => e.ProcessStructure) - .IsRequired(); - - entity.HasOne(d => d.Report) - .WithMany(f => f.ReportTypeInvalidProcessAllocations); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.ReportNumber); - - entity.Property(e => e.ReportNumber) - .UseMySQLAutoIncrementColumn(entity.Property(e => e.ReportNumber).Metadata.Name); - - entity.Property(e => e.ModuleBaseAddress) - .IsRequired(); - - entity.Property(e => e.ModuleSize) - .IsRequired(); - - entity.Property(e => e.ModuleName) - .IsRequired(); - - entity.HasOne(d => d.Report) - .WithMany(f => f.ReportTypeProcessModuleIntegrityChecks); - }); - } - } -} diff --git a/server/Helper.cs b/server/Helper.cs deleted file mode 100644 index 907d00b..0000000 --- a/server/Helper.cs +++ /dev/null @@ -1,89 +0,0 @@ -using Microsoft.AspNetCore.Mvc.Infrastructure; -using Serilog; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; - -#pragma warning disable CS8600 -#pragma warning disable CS8603 - -namespace server -{ - public class Helper - { - unsafe public static T BytesToStructure(byte[] buffer, int offset) - { - int typeSize = Marshal.SizeOf(typeof(T)); - - if (buffer.Length == 0) - return default(T); - - IntPtr ptr = Marshal.AllocHGlobal(typeSize); - - try - { - Marshal.Copy(buffer, offset, ptr, typeSize); - T result = (T)Marshal.PtrToStructure(ptr, typeof(T)); - Marshal.FreeHGlobal(ptr); - return result; - } - catch(Exception ex) - { - Log.Information(ex.Message); - return default(T); - } - } - - unsafe public static byte[] StructureToBytes(ref T structure) - { - int typeSize = Marshal.SizeOf(typeof(T)); - byte[] buffer = new byte[typeSize]; - IntPtr ptr = Marshal.AllocHGlobal(typeSize); - - try - { - Marshal.StructureToPtr(structure, ptr, true); - Marshal.Copy(ptr, buffer, 0, typeSize); - Marshal.FreeHGlobal(ptr); - return buffer; - } - catch (Exception ex) - { - Log.Information(ex.Message); - return null; - } - } - - unsafe public static string FixedUnsafeBufferToSafeString(ref byte[] buffer, int bufferSize, int offset, int stringSize) - { - if (stringSize > bufferSize) - return null; - - char[] stringBuffer = new char[stringSize]; - - for (int i = 0; i < stringSize; i++) - { - stringBuffer[i] = (char)buffer[offset + i]; - } - - return new string(stringBuffer); - } - - unsafe public static void CopyMemory(ref byte[] source, ref byte[] destination, int size, int offset) - { - if (size > destination.Length) - return; - - for (int i=0; i < size; i++) - { - destination[i] = source[i + offset]; - } - } - } -} - -#pragma warning restore CS8600 -#pragma warning restore CS8603 \ No newline at end of file diff --git a/server/Message/ClientReport.cs b/server/Message/ClientReport.cs deleted file mode 100644 index 52ef540..0000000 --- a/server/Message/ClientReport.cs +++ /dev/null @@ -1,607 +0,0 @@ -using Serilog; -using server.Database.Entity; -using server.Database.Entity.Report; -using server.Database.Entity.Report.Types; -using server.Database.Model; -using server.Types.ClientReport; -using System; -using System.Collections.Generic; -using System.Drawing.Printing; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; -using static server.Message.MessageHandler; - -namespace server.Message -{ - public class ClientReport : IClientMessage - { - private readonly ILogger _logger; - private byte[] _buffer; - private int _bufferSize; - private int _bytesRead; - private PACKET_HEADER _packetHeader; - CLIENT_REPORT_PACKET_HEADER _currentReportHeader; - private CLIENT_REPORT_PACKET_RESPONSE _responsePacket; - - private enum CLIENT_SEND_REPORT_ID - { - PROCESS_MODULE_VERIFICATION = 10, - START_ADDRESS_VERIFICATION = 20, - PAGE_PROTECTION_VERIFICATION = 30, - PATTERN_SCAN_FAILURE = 40, - NMI_CALLBACK_FAILURE = 50, - MODULE_VALIDATION_FAILURE = 60, - ILLEGAL_HANDLE_OPERATION = 70, - INVALID_PROCESS_ALLOCATION = 80, - HIDDEN_SYSTEM_THREAD = 90, - ILLEGAL_ATTACH_PROCESS = 100 - } - - private struct CLIENT_REPORT_PACKET_HEADER - { - public int reportCode; - } - - private struct CLIENT_REPORT_PACKET_RESPONSE - { - public int success; - } - - public ClientReport(ILogger logger, byte[] buffer, int bufferSize, PACKET_HEADER packetHeader) - { - this._logger = logger; - this._buffer = buffer; - this._bufferSize = bufferSize; - this._packetHeader = packetHeader; - this._bytesRead = 0; - this._responsePacket = new CLIENT_REPORT_PACKET_RESPONSE(); - this.GetPacketHeader(); - - _logger.Information("buffer size: {0}", bufferSize); - } - - unsafe public void GetPacketHeader() - { - this._currentReportHeader = - Helper.BytesToStructure(this._buffer, Marshal.SizeOf(typeof(PACKET_HEADER)) + this._bytesRead); - } - - public byte[] GetResponsePacket() - { - return Helper.StructureToBytes(ref this._responsePacket); - } - - private void SetResponsePacketData(int success) - { - this._responsePacket.success = success; - } - - unsafe public bool HandleMessage() - { - if (this._currentReportHeader.reportCode == 0) - { - _logger.Error("Failed to get the report packet code"); - SetResponsePacketData(1); - return false; - } - - while (this._bytesRead < this._bufferSize) - { - this.GetPacketHeader(); - - _logger.Information("Report code: {0}", this._currentReportHeader.reportCode); - - switch (this._currentReportHeader.reportCode) - { - case (int)CLIENT_SEND_REPORT_ID.PROCESS_MODULE_VERIFICATION: - _logger.Information("REPORT CODE: MODULE_VERIFICATION"); - break; - case (int)CLIENT_SEND_REPORT_ID.START_ADDRESS_VERIFICATION: - - _logger.Information("REPORT CODE: START_ADDRESS_VERIFICATION"); - - HandleReportStartAddressVerification(this._bytesRead); - - this._bytesRead += Marshal.SizeOf(typeof(PROCESS_THREAD_START_FAILURE)) + - Marshal.SizeOf(typeof(PACKET_HEADER)); - - break; - - case (int)CLIENT_SEND_REPORT_ID.PAGE_PROTECTION_VERIFICATION: - - _logger.Information("REPORT CODE: PAGE_PROTECTION_VERIFICATION"); - - HandleReportPageProtection(this._bytesRead); - - this._bytesRead += Marshal.SizeOf(typeof(PAGE_PROTECTION_FAILURE)) + - Marshal.SizeOf(typeof(PACKET_HEADER)); - - break; - - case (int)CLIENT_SEND_REPORT_ID.PATTERN_SCAN_FAILURE: - - _logger.Information("REPORT_PATTERN_SCAN_FAILURE"); - - HandleReportPatternScan(this._bytesRead); - - this._bytesRead += Marshal.SizeOf(typeof(PATTERN_SCAN_FAILURE)) + - Marshal.SizeOf(typeof(PACKET_HEADER)); - - - break; - - case (int)CLIENT_SEND_REPORT_ID.NMI_CALLBACK_FAILURE: - - _logger.Information("REPORT_NMI_CALLBACK_FAILURE"); - - HandleReportNmiCallback(this._bytesRead); - - this._bytesRead += Marshal.SizeOf(typeof(NMI_CALLBACK_FAILURE)) + - Marshal.SizeOf(typeof(PACKET_HEADER)); - - - break; - - case (int)CLIENT_SEND_REPORT_ID.MODULE_VALIDATION_FAILURE: - - _logger.Information("REPORT_MODULE_VALIDATION_FAILURE"); - - HandleReportSystemModuleValidation(this._bytesRead); - - this._bytesRead += Marshal.SizeOf(typeof(MODULE_VALIDATION_FAILURE)) + - Marshal.SizeOf(typeof(PACKET_HEADER)); - - break; - - case (int)CLIENT_SEND_REPORT_ID.ILLEGAL_HANDLE_OPERATION: - - _logger.Information("REPORT_ILLEGAL_HANDLE_OPERATION"); - - HandleReportIllegalHandleOperation(this._bytesRead); - - this._bytesRead += Marshal.SizeOf(typeof(OPEN_HANDLE_FAILURE)) + - Marshal.SizeOf(typeof(PACKET_HEADER)); - - break; - - case (int)CLIENT_SEND_REPORT_ID.INVALID_PROCESS_ALLOCATION: - - _logger.Information("REPORT_INVALID_PROCESS_ALLOCATION"); - - HandleReportInvalidProcessAllocation(this._bytesRead); - - this._bytesRead += Marshal.SizeOf(typeof(INVALID_PROCESS_ALLOCATION_FAILURE)) + - Marshal.SizeOf(typeof(PACKET_HEADER)); - - break; - - case (int)CLIENT_SEND_REPORT_ID.HIDDEN_SYSTEM_THREAD: - - _logger.Information("REPORT_HIDDEN_SYSTEM_THREAD"); - - HandleReportHiddenSystemThread(this._bytesRead); - - this._bytesRead += Marshal.SizeOf(typeof(HIDDEN_SYSTEM_THREAD_FAILURE)) + - Marshal.SizeOf(typeof(PACKET_HEADER)); - - break; - - case (int)CLIENT_SEND_REPORT_ID.ILLEGAL_ATTACH_PROCESS: - - _logger.Information("REPORT_ILLEGAL_ATTACH_PROCESS"); - - HandleReportAttachProcess(this._bytesRead); - - this._bytesRead += Marshal.SizeOf(typeof(ATTACH_PROCESS_FAILURE)) + - Marshal.SizeOf(typeof(PACKET_HEADER)); - - - break; - - default: - _logger.Information("Report code not handled yet"); - SetResponsePacketData(0); - return false; - } - } - - SetResponsePacketData(1); - return true; - } - - unsafe public void HandleReportIllegalHandleOperation(int offset) - { - OPEN_HANDLE_FAILURE report = - Helper.BytesToStructure(_buffer, sizeof(PACKET_HEADER) + offset); - - if (report.IsKernelHandle == 0 && - report.ProcessId == 0 && - report.DesiredAccess == 0) - { - return; - } - - _logger.Information("ProcessName: {0}, ProcessID: {1:x}, ThreadId: {2:x}, DesiredAccess{3:x}", - report.ProcessName, - report.ProcessId, - report.ThreadId, - report.DesiredAccess); - - using (var context = new ModelContext()) - { - /* - * This doesn't seem to be the most optimal way to do this, but it works.. - * Maybe look into it further at somepoint.. - */ - UserEntity user = new UserEntity(context); - - var newReport = new ReportEntity(context) - { - User = user.GetUserBySteamId(this._packetHeader.steam64_id), - ReportCode = (int)CLIENT_SEND_REPORT_ID.ILLEGAL_HANDLE_OPERATION - }; - - newReport.InsertReport(); - - var reportTypeIllegalHandleOperation = new ReportTypeIllegalHandleOperationEntity(context) - { - Report = newReport, - IsKernelHandle = report.IsKernelHandle, - ProcessId = report.ProcessId, - ThreadId = report.ThreadId, - DesiredAccess = report.DesiredAccess, - ProcessName = report.ProcessName - }; - - reportTypeIllegalHandleOperation.InsertReport(); - - context.SaveChanges(); - } - } - - unsafe public void HandleReportStartAddressVerification(int offset) - { - PROCESS_THREAD_START_FAILURE report = - Helper.BytesToStructure(_buffer, sizeof(PACKET_HEADER) + offset); - - if (report.ThreadId == 0 && - report.StartAddress == 0) - { - return; - } - - _logger.Information("ThreadId: {0}, ThreadStartAddress: {1:x}", - report.ThreadId, - report.StartAddress); - - using (var context = new ModelContext()) - { - UserEntity user = new UserEntity(context); - - var newReport = new ReportEntity(context) - { - User = user.GetUserBySteamId(this._packetHeader.steam64_id), - ReportCode = (int)CLIENT_SEND_REPORT_ID.START_ADDRESS_VERIFICATION - }; - - newReport.InsertReport(); - - var reportTypeStartAddress = new StartAddressEntity(context) - { - Report = newReport, - ThreadId = report.ThreadId, - ThreadStartAddress = report.StartAddress - }; - - reportTypeStartAddress.InsertReport(); - - context.SaveChanges(); - } - } - - unsafe public void HandleReportPageProtection(int offset) - { - PAGE_PROTECTION_FAILURE report = - Helper.BytesToStructure(_buffer, sizeof(PACKET_HEADER) + offset); - - if (report.AllocationProtection == 0 && - report.PageBaseAddress == 0 && - report.AllocationState == 0 && - report.AllocationType == 0 ) - { - return; - } - - _logger.Information("Page base address: {0:x}, allocation protection: {1:x}, allocation state: {2:x}, allocationtype: {3:x}", - report.PageBaseAddress, - report.AllocationProtection, - report.AllocationState, - report.AllocationType); - - using (var context = new ModelContext()) - { - UserEntity user = new UserEntity(context); - - var newReport = new ReportEntity(context) - { - User = user.GetUserBySteamId(this._packetHeader.steam64_id), - ReportCode = (int)CLIENT_SEND_REPORT_ID.PAGE_PROTECTION_VERIFICATION - }; - - newReport.InsertReport(); - - var reportTypePageProtection = new PageProtectionEntity(context) - { - Report = newReport, - PageBaseAddress = report.PageBaseAddress, - AllocationProtection = report.AllocationProtection, - AllocationState = report.AllocationState, - AllocationType = report.AllocationType - }; - - reportTypePageProtection.InsertReport(); - - context.SaveChanges(); - } - } - - unsafe public void HandleReportPatternScan(int offset) - { - PATTERN_SCAN_FAILURE report = - Helper.BytesToStructure(_buffer, sizeof(PACKET_HEADER) + offset); - - if (report.Address == 0 && - report.SignatureId == 0) - { - return; - } - - _logger.Information("signature id: {0}, address: {1:x}", - report.SignatureId, - report.Address); - - using (var context = new ModelContext()) - { - UserEntity user = new UserEntity(context); - - var newReport = new ReportEntity(context) - { - User = user.GetUserBySteamId(this._packetHeader.steam64_id), - ReportCode = (int)CLIENT_SEND_REPORT_ID.PATTERN_SCAN_FAILURE - }; - - newReport.InsertReport(); - - var reportTypePatternScan = new PatternScanEntity(context) - { - Report = newReport, - SignatureId = report.SignatureId, - Address = report.Address - }; - - reportTypePatternScan.InsertReport(); - - context.SaveChanges(); - } - } - - unsafe public void HandleReportNmiCallback(int offset) - { - NMI_CALLBACK_FAILURE report = - Helper.BytesToStructure(_buffer, sizeof(PACKET_HEADER) + offset); - - if (report.InvalidRip == 0 && - report.WereNmisDisabled == 0 && - report.KThreadAddress == 0) - { - return; - } - - _logger.Information("were nmis disabled: {0}, kthread: {1:x}, invalid rip: {2:x}", - report.WereNmisDisabled, - report.KThreadAddress, - report.InvalidRip); - - using (var context = new ModelContext()) - { - UserEntity user = new UserEntity(context); - - var newReport = new ReportEntity(context) - { - User = user.GetUserBySteamId(this._packetHeader.steam64_id), - ReportCode = (int)CLIENT_SEND_REPORT_ID.NMI_CALLBACK_FAILURE - }; - - newReport.InsertReport(); - - var reportTypeNmiCallback = new NmiCallbackEntity(context) - { - Report = newReport, - WereNmisDisabled = report.WereNmisDisabled, - KThreadAddress = report.KThreadAddress, - InvalidRip = report.InvalidRip - }; - - reportTypeNmiCallback.InsertReport(); - - context.SaveChanges(); - } - } - - unsafe public void HandleReportSystemModuleValidation(int offset) - { - MODULE_VALIDATION_FAILURE report = - Helper.BytesToStructure(_buffer, sizeof(PACKET_HEADER) + offset); - - if (report.ReportType == 0 && - report.ReportCode == 0 && - report.DriverSize == 0 && - report.DriverBaseAddress == 0) - { - return; - } - - _logger.Information("report type: {0}, driver base: {1:x}, size: {2}, module name: {3}", - report.ReportType, - report.DriverBaseAddress, - report.DriverSize, - report.ModuleName); - - using (var context = new ModelContext()) - { - UserEntity user = new UserEntity(context); - - var newReport = new ReportEntity(context) - { - User = user.GetUserBySteamId(this._packetHeader.steam64_id), - ReportCode = (int)CLIENT_SEND_REPORT_ID.MODULE_VALIDATION_FAILURE - }; - - newReport.InsertReport(); - - var reportTypeSystemModuleValidation = new SystemModuleValidationEntity(context) - { - Report = newReport, - ReportType = report.ReportType, - DriverBaseAddress = report.DriverBaseAddress, - DriverSize = report.DriverSize, - ModuleName = report.ModuleName - }; - - reportTypeSystemModuleValidation.InsertReport(); - - context.SaveChanges(); - } - } - - unsafe public void HandleReportHiddenSystemThread(int offset) - { - HIDDEN_SYSTEM_THREAD_FAILURE report = - Helper.BytesToStructure(_buffer, sizeof(PACKET_HEADER) + offset); - - /* todo: some weird reference bug here */ - - if (report.FoundInPspCidTable == 0 && - report.FoundInKThreadList == 0 && - report.ThreadId == 0 && - report.ThreadAddress == 0) - { - return; - } - - _logger.Information("found in kthread list: {0}, found in pspcidtable: {1}, thread address: {2:x}, thread id: {3:x}", - report.FoundInKThreadList, - report.FoundInPspCidTable, - report.ThreadAddress, - report.ThreadId); - - using (var context = new ModelContext()) - { - UserEntity user = new UserEntity(context); - - var newReport = new ReportEntity(context) - { - User = user.GetUserBySteamId(this._packetHeader.steam64_id), - ReportCode = (int)CLIENT_SEND_REPORT_ID.HIDDEN_SYSTEM_THREAD - }; - - newReport.InsertReport(); - - var reportTypeHiddenSystemThread = new HiddenSystemThreadEntity(context) - { - Report = newReport, - FoundInKThreadList = report.FoundInKThreadList, - FoundInPspCidTable = report.FoundInPspCidTable, - ThreadAddress = report.ThreadAddress, - ThreadId = report.ThreadId, - ThreadStructure = report.ThreadStructure - }; - - reportTypeHiddenSystemThread.InsertReport(); - - context.SaveChanges(); - } - } - - unsafe public void HandleReportAttachProcess(int offset) - { - ATTACH_PROCESS_FAILURE report = - Helper.BytesToStructure(_buffer, sizeof(PACKET_HEADER) + offset); - - if (report.ThreadAddress == 0 && - report.ThreadId == 0) - { - return; - } - - _logger.Information("thread id: {0:x}, thread address: {1:x}", - report.ThreadId, - report.ThreadAddress); - - using (var context = new ModelContext()) - { - UserEntity user = new UserEntity(context); - - var newReport = new ReportEntity(context) - { - User = user.GetUserBySteamId(this._packetHeader.steam64_id), - ReportCode = (int)CLIENT_SEND_REPORT_ID.ILLEGAL_ATTACH_PROCESS - }; - - newReport.InsertReport(); - - var reportTypeAttachProcess = new AttachProcessEntity(context) - { - Report = newReport, - ThreadId = report.ThreadId, - ThreadAddress = report.ThreadAddress, - }; - - reportTypeAttachProcess.InsertReport(); - - context.SaveChanges(); - } - } - - unsafe public void HandleReportInvalidProcessAllocation(int offset) - { - INVALID_PROCESS_ALLOCATION_FAILURE report = - Helper.BytesToStructure(_buffer, sizeof(PACKET_HEADER) + offset); - - if (report.Equals(null)) { return; } - - if (report.ReportCode == 0 && - report.ProcessStructure.Length == 0) - { - return; - } - - _logger.Information("received invalid process allocation structure"); - - using (var context = new ModelContext()) - { - UserEntity user = new UserEntity(context); - - var newReport = new ReportEntity(context) - { - User = user.GetUserBySteamId(this._packetHeader.steam64_id), - ReportCode = (int)CLIENT_SEND_REPORT_ID.INVALID_PROCESS_ALLOCATION - }; - - newReport.InsertReport(); - - var reportTypeInvalidProcessAllocation = new InvalidProcessAllocationEntity(context) - { - Report = newReport, - ProcessStructure = report.ProcessStructure - }; - - reportTypeInvalidProcessAllocation.InsertReport(); - - context.SaveChanges(); - } - } - } -} diff --git a/server/Message/ClientRequest.cs b/server/Message/ClientRequest.cs deleted file mode 100644 index 100627c..0000000 --- a/server/Message/ClientRequest.cs +++ /dev/null @@ -1,53 +0,0 @@ -using Serilog; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; -using static server.Message.MessageHandler; - -namespace server.Message -{ - public class ClientRequest : IClientMessage - { - private readonly ILogger _logger; - private byte[] _buffer; - private int _bufferSize; - private CLIENT_REQUEST_HEADER _header; - - private enum CLIENT_REQUEST_ID - { - BLACKLISTED_SIGNATURES = 10, - WINDOWS_VERSION_STRUCTURE_OFFSETS = 20 - } - - private struct CLIENT_REQUEST_HEADER - { - public int RequestId; - } - - public ClientRequest(ILogger logger, ref byte[] buffer, int bufferSize) - { - this._logger = logger; - this._buffer = buffer; - this._bufferSize = bufferSize; - } - - public bool HandleMessage() - { - throw new NotImplementedException(); - } - - public unsafe void GetPacketHeader() - { - this._header = - Helper.BytesToStructure(this._buffer, Marshal.SizeOf(typeof(PACKET_HEADER))); - } - - public byte[] GetResponsePacket() - { - throw new NotImplementedException(); - } - } -} diff --git a/server/Message/ClientSend.cs b/server/Message/ClientSend.cs deleted file mode 100644 index 6fc3b0d..0000000 --- a/server/Message/ClientSend.cs +++ /dev/null @@ -1,157 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection.PortableExecutable; -using System.Text; -using System.Threading.Tasks; -using Serilog; -using server.Database.Entity; -using server.Database.Model; -using server.Types.ClientSend; -using static server.Message.MessageHandler; - -namespace server.Message -{ - public class ClientSend : IClientMessage - { - private readonly ILogger _logger; - private byte[] _buffer; - private int _bufferSize; - private int _sendId; - private PACKET_HEADER _packetHeader; - private CLIENT_SEND_PACKET_HEADER _clientSendPacketHeader; - private CLIENT_SEND_PACKET_RESPONSE _responsePacket; - - private enum CLIENT_SEND_REQUEST_ID - { - SYSTEM_INFORMATION = 10 - } - - private struct CLIENT_SEND_PACKET_HEADER - { - public int RequestId; - public int PacketSize; - }; - - private struct CLIENT_SEND_PACKET_RESPONSE - { - public int RequestId; - public int CanUserProceed; - public int reason; - } - - public ClientSend(ILogger logger, ref byte[] buffer, int bufferSize, PACKET_HEADER packetHeader) - { - this._logger = logger; - this._buffer = buffer; - this._bufferSize = bufferSize; - this._packetHeader = packetHeader; - this._responsePacket = new CLIENT_SEND_PACKET_RESPONSE(); - this.GetPacketHeader(); - } - - unsafe public void GetPacketHeader() - { - this._clientSendPacketHeader = - Helper.BytesToStructure(_buffer, sizeof(PACKET_HEADER)); - } - - public byte[] GetResponsePacket() - { - return Helper.StructureToBytes(ref this._responsePacket); - } - - public bool HandleMessage() - { - if (this._clientSendPacketHeader.RequestId == 0) - { - _logger.Error("Failed to get the client send report code"); - return false; - } - - switch (this._clientSendPacketHeader.RequestId) - { - case (int)CLIENT_SEND_REQUEST_ID.SYSTEM_INFORMATION: - HandleClientSendHardwareInformation(this._clientSendPacketHeader); - break; - } - - return true; - } - - unsafe private void HandleClientSendHardwareInformation(CLIENT_SEND_PACKET_HEADER sendPacketHeader) - { - _logger.Information("Handling client send hardware information"); - - PACKET_CLIENT_HARDWARE_INFORMATION info = - Helper.BytesToStructure( - _buffer, sizeof(PACKET_HEADER) + sizeof(CLIENT_SEND_PACKET_HEADER)); - - _logger.Information("SteamId: {0}, Mobo Serial: {1}, drive serial: {2}", - this._packetHeader.steam64_id, - info.MotherboardSerialNumber, - info.DeviceDriver0Serial); - - using (var context = new ModelContext()) - { - context.Database.EnsureCreated(); - - var user = new UserEntity(context) - { - Steam64Id = this._packetHeader.steam64_id - }; - - var hardwareConfiguration = new HardwareConfigurationEntity(context) - { - DeviceDrive0Serial = info.DeviceDriver0Serial, - MotherboardSerial = info.MotherboardSerialNumber, - }; - - if (user.CheckIfUserExists()) - { - if (user.CheckIfUserIsBanned()) - { - _logger.Information("User is banned, updating response packet to halt client."); - SetResponsePacketData(0, sendPacketHeader.RequestId, (int)USER_BAN_REASONS.USER_BAN); - return; - } - - hardwareConfiguration.User = user.GetUserBySteamId(this._packetHeader.steam64_id); - } - else - { - _logger.Information("User does not exist in database, creating new user."); - user.InsertUser(); - hardwareConfiguration.User = user; - } - - if (hardwareConfiguration.CheckIfHardwareIsBanned()) - { - _logger.Information("User is hardware banned, updating response packet to halt client."); - SetResponsePacketData(0, sendPacketHeader.RequestId, (int)USER_BAN_REASONS.HARDWARE_BAN); - return; - } - - if (user.CheckIfUsersHardwareExists()) - { - _logger.Information("Users hardware already references the user."); - SetResponsePacketData(1, sendPacketHeader.RequestId, 0); - return; - } - - _logger.Information("Users hardware does not existing, inserting hardware."); - hardwareConfiguration.InsertHardwareConfiguration(); - SetResponsePacketData(1, sendPacketHeader.RequestId, 0); - - context.SaveChanges(); - } - } - - private void SetResponsePacketData(int canUserProceed, int requestId, int reason) - { - this._responsePacket.CanUserProceed = canUserProceed; - this._responsePacket.RequestId = requestId; - this._responsePacket.reason = reason; - } - } -} diff --git a/server/Message/IClientMessage.cs b/server/Message/IClientMessage.cs deleted file mode 100644 index fd3a00f..0000000 --- a/server/Message/IClientMessage.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace server.Message -{ - public interface IClientMessage - { - /// - /// Implements a function that returns the packet header for the type of client - /// message it is handling. Is an unsafe function because we are taking the - /// size of struct which makes c# unhappy. - /// - unsafe void GetPacketHeader(); - /// - /// Function which implements the core logic to handle a message received from - /// the client. Should take care of all major actions when handling the message. - /// - bool HandleMessage(); - /// - /// Function that returns the response packet in the form of a byte array. - /// - byte[] GetResponsePacket(); - - } -} diff --git a/server/Message/MessageHandler.cs b/server/Message/MessageHandler.cs deleted file mode 100644 index d664c95..0000000 --- a/server/Message/MessageHandler.cs +++ /dev/null @@ -1,108 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection.Metadata.Ecma335; -using System.Runtime.CompilerServices; -using System.Text; -using System.Threading.Tasks; -using Serilog; -using System.Net; -using System.Net.Sockets; -using server.Types.ClientReport; -using server.Types.ClientSend; -using System.Runtime.InteropServices; -using server.Database.Model; -using server.Database.Entity; -using Org.BouncyCastle.Asn1.BC; -using Org.BouncyCastle.Asn1.Ocsp; - -namespace server.Message -{ - public class MessageHandler - { - private byte[] _buffer; - private int _bufferSize; - private ILogger _logger; - private PACKET_HEADER _header; - private NetworkStream _networkStream; - private TcpClient _tcpClient; - - private enum MESSAGE_TYPE - { - MESSAGE_TYPE_CLIENT_REPORT = 1, - MESSAGE_TYPE_CLIENT_SEND = 2, - MESSAGE_TYPE_CLIENT_REQUEST = 3 - } - - public struct PACKET_HEADER - { - public int message_type; - public ulong steam64_id; - }; - - private struct PACKET_REQUEST_HEADER - { - public int RequestId; - } - - public MessageHandler(TcpClient client, byte[] buffer, int bufferSize, ILogger logger) - { - _tcpClient = client; - _networkStream = client.GetStream(); - _buffer = buffer; - _bufferSize = bufferSize; - _logger = logger; - _header = GetMessageHeader(); - - switch (_header.message_type) - { - case (int)MESSAGE_TYPE.MESSAGE_TYPE_CLIENT_REPORT: - HandleClientSendReport(); - break; - case (int)MESSAGE_TYPE.MESSAGE_TYPE_CLIENT_SEND: - HandleClientSendMessage(); - break; - default: - _logger.Information("This message type is not accepted at the moment."); - break; - } - } - - private void HandleClientSendReport() - { - ClientReport report = new ClientReport(_logger, _buffer, _bufferSize, _header); - - if (report.HandleMessage()) - { - byte[] reponsePacket = report.GetResponsePacket(); - this.SendResponsePacketToClient(reponsePacket); - return; - } - - _logger.Warning("Failed to handle client sent report"); - } - - private void HandleClientSendMessage() - { - ClientSend send = new ClientSend(_logger, ref _buffer, _bufferSize, _header); - - if (send.HandleMessage()) - { - byte[] responsePacket = send.GetResponsePacket(); - this.SendResponsePacketToClient(responsePacket); - return; - } - - _logger.Warning("Failed to handle client send message"); - } - private PACKET_HEADER GetMessageHeader() - { - return Helper.BytesToStructure(_buffer, 0); - } - - private void SendResponsePacketToClient(byte[] responsePacket) - { - _networkStream.Write(responsePacket, 0, responsePacket.Length); - } - } -} diff --git a/server/Program.cs b/server/Program.cs deleted file mode 100644 index c7a346f..0000000 --- a/server/Program.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Serilog; -using server.Database; -using server.Database.Entity; -using server.Database.Model; -using System.Configuration; -using System.Net; -using System.Net.Sockets; -using System.Reflection.Metadata.Ecma335; -using System.Text; - -namespace server -{ - public class Program - { - public static async Task Main(string[] args) - { - using var logger = new LoggerConfiguration() - .WriteTo.Console() - .CreateLogger(); - - Server server = new Server(logger); - await server.Listen(); - } - } -} \ No newline at end of file diff --git a/server/Server.cs b/server/Server.cs deleted file mode 100644 index 65648b5..0000000 --- a/server/Server.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System.IO; -using System; -using System.Net; -using System.Net.Sockets; -using System.Reflection.Metadata.Ecma335; -using System.Text; -using Serilog; -using server.Message; -using Microsoft.EntityFrameworkCore.Metadata.Conventions; -using K4os.Compression.LZ4.Streams.Adapters; - -namespace server -{ - public class Server - { - private IPEndPoint _ipEndPoint; - private TcpListener _tcpListener; - private ILogger _logger; - - public Server(ILogger logger) - { - _ipEndPoint = new IPEndPoint(IPAddress.Any, 8888); - _tcpListener = new TcpListener(_ipEndPoint); - _logger = logger; - } - - public async Task Listen() - { - _tcpListener.Start(); - - _logger.Information("Listening for incoming connections..."); - - while (true) - { - TcpClient client = await _tcpListener.AcceptTcpClientAsync(); - - NetworkStream _stream = client.GetStream(); - TcpClient clientReference = client; - - byte[] buffer = new byte[2048]; - int bytesRead = 0; - - using (MemoryStream stream = new MemoryStream()) - { - while (_stream.DataAvailable) - { - bytesRead = _stream.Read(buffer, 0, buffer.Length); - - _logger.Information("bytes read: {0}", bytesRead); - - stream.Write(buffer, 0, bytesRead); - } - - byte[] message = stream.ToArray(); - - if (message.Length == 0) - { - _logger.Error("Null message received at server"); - continue; - } - - ThreadPool.QueueUserWorkItem(state => DispatchMessage(state, clientReference, message, message.Length)); - } - } - } - - private void DispatchMessage(Object? stateInfo, TcpClient client, byte[] buffer, int bufferSize) - { - MessageHandler message = new MessageHandler(client, buffer, bufferSize, _logger); - } - } -} \ No newline at end of file diff --git a/server/Types.cs b/server/Types.cs deleted file mode 100644 index 66a02c0..0000000 --- a/server/Types.cs +++ /dev/null @@ -1,134 +0,0 @@ -using Org.BouncyCastle.Utilities; -using Serilog; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Numerics; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; - -namespace server -{ - namespace Types - { - namespace ClientSend - { - struct CLIENT_SEND_PACKET_HEADER - { - public int RequestId; - public int PacketSize; - }; - - public enum USER_BAN_REASONS - { - HARDWARE_BAN = 10, - USER_BAN = 20 - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public unsafe struct PACKET_CLIENT_HARDWARE_INFORMATION - { - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] - public string MotherboardSerialNumber; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] - public string DeviceDriver0Serial; - } - } - - namespace ClientReport - { - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public unsafe struct PROCESS_MODULE_INTEGRITY_CHECK_FAILURE - { - public int ReportCode; - public UInt64 ModuleBaseAddress; - public int ModuleSize; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] - public string ModuleName; - } - - public struct PROCESS_THREAD_START_FAILURE - { - public int ReportCode; - public int ThreadId; - public long StartAddress; - } - - public struct PAGE_PROTECTION_FAILURE - { - public int ReportCode; - public UInt64 PageBaseAddress; - public long AllocationProtection; - public long AllocationState; - public long AllocationType; - } - - public struct PATTERN_SCAN_FAILURE - { - public int ReportCode; - public int SignatureId; - public UInt64 Address; - } - - public struct NMI_CALLBACK_FAILURE - { - public int ReportCode; - public int WereNmisDisabled; - public UInt64 KThreadAddress; - public UInt64 InvalidRip; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public unsafe struct MODULE_VALIDATION_FAILURE - { - public int ReportCode; - public int ReportType; - public long DriverBaseAddress; - public long DriverSize; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] - public string ModuleName; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public unsafe struct OPEN_HANDLE_FAILURE - { - public int ReportCode; - public int IsKernelHandle; - public uint ProcessId; - public uint ThreadId; - public uint DesiredAccess; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] - public string ProcessName; - - } - - [StructLayout(LayoutKind.Sequential)] - public unsafe struct INVALID_PROCESS_ALLOCATION_FAILURE - { - public int ReportCode; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4096)] - public byte[] ProcessStructure; - } - - [StructLayout(LayoutKind.Sequential)] - public struct HIDDEN_SYSTEM_THREAD_FAILURE - { - public int ReportCode; - public int FoundInKThreadList; - public int FoundInPspCidTable; - public long ThreadAddress; - public int ThreadId; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4096)] - public byte[] ThreadStructure; - } - - public struct ATTACH_PROCESS_FAILURE - { - public int ReportCode; - public int ThreadId; - public long ThreadAddress; - } - } - } -} diff --git a/server/main.go b/server/main.go new file mode 100644 index 0000000..a3dd973 --- /dev/null +++ b/server/main.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("Hello, World!") +} diff --git a/server/server.csproj b/server/server.csproj deleted file mode 100644 index 190a6e2..0000000 --- a/server/server.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - Exe - net7.0 - enable - enable - True - Debug;Release;Release - No Server;Release - No Server - Win11 - - - - - - - - - - - - - - - - diff --git a/service/Client.cs b/service/Client.cs deleted file mode 100644 index 47c1c68..0000000 --- a/service/Client.cs +++ /dev/null @@ -1,65 +0,0 @@ -using Microsoft.AspNetCore.Authentication.OAuth.Claims; -using System.Net; -using System.Net.Sockets; -using System.Text; -using Serilog; -using Microsoft.AspNetCore.Http; -using System.Linq.Expressions; - -namespace service -{ - public class Client - { - private readonly Serilog.ILogger _logger; - private IPEndPoint _ipEndPoint; - private TcpClient _tcpClient; - private NetworkStream _stream; - private byte[] _buffer; - private int _bufferSize; - - public Client(ref byte[] buffer, int bufferSize, Serilog.ILogger logger) - { - _logger = logger; - _ipEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8888); - _tcpClient = new TcpClient(); - _tcpClient.Connect(_ipEndPoint); - _stream = _tcpClient.GetStream(); - _buffer = buffer; - _bufferSize = bufferSize; - } - - public void SendMessageToServer() - { - try - { - _stream.Write(_buffer, 0, _bufferSize); - } - catch(Exception ex) - { - _logger.Error("{0}", ex.Message); - } - } - - public byte[]? GetResponseFromServer() - { - byte[] buffer = new byte[1024]; - - try - { - using (MemoryStream memoryStream = new MemoryStream()) - { - int bytesRead = _stream.Read(buffer, 0, 1024); - - memoryStream.Write(buffer, 0, bytesRead); - - return memoryStream.ToArray(); - } - } - catch(Exception ex) - { - _logger.Error("{0}", ex.Message); - return null; - } - } - } -} \ No newline at end of file diff --git a/service/Program.cs b/service/Program.cs deleted file mode 100644 index c595904..0000000 --- a/service/Program.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Serilog; - -namespace service -{ - public class Program - { - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .UseWindowsService() - .ConfigureServices((hostContext, services) => - { - services.AddHostedService(); - }) - .UseSerilog((context, configuration) => - { - var config = context.Configuration; - configuration.ReadFrom.Configuration(config); - }); - } -} \ No newline at end of file diff --git a/service/Properties/launchSettings.json b/service/Properties/launchSettings.json deleted file mode 100644 index aea80af..0000000 --- a/service/Properties/launchSettings.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "profiles": { - "service": { - "commandName": "Project", - "dotnetRunMessages": true, - "environmentVariables": { - "DOTNET_ENVIRONMENT": "Development" - } - } - } -} diff --git a/service/Worker.cs b/service/Worker.cs deleted file mode 100644 index e35fb9d..0000000 --- a/service/Worker.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System.IO.Pipes; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System; -using System.Reflection.PortableExecutable; -using System.Net.Sockets; -using System.Net; -using System.Net.Http; -using Serilog; - -#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously -#pragma warning disable CS8600 -#pragma warning disable CS8603 - -namespace service -{ - public class Worker : BackgroundService - { - private readonly Serilog.ILogger _logger; - private NamedPipeServerStream _pipeServer; - private byte[] _buffer; - private int _bufferSize; - private static int MAX_BUFFER_SIZE = 8192; - - private static int OK_RESPONSE_SIZE = 4; - - public Worker(Serilog.ILogger logger) - { - _logger = logger; - - _pipeServer = new NamedPipeServerStream( - "DonnaACPipe", - PipeDirection.InOut, - 1, - 0, - PipeOptions.Asynchronous, - MAX_BUFFER_SIZE, - MAX_BUFFER_SIZE); - - _bufferSize = MAX_BUFFER_SIZE; - _buffer = new byte[_bufferSize]; - } - - protected override async Task ExecuteAsync(CancellationToken stoppingToken) - { - _logger.Information("Windows service starting, waiting for client to connect"); - - // to do: verify whos connecting - _pipeServer.WaitForConnection(); - - _logger.Information("Client connected to the pipe server"); - - while (!stoppingToken.IsCancellationRequested) - { - try - { - int numBytesRead = _pipeServer.Read(_buffer, 0, _bufferSize); - - if (numBytesRead > 0) - { - _logger.Information("Message received at pipe server with size: {0}", numBytesRead); - - Client message = new Client(ref _buffer, numBytesRead, _logger); - - message.SendMessageToServer(); - - ThreadPool.QueueUserWorkItem(state => RelayResponseMessage(ref message)); - } - } - catch (Exception ex) - { - _logger.Error("Reading buffer from pipe failed with message: {0}", ex.Message); - } - - Array.Clear(_buffer, 0, _bufferSize); - } - } - - private void RelayResponseMessage(ref Client message) - { - byte[] responseMessage = message.GetResponseFromServer(); - - if (responseMessage == null) - { - _logger.Warning("Response message is null"); - return; - } - - _logger.Information("Sending response message to client with size: {0}", responseMessage.Length); - - _pipeServer.Write(responseMessage, 0, responseMessage.Length); - } - - [DllImport("kernel32.dll", SetLastError = true)] - internal static extern bool GetNamedPipeClientProcessId(IntPtr Pipe, out uint ClientProcessId); - public static uint GetNamedPipeClientProcId(NamedPipeServerStream PipeServer) - { - UInt32 procId; - IntPtr pipeHandle = PipeServer.SafePipeHandle.DangerousGetHandle(); - - if (GetNamedPipeClientProcessId(pipeHandle, out procId)) - return procId; - - return 0; - } - } -} -#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously -#pragma warning restore CS8600 -#pragma warning restore CS8603 \ No newline at end of file diff --git a/service/appsettings.Development.json b/service/appsettings.Development.json deleted file mode 100644 index b2dcdb6..0000000 --- a/service/appsettings.Development.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.Hosting.Lifetime": "Information" - } - } -} diff --git a/service/appsettings.json b/service/appsettings.json deleted file mode 100644 index 951f5ac..0000000 --- a/service/appsettings.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "AllowedHosts": "*", - "Serilog": { - "MinimumLevel": "Debug", - "Override": { - "Microsoft.AspNetCore": "Warning" - }, - "WriteTo": [ - { - "Name": "Console" - }, - { - "Name": "File", - "Args": { - "path": "bin/logs.txt", - "rollingInterval": "Day" - } - } - ] - } -} \ No newline at end of file diff --git a/service/helper.cs b/service/helper.cs deleted file mode 100644 index f613b94..0000000 --- a/service/helper.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Serilog; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; - -#pragma warning disable CS8600 -#pragma warning disable CS8603 - -namespace service -{ - public class Helper - { - unsafe public static T BytesToStructure(byte[] buffer, int offset) - { - int typeSize = Marshal.SizeOf(typeof(T)); - - if (buffer.Length == 0) - return default(T); - - IntPtr ptr = Marshal.AllocHGlobal(typeSize); - - try - { - Marshal.Copy(buffer, offset, ptr, typeSize); - T result = (T)Marshal.PtrToStructure(ptr, typeof(T)); - Marshal.FreeHGlobal(ptr); - return result; - } - catch (Exception ex) - { - Log.Information(ex.Message); - return default(T); - } - } - } -} - -#pragma warning restore CS8600 -#pragma warning restore CS8603 \ No newline at end of file diff --git a/service/service.csproj b/service/service.csproj deleted file mode 100644 index f22dfdd..0000000 --- a/service/service.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - net7.0 - enable - enable - dotnet-service-ab667d6f-8728-45a8-a87c-ae511852674a - true - Debug;Release;Release - No Server;Release - No Server - Win11 - - - - - - - - - - - - - diff --git a/test/cli/driver.h b/test/cli/driver.h deleted file mode 100644 index 21ae7f5..0000000 --- a/test/cli/driver.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -#include -#include - -#include - -class DriverInterface -{ - HANDLE driver_handle; - - bool validate_process_name() - { - - } - -public: - DriverInterface(std::string& process_name) - { - this->driver_handle = CreateFileW( - L"donna-ac-test", - GENERIC_WRITE | GENERIC_READ | GENERIC_EXECUTE, - 0, - 0, - OPEN_EXISTING, - FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, - 0 - ); - - if (this->driver_handle == INVALID_HANDLE_VALUE) - { - std::cerr << "Failed to open handle to driver" << std::endl; - return; - } - - - } -}; \ No newline at end of file diff --git a/test/cli/main.cpp b/test/cli/main.cpp deleted file mode 100644 index 40b39d9..0000000 --- a/test/cli/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include -#include -#include - -#include -#include - -std::wstring cstr_to_wstr(std::string cstr) -{ - return std::wstring(cstr.begin(), cstr.end()); -} - -DWORD get_proc_id_by_name(const std::string& process_name) -{ - PROCESSENTRY32 entry = { 0 }; - entry.dwSize = sizeof(PROCESSENTRY32); - - HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - - while (Process32Next(snapshot, &entry)) - { - if (entry.szExeFile == cstr_to_wstr(process_name)) - { - return entry.th32ProcessID; - } - } - - CloseHandle(snapshot); - - return 0; -} - -int main(int argc, char* argv[]) -{ - if (argc < 2) - { - std::cerr << "Please enter a valid Process Name"; - return EXIT_FAILURE; - } - - const std::vector args(argv + 1, argv + argc); - - std::string process_name = std::string(args[0].data()); - - DWORD proc_id = get_proc_id_by_name(process_name); - - if (!proc_id) - { - std::cerr << "Process does not exist, please enter a valid running process name." << std::endl; - return EXIT_FAILURE; - } - - - - return EXIT_SUCCESS; -} \ No newline at end of file diff --git a/test/cli/testcli.vcxproj b/test/cli/testcli.vcxproj deleted file mode 100644 index d1137d5..0000000 --- a/test/cli/testcli.vcxproj +++ /dev/null @@ -1,201 +0,0 @@ - - - - - Debug - Win32 - - - Release - No Server - Win32 - - - Release - No Server - x64 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 17.0 - Win32Proj - {bb9e4b6e-81e3-4d39-8928-0ba3f947c479} - testcli - 10.0 - - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - Application - false - v143 - true - Unicode - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - Application - false - v143 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpp17 - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpp17 - - - Console - true - true - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpp17 - - - Console - true - true - true - - - - - - - - - - - - \ No newline at end of file diff --git a/test/cli/testcli.vcxproj.filters b/test/cli/testcli.vcxproj.filters deleted file mode 100644 index 3aecf20..0000000 --- a/test/cli/testcli.vcxproj.filters +++ /dev/null @@ -1,27 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - - - Header Files - - - \ No newline at end of file diff --git a/test/driver/common.hpp b/test/driver/common.hpp deleted file mode 100644 index 8dfd8da..0000000 --- a/test/driver/common.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#include - -#define STATIC static -#define VOID void - -typedef UINT32 uint32_t; -typedef UINT64 uint64_t; -typedef UINT16 uint16_t; - -#define DEBUG_LOG(fmt, ...) ImpDbgPrintEx(DPFLTR_IHVDRIVER_ID, 0, "[+] " fmt "\n", ##__VA_ARGS__) -#define DEBUG_ERROR(fmt, ...) ImpDbgPrintEx(DPFLTR_IHVDRIVER_ID, 0, "[-] " fmt "\n", ##__VA_ARGS__) \ No newline at end of file diff --git a/test/driver/driver.hpp b/test/driver/driver.hpp deleted file mode 100644 index 71b5aa6..0000000 --- a/test/driver/driver.hpp +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -#include "common.hpp" \ No newline at end of file diff --git a/test/driver/framework.hpp b/test/driver/framework.hpp deleted file mode 100644 index ed0da6b..0000000 --- a/test/driver/framework.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "common.hpp" - -namespace framework -{ - class state - { - - }; -} \ No newline at end of file diff --git a/test/driver/main.cpp b/test/driver/main.cpp deleted file mode 100644 index c44af6e..0000000 --- a/test/driver/main.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "driver.hpp" - -UNICODE_STRING DRIVER_NAME = RTL_CONSTANT_STRING(L"donna-ac-test"); -UNICODE_STRING DRIVER_LINK = RTL_CONSTANT_STRING(L"donna-ac-test-link"); - -#define IOCTL_RUN_NMI_CALLBACKS \ - CTL_CODE(FILE_DEVICE_UNKNOWN, 0x20001, METHOD_BUFFERED, FILE_ANY_ACCESS) - -NTSTATUS -DeviceControl(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp) { - UNREFERENCED_PARAMETER(DeviceObject); - - NTSTATUS status = STATUS_SUCCESS; - PIO_STACK_LOCATION stack_location = IoGetCurrentIrpStackLocation(Irp); - - switch (stack_location->Parameters.DeviceIoControl.IoControlCode) {} -end: - Irp->IoStatus.Status = status; - IoCompleteRequest(Irp, IO_NO_INCREMENT); - return status; -} - -NTSTATUS -DeviceClose(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp) { - UNREFERENCED_PARAMETER(DeviceObject); - IoCompleteRequest(Irp, IO_NO_INCREMENT); - return Irp->IoStatus.Status; -} - -NTSTATUS -DeviceCreate(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp) { - UNREFERENCED_PARAMETER(DeviceObject); - IoCompleteRequest(Irp, IO_NO_INCREMENT); - return Irp->IoStatus.Status; -} - -STATIC -VOID DriverUnload(_In_ PDRIVER_OBJECT DriverObject) { - IoDeleteDevice(DriverObject->DeviceObject); -} - -extern "C" NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT DriverObject, - _In_ PUNICODE_STRING RegistryPath) { - NTSTATUS status; - - status = IoCreateDevice(DriverObject, NULL, &DRIVER_NAME, FILE_DEVICE_UNKNOWN, - FILE_DEVICE_SECURE_OPEN, FALSE, - &DriverObject->DeviceObject); - - if (!NT_SUCCESS(status)) { - return STATUS_FAILED_DRIVER_ENTRY; - } - - status = IoCreateSymbolicLink(&DRIVER_LINK, &DRIVER_NAME); - - if (!NT_SUCCESS(status)) { - IoDeleteDevice(DriverObject->DeviceObject); - return STATUS_FAILED_DRIVER_ENTRY; - } - - DriverObject->MajorFunction[IRP_MJ_CREATE] = DeviceCreate; - DriverObject->MajorFunction[IRP_MJ_CLOSE] = DeviceClose; - DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DeviceControl; - DriverObject->DriverUnload = DriverUnload; - - return STATUS_SUCCESS; -} \ No newline at end of file diff --git a/test/driver/patch.cpp b/test/driver/patch.cpp deleted file mode 100644 index 3fd4134..0000000 --- a/test/driver/patch.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "patch.hpp" - -namespace framework { -patch::patch(char *image_name) {} - -patch::~patch() {} -} // namespace framework \ No newline at end of file diff --git a/test/driver/patch.hpp b/test/driver/patch.hpp deleted file mode 100644 index 8a180bf..0000000 --- a/test/driver/patch.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "common.hpp" - -namespace framework { -class patch -{ - private: - char* image_name; - void* image_base; - void* patch_address; - void* original_bytes; - unsigned long patch_size; - - public: - patch(char* image_name); - ~patch(); -}; -} \ No newline at end of file diff --git a/test/driver/testdrv.inf b/test/driver/testdrv.inf deleted file mode 100644 index b628978..0000000 --- a/test/driver/testdrv.inf +++ /dev/null @@ -1,77 +0,0 @@ -; -; testdrv.inf -; - -[Version] -Signature="$WINDOWS NT$" -Class=System ; TODO: specify appropriate Class -ClassGuid={4d36e97d-e325-11ce-bfc1-08002be10318} ; TODO: specify appropriate ClassGuid -Provider=%ManufacturerName% -CatalogFile=testdrv.cat -DriverVer= ; TODO: set DriverVer in stampinf property pages -PnpLockdown=1 - -[DestinationDirs] -DefaultDestDir = 12 -testdrv_Device_CoInstaller_CopyFiles = 11 - -[SourceDisksNames] -1 = %DiskName%,,,"" - -[SourceDisksFiles] -testdrv.sys = 1,, -WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll=1 ; make sure the number matches with SourceDisksNames - -;***************************************** -; Install Section -;***************************************** - -[Manufacturer] -%ManufacturerName%=Standard,NT$ARCH$ - -[Standard.NT$ARCH$] -%testdrv.DeviceDesc%=testdrv_Device, Root\testdrv ; TODO: edit hw-id - -[testdrv_Device.NT] -CopyFiles=Drivers_Dir - -[Drivers_Dir] -testdrv.sys - -;-------------- Service installation -[testdrv_Device.NT.Services] -AddService = testdrv,%SPSVCINST_ASSOCSERVICE%, testdrv_Service_Inst - -; -------------- testdrv driver install sections -[testdrv_Service_Inst] -DisplayName = %testdrv.SVCDESC% -ServiceType = 1 ; SERVICE_KERNEL_DRIVER -StartType = 3 ; SERVICE_DEMAND_START -ErrorControl = 1 ; SERVICE_ERROR_NORMAL -ServiceBinary = %12%\testdrv.sys - -; -;--- testdrv_Device Coinstaller installation ------ -; - -[testdrv_Device.NT.CoInstallers] -AddReg=testdrv_Device_CoInstaller_AddReg -CopyFiles=testdrv_Device_CoInstaller_CopyFiles - -[testdrv_Device_CoInstaller_AddReg] -HKR,,CoInstallers32,0x00010000, "WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll,WdfCoInstaller" - -[testdrv_Device_CoInstaller_CopyFiles] -WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll - -[testdrv_Device.NT.Wdf] -KmdfService = testdrv, testdrv_wdfsect -[testdrv_wdfsect] -KmdfLibraryVersion = $KMDFVERSION$ - -[Strings] -SPSVCINST_ASSOCSERVICE= 0x00000002 -ManufacturerName="" ;TODO: Replace with your manufacturer name -DiskName = "testdrv Installation Disk" -testdrv.DeviceDesc = "testdrv Device" -testdrv.SVCDESC = "testdrv Service" diff --git a/test/driver/testdrv.vcxproj b/test/driver/testdrv.vcxproj deleted file mode 100644 index 6cd7499..0000000 --- a/test/driver/testdrv.vcxproj +++ /dev/null @@ -1,221 +0,0 @@ - - - - - Debug - x64 - - - Release - No Server - Win11 - ARM64 - - - Release - No Server - Win11 - x64 - - - Release - No Server - ARM64 - - - Release - No Server - x64 - - - Release - x64 - - - Debug - ARM64 - - - Release - ARM64 - - - - {3CE9C9B1-1FB1-4770-ABBB-EE4E6AA949B0} - {1bc93793-694f-48fe-9372-81e2b05556fd} - v4.5 - 12.0 - Debug - x64 - testdrv - $(LatestTargetPlatformVersion) - - - - Windows10 - true - WindowsKernelModeDriver10.0 - Driver - KMDF - Universal - - - Windows10 - false - WindowsKernelModeDriver10.0 - Driver - KMDF - Universal - false - - - Windows10 - false - WindowsKernelModeDriver10.0 - Driver - KMDF - Universal - false - - - Windows10 - false - WindowsKernelModeDriver10.0 - Driver - KMDF - Universal - false - - - Windows10 - true - WindowsKernelModeDriver10.0 - Driver - KMDF - Universal - - - Windows10 - false - WindowsKernelModeDriver10.0 - Driver - KMDF - Universal - - - Windows10 - false - WindowsKernelModeDriver10.0 - Driver - KMDF - Universal - - - Windows10 - false - WindowsKernelModeDriver10.0 - Driver - KMDF - Universal - - - - - - - - - - - DbgengKernelDebugger - - - DbgengKernelDebugger - true - - - DbgengKernelDebugger - true - $(SolutionDir)$(Platform)\$(Configuration)\ - - - DbgengKernelDebugger - true - $(SolutionDir)$(Platform)\$(Configuration)\ - - - DbgengKernelDebugger - - - DbgengKernelDebugger - - - DbgengKernelDebugger - - - DbgengKernelDebugger - - - - sha256 - - - - - sha256 - - - false - stdcpp20 - - - - - sha256 - - - false - - - - - sha256 - - - false - - - - - sha256 - - - - - sha256 - - - - - sha256 - - - - - sha256 - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/test/driver/testdrv.vcxproj.filters b/test/driver/testdrv.vcxproj.filters deleted file mode 100644 index 52a3663..0000000 --- a/test/driver/testdrv.vcxproj.filters +++ /dev/null @@ -1,48 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {8E41214B-6785-4CFE-B992-037D68949A14} - inf;inv;inx;mof;mc; - - - - - Driver Files - - - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file