Skip to content

Instantly share code, notes, and snippets.

@JLChnToZ
Last active December 7, 2019 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JLChnToZ/9c46da68fe067a91889d5f10c3df5ace to your computer and use it in GitHub Desktop.
Save JLChnToZ/9c46da68fe067a91889d5f10c3df5ace to your computer and use it in GitHub Desktop.
Simple PowerShell script that gives you BSOD
$winId = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$winPrincipal = New-Object System.Security.Principal.WindowsPrincipal($winId)
$adminRole = [System.Security.Principal.WindowsBuiltInRole]::Administrator
If (-Not $winPrincipal.IsInRole($adminRole)) {
$cmdArgs = '-File', $MyInvocation.MyCommand.Path, '-ExecutionPolicy', 'Bypass'
Start-Process 'PowerShell' $cmdArgs -Verb RunAs
Exit
}
$memberDef = @'
[DllImport("ntdll.dll", SetLastError = true)]
public static extern int NtSetInformationProcess(IntPtr hProc, int piClass, ref int pi, int piLen);
'@
$ntDll = Add-Type 'NtDll' -MemberDefinition $memberDef -PassThru
[System.Diagnostics.Process]::EnterDebugMode()
$proc = [System.Diagnostics.Process]::GetCurrentProcess()
$val = 1
$ntDll::NtSetInformationProcess($proc.Handle, 0x1D, [ref]$val, 4)
$proc.Kill()
@JLChnToZ
Copy link
Author

JLChnToZ commented Dec 6, 2019

This script will not harm your computer, but will gives you BSOD (real thing, not fake) after getting administrator privileges.
Remember to save all your stuffs before trying this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment