Files
ghost/ghost-cli/src/main.rs

57 lines
1.6 KiB
Rust
Raw Normal View History

2025-11-07 18:05:07 +02:00
use anyhow::Result;
use ghost_core::{memory, process, thread, DetectionEngine, ThreatLevel};
2025-11-07 18:05:07 +02:00
fn main() -> Result<()> {
env_logger::init();
2025-11-07 18:08:21 +02:00
println!("Ghost v0.1.0 - Process Injection Detection\n");
2025-11-07 18:05:07 +02:00
2025-11-07 18:08:21 +02:00
let mut engine = DetectionEngine::new();
2025-11-07 18:05:07 +02:00
let processes = process::enumerate_processes()?;
2025-11-07 18:08:21 +02:00
println!("Scanning {} processes...\n", processes.len());
2025-11-07 18:05:07 +02:00
2025-11-07 18:08:21 +02:00
let mut detections = Vec::new();
for proc in &processes {
2025-11-07 18:05:07 +02:00
if let Ok(regions) = memory::enumerate_memory_regions(proc.pid) {
// Get thread information if available
let threads = thread::enumerate_threads(proc.pid).ok();
let result = engine.analyze_process(proc, &regions, threads.as_deref());
2025-11-07 18:08:21 +02:00
if result.threat_level != ThreatLevel::Clean {
detections.push(result);
}
}
}
if detections.is_empty() {
println!("No suspicious activity detected.");
} else {
println!("Found {} suspicious processes:\n", detections.len());
for detection in detections {
let level_str = match detection.threat_level {
ThreatLevel::Suspicious => "SUSPICIOUS",
ThreatLevel::Malicious => "MALICIOUS",
_ => "CLEAN",
};
println!(
"[{}] {} (PID: {}) - Confidence: {:.1}%",
level_str,
detection.process.name,
detection.process.pid,
detection.confidence * 100.0
);
2025-11-07 18:05:07 +02:00
2025-11-07 18:08:21 +02:00
for indicator in &detection.indicators {
println!(" - {}", indicator);
2025-11-07 18:05:07 +02:00
}
2025-11-07 18:08:21 +02:00
println!();
2025-11-07 18:05:07 +02:00
}
}
Ok(())
}