Skip to content

Commit 4011a00

Browse files
committed
1.8 release
1 parent c3993f7 commit 4011a00

3 files changed

Lines changed: 48 additions & 12 deletions

File tree

docs/documentation.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ This will essentially return the VM brand as a `std::string`. The exact possible
203203
- `Hyper-V artifact (not an actual VM)`
204204
- `User-mode Linux`
205205
- `IBM PowerVM`
206+
- `Google Compute Engine (KVM)`
207+
- `OpenStack (KVM)`
208+
- `KubeVirt (KVM)`
209+
- `AWS Nitro System (KVM-based)`
210+
- `Podman`
211+
- `WSL`
206212

207213
If none were detected, it will return `Unknown`. It's often NOT going to produce a satisfying result due to technical difficulties with accomplishing this, on top of being highly dependent on what mechanisms detected a VM. This is especially true for VMware sub-versions (ESX, GSX, Fusion, etc...) Don't rely on this function for critical operations as if it's your golden bullet. It's arguably unreliable and it'll most likely return `Unknown` (assuming it is actually running under a VM).
208214

src/cli.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,13 @@ SimpleVisor
247247
Hyper-V artifact (not an actual VM)
248248
User-mode Linux
249249
IBM PowerVM
250+
Google Compute Engine (KVM)
251+
OpenStack (KVM)
252+
KubeVirt (KVM)
253+
AWS Nitro System (KVM-based)
254+
Podman
255+
WSL
256+
OpenVZ
250257
)";
251258

252259
std::exit(0);
@@ -274,6 +281,11 @@ std::string type(const std::string &brand_str) {
274281
{ "Intel HAXM", "Hypervisor (type 1)" },
275282
{ "Intel KGT (Trusty)", "Hypervisor (type 1)" },
276283
{ "SimpleVisor", "Hypervisor (type 1)" },
284+
{ "Google Compute Engine (KVM)", "Hypervisor (type 1)" },
285+
{ "OpenStack (KVM)", "Hypervisor (type 1)" },
286+
{ "KubeVirt (KVM)", "Hypervisor (type 1)" },
287+
{ "IBM PowerVM", "Hypervisor (type 1)" },
288+
{ "AWS Nitro System EC2 (KVM-based)", "Hypervisor (type 1)" },
277289

278290
// type 2
279291
{ "VirtualBox", "Hypervisor (type 2)" },
@@ -307,11 +319,15 @@ std::string type(const std::string &brand_str) {
307319
{ "Jailhouse", "Partitioning Hypervisor" },
308320
{ "Unisys s-Par", "Partitioning Hypervisor" },
309321
{ "Docker", "Container" },
322+
{ "Podman", "Container" },
323+
{ "OpenVZ", "Container" },
310324
{ "Microsoft Virtual PC/Hyper-V", "Hypervisor (either type 1 or 2)" },
311325
{ "Lockheed Martin LMHS", "Hypervisor (unknown type)" },
312326
{ "Wine", "Compatibility layer" },
313327
{ "Apple VZ", "Unknown" },
314-
{ "Hyper-V artifact (not an actual VM)", "No VM" }
328+
{ "Hyper-V artifact (not an actual VM)", "No VM" },
329+
{ "User-mode Linux", "Paravirtualised" },
330+
{ "WSL", "Hybrid Hyper-V (type 1 and 2)" }, // debatable tbh
315331
};
316332

317333
auto it = type_table.find(brand_str);
@@ -365,7 +381,8 @@ bool is_spoofable(const VM::enum_flags flag) {
365381
case VM::BLUESTACKS_FOLDERS:
366382
case VM::EVENT_LOGS:
367383
case VM::KMSG:
368-
case VM::XEN_PROC: return true;
384+
case VM::VM_PROCS:
385+
case VM::PODMAN_FILE: return true;
369386
default: return false;
370387
}
371388
}
@@ -564,7 +581,7 @@ void general() {
564581
checker(VM::HYPERVISOR_DIR, "Hypervisor directory (Linux)");
565582
checker(VM::UML_CPU, "User-mode Linux CPU");
566583
checker(VM::KMSG, "/dev/kmsg hypervisor message");
567-
checker(VM::XEN_PROC, "/proc/xen");
584+
checker(VM::VM_PROCS, "various VM files in /proc");
568585
checker(VM::VBOX_MODULE, "VBox kernel module");
569586
checker(VM::SYSINFO_PROC, "/proc/sysinfo");
570587
checker(VM::DEVICE_TREE, "/proc/device-tree");

src/vmaware.hpp

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ struct VM {
417417
HYPERVISOR_DIR,
418418
UML_CPU,
419419
KMSG,
420-
XEN_PROC,
420+
VM_PROCS,
421421
VBOX_MODULE,
422422
SYSINFO_PROC,
423423
DEVICE_TREE,
@@ -547,9 +547,10 @@ struct VM {
547547
static constexpr const char* GCE = "Google Compute Engine (KVM)";
548548
static constexpr const char* OPENSTACK = "OpenStack (KVM)";
549549
static constexpr const char* KUBEVIRT = "KubeVirt (KVM)";
550-
static constexpr const char* AWS_NITRO = "AWS Nitro System (KVM-based)";
550+
static constexpr const char* AWS_NITRO = "AWS Nitro System EC2 (KVM-based)";
551551
static constexpr const char* PODMAN = "Podman";
552552
static constexpr const char* WSL = "WSL";
553+
static constexpr const char* OPENVZ = "OpenVZ";
553554

554555
static flagset global_flags; // for certain techniques where the flags MUST be accessible
555556

@@ -648,12 +649,13 @@ struct VM {
648649

649650
// check Intel
650651
[[nodiscard]] static bool is_intel() {
651-
constexpr u32 intel_ecx = 0x6c65746e;
652+
constexpr u32 intel_ecx1 = 0x6c65746e; // "ntel"
653+
constexpr u32 intel_ecx2 = 0x6c65746f; // "otel", this is because some Intel CPUs have a rare manufacturer string of "GenuineIotel"
652654

653655
u32 unused, ecx = 0;
654656
cpuid(unused, unused, ecx, unused, 0);
655657

656-
return (ecx == intel_ecx);
658+
return ((ecx == intel_ecx1) || (ecx == intel_ecx2));
657659
}
658660

659661
// check for POSSIBILITY of hyperthreading, I don't think there's a
@@ -8829,18 +8831,22 @@ struct VM {
88298831
* @note idea from https://github.com/ShellCode33/VM-Detection/blob/master/vmdetect/linux.go
88308832
* @category Linux
88318833
*/
8832-
[[nodiscard]] static bool xen_proc() try {
8834+
[[nodiscard]] static bool vm_procs() try {
88338835
#if (!LINUX)
88348836
return false;
88358837
#else
88368838
if (util::exists("/proc/xen")) {
88378839
return core::add(XEN);
88388840
}
88398841

8842+
if (util::exists("/proc/vz")) {
8843+
return core::add(OPENVZ);
8844+
}
8845+
88408846
return false;
88418847
#endif
88428848
} catch (...) {
8843-
debug("XEN_PROC: caught error, returned false");
8849+
debug("VM_PROCS: caught error, returned false");
88448850
return false;
88458851
}
88468852

@@ -8990,7 +8996,13 @@ struct VM {
89908996

89918997
if (std::regex_search(content, std::regex(vm_string.first))) {
89928998
debug("DMI_SCAN: content = ", content);
8993-
return core::add(vm_string.second);
8999+
if (std::strcmp(vm_string.second, AWS_NITRO) == 0) {
9000+
if (smbios_vm_bit()) {
9001+
return core::add(AWS_NITRO);
9002+
}
9003+
} else {
9004+
return core::add(vm_string.second);
9005+
}
89949006
}
89959007
}
89969008
}
@@ -10063,7 +10075,8 @@ std::map<const char*, VM::brand_score_t> VM::core::brand_scoreboard{
1006310075
{ VM::KUBEVIRT, 0 },
1006410076
{ VM::AWS_NITRO, 0 },
1006510077
{ VM::PODMAN, 0 },
10066-
{ VM::WSL, 0 }
10078+
{ VM::WSL, 0 },
10079+
{ VM::OPENVZ, 0 }
1006710080
};
1006810081

1006910082

@@ -10261,7 +10274,7 @@ const std::map<VM::enum_flags, VM::core::technique> VM::core::technique_table =
1026110274
{ VM::HYPERVISOR_DIR, { 20, VM::hypervisor_dir, false } },
1026210275
{ VM::UML_CPU, { 80, VM::uml_cpu, false } },
1026310276
{ VM::KMSG, { 10, VM::kmsg, true } },
10264-
{ VM::XEN_PROC, { 20, VM::xen_proc, true } },
10277+
{ VM::VM_PROCS, { 20, VM::vm_procs, true } },
1026510278
{ VM::VBOX_MODULE, { 15, VM::vbox_module, false } },
1026610279
{ VM::SYSINFO_PROC, { 15, VM::sysinfo_proc, false } },
1026710280
{ VM::DEVICE_TREE, { 20, VM::device_tree, false } },

0 commit comments

Comments
 (0)