From 1882a2f3f5870fb7e99919f76831b120390d50cd Mon Sep 17 00:00:00 2001 From: b1-team <120295547+b1nhack@users.noreply.github.com> Date: Sat, 24 Jun 2023 23:00:27 -0700 Subject: [PATCH] Fixed crash under Windows server 2008 --- Cargo.lock | 2 +- Cargo.toml | 4 ++-- src/driver.rs | 13 +++++++------ src/main.rs | 6 +++--- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1e5fafd..95af486 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -455,7 +455,7 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "superman" -version = "1.1.6" +version = "1.1.7" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index 9f4b19f..9ac3585 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "superman" -version = "1.1.6" +version = "1.1.7" edition = "2021" authors = ["b1n "] -description = "Kill everything." +description = "Kill The Protected Process" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/driver.rs b/src/driver.rs index 197c2f6..d1d24b5 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -44,17 +44,17 @@ impl Driver { } /// Load and start driver - pub fn load_driver(&self) -> anyhow::Result<()> { + pub fn load(&self) -> anyhow::Result<()> { load_driver(self) } /// Unload and delete driver - pub fn unload_driver(&self) -> anyhow::Result<()> { + pub fn unload(&self) -> anyhow::Result<()> { unload_driver(self) } /// Send ioctl to kill pid - pub fn kill_pid(&self, args: &Args, rx: Receiver) -> anyhow::Result<()> { + pub fn kill(&self, args: &Args, rx: Receiver) -> anyhow::Result<()> { kill_pid(self, args, rx) } } @@ -100,7 +100,7 @@ fn check_service_status(driver: &Driver) -> anyhow::Result { Ok(true) } _ => { - driver.unload_driver()?; + driver.unload()?; Ok(false) } } @@ -208,6 +208,7 @@ fn kill_pid(driver: &Driver, args: &Args, rx: Receiver) -> anyhow::Result< let device_name = CStr::from_bytes_with_nul(b"\\\\.\\superman\0")?; let pid = args.pid; let mut output = 0u64; + let mut ret = 0u32; unsafe { let device = CreateFileA( @@ -232,7 +233,7 @@ fn kill_pid(driver: &Driver, args: &Args, rx: Receiver) -> anyhow::Result< u32::try_from(size_of_val(&pid))?, addr_of_mut!(output).cast(), u32::try_from(size_of_val(&output))?, - null_mut(), + addr_of_mut!(ret), null_mut(), ); if res == FALSE { @@ -259,7 +260,7 @@ fn kill_pid(driver: &Driver, args: &Args, rx: Receiver) -> anyhow::Result< // exit if rx.try_recv().is_ok() { CloseHandle(device); - driver.unload_driver()?; + driver.unload()?; process::exit(0i32); } diff --git a/src/main.rs b/src/main.rs index 5f5ac6a..c4a1cf5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -56,7 +56,7 @@ fn main() { if let Err(e) = try_main(&args, &driver) { eprintln!("{}", e); } - let _ = driver.unload_driver(); + let _ = driver.unload(); } fn try_main(args: &Args, driver: &Driver) -> anyhow::Result<()> { @@ -67,7 +67,7 @@ fn try_main(args: &Args, driver: &Driver) -> anyhow::Result<()> { return Err(anyhow!("[-]Process not exists!")); } - driver.load_driver()?; - driver.kill_pid(args, rx)?; + driver.load()?; + driver.kill(args, rx)?; Ok(()) }