Skip to content
Open
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
20 changes: 13 additions & 7 deletions src/helpers/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::env;
use std::str;
use human_bytes::human_bytes;
use sysinfo::CpuExt;
use sysinfo::{System, SystemExt, DiskExt};
use sysinfo::{System, Disks, RefreshKind, CpuRefreshKind};

// Evaluate platform & environment information
pub fn evaluate_env() {
Expand All @@ -15,19 +14,26 @@ pub fn evaluate_env() {
log::info!("Operating system information OS: {} ARCH: {}", env::consts::OS, env::consts::ARCH);
// System Names
log::info!("System information NAME: {:?} KERNEL: {:?} OS_VER: {:?} HOSTNAME: {:?}",
sys.name().unwrap(), sys.kernel_version().unwrap(), sys.os_version().unwrap(), sys.host_name().unwrap());
System::name().unwrap(), System::kernel_version().unwrap(), System::os_version().unwrap(), System::host_name().unwrap());
// CPU
let s = System::new_with_specifics(
RefreshKind::new().with_cpu(CpuRefreshKind::everything()),
);
/*for cpu in s.cpus() {
println!("{}", cpu.frequency());
}*/
log::info!("CPU information NUM_CORES: {} FREQUENCY: {:?} VENDOR: {:?}",
sys.cpus().len(), sys.cpus()[0].frequency(), sys.cpus()[0].vendor_id());
s.cpus().len(), s.cpus()[0].frequency(), s.cpus()[0].vendor_id());
// Memory
log::info!("Memory information TOTAL: {:?} USED: {:?}",
human_bytes(sys.total_memory() as f64), human_bytes(sys.used_memory() as f64));
// Hard disks
for disk in sys.disks() {
let disks = Disks::new_with_refreshed_list();
for disk in disks.list() {
log::info!(
"Hard disk NAME: {:?} FS_TYPE: {:?} MOUNT_POINT: {:?} AVAIL: {:?} TOTAL: {:?} REMOVABLE: {:?}",
disk.name(),
str::from_utf8(disk.file_system()).unwrap(),
disk.file_system(),
disk.mount_point(),
human_bytes(disk.available_space() as f64),
human_bytes(disk.total_space() as f64),
Expand All @@ -39,7 +45,7 @@ pub fn evaluate_env() {
pub fn get_hostname() -> String {
let mut sys = System::new_all();
sys.refresh_all();
sys.host_name().unwrap()
System::host_name().unwrap()
}

pub fn get_os_type() -> String {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/process_check.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::process;
use arrayvec::ArrayVec;
use yara::*;
use sysinfo::{System, SystemExt, ProcessExt, PidExt};
use sysinfo::{System};

use crate::{ScanConfig, GenMatch};

Expand Down