pub mod father {
pub const MAGIC_GID: u32 = 7823;
pub const BACKDOOR_SOURCE_PORT: u16 = 48411;
pub const SHELL_PASS: &str = "ymv";
pub const DEFAULT_PRELOAD_PATH: &str = "/usr/lib/x86_64-linux-gnu/libymv.so.3";
pub const HIDDEN_PORT: u16 = 0xD431;
pub const PAM_ARTIFACT_PATH: &str = "/tmp/silly.txt";
pub const CONFIG_MAGIC: &[u8] = b"\x46\x41\x54\x48\x45\x52";
}
pub const KNOWN_LD_PRELOAD_ROOTKITS: &[&str] = &[
"libprocesshider",
"libymv",
"reptile",
"azazel",
"jynx",
"jynx2",
];
pub fn is_known_rootkit_lib(filename: &str) -> bool {
let lower = filename.to_ascii_lowercase();
KNOWN_LD_PRELOAD_ROOTKITS.iter().any(|k| lower.contains(*k))
}
pub fn is_rootkit_gid(gid: u32) -> bool {
gid == father::MAGIC_GID
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn father_magic_gid_is_7823() {
assert_eq!(father::MAGIC_GID, 7823);
}
#[test]
fn father_backdoor_source_port_is_48411() {
assert_eq!(father::BACKDOOR_SOURCE_PORT, 48411);
}
#[test]
fn father_hidden_port_is_0xd431() {
assert_eq!(father::HIDDEN_PORT, 0xD431);
}
#[test]
fn father_hidden_port_decimal_equals_54321() {
assert_eq!(father::HIDDEN_PORT, 54321);
}
#[test]
fn father_pam_artifact_path_is_tmp_silly_txt() {
assert_eq!(father::PAM_ARTIFACT_PATH, "/tmp/silly.txt");
}
#[test]
fn father_config_magic_starts_with_father_bytes() {
assert!(father::CONFIG_MAGIC.starts_with(b"FATHER"));
}
#[test]
fn libymv_so3_is_known_rootkit() {
assert!(is_known_rootkit_lib("libymv.so.3"));
}
#[test]
fn libc_so6_is_not_rootkit() {
assert!(!is_known_rootkit_lib("libc.so.6"));
}
#[test]
fn libprocesshider_is_known_rootkit() {
assert!(is_known_rootkit_lib("libprocesshider.so"));
}
#[test]
fn reptile_so_is_known_rootkit() {
assert!(is_known_rootkit_lib("reptile.so"));
}
#[test]
fn azazel_is_known_rootkit() {
assert!(is_known_rootkit_lib("azazel.so.1"));
}
#[test]
fn jynx2_is_known_rootkit() {
assert!(is_known_rootkit_lib("jynx2.so"));
}
#[test]
fn libssl_so_is_not_rootkit() {
assert!(!is_known_rootkit_lib("libssl.so.3"));
}
#[test]
fn empty_string_is_not_rootkit() {
assert!(!is_known_rootkit_lib(""));
}
#[test]
fn case_insensitive_libymv_uppercase() {
assert!(is_known_rootkit_lib("LIBYMV.SO.3"));
}
#[test]
fn gid_7823_is_rootkit_gid() {
assert!(is_rootkit_gid(7823));
}
#[test]
fn gid_1000_is_not_rootkit_gid() {
assert!(!is_rootkit_gid(1000));
}
#[test]
fn gid_0_is_not_rootkit_gid() {
assert!(!is_rootkit_gid(0));
}
}