Created
March 4, 2021 23:22
-
-
Save MerijnHendriks/97f3096a5d779643ba6029d03dd86992 to your computer and use it in GitHub Desktop.
Multiple methods of triggering a BSOD on a windows systems. WinApi.BSODManual() is recommended.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Program.cs | |
| * License: NCSA | |
| * Author: Merijn Hendriks | |
| */ | |
| using System; | |
| using System.Diagnostics; | |
| using System.Runtime.InteropServices; | |
| namespace TriggerBSOD | |
| { | |
| /// <remarks> | |
| /// RtlSetProcessIsCritical, RtlAdjustPrivilege, NtRaiseHardError are undocumented NTDLL features | |
| /// </remarks> | |
| public static class WinApi | |
| { | |
| [DllImport("ntdll.dll")] | |
| private static extern void RtlSetProcessIsCritical(uint bNew, uint pbOld, uint bNeedScb); | |
| [DllImport("ntdll.dll")] | |
| public static extern uint RtlAdjustPrivilege(int Privilege, bool bEnablePrivilege, bool IsThreadPrivilege, out bool PreviousValue); | |
| [DllImport("ntdll.dll")] | |
| public static extern uint NtRaiseHardError(uint ErrorStatus, uint NumberOfParameters, uint UnicodeStringParameterMask, IntPtr Parameters, uint ValidResponseOption, out uint Response); | |
| public const uint signal = 0xc0000022; | |
| /// <summary> | |
| /// This creates a BSOD manually | |
| /// </summary> | |
| public static unsafe void BSODManual() | |
| { | |
| bool bool_0; | |
| uint uint_0; | |
| RtlAdjustPrivilege(19, true, false, out bool_0); | |
| NtRaiseHardError(signal, 0, 0, IntPtr.Zero, 6, out uint_0); | |
| } | |
| /// <summary> | |
| /// We make our process "critical" for windows to function, then kill it for BSOD. | |
| /// </summary> | |
| /// <remarks> | |
| /// Requires administrator privilages. | |
| /// </remarks> | |
| public static void BSODProcessSelf() | |
| { | |
| Process.EnterDebugMode(); | |
| RtlSetProcessIsCritical(1, 0, 0); | |
| Process.GetCurrentProcess().Kill(); | |
| } | |
| /// <summary> | |
| /// Kill csrss to cause BSOD | |
| /// </summary> | |
| /// <remarks> | |
| /// Requires administrator privilages. | |
| /// </remarks> | |
| public static void BSODProcessCSRSS() | |
| { | |
| Process.GetProcessesByName("csrss")[0].Kill(); | |
| } | |
| } | |
| public static class Program | |
| { | |
| public static void Main() | |
| { | |
| WinApi.BSODManual(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment