#vm #detect #timing

inside-vm_arch_support

detect virtual machine using timing

4 releases

Uses old Rust 2015

0.3.2 Jun 11, 2023
0.3.1 Feb 5, 2023
0.3.0 Feb 5, 2023
0.2.0 Feb 5, 2023

#59 in Emulators

Download history 1031/week @ 2024-01-02 3856/week @ 2024-01-09 4601/week @ 2024-01-16 2037/week @ 2024-01-23 2875/week @ 2024-01-30 2076/week @ 2024-02-06 3116/week @ 2024-02-13 1877/week @ 2024-02-20 1463/week @ 2024-02-27 1624/week @ 2024-03-05 2229/week @ 2024-03-12 2450/week @ 2024-03-19 1368/week @ 2024-03-26 1595/week @ 2024-04-02 1517/week @ 2024-04-09 871/week @ 2024-04-16

5,978 downloads per month

MIT/Apache

7KB

rtw crate

inside-vm

Detect if code is running inside a virtual machine.

works on x86 and x86-64. aarch64 support coming later

How does it work

Measure average cpu cycles when calling cpuid and compare to a threshold, if the value is high assume code is running inside a VM.

Quick Start

git clone https://github.com/Talhahpatelia/inside-vm_arch_support
cd inside-vm_arch_support/
cargo run --example test-inside-vm

output: avg cycles for __cpuid: 108

vs inside VM

[vagrant@archlinux vagrant]$ ./target/release/examples/test-inside-vm 

output: avg cycles for __cpuid: 30578

API

use inside_vm_arch_support::inside_vm;

let inside = inside_vm();
println!("inside vm: {}", inside);

Credits

https://evasions.checkpoint.com/techniques/timing.html#difference-vm-hosts

Changelog

Please see the CHANGELOG for a release history.

License

Dual-licensed under MIT or the Apache License V2.0.

No runtime deps