79 lines
2.6 KiB
Rust
79 lines
2.6 KiB
Rust
use anyhow::Result;
|
|
use tracing_subscriber;
|
|
|
|
// Define the module inline to make this a standalone binary
|
|
mod device;
|
|
use device::HardwareFingerprintService;
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<()> {
|
|
// Initialize logging
|
|
tracing_subscriber::fmt::init();
|
|
|
|
println!("🔍 Testing hardware fingerprinting...");
|
|
|
|
let mut service = HardwareFingerprintService::new();
|
|
let fingerprint = service.generate_fingerprint().await?;
|
|
|
|
println!("✅ Hardware fingerprint generated successfully!");
|
|
println!("");
|
|
println!("Hardware Information:");
|
|
println!(" CPU ID: {}", fingerprint.cpu_id);
|
|
println!(" Board Serial: {}", fingerprint.board_serial);
|
|
println!(" MAC Addresses: {}", fingerprint.mac_addresses.join(", "));
|
|
println!(" Disk UUID: {}", fingerprint.disk_uuid);
|
|
if let Some(tmp) = &fingerprint.tpm_attestation {
|
|
println!(" TPM Attestation: {}...", &tmp[..20]);
|
|
} else {
|
|
println!(" TPM Attestation: Not available");
|
|
}
|
|
println!(" Computed Hash: {}", fingerprint.computed_hash);
|
|
|
|
println!("");
|
|
println!("System Information:");
|
|
println!(" Hostname: {}", fingerprint.system_info.hostname);
|
|
println!(
|
|
" OS: {} {}",
|
|
fingerprint.system_info.os_name, fingerprint.system_info.os_version
|
|
);
|
|
println!(" Kernel: {}", fingerprint.system_info.kernel_version);
|
|
println!(" Architecture: {}", fingerprint.system_info.architecture);
|
|
println!(
|
|
" Memory: {} MB total, {} MB available",
|
|
fingerprint.system_info.total_memory / 1024 / 1024,
|
|
fingerprint.system_info.available_memory / 1024 / 1024
|
|
);
|
|
println!(
|
|
" CPU: {} cores, {}",
|
|
fingerprint.system_info.cpu_count, fingerprint.system_info.cpu_brand
|
|
);
|
|
println!(
|
|
" Disks: {} mounted",
|
|
fingerprint.system_info.disk_info.len()
|
|
);
|
|
|
|
// Test fingerprint validation
|
|
println!("");
|
|
println!("🔐 Testing fingerprint validation...");
|
|
let is_valid = service.validate_fingerprint(&fingerprint)?;
|
|
if is_valid {
|
|
println!("✅ Fingerprint validation: PASSED");
|
|
} else {
|
|
println!("❌ Fingerprint validation: FAILED");
|
|
}
|
|
|
|
// Test consistency
|
|
println!("");
|
|
println!("🔄 Testing fingerprint consistency...");
|
|
let fingerprint2 = service.generate_fingerprint().await?;
|
|
if fingerprint.computed_hash == fingerprint2.computed_hash {
|
|
println!("✅ Fingerprint consistency: PASSED");
|
|
} else {
|
|
println!("❌ Fingerprint consistency: FAILED");
|
|
println!(" First: {}", fingerprint.computed_hash);
|
|
println!(" Second: {}", fingerprint2.computed_hash);
|
|
}
|
|
|
|
Ok(())
|
|
}
|