Skip to content
Merged
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
4 changes: 3 additions & 1 deletion implants/lib/eldritch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ hex-literal = { workspace = true }
ipnetwork = { workspace = true }
log = { workspace = true }
md5 = { workspace = true }
netstat2 = { workspace = true }
nix = { workspace = true }
notify = { workspace = true }
object = { workspace = true }
Expand Down Expand Up @@ -76,6 +75,9 @@ winreg = { workspace = true }
[target.'cfg(not(windows))'.dependencies]
pnet = { workspace = true }

[target.'cfg(not(target_os = "freebsd"))'.dependencies]
netstat2 = { workspace = true }

[dev-dependencies]
transport = { workspace = true, features = ["mock"]}
httptest = { workspace = true }
Expand Down
2 changes: 2 additions & 0 deletions implants/lib/eldritch/src/file/list_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use std::os::macos::fs::MetadataExt;
use std::os::unix::fs::PermissionsExt;
#[cfg(target_os = "windows")]
use std::os::windows::fs::MetadataExt;
#[cfg(target_os = "freebsd")]
use std::os::freebsd::fs::MetadataExt;
use sysinfo::{System, SystemExt, UserExt};

const UNKNOWN: &str = "UNKNOWN";
Expand Down
9 changes: 9 additions & 0 deletions implants/lib/eldritch/src/process/netstat_impl.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
use super::super::insert_dict_kv;
use anyhow::Result;
#[cfg(target_os = "freebsd")]
use anyhow::anyhow;
#[cfg(not(target_os = "freebsd"))]
use netstat2::*;
use starlark::{
collections::SmallMap,
const_frozen_string,
values::{dict::Dict, Heap, Value},
};

#[cfg(target_os = "freebsd")]
pub fn netstat(_: &Heap) -> Result<Vec<Dict>> {
Err(anyhow!("Not implemented for FreeBSD"))
}

#[cfg(not(target_os = "freebsd"))]
pub fn netstat(starlark_heap: &Heap) -> Result<Vec<Dict>> {
let mut out: Vec<Dict> = Vec::new();
let af_flags = AddressFamilyFlags::IPV4 | AddressFamilyFlags::IPV6;
Expand Down
6 changes: 3 additions & 3 deletions implants/lib/eldritch/src/sys/exec_impl.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::super::insert_dict_kv;
use super::CommandOutput;
use anyhow::{Context, Result};
#[cfg(any(target_os = "linux", target_os = "macos"))]
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))]
use nix::{
sys::wait::waitpid,
unistd::{fork, ForkResult},
Expand All @@ -11,7 +11,7 @@ use starlark::{
const_frozen_string,
values::{dict::Dict, Heap},
};
#[cfg(any(target_os = "linux", target_os = "macos"))]
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))]
use std::process::exit;
use std::process::Command;
// https://stackoverflow.com/questions/62978157/rust-how-to-spawn-child-process-that-continues-to-live-after-parent-receives-si#:~:text=You%20need%20to%20double%2Dfork,is%20not%20related%20to%20rust.&text=You%20must%20not%20forget%20to,will%20become%20a%20zombie%20process.
Expand Down Expand Up @@ -54,7 +54,7 @@ fn handle_exec(path: String, args: Vec<String>, disown: Option<bool>) -> Result<
"Windows is not supported for disowned processes."
));

#[cfg(any(target_os = "linux", target_os = "macos"))]
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))]
match unsafe { fork()? } {
ForkResult::Parent { child } => {
// Wait for intermediate process to exit.
Expand Down