Skip to content

Commit

Permalink
Fixed crash under Windows server 2008
Browse files Browse the repository at this point in the history
  • Loading branch information
b1nhack committed Jun 25, 2023
1 parent 8e0328f commit 1882a2f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "superman"
version = "1.1.6"
version = "1.1.7"
edition = "2021"
authors = ["b1n <[email protected]>"]
description = "Kill everything."
description = "Kill The Protected Process"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
13 changes: 7 additions & 6 deletions src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>) -> anyhow::Result<()> {
pub fn kill(&self, args: &Args, rx: Receiver<bool>) -> anyhow::Result<()> {
kill_pid(self, args, rx)
}
}
Expand Down Expand Up @@ -100,7 +100,7 @@ fn check_service_status(driver: &Driver) -> anyhow::Result<bool> {
Ok(true)
}
_ => {
driver.unload_driver()?;
driver.unload()?;
Ok(false)
}
}
Expand Down Expand Up @@ -208,6 +208,7 @@ fn kill_pid(driver: &Driver, args: &Args, rx: Receiver<bool>) -> 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(
Expand All @@ -232,7 +233,7 @@ fn kill_pid(driver: &Driver, args: &Args, rx: Receiver<bool>) -> 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 {
Expand All @@ -259,7 +260,7 @@ fn kill_pid(driver: &Driver, args: &Args, rx: Receiver<bool>) -> anyhow::Result<
// exit
if rx.try_recv().is_ok() {
CloseHandle(device);
driver.unload_driver()?;
driver.unload()?;
process::exit(0i32);
}

Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> {
Expand All @@ -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(())
}

0 comments on commit 1882a2f

Please sign in to comment.