Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions implants/lib/eldritch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ listeners = { workspace = true }
transport = { workspace = true, features = ["mock"] }
httptest = { workspace = true }
uuid = { workspace = true, features = ["v4"] }
once_cell = "1.21.3"

# BUILD
[build-dependencies]
Expand Down
9 changes: 9 additions & 0 deletions implants/lib/eldritch/src/sys/exec_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,14 @@ fn handle_exec(
#[cfg(test)]
mod tests {
use std::{fs, path::Path, process, thread, time};
use std::sync::Mutex;
use once_cell::sync::Lazy;

use sysinfo::{PidExt, ProcessExt, System, SystemExt};
use tempfile::NamedTempFile;

static TEST_MUTEX: Lazy<Mutex<()>> = Lazy::new(|| Mutex::new(()));

fn init_logging() {
let _ = pretty_env_logger::formatted_timed_builder()
.filter_level(log::LevelFilter::Info)
Expand Down Expand Up @@ -168,6 +172,7 @@ mod tests {
use super::*;
#[test]
fn test_sys_exec_current_user() -> anyhow::Result<()> {
let _lock = TEST_MUTEX.lock().unwrap();
if cfg!(target_os = "linux")
|| cfg!(target_os = "ios")
|| cfg!(target_os = "android")
Expand Down Expand Up @@ -216,6 +221,7 @@ mod tests {
}
#[test]
fn test_sys_exec_complex_linux() -> anyhow::Result<()> {
let _lock = TEST_MUTEX.lock().unwrap();
if cfg!(target_os = "linux")
|| cfg!(target_os = "ios")
|| cfg!(target_os = "macos")
Expand All @@ -239,6 +245,7 @@ mod tests {

#[test]
fn test_sys_exec_disown_linux() -> anyhow::Result<()> {
let _lock = TEST_MUTEX.lock().unwrap();
if cfg!(target_os = "linux")
|| cfg!(target_os = "ios")
|| cfg!(target_os = "macos")
Expand Down Expand Up @@ -269,6 +276,7 @@ mod tests {

#[test]
fn test_sys_exec_disown_no_defunct() -> anyhow::Result<()> {
let _lock = TEST_MUTEX.lock().unwrap();
init_logging();

if cfg!(target_os = "linux")
Expand All @@ -294,6 +302,7 @@ mod tests {

#[test]
fn test_sys_exec_complex_windows() -> anyhow::Result<()> {
let _lock = TEST_MUTEX.lock().unwrap();
if cfg!(target_os = "windows") {
let res = handle_exec(
String::from("C:\\Windows\\System32\\cmd.exe"),
Expand Down
Loading